From fb21c53cbd54c730de98753ddbb31eaf75824632 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 6 Dec 2022 22:40:27 +0000 Subject: [PATCH] GridPrinter: Add example with StringGrid.Columns. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8638 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/stringgrid_columns/project1.lpi | 90 ++++++++++++++ .../examples/stringgrid_columns/project1.lpr | 25 ++++ .../examples/stringgrid_columns/unit1.lfm | 114 ++++++++++++++++++ .../examples/stringgrid_columns/unit1.pas | 43 +++++++ 4 files changed, 272 insertions(+) create mode 100644 components/gridprinter/examples/stringgrid_columns/project1.lpi create mode 100644 components/gridprinter/examples/stringgrid_columns/project1.lpr create mode 100644 components/gridprinter/examples/stringgrid_columns/unit1.lfm create mode 100644 components/gridprinter/examples/stringgrid_columns/unit1.pas diff --git a/components/gridprinter/examples/stringgrid_columns/project1.lpi b/components/gridprinter/examples/stringgrid_columns/project1.lpi new file mode 100644 index 000000000..f0c855118 --- /dev/null +++ b/components/gridprinter/examples/stringgrid_columns/project1.lpi @@ -0,0 +1,90 @@ + + + + + + + + + + + + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> + <Icon Value="0"/> + </General> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <RequiredPackages Count="3"> + <Item1> + <PackageName Value="Printer4Lazarus"/> + </Item1> + <Item2> + <PackageName Value="GridPrinterPkg"/> + </Item2> + <Item3> + <PackageName Value="LCL"/> + </Item3> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="project1.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="project1"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + </Debugging> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/components/gridprinter/examples/stringgrid_columns/project1.lpr b/components/gridprinter/examples/stringgrid_columns/project1.lpr new file mode 100644 index 000000000..cb17c8b9d --- /dev/null +++ b/components/gridprinter/examples/stringgrid_columns/project1.lpr @@ -0,0 +1,25 @@ +program project1; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX} + cthreads, + {$ENDIF} + {$IFDEF HASAMIGA} + athreads, + {$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, printer4lazarus, Unit1 + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/components/gridprinter/examples/stringgrid_columns/unit1.lfm b/components/gridprinter/examples/stringgrid_columns/unit1.lfm new file mode 100644 index 000000000..268629da6 --- /dev/null +++ b/components/gridprinter/examples/stringgrid_columns/unit1.lfm @@ -0,0 +1,114 @@ +object Form1: TForm1 + Left = 256 + Height = 324 + Top = 134 + Width = 303 + Caption = 'Form1' + ClientHeight = 324 + ClientWidth = 303 + LCLVersion = '2.3.0.0' + object StringGrid1: TStringGrid + Left = 0 + Height = 287 + Top = 0 + Width = 303 + Align = alClient + ColCount = 4 + Columns = < + item + Title.Caption = 'Col 1' + Width = 64 + end + item + Alignment = taRightJustify + Title.Alignment = taRightJustify + Title.Caption = 'Col 2' + Width = 64 + end + item + ButtonStyle = cbsCheckboxColumn + Color = clActiveBorder + Title.Alignment = taCenter + Title.Caption = 'Col 3' + Width = 64 + end> + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll, goFixedRowNumbering] + TabOrder = 0 + Cells = ( + 11 + 1 + 1 + 'abc' + 1 + 2 + 'def' + 1 + 3 + 'ghi' + 1 + 4 + 'jkl' + 2 + 1 + 'test 1' + 2 + 2 + 'test 2' + 2 + 3 + 'test 3' + 2 + 4 + 'test 5' + 3 + 1 + '1' + 3 + 2 + '0' + 3 + 4 + '1' + ) + end + object Panel1: TPanel + Left = 0 + Height = 37 + Top = 287 + Width = 303 + Align = alBottom + AutoSize = True + BevelOuter = bvNone + ClientHeight = 37 + ClientWidth = 303 + TabOrder = 1 + object Button1: TButton + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = Panel1 + Left = 6 + Height = 25 + Top = 6 + Width = 75 + BorderSpacing.Around = 6 + Caption = 'Preview...' + OnClick = Button1Click + TabOrder = 0 + end + end + object GridPrinter1: TGridPrinter + Grid = StringGrid1 + Footer.Font.Height = -11 + Footer.FontSize = 8 + Header.Font.Height = -11 + Header.FontSize = 8 + ShowPrintDialog = gpdPrintDialog + Left = 63 + Top = 143 + end + object GridPrintPreviewDialog1: TGridPrintPreviewDialog + FormParams.PixelsPerInch = 96 + GridPrinter = GridPrinter1 + Left = 192 + Top = 143 + end +end diff --git a/components/gridprinter/examples/stringgrid_columns/unit1.pas b/components/gridprinter/examples/stringgrid_columns/unit1.pas new file mode 100644 index 000000000..7ea6c94ee --- /dev/null +++ b/components/gridprinter/examples/stringgrid_columns/unit1.pas @@ -0,0 +1,43 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids, ExtCtrls, + StdCtrls, GridPrn, GridPrnPreviewDlg; + +type + + { TForm1 } + + TForm1 = class(TForm) + Button1: TButton; + GridPrinter1: TGridPrinter; + GridPrintPreviewDialog1: TGridPrintPreviewDialog; + Panel1: TPanel; + StringGrid1: TStringGrid; + procedure Button1Click(Sender: TObject); + private + + public + + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +{ TForm1 } + +procedure TForm1.Button1Click(Sender: TObject); +begin + GridPrintPreviewDialog1.Execute; +end; + +end. +