diff --git a/label_properties/label_form.lfm b/label_properties/label_form.lfm new file mode 100644 index 0000000..3708af2 --- /dev/null +++ b/label_properties/label_form.lfm @@ -0,0 +1,90 @@ +object propertiesForm: TpropertiesForm + Left = 308 + Height = 285 + Top = 239 + Width = 400 + Caption = 'TLabel properties demo' + ClientHeight = 285 + ClientWidth = 400 + OnCreate = FormCreate + LCLVersion = '2.0.12.0' + object rgAlignment: TRadioGroup + Left = 0 + Height = 130 + Top = 150 + Width = 125 + AutoFill = True + Caption = 'Alignment' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 110 + ClientWidth = 121 + ItemIndex = 0 + Items.Strings = ( + 'taLeftJustify' + 'taRightJustify' + 'taCenter' + ) + OnClick = rgAlignmentClick + TabOrder = 0 + end + object rgLayout: TRadioGroup + Left = 137 + Height = 130 + Top = 150 + Width = 125 + AutoFill = True + Caption = 'Layout' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 110 + ClientWidth = 121 + ItemIndex = 0 + Items.Strings = ( + 'tlTop' + 'tlCenter' + 'tlBottom' + ) + OnClick = rgLayoutClick + TabOrder = 1 + end + object cgFontStyle: TCheckGroup + Left = 274 + Height = 130 + Top = 150 + Width = 125 + AutoFill = True + Caption = 'Font.Style' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 110 + ClientWidth = 121 + Items.Strings = ( + 'fsBold' + 'fsItalic' + 'fsUnderline' + 'fsStrikeout' + ) + OnItemClick = cgFontStyleItemClick + TabOrder = 2 + Data = { + 0400000002020202 + } + end +end diff --git a/label_properties/label_form.pas b/label_properties/label_form.pas new file mode 100644 index 0000000..5ac8dae --- /dev/null +++ b/label_properties/label_form.pas @@ -0,0 +1,112 @@ +unit label_form; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls; + +const + limit = 3; + cWidth = 100; + cHeight = 35; + +type + TLabelGrid = array[0..limit, 0..limit] of TLabel; + + { TpropertiesForm } + + TpropertiesForm = class(TForm) + cgFontStyle: TCheckGroup; + rgAlignment: TRadioGroup; + rgLayout: TRadioGroup; + procedure cgFontStyleItemClick(Sender: TObject; Index: integer); + procedure FormCreate(Sender: TObject); + procedure rgAlignmentClick(Sender: TObject); + procedure rgLayoutClick(Sender: TObject); + private + labelGrid: TLabelGrid; + procedure SetupLabelGrid; + function CreateLabel(aCol, aRow: integer): TLabel; + end; + +var + propertiesForm: TpropertiesForm; + +implementation + +{$R *.lfm} + +{ TpropertiesForm } + +procedure TpropertiesForm.FormCreate(Sender: TObject); +begin + SetupLabelGrid; +end; + +procedure TpropertiesForm.cgFontStyleItemClick(Sender: TObject; Index: integer); +var c, r :integer; + fs: TFontStyle; +begin + fs := TFontStyle(Index); + for c := 0 to limit do + for r := 0 to limit do + if cgFontStyle.Checked[Index] + then labelGrid[c, r].Font.Style := labelGrid[c, r].Font.Style + [fs] + else labelGrid[c, r].Font.Style := labelGrid[c, r].Font.Style - [fs]; +end; + +procedure TpropertiesForm.rgAlignmentClick(Sender: TObject); +var rg: TRadioGroup; + c, r, idx: integer; + alignment: TAlignment; +begin + rg := TRadioGroup(Sender); // Cast sender object to its concrete type + idx := rg.ItemIndex; + alignment := TAlignment(idx); + for c := 0 to limit do + for r := 0 to limit do + labelGrid[c, r].Alignment := alignment; +end; + +procedure TpropertiesForm.rgLayoutClick(Sender: TObject); +var rg: TRadioGroup; + c, r, idx: integer; + layout: TTextLayout; +begin + rg := TRadioGroup(Sender); + idx := rg.ItemIndex; + layout := TTextLayout(idx); + for c := 0 to limit do + for r := 0 to limit do + labelGrid[c, r].Layout := layout; +end; + +function TpropertiesForm.CreateLabel(aCol, aRow: integer): TLabel; +var sum: integer; +begin + result := TLabel.Create(Self); + result.Parent := Self; + result.Caption := Format('col: %d, row: %d', [aCol, aRow]); + result.AutoSize := False; + result.SetBounds(aCol * cWidth, aRow * cHeight, cWidth, cHeight); + + sum := aCol + aRow; + if (sum = 1) then sum := 4; + + result.Color := clInfoBk + sum; +end; + +procedure TpropertiesForm.SetupLabelGrid; +var c, r : Integer; +begin + for c := 0 to limit do + for r:= 0 to limit do + begin + labelGrid[c, r] := CreateLabel(c, r); + end; +end; + +end. + diff --git a/label_properties/label_properties.ico b/label_properties/label_properties.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/label_properties/label_properties.ico differ diff --git a/label_properties/label_properties.lpi b/label_properties/label_properties.lpi new file mode 100644 index 0000000..dd85417 --- /dev/null +++ b/label_properties/label_properties.lpi @@ -0,0 +1,78 @@ + + + + + + + + + + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True/PM"/> + </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"/> + <Modes Count="0"/> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="LCL"/> + </Item1> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="label_properties.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="label_form.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="propertiesForm"/> + <ResourceBaseClass Value="Form"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="label_properties"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <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/label_properties/label_properties.lpr b/label_properties/label_properties.lpr new file mode 100644 index 0000000..8d774bb --- /dev/null +++ b/label_properties/label_properties.lpr @@ -0,0 +1,23 @@ +program label_properties; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, label_form + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Title:='label_properties'; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TpropertiesForm, propertiesForm); + Application.Run; +end. + diff --git a/labels/labels.ico b/labels/labels.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/labels/labels.ico differ diff --git a/labels/labels.lpi b/labels/labels.lpi new file mode 100644 index 0000000..4a8ce44 --- /dev/null +++ b/labels/labels.lpi @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <General> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <Title Value="labels"/> + <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"/> + <Modes Count="0"/> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="LCL"/> + </Item1> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="labels.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="umain.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <ResourceBaseClass Value="Form"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="labels"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <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/labels/labels.lpr b/labels/labels.lpr new file mode 100644 index 0000000..c313980 --- /dev/null +++ b/labels/labels.lpr @@ -0,0 +1,23 @@ +program labels; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, umain + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Title:='labels'; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/labels/umain.lfm b/labels/umain.lfm new file mode 100644 index 0000000..cb391fd --- /dev/null +++ b/labels/umain.lfm @@ -0,0 +1,35 @@ +object Form1: TForm1 + Left = 483 + Height = 240 + Top = 198 + Width = 320 + Caption = 'Form1' + ClientHeight = 240 + ClientWidth = 320 + LCLVersion = '2.0.12.0' + object Label1: TLabel + Left = 25 + Height = 15 + Top = 112 + Width = 34 + Caption = 'Label1' + FocusControl = Edit1 + ParentColor = False + end + object Edit1: TEdit + Left = 100 + Height = 23 + Top = 108 + Width = 80 + TabOrder = 1 + Text = 'Edit1' + end + object Button1: TButton + Left = 221 + Height = 25 + Top = 106 + Width = 75 + Caption = 'Button1' + TabOrder = 0 + end +end diff --git a/labels/umain.pas b/labels/umain.pas new file mode 100644 index 0000000..b6f55d8 --- /dev/null +++ b/labels/umain.pas @@ -0,0 +1,32 @@ +unit umain; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; + +type + + { TForm1 } + + TForm1 = class(TForm) + Button1: TButton; + Edit1: TEdit; + Label1: TLabel; + private + + public + + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +end. +