From f44d2bc88f221330e96f4020288904701977b39f Mon Sep 17 00:00:00 2001 From: jesus Date: Wed, 22 Sep 2010 21:18:05 +0000 Subject: [PATCH] LazReport, added sample for OnUserFunction to editor project git-svn-id: trunk@27441 - --- .../samples/editor/maincalleditor.lfm | 70 +++++++++++-------- .../samples/editor/maincalleditor.pas | 21 +++++- .../lazreport/samples/editor/salida.lrf | 45 +++++++++++- 3 files changed, 102 insertions(+), 34 deletions(-) diff --git a/components/lazreport/samples/editor/maincalleditor.lfm b/components/lazreport/samples/editor/maincalleditor.lfm index 256ab26aaf..37e8c978c8 100644 --- a/components/lazreport/samples/editor/maincalleditor.lfm +++ b/components/lazreport/samples/editor/maincalleditor.lfm @@ -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 diff --git a/components/lazreport/samples/editor/maincalleditor.pas b/components/lazreport/samples/editor/maincalleditor.pas index e3deeb4baa..ede1748525 100644 --- a/components/lazreport/samples/editor/maincalleditor.pas +++ b/components/lazreport/samples/editor/maincalleditor.pas @@ -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; diff --git a/components/lazreport/samples/editor/salida.lrf b/components/lazreport/samples/editor/salida.lrf index 9fbe9ec2c3..39a31c5482 100644 --- a/components/lazreport/samples/editor/salida.lrf +++ b/components/lazreport/samples/editor/salida.lrf @@ -35,7 +35,7 @@ - + @@ -248,6 +248,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + +