mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 22:18:15 +02:00
LazReport, added sample for OnUserFunction to editor project
git-svn-id: trunk@27441 -
This commit is contained in:
parent
5e315771f3
commit
f44d2bc88f
@ -7,6 +7,7 @@ object frmMain: TfrmMain
|
||||
Caption = 'LazReport Test Suite'
|
||||
ClientHeight = 522
|
||||
ClientWidth = 828
|
||||
Font.Name = 'Sans'
|
||||
Menu = MainMenu1
|
||||
OnCreate = frmMainCreate
|
||||
ShowHint = True
|
||||
@ -15,9 +16,9 @@ object frmMain: TfrmMain
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideBottom.Control = grid
|
||||
Left = 6
|
||||
Height = 16
|
||||
Height = 18
|
||||
Top = 103
|
||||
Width = 35
|
||||
Width = 38
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Index'
|
||||
@ -27,10 +28,10 @@ object frmMain: TfrmMain
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = grid
|
||||
Left = 752
|
||||
Height = 16
|
||||
Left = 745
|
||||
Height = 18
|
||||
Top = 103
|
||||
Width = 70
|
||||
Width = 77
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Expression'
|
||||
@ -54,10 +55,10 @@ object frmMain: TfrmMain
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = lblExpr
|
||||
AnchorSideBottom.Control = grid
|
||||
Left = 47
|
||||
Height = 29
|
||||
Left = 50
|
||||
Height = 31
|
||||
Top = 90
|
||||
Width = 699
|
||||
Width = 689
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
ItemHeight = 0
|
||||
@ -71,14 +72,15 @@ object frmMain: TfrmMain
|
||||
AnchorSideRight.Control = grid
|
||||
AnchorSideBottom.Control = sbar
|
||||
Left = 0
|
||||
Height = 380
|
||||
Top = 125
|
||||
Height = 378
|
||||
Top = 127
|
||||
Width = 204
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
Color = clMoneyGreen
|
||||
Columns = <>
|
||||
DataSource = srcMaster
|
||||
TabOrder = 3
|
||||
TitleFont.Name = 'Sans'
|
||||
Visible = False
|
||||
end
|
||||
object grid: TDBGrid
|
||||
@ -89,15 +91,18 @@ object frmMain: TfrmMain
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = sbar
|
||||
Left = 0
|
||||
Height = 380
|
||||
Top = 125
|
||||
Height = 378
|
||||
Top = 127
|
||||
Width = 828
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Color = clWhite
|
||||
Columns = <>
|
||||
DataSource = srcDetail
|
||||
Font.Name = 'Sans'
|
||||
Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit]
|
||||
ParentFont = False
|
||||
TabOrder = 0
|
||||
TitleFont.Name = 'Sans'
|
||||
OnTitleClick = gridTitleClick
|
||||
end
|
||||
object Panel1: TPanel
|
||||
@ -118,47 +123,47 @@ object frmMain: TfrmMain
|
||||
Left = 6
|
||||
Height = 33
|
||||
Top = 6
|
||||
Width = 169
|
||||
Width = 170
|
||||
Action = accNewReport
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnOpenReport: TButton
|
||||
Left = 181
|
||||
Left = 182
|
||||
Height = 33
|
||||
Top = 6
|
||||
Width = 146
|
||||
Width = 147
|
||||
Action = accOpenReport
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnEditReport: TButton
|
||||
Left = 333
|
||||
Left = 335
|
||||
Height = 33
|
||||
Top = 6
|
||||
Width = 136
|
||||
Width = 135
|
||||
Action = accEditReport
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 3
|
||||
end
|
||||
object btnPreviewReport: TButton
|
||||
Left = 475
|
||||
Left = 476
|
||||
Height = 33
|
||||
Top = 6
|
||||
Width = 160
|
||||
Width = 162
|
||||
Action = accPreviewReport
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 4
|
||||
end
|
||||
object btnPrintReport: TButton
|
||||
Left = 641
|
||||
Left = 644
|
||||
Height = 33
|
||||
Top = 6
|
||||
Width = 181
|
||||
Width = 178
|
||||
Action = accPrintReport
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
@ -168,7 +173,7 @@ object frmMain: TfrmMain
|
||||
Left = 6
|
||||
Height = 33
|
||||
Top = 45
|
||||
Width = 169
|
||||
Width = 170
|
||||
Action = accCustomPreview
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
@ -176,10 +181,10 @@ object frmMain: TfrmMain
|
||||
end
|
||||
object btnPrintGrid: TButton
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 181
|
||||
Left = 182
|
||||
Height = 33
|
||||
Top = 45
|
||||
Width = 146
|
||||
Width = 147
|
||||
Action = accPrintGrid
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
@ -187,10 +192,10 @@ object frmMain: TfrmMain
|
||||
end
|
||||
object btnComposite: TButton
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 333
|
||||
Left = 335
|
||||
Height = 33
|
||||
Top = 45
|
||||
Width = 136
|
||||
Width = 135
|
||||
Action = accComposite
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
@ -199,20 +204,20 @@ object frmMain: TfrmMain
|
||||
object btnImageList: TButton
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 475
|
||||
Left = 476
|
||||
Height = 33
|
||||
Top = 45
|
||||
Width = 160
|
||||
Width = 162
|
||||
Action = accThumbnails
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 7
|
||||
end
|
||||
object btnMasterDetail: TToggleBox
|
||||
Left = 641
|
||||
Left = 644
|
||||
Height = 33
|
||||
Top = 45
|
||||
Width = 181
|
||||
Width = 178
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Master-Detail Test'
|
||||
@ -223,12 +228,13 @@ object frmMain: TfrmMain
|
||||
object TheReport: TfrReport
|
||||
Dataset = frDbDetail
|
||||
InitialZoom = pzDefault
|
||||
Options = []
|
||||
Options = [roIgnoreFieldNotFound]
|
||||
PreviewButtons = [pbZoom, pbLoad, pbSave, pbPrint, pbFind, pbHelp, pbExit]
|
||||
DataType = dtDataSet
|
||||
OnBeginDoc = TheReportBeginDoc
|
||||
OnGetValue = TheReportGetValue
|
||||
OnEnterRect = TheReportEnterRect
|
||||
OnUserFunction = TheReportUserFunction
|
||||
OnExportFilterSetup = TheReportExportFilterSetup
|
||||
left = 40
|
||||
top = 192
|
||||
@ -397,6 +403,8 @@ object frmMain: TfrmMain
|
||||
object PrintGrid: TFrPrintGrid
|
||||
DBGrid = grid
|
||||
Orientation = poLandscape
|
||||
Font.Name = 'Sans'
|
||||
TitleFont.Name = 'Sans'
|
||||
Caption = 'Grid'
|
||||
ShowCaption = True
|
||||
left = 352
|
||||
|
@ -26,11 +26,11 @@ unit maincalleditor;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
Classes, SysUtils, Variants, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
Buttons, StdCtrls, LR_Const, LR_Class, LR_Desgn, Dbf, DB, DBGrids, LR_DBSet,
|
||||
LR_PGrid, Menus, ComCtrls, ActnList, Lr_e_txt, Lr_e_htm, LR_E_CSV, LR_DSet,
|
||||
LR_BarC, LR_RRect, LR_Shape, LR_ChBox, lr_e_pdf, lconvencoding, lr_e_gen,
|
||||
lr_utils, LCLProc, ExtCtrls, custompreview;
|
||||
lr_utils, LCLProc, ExtCtrls, custompreview, LR_Pars;
|
||||
|
||||
type
|
||||
|
||||
@ -140,6 +140,8 @@ type
|
||||
procedure TheReportEnterRect(Memo: TStringList; View: TfrView);
|
||||
procedure TheReportExportFilterSetup(Sender: TfrExportFilter);
|
||||
procedure TheReportGetValue(const ParName: String; var ParValue: Variant);
|
||||
procedure TheReportUserFunction(const AName: String; p1, p2, p3: Variant;
|
||||
var Val: Variant);
|
||||
private
|
||||
{ private declarations }
|
||||
FImageList: TStringList;
|
||||
@ -485,6 +487,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.TheReportUserFunction(const AName: String; p1, p2,
|
||||
p3: Variant; var Val: Variant);
|
||||
var
|
||||
v: variant;
|
||||
b: boolean;
|
||||
begin
|
||||
if AName='STOCKFLAG' then begin
|
||||
v := frParser.Calc(P1);
|
||||
if VarIsNull(V) or not boolean(v) then
|
||||
Val := ':('
|
||||
else
|
||||
Val:= ':)';
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.SetIndex(const aIndexName: string);
|
||||
begin
|
||||
Detail.IndexName := aIndexName;
|
||||
|
@ -35,7 +35,7 @@
|
||||
<ColCount Value="1"/>
|
||||
<ColGap Value="0"/>
|
||||
<LayoutOrder Value="loColumns"/>
|
||||
<ObjectCount Value="6"/>
|
||||
<ObjectCount Value="7"/>
|
||||
<Object1>
|
||||
<Name Value="ReportTitle1"/>
|
||||
<ClassName Value="TfrBandView"/>
|
||||
@ -248,6 +248,49 @@
|
||||
<Layout Value="tlTop"/>
|
||||
<Angle Value="0"/>
|
||||
</Object6>
|
||||
<Object7>
|
||||
<Name Value="Memo5"/>
|
||||
<ClassName Value="TfrMemoView"/>
|
||||
<Visible Value="1"/>
|
||||
<Typ Value="gtMemo"/>
|
||||
<StreamMode Value="0"/>
|
||||
<Size>
|
||||
<Left Value="624"/>
|
||||
<Top Value="128"/>
|
||||
<Width Value="96"/>
|
||||
<Height Value="18"/>
|
||||
</Size>
|
||||
<Flags Value="3"/>
|
||||
<FillColor Value="clNone"/>
|
||||
<Frames>
|
||||
<FrameColor Value="clBlack"/>
|
||||
<FrameStyle Value="frsSolid"/>
|
||||
<FrameWidth Value="1"/>
|
||||
<FrameBorders Value=""/>
|
||||
</Frames>
|
||||
<Data>
|
||||
<Format Value="556"/>
|
||||
<FormatStr Value=""/>
|
||||
<Memo Value="[StockFlag([Detail."IN_STOCK"])]
"/>
|
||||
<Script Value=""/>
|
||||
</Data>
|
||||
<Font>
|
||||
<Name Value="helvetica [urw]"/>
|
||||
<Size Value="10"/>
|
||||
<Color Value="clBlack"/>
|
||||
<Charset Value="0"/>
|
||||
<Style Value=""/>
|
||||
</Font>
|
||||
<Highlight>
|
||||
<FontStyle Value="2"/>
|
||||
<FontColor Value="clBlack"/>
|
||||
<FillColor Value="clWhite"/>
|
||||
<HighlightStr Value=""/>
|
||||
</Highlight>
|
||||
<Alignment Value="taLeftJustify"/>
|
||||
<Layout Value="tlTop"/>
|
||||
<Angle Value="0"/>
|
||||
</Object7>
|
||||
</Page1>
|
||||
<FVal>
|
||||
<Count Value="0"/>
|
||||
|
Loading…
Reference in New Issue
Block a user