mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-28 09:29:17 +02:00
Example project for CoolBar and ToolBars from Vojtech Cihak. Issue #27168.
git-svn-id: trunk@47205 -
This commit is contained in:
parent
11b7a200a1
commit
3b1a4df523
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -4653,6 +4653,11 @@ examples/controlhint/Project1.lpr svneol=native#text/plain
|
||||
examples/controlhint/Project1.res -text
|
||||
examples/controlhint/Unit1.lfm svneol=native#text/plain
|
||||
examples/controlhint/Unit1.pas svneol=native#text/plain
|
||||
examples/cooltoolbar/README.txt svneol=native#text/plain
|
||||
examples/cooltoolbar/project1.lpi svneol=native#text/plain
|
||||
examples/cooltoolbar/project1.lpr svneol=native#text/pascal
|
||||
examples/cooltoolbar/unit1.lfm svneol=native#text/plain
|
||||
examples/cooltoolbar/unit1.pas svneol=native#text/pascal
|
||||
examples/cursors/car.cur -text svneol=unset#image/x-cursor
|
||||
examples/cursors/car.res -text
|
||||
examples/cursors/project1.lpi svneol=native#text/plain
|
||||
|
7
examples/cooltoolbar/README.txt
Normal file
7
examples/cooltoolbar/README.txt
Normal file
@ -0,0 +1,7 @@
|
||||
Demonstrates the usage of TToolBars inside a TCoolBar.
|
||||
|
||||
Contains a CoolBar with five FixedSize bands with ToolBars.
|
||||
It can be configured (orientation, visibility, size of buttons).
|
||||
This configuration is stored to INI file and is restored when you run demo again.
|
||||
|
||||
Author: Vojtech Cihak
|
135
examples/cooltoolbar/project1.lpi
Normal file
135
examples/cooltoolbar/project1.lpi
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="CoolToolBar"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
<Item2 Name="Final">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="."/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<CStyleOperator Value="False"/>
|
||||
<AllowLabel Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<TargetCPU Value="x86_64"/>
|
||||
<TargetOS Value="linux"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsStabs"/>
|
||||
<StripSymbols Value="True"/>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-godwarfsets"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
<SharedMatrixOptions Count="1">
|
||||
<Item1 ID="656728948051" Type="IDEMacro" MacroName="LCLWidgetType" Value="gtk2"/>
|
||||
</SharedMatrixOptions>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="CoolBarDemo"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="include;$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="."/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<CStyleOperator Value="False"/>
|
||||
<AllowLabel Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<TargetCPU Value="x86_64"/>
|
||||
<TargetOS Value="linux"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="0"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-godwarfsets"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
22
examples/cooltoolbar/project1.lpr
Normal file
22
examples/cooltoolbar/project1.lpr
Normal file
@ -0,0 +1,22 @@
|
||||
program project1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, Unit1
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Title:='CoolToolBar';
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TCoolBarDemo, CoolBarDemo);
|
||||
Application.Run;
|
||||
end.
|
||||
|
477
examples/cooltoolbar/unit1.lfm
Normal file
477
examples/cooltoolbar/unit1.lfm
Normal file
@ -0,0 +1,477 @@
|
||||
object CoolBarDemo: TCoolBarDemo
|
||||
Left = 505
|
||||
Height = 490
|
||||
Top = 205
|
||||
Width = 647
|
||||
Caption = 'CoolBarDemo'
|
||||
ClientHeight = 465
|
||||
ClientWidth = 647
|
||||
Menu = MainMenu1
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '1.3'
|
||||
object CoolBar1: TCoolBar
|
||||
Left = 0
|
||||
Height = 152
|
||||
Top = 0
|
||||
Width = 646
|
||||
Align = alNone
|
||||
AutoSize = True
|
||||
Bands = <
|
||||
item
|
||||
Control = ToolBar1
|
||||
FixedSize = True
|
||||
Width = 179
|
||||
end
|
||||
item
|
||||
Control = ToolBar2
|
||||
FixedSize = True
|
||||
Width = 179
|
||||
end
|
||||
item
|
||||
Control = ToolBar3
|
||||
FixedSize = True
|
||||
Width = 179
|
||||
end
|
||||
item
|
||||
Control = ToolBar4
|
||||
FixedSize = True
|
||||
Width = 179
|
||||
end
|
||||
item
|
||||
Control = ToolBar5
|
||||
FixedSize = True
|
||||
Width = 179
|
||||
end>
|
||||
PopupMenu = PopupMenu1
|
||||
object ToolBar1: TToolBar
|
||||
AnchorSideLeft.Control = CoolBar1
|
||||
AnchorSideTop.Control = CoolBar1
|
||||
Left = 24
|
||||
Height = 22
|
||||
Top = 5
|
||||
Width = 69
|
||||
Align = alNone
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 22
|
||||
BorderSpacing.Top = 3
|
||||
ButtonWidth = 22
|
||||
Caption = 'ToolBar1'
|
||||
EdgeBorders = []
|
||||
EdgeInner = esNone
|
||||
EdgeOuter = esNone
|
||||
Flat = False
|
||||
Indent = 0
|
||||
ShowCaptions = True
|
||||
TabOrder = 0
|
||||
object TBtn11: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = '11'
|
||||
end
|
||||
object TBtn12: TToolButton
|
||||
Left = 23
|
||||
Top = 0
|
||||
Caption = '12'
|
||||
end
|
||||
object TBtn13: TToolButton
|
||||
Left = 46
|
||||
Top = 0
|
||||
Caption = '13'
|
||||
end
|
||||
end
|
||||
object ToolBar2: TToolBar
|
||||
AnchorSideLeft.Control = CoolBar1
|
||||
AnchorSideTop.Control = CoolBar1
|
||||
Left = 24
|
||||
Height = 22
|
||||
Top = 35
|
||||
Width = 92
|
||||
Align = alNone
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 22
|
||||
BorderSpacing.Top = 33
|
||||
ButtonWidth = 22
|
||||
Caption = 'ToolBar2'
|
||||
EdgeBorders = []
|
||||
EdgeInner = esNone
|
||||
EdgeOuter = esNone
|
||||
Flat = False
|
||||
Indent = 0
|
||||
ShowCaptions = True
|
||||
TabOrder = 1
|
||||
object TBtn21: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = '21'
|
||||
end
|
||||
object TBtn22: TToolButton
|
||||
Left = 23
|
||||
Top = 0
|
||||
Caption = '22'
|
||||
end
|
||||
object TBtn23: TToolButton
|
||||
Left = 46
|
||||
Top = 0
|
||||
Caption = '23'
|
||||
end
|
||||
object TBtn24: TToolButton
|
||||
Left = 69
|
||||
Top = 0
|
||||
Caption = '24'
|
||||
end
|
||||
end
|
||||
object ToolBar3: TToolBar
|
||||
AnchorSideLeft.Control = CoolBar1
|
||||
AnchorSideTop.Control = CoolBar1
|
||||
Left = 24
|
||||
Height = 22
|
||||
Top = 65
|
||||
Width = 115
|
||||
Align = alNone
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 22
|
||||
BorderSpacing.Top = 63
|
||||
ButtonWidth = 22
|
||||
Caption = 'ToolBar3'
|
||||
EdgeBorders = []
|
||||
EdgeInner = esNone
|
||||
EdgeOuter = esNone
|
||||
Flat = False
|
||||
Indent = 0
|
||||
ShowCaptions = True
|
||||
TabOrder = 2
|
||||
object TBtn31: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = '31'
|
||||
end
|
||||
object TBtn32: TToolButton
|
||||
Left = 23
|
||||
Top = 0
|
||||
Caption = '32'
|
||||
end
|
||||
object TBtn33: TToolButton
|
||||
Left = 46
|
||||
Top = 0
|
||||
Caption = '33'
|
||||
end
|
||||
object TBtn34: TToolButton
|
||||
Left = 69
|
||||
Top = 0
|
||||
Caption = '34'
|
||||
end
|
||||
object TBtn35: TToolButton
|
||||
Left = 92
|
||||
Top = 0
|
||||
Caption = '35'
|
||||
end
|
||||
end
|
||||
object ToolBar4: TToolBar
|
||||
AnchorSideLeft.Control = CoolBar1
|
||||
AnchorSideTop.Control = CoolBar1
|
||||
Left = 24
|
||||
Height = 22
|
||||
Top = 95
|
||||
Width = 69
|
||||
Align = alNone
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 22
|
||||
BorderSpacing.Top = 93
|
||||
ButtonWidth = 22
|
||||
Caption = 'ToolBar4'
|
||||
EdgeBorders = []
|
||||
EdgeInner = esNone
|
||||
EdgeOuter = esNone
|
||||
Flat = False
|
||||
Indent = 0
|
||||
ShowCaptions = True
|
||||
TabOrder = 3
|
||||
object TBtn41: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = '41'
|
||||
end
|
||||
object TBtn42: TToolButton
|
||||
Left = 23
|
||||
Top = 0
|
||||
Caption = '42'
|
||||
end
|
||||
object TBtn43: TToolButton
|
||||
Left = 46
|
||||
Top = 0
|
||||
Caption = '43'
|
||||
end
|
||||
end
|
||||
object ToolBar5: TToolBar
|
||||
AnchorSideLeft.Control = CoolBar1
|
||||
AnchorSideTop.Control = CoolBar1
|
||||
Left = 24
|
||||
Height = 22
|
||||
Top = 125
|
||||
Width = 138
|
||||
Align = alNone
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 22
|
||||
BorderSpacing.Top = 123
|
||||
ButtonWidth = 22
|
||||
Caption = 'ToolBar5'
|
||||
EdgeBorders = []
|
||||
EdgeInner = esNone
|
||||
EdgeOuter = esNone
|
||||
Flat = False
|
||||
Indent = 0
|
||||
ShowCaptions = True
|
||||
TabOrder = 4
|
||||
object TBtn51: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = '51'
|
||||
end
|
||||
object TBtn52: TToolButton
|
||||
Left = 23
|
||||
Top = 0
|
||||
Caption = '52'
|
||||
end
|
||||
object TBtn53: TToolButton
|
||||
Left = 46
|
||||
Top = 0
|
||||
Caption = '53'
|
||||
end
|
||||
object TBtn54: TToolButton
|
||||
Left = 69
|
||||
Top = 0
|
||||
Caption = '54'
|
||||
end
|
||||
object TBtn55: TToolButton
|
||||
Left = 92
|
||||
Top = 0
|
||||
Caption = '55'
|
||||
end
|
||||
object TBtn56: TToolButton
|
||||
Left = 115
|
||||
Top = 0
|
||||
Caption = '56'
|
||||
end
|
||||
end
|
||||
end
|
||||
object RadioGroup1: TRadioGroup
|
||||
Left = 224
|
||||
Height = 73
|
||||
Top = 176
|
||||
Width = 168
|
||||
AutoFill = True
|
||||
Caption = 'BiDi Mode'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 54
|
||||
ClientWidth = 164
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'Left to Right'
|
||||
'Right to Left'
|
||||
)
|
||||
OnClick = RadioGroup1Click
|
||||
TabOrder = 1
|
||||
end
|
||||
object ComboBox1: TComboBox
|
||||
Left = 224
|
||||
Height = 21
|
||||
Top = 288
|
||||
Width = 168
|
||||
ItemHeight = 15
|
||||
ItemIndex = 1
|
||||
Items.Strings = (
|
||||
'gsSimple'
|
||||
'gsDouble'
|
||||
'gsHorLines'
|
||||
'gsVerLines'
|
||||
'gsGripper'
|
||||
'gsButton'
|
||||
)
|
||||
OnChange = ComboBox1Change
|
||||
Style = csDropDownList
|
||||
TabOrder = 2
|
||||
Text = 'gsDouble'
|
||||
end
|
||||
object Label1: TLabel
|
||||
Left = 224
|
||||
Height = 15
|
||||
Top = 265
|
||||
Width = 65
|
||||
Caption = 'Grab Style'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 224
|
||||
Height = 15
|
||||
Top = 328
|
||||
Width = 69
|
||||
Caption = 'Grab Width'
|
||||
ParentColor = False
|
||||
end
|
||||
object SpinEdit1: TSpinEdit
|
||||
AnchorSideTop.Control = Label2
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 344
|
||||
Height = 21
|
||||
Top = 325
|
||||
Width = 50
|
||||
OnChange = SpinEdit1Change
|
||||
TabOrder = 3
|
||||
Value = 10
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 232
|
||||
Height = 25
|
||||
Top = 376
|
||||
Width = 123
|
||||
Caption = 'Autosize Bands'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 4
|
||||
end
|
||||
object MainMenu1: TMainMenu
|
||||
left = 552
|
||||
top = 168
|
||||
object MenuItem1: TMenuItem
|
||||
Caption = 'View'
|
||||
object MITBSmall: TMenuItem
|
||||
Action = AcToolBarSmall
|
||||
AutoCheck = True
|
||||
GroupIndex = 11
|
||||
RadioItem = True
|
||||
end
|
||||
object MITBMedium: TMenuItem
|
||||
Action = AcToolBarMedium
|
||||
AutoCheck = True
|
||||
GroupIndex = 11
|
||||
RadioItem = True
|
||||
end
|
||||
object MITBLarge: TMenuItem
|
||||
Action = AcToolBarLarge
|
||||
AutoCheck = True
|
||||
GroupIndex = 11
|
||||
RadioItem = True
|
||||
end
|
||||
object MenuItem2: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object MITBLeft: TMenuItem
|
||||
Action = AcTBLeft
|
||||
AutoCheck = True
|
||||
GroupIndex = 12
|
||||
RadioItem = True
|
||||
end
|
||||
object MITBTop: TMenuItem
|
||||
Action = AcTBTop
|
||||
AutoCheck = True
|
||||
GroupIndex = 12
|
||||
RadioItem = True
|
||||
end
|
||||
object MITBRight: TMenuItem
|
||||
Action = AcTBRight
|
||||
AutoCheck = True
|
||||
GroupIndex = 12
|
||||
RadioItem = True
|
||||
end
|
||||
object MenuItem3: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object MIShowTB1: TMenuItem
|
||||
Action = AcTB1Visi
|
||||
AutoCheck = True
|
||||
end
|
||||
object MIShowTB2: TMenuItem
|
||||
Action = AcTB2Visi
|
||||
AutoCheck = True
|
||||
end
|
||||
object MIShowTB3: TMenuItem
|
||||
Action = AcTB3Visi
|
||||
AutoCheck = True
|
||||
end
|
||||
object MIShowTB4: TMenuItem
|
||||
Action = AcTB4Visi
|
||||
AutoCheck = True
|
||||
end
|
||||
object MIShowTB5: TMenuItem
|
||||
Action = AcTB5Visi
|
||||
AutoCheck = True
|
||||
end
|
||||
end
|
||||
end
|
||||
object ActionList1: TActionList
|
||||
left = 552
|
||||
top = 232
|
||||
object AcToolBarSmall: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Small Buttons'
|
||||
GroupIndex = 11
|
||||
OnExecute = AcToolBarSmallExecute
|
||||
end
|
||||
object AcToolBarMedium: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Medium Buttons'
|
||||
GroupIndex = 11
|
||||
OnExecute = AcToolBarMediumExecute
|
||||
end
|
||||
object AcToolBarLarge: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Large Buttons'
|
||||
GroupIndex = 11
|
||||
OnExecute = AcToolBarLargeExecute
|
||||
end
|
||||
object AcTBLeft: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Toolbar Left'
|
||||
GroupIndex = 12
|
||||
OnExecute = AcTBLeftExecute
|
||||
end
|
||||
object AcTBTop: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Toolbar Top'
|
||||
GroupIndex = 12
|
||||
OnExecute = AcTBTopExecute
|
||||
end
|
||||
object AcTBRight: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Toolbar Right'
|
||||
GroupIndex = 12
|
||||
OnExecute = AcTBRightExecute
|
||||
end
|
||||
object AcTB1Visi: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Show Toolbar1'
|
||||
OnExecute = AcTB1VisiExecute
|
||||
end
|
||||
object AcTB2Visi: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Show Toolbar2'
|
||||
OnExecute = AcTB2VisiExecute
|
||||
end
|
||||
object AcTB3Visi: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Show Toolbar3'
|
||||
OnExecute = AcTB3VisiExecute
|
||||
end
|
||||
object AcTB4Visi: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Show Toolbar4'
|
||||
OnExecute = AcTB4VisiExecute
|
||||
end
|
||||
object AcTB5Visi: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Show Toolbar5'
|
||||
OnExecute = AcTB5VisiExecute
|
||||
end
|
||||
end
|
||||
object PopupMenu1: TPopupMenu
|
||||
left = 552
|
||||
top = 296
|
||||
end
|
||||
end
|
384
examples/cooltoolbar/unit1.pas
Normal file
384
examples/cooltoolbar/unit1.pas
Normal file
@ -0,0 +1,384 @@
|
||||
unit Unit1;
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
|
||||
Menus, ActnList, ExtCtrls, StdCtrls, Spin, Toolwin, IniFiles;
|
||||
|
||||
type
|
||||
{ TCoolBarDemo }
|
||||
TCoolBarDemo = class(TForm)
|
||||
AcTBLeft: TAction;
|
||||
AcTBTop: TAction;
|
||||
AcTBRight: TAction;
|
||||
AcTB1Visi: TAction;
|
||||
AcTB2Visi: TAction;
|
||||
AcTB3Visi: TAction;
|
||||
AcTB4Visi: TAction;
|
||||
AcTB5Visi: TAction;
|
||||
AcToolBarSmall: TAction;
|
||||
AcToolBarMedium: TAction;
|
||||
AcToolBarLarge: TAction;
|
||||
ActionList1: TActionList;
|
||||
Button1: TButton;
|
||||
ComboBox1: TComboBox;
|
||||
CoolBar1: TCoolBar;
|
||||
Label1: TLabel;
|
||||
Label2: TLabel;
|
||||
MainMenu1: TMainMenu;
|
||||
MenuItem1: TMenuItem;
|
||||
MenuItem2: TMenuItem;
|
||||
MenuItem3: TMenuItem;
|
||||
MIShowTB1: TMenuItem;
|
||||
MIShowTB2: TMenuItem;
|
||||
MIShowTB3: TMenuItem;
|
||||
MIShowTB4: TMenuItem;
|
||||
MIShowTB5: TMenuItem;
|
||||
MITBLeft: TMenuItem;
|
||||
MITBTop: TMenuItem;
|
||||
MITBRight: TMenuItem;
|
||||
MITBMedium: TMenuItem;
|
||||
MITBLarge: TMenuItem;
|
||||
MITBSmall: TMenuItem;
|
||||
PopupMenu1: TPopupMenu;
|
||||
RadioGroup1: TRadioGroup;
|
||||
SpinEdit1: TSpinEdit;
|
||||
ToolBar1: TToolBar;
|
||||
ToolBar2: TToolBar;
|
||||
ToolBar3: TToolBar;
|
||||
ToolBar4: TToolBar;
|
||||
ToolBar5: TToolBar;
|
||||
TBtn21: TToolButton;
|
||||
TBtn22: TToolButton;
|
||||
TBtn23: TToolButton;
|
||||
TBtn24: TToolButton;
|
||||
TBtn11: TToolButton;
|
||||
TBtn12: TToolButton;
|
||||
TBtn13: TToolButton;
|
||||
TBtn41: TToolButton;
|
||||
TBtn42: TToolButton;
|
||||
TBtn43: TToolButton;
|
||||
TBtn31: TToolButton;
|
||||
TBtn32: TToolButton;
|
||||
TBtn33: TToolButton;
|
||||
TBtn34: TToolButton;
|
||||
TBtn35: TToolButton;
|
||||
TBtn51: TToolButton;
|
||||
TBtn52: TToolButton;
|
||||
TBtn53: TToolButton;
|
||||
TBtn54: TToolButton;
|
||||
TBtn55: TToolButton;
|
||||
TBtn56: TToolButton;
|
||||
procedure AcTB1VisiExecute(Sender: TObject);
|
||||
procedure AcTB2VisiExecute(Sender: TObject);
|
||||
procedure AcTB3VisiExecute(Sender: TObject);
|
||||
procedure AcTB4VisiExecute(Sender: TObject);
|
||||
procedure AcTB5VisiExecute(Sender: TObject);
|
||||
procedure AcTBLeftExecute(Sender: TObject);
|
||||
procedure AcTBRightExecute(Sender: TObject);
|
||||
procedure AcTBTopExecute(Sender: TObject);
|
||||
procedure AcToolBarLargeExecute(Sender: TObject);
|
||||
procedure AcToolBarMediumExecute(Sender: TObject);
|
||||
procedure AcToolBarSmallExecute(Sender: TObject);
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure ComboBox1Change(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure RadioGroup1Click(Sender: TObject);
|
||||
procedure SpinEdit1Change(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
IniFileName: string;
|
||||
const
|
||||
cTBSmall = 0;
|
||||
cTBMedium = 1;
|
||||
cTBLarge = 2;
|
||||
cTBTop = 0;
|
||||
cTBLeft = 1;
|
||||
cTBRight = 2;
|
||||
cCoolBarSettings = 'CoolBarSettings';
|
||||
cButtonSize = 'ButtonSize';
|
||||
cCoolBarPos = 'CoolBarPos';
|
||||
cBandBreak = 'CoolBandBreak';
|
||||
cBandPos = 'CoolBandPos';
|
||||
cBandVisi = 'CoolBandVisi';
|
||||
procedure LoadFromIni;
|
||||
procedure SaveToIni;
|
||||
procedure SetButtonSize(ASize: Integer);
|
||||
procedure SetCoolBarAlign(AAlign: TAlign; AVertical: Boolean);
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
CoolBarDemo: TCoolBarDemo;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TCoolBarDemo }
|
||||
|
||||
procedure TCoolBarDemo.RadioGroup1Click(Sender: TObject);
|
||||
begin
|
||||
case TRadioGroup(Sender).ItemIndex of
|
||||
0: CoolBar1.BiDiMode:=bdLeftToRight;
|
||||
1: CoolBar1.BiDiMode:=bdRightToLeft;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.SpinEdit1Change(Sender: TObject);
|
||||
begin
|
||||
CoolBar1.GrabWidth:=TSpinEdit(Sender).Value;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.LoadFromIni;
|
||||
var INI:TINIFile;
|
||||
i, j, aPos: Integer;
|
||||
begin
|
||||
INI:=TIniFile.Create(IniFileName);
|
||||
try
|
||||
i:=INI.ReadInteger(cCoolBarSettings, cButtonSize, cTBSmall);
|
||||
if i=cTBSmall
|
||||
then AcToolBarSmall.Execute
|
||||
else if i=cTBMedium
|
||||
then AcToolBarMedium.Execute
|
||||
else AcToolBarLarge.Execute;
|
||||
i:=INI.ReadInteger(cCoolBarSettings, cCoolBarPos, cTBTop);
|
||||
if i=cTBTop
|
||||
then AcTBTop.Execute
|
||||
else if i=cTBLeft
|
||||
then AcTBLeft.Execute
|
||||
else AcTBRight.Execute;
|
||||
CoolBar1.DisableAutoSizing;
|
||||
for i:=0 to CoolBar1.Bands.Count-1 do
|
||||
begin
|
||||
aPos:=INI.ReadInteger(cCoolBarSettings, cBandPos+inttostr(i), i);
|
||||
if aPos<>CoolBar1.Bands[i].ID then
|
||||
for j:=i+1 to CoolBar1.Bands.Count-1 do
|
||||
if CoolBar1.Bands[j].ID=aPos then
|
||||
begin
|
||||
CoolBar1.Bands[j].Index:=i;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
for i:=0 to CoolBar1.Bands.Count-1 do
|
||||
begin
|
||||
CoolBar1.Bands[i].Break:=INI.ReadBool(cCoolBarSettings, cBandBreak+inttostr(i), True);
|
||||
CoolBar1.Bands[i].Visible:=INI.ReadBool(cCoolBarSettings, cBandVisi+inttostr(i), True);
|
||||
end;
|
||||
CoolBar1.EnableAutoSizing;
|
||||
AcTB1Visi.Checked:=TCoolBand(CoolBar1.Bands.FindItemID(0)).Visible;
|
||||
AcTB2Visi.Checked:=TCoolBand(CoolBar1.Bands.FindItemID(1)).Visible;
|
||||
AcTB3Visi.Checked:=TCoolBand(CoolBar1.Bands.FindItemID(2)).Visible;
|
||||
AcTB4Visi.Checked:=TCoolBand(CoolBar1.Bands.FindItemID(3)).Visible;
|
||||
AcTB5Visi.Checked:=TCoolBand(CoolBar1.Bands.FindItemID(4)).Visible;
|
||||
finally
|
||||
INI.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.SaveToIni;
|
||||
var INI:TINIFile;
|
||||
i: Integer;
|
||||
begin
|
||||
INI:=TIniFile.Create(IniFileName);
|
||||
try
|
||||
if AcToolBarLarge.Checked
|
||||
then i:=cTBLarge
|
||||
else if AcToolBarMedium.Checked
|
||||
then i:=cTBMedium
|
||||
else i:=cTBSmall;
|
||||
INI.WriteInteger(cCoolBarSettings, cButtonSize, i);
|
||||
if AcTBLeft.Checked
|
||||
then i:=cTBLeft
|
||||
else if AcTBRight.Checked
|
||||
then i:=cTBRight
|
||||
else i:=cTBTop;
|
||||
INI.WriteInteger(cCoolBarSettings, cCoolBarPos, i);
|
||||
for i:=0 to CoolBar1.Bands.Count-1 do
|
||||
begin
|
||||
INI.WriteInteger(cCoolBarSettings, cBandPos+inttostr(i), CoolBar1.Bands[i].ID);
|
||||
INI.WriteBool(cCoolBarSettings, cBandBreak+inttostr(i), CoolBar1.Bands[i].Break);
|
||||
INI.WriteBool(cCoolBarSettings, cBandVisi+inttostr(i), CoolBar1.Bands[i].Visible);
|
||||
end;
|
||||
finally
|
||||
INI.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.SetButtonSize(ASize: Integer);
|
||||
begin
|
||||
ToolBar1.ButtonWidth:=ASize;
|
||||
ToolBar1.ButtonHeight:=ASize;
|
||||
ToolBar2.ButtonWidth:=ASize;
|
||||
ToolBar2.ButtonHeight:=ASize;
|
||||
ToolBar3.ButtonWidth:=ASize;
|
||||
ToolBar3.ButtonHeight:=ASize;
|
||||
ToolBar4.ButtonWidth:=ASize;
|
||||
ToolBar4.ButtonHeight:=ASize;
|
||||
ToolBar5.ButtonWidth:=ASize;
|
||||
ToolBar5.ButtonHeight:=ASize;
|
||||
CoolBar1.AutosizeBands;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.SetCoolBarAlign(AAlign: TAlign; AVertical: Boolean);
|
||||
var w, h: Integer;
|
||||
bTurn: Boolean;
|
||||
begin
|
||||
BeginFormUpdate;
|
||||
bTurn:= (AVertical<>CoolBar1.Vertical);
|
||||
CoolBar1.Vertical:=AVertical;
|
||||
case AAlign of
|
||||
alLeft:
|
||||
begin
|
||||
CoolBar1.Anchors:=[akLeft, akTop, akBottom];
|
||||
CoolBar1.AnchorParallel(akLeft, 0, self);
|
||||
CoolBar1.AnchorParallel(akTop, 0, self);
|
||||
CoolBar1.AnchorParallel(akBottom, 0, self);
|
||||
CoolBar1.EdgeBorders:=[ebRight];
|
||||
end;
|
||||
alTop:
|
||||
begin
|
||||
CoolBar1.Anchors:=[akLeft, akTop, akRight];
|
||||
CoolBar1.AnchorParallel(akLeft, 0, self);
|
||||
CoolBar1.AnchorParallel(akTop, 0, self);
|
||||
CoolBar1.AnchorParallel(akRight, 0, self);
|
||||
CoolBar1.EdgeBorders:=[ebBottom];
|
||||
end;
|
||||
alRight:
|
||||
begin
|
||||
CoolBar1.Anchors:=[akRight, akTop, akBottom];
|
||||
CoolBar1.AnchorParallel(akRight, 0, self);
|
||||
CoolBar1.AnchorParallel(akTop, 0, self);
|
||||
CoolBar1.AnchorParallel(akBottom, 0, self);
|
||||
CoolBar1.EdgeBorders:=[ebLeft];
|
||||
end;
|
||||
end;
|
||||
EndFormUpdate;
|
||||
if bTurn then
|
||||
begin
|
||||
if not AVertical then
|
||||
begin
|
||||
w:=100;
|
||||
h:=25;
|
||||
end else
|
||||
begin
|
||||
w:=25;
|
||||
h:=100;
|
||||
end;
|
||||
ToolBar1.AutoSize:=False;
|
||||
ToolBar2.AutoSize:=False;
|
||||
ToolBar3.AutoSize:=False;
|
||||
ToolBar4.AutoSize:=False;
|
||||
ToolBar5.AutoSize:=False;
|
||||
ToolBar1.Width:=w;
|
||||
ToolBar1.Height:=h;
|
||||
ToolBar2.Width:=w;
|
||||
ToolBar2.Height:=h;
|
||||
ToolBar3.Width:=w;
|
||||
ToolBar3.Height:=h;
|
||||
ToolBar4.Width:=w;
|
||||
ToolBar4.Height:=h;
|
||||
ToolBar5.Width:=w;
|
||||
ToolBar5.Height:=h;
|
||||
ToolBar1.AutoSize:=True;
|
||||
ToolBar2.AutoSize:=True;
|
||||
ToolBar3.AutoSize:=True;
|
||||
ToolBar4.AutoSize:=True;
|
||||
ToolBar5.AutoSize:=True;
|
||||
end;
|
||||
CoolBar1.AutosizeBands;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.ComboBox1Change(Sender: TObject);
|
||||
begin
|
||||
CoolBar1.GrabStyle:=TGrabStyle(TComboBox(Sender).ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.FormActivate(Sender: TObject);
|
||||
begin
|
||||
LoadFromIni;
|
||||
CoolBarDemo.OnActivate:=nil;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.FormCreate(Sender: TObject);
|
||||
var
|
||||
ConfDir: String;
|
||||
begin
|
||||
ConfDir:=GetAppConfigDir(False);
|
||||
ForceDirectories(ConfDir);
|
||||
IniFileName:=ConfDir+'cooltoolbar.ini';
|
||||
writeln(IniFileName);
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
SaveToIni;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcToolBarLargeExecute(Sender: TObject);
|
||||
begin
|
||||
SetButtonSize(38);
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcTBLeftExecute(Sender: TObject);
|
||||
begin
|
||||
SetCoolBarAlign(alLeft, True);
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcTB1VisiExecute(Sender: TObject);
|
||||
begin
|
||||
TCoolBand(CoolBar1.Bands.FindItemID(0)).Visible:=TAction(Sender).Checked;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcTB2VisiExecute(Sender: TObject);
|
||||
begin
|
||||
TCoolBand(CoolBar1.Bands.FindItemID(1)).Visible:=TAction(Sender).Checked;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcTB3VisiExecute(Sender: TObject);
|
||||
begin
|
||||
TCoolBand(CoolBar1.Bands.FindItemID(2)).Visible:=TAction(Sender).Checked;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcTB4VisiExecute(Sender: TObject);
|
||||
begin
|
||||
TCoolBand(CoolBar1.Bands.FindItemID(3)).Visible:=TAction(Sender).Checked;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcTB5VisiExecute(Sender: TObject);
|
||||
begin
|
||||
TCoolBand(CoolBar1.Bands.FindItemID(4)).Visible:=TAction(Sender).Checked;
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcTBRightExecute(Sender: TObject);
|
||||
begin
|
||||
SetCoolBarAlign(alRight, True);
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcTBTopExecute(Sender: TObject);
|
||||
begin
|
||||
SetCoolBarAlign(alTop, False);
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcToolBarMediumExecute(Sender: TObject);
|
||||
begin
|
||||
SetButtonSize(30);
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.AcToolBarSmallExecute(Sender: TObject);
|
||||
begin
|
||||
SetButtonSize(22);
|
||||
end;
|
||||
|
||||
procedure TCoolBarDemo.Button1Click(Sender: TObject);
|
||||
begin
|
||||
CoolBar1.AutosizeBands;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user