SpkToolbar: Support SpkPopupMenu also by MenuButton. Integrate SpkPopupMenu into the "actions" and "runtime" demo projects.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8739 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-02-23 22:25:12 +00:00
parent 318afbd40f
commit a49c3ad55f
9 changed files with 890 additions and 1653 deletions

View File

@ -555,7 +555,7 @@ type
implementation implementation
uses uses
LCLIntf, Themes, spkt_Buttons; LCLIntf, Themes, spkt_Buttons, SpkPopup;
{ TSpkToolbarDispatch } { TSpkToolbarDispatch }
@ -2551,6 +2551,9 @@ end;
procedure TSpkToolbar.SetMenuButtonDropdownMenu(const Value: TPopupMenu); procedure TSpkToolbar.SetMenuButtonDropdownMenu(const Value: TPopupMenu);
begin begin
FMenuButtonDropdownMenu := Value; FMenuButtonDropdownMenu := Value;
if (FMenuButtonDropdownMenu is TSpkPopupMenu) then
TSpkPopupMenu(FMenuButtonDropdownMenu).Appearance := Self.Appearance;
//if Assigned(FToolbarDispatch) then //if Assigned(FToolbarDispatch) then
// FToolbarDispatch.NotifyMetricsChanged; // FToolbarDispatch.NotifyMetricsChanged;
end; end;

View File

@ -111,7 +111,6 @@ type
property AllowAllUp: Boolean read FAllowAllUp write SetAllowAllUp default false; property AllowAllUp: Boolean read FAllowAllUp write SetAllowAllUp default false;
property ButtonKind: TSpkButtonKind read FButtonKind write SetButtonKind default bkButton; property ButtonKind: TSpkButtonKind read FButtonKind write SetButtonKind default bkButton;
property Checked: Boolean read GetChecked write SetChecked default false;
property DropdownMenu: TPopupMenu read FDropdownMenu write SetDropdownMenu; property DropdownMenu: TPopupMenu read FDropdownMenu write SetDropdownMenu;
property GroupIndex: Integer read FGroupIndex write SetGroupIndex default 0; property GroupIndex: Integer read FGroupIndex write SetGroupIndex default 0;
@ -129,6 +128,7 @@ type
function GetRootComponent: TComponent; function GetRootComponent: TComponent;
property ActionLink: TSpkButtonActionLink read FActionLink; property ActionLink: TSpkButtonActionLink read FActionLink;
property Checked: Boolean read GetChecked write SetChecked default false;
published published
property Action: TBasicAction read GetAction write SetAction; property Action: TBasicAction read GetAction write SetAction;

View File

@ -76,6 +76,9 @@
<SmartLinkUnit Value="True"/> <SmartLinkUnit Value="True"/>
</CodeGeneration> </CodeGeneration>
<Linking> <Linking>
<Debugging>
<DebugInfoType Value="dsDwarf3"/>
</Debugging>
<LinkSmart Value="True"/> <LinkSmart Value="True"/>
<Options> <Options>
<Win32> <Win32>

View File

@ -4,12 +4,12 @@ object Form1: TForm1
Top = 248 Top = 248
Width = 501 Width = 501
Caption = 'TSpkToolbar demo' Caption = 'TSpkToolbar demo'
ClientHeight = 284 ClientHeight = 304
ClientWidth = 501 ClientWidth = 501
Menu = MainMenu Menu = MainMenu
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '2.1.0.0' LCLVersion = '2.3.0.0'
object ToolBar1: TToolBar object ToolBar1: TToolBar
Left = 0 Left = 0
Height = 24 Height = 24
@ -105,12 +105,12 @@ object Form1: TForm1
end end
object Panel1: TPanel object Panel1: TPanel
Left = 0 Left = 0
Height = 148 Height = 168
Top = 136 Top = 136
Width = 501 Width = 501
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 148 ClientHeight = 168
ClientWidth = 501 ClientWidth = 501
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
@ -218,6 +218,26 @@ object Form1: TForm1
Appearance.Element.ActiveInnerDarkColor = 961020 Appearance.Element.ActiveInnerDarkColor = 961020
Appearance.Element.ActiveCaptionColor = 8405614 Appearance.Element.ActiveCaptionColor = 8405614
Appearance.Element.Style = esRounded Appearance.Element.Style = esRounded
Appearance.Popup.CheckedFrameColor = 3577330
Appearance.Popup.CheckedGradientFromColor = 9823231
Appearance.Popup.CheckedGradientToColor = 9823231
Appearance.Popup.CheckedGradientType = bkSolid
Appearance.Popup.DisabledCaptionColor = clSilver
Appearance.Popup.DividerLineColor = 14922381
Appearance.Popup.GutterFrameColor = 12961221
Appearance.Popup.GutterGradientFromColor = 15658729
Appearance.Popup.GutterGradientToColor = 15658729
Appearance.Popup.GutterGradientType = bkSolid
Appearance.Popup.HotTrackCaptionColor = 8864367
Appearance.Popup.HotTrackFrameColor = 10079963
Appearance.Popup.HotTrackGradientFromColor = 14351615
Appearance.Popup.HotTrackGradientToColor = 5101567
Appearance.Popup.HotTrackGradientType = bkConcave
Appearance.Popup.IdleCaptionColor = 11631958
Appearance.Popup.IdleGradientFromColor = 16448250
Appearance.Popup.IdleGradientToColor = 16448250
Appearance.Popup.IdleGradientType = bkConcave
Appearance.Popup.Style = psGutter
TabIndex = 0 TabIndex = 0
Images = ImageList Images = ImageList
LargeImages = LargeImageList LargeImages = LargeImageList
@ -295,6 +315,26 @@ object Form1: TForm1
CustomAppearance.Element.ActiveInnerDarkColor = 961020 CustomAppearance.Element.ActiveInnerDarkColor = 961020
CustomAppearance.Element.ActiveCaptionColor = 8405614 CustomAppearance.Element.ActiveCaptionColor = 8405614
CustomAppearance.Element.Style = esRounded CustomAppearance.Element.Style = esRounded
CustomAppearance.Popup.CheckedFrameColor = 3577330
CustomAppearance.Popup.CheckedGradientFromColor = 9823231
CustomAppearance.Popup.CheckedGradientToColor = 9823231
CustomAppearance.Popup.CheckedGradientType = bkSolid
CustomAppearance.Popup.DisabledCaptionColor = clSilver
CustomAppearance.Popup.DividerLineColor = 14922381
CustomAppearance.Popup.GutterFrameColor = 12961221
CustomAppearance.Popup.GutterGradientFromColor = 15658729
CustomAppearance.Popup.GutterGradientToColor = 15658729
CustomAppearance.Popup.GutterGradientType = bkSolid
CustomAppearance.Popup.HotTrackCaptionColor = 8864367
CustomAppearance.Popup.HotTrackFrameColor = 10079963
CustomAppearance.Popup.HotTrackGradientFromColor = 14351615
CustomAppearance.Popup.HotTrackGradientToColor = 5101567
CustomAppearance.Popup.HotTrackGradientType = bkConcave
CustomAppearance.Popup.IdleCaptionColor = 11631958
CustomAppearance.Popup.IdleGradientFromColor = 16448250
CustomAppearance.Popup.IdleGradientToColor = 16448250
CustomAppearance.Popup.IdleGradientType = bkConcave
CustomAppearance.Popup.Style = psGutter
Caption = 'File' Caption = 'File'
Panes = ( Panes = (
'SpkPane1' 'SpkPane1'
@ -391,6 +431,26 @@ object Form1: TForm1
CustomAppearance.Element.ActiveInnerDarkColor = 961020 CustomAppearance.Element.ActiveInnerDarkColor = 961020
CustomAppearance.Element.ActiveCaptionColor = 8405614 CustomAppearance.Element.ActiveCaptionColor = 8405614
CustomAppearance.Element.Style = esRounded CustomAppearance.Element.Style = esRounded
CustomAppearance.Popup.CheckedFrameColor = 3577330
CustomAppearance.Popup.CheckedGradientFromColor = 9823231
CustomAppearance.Popup.CheckedGradientToColor = 9823231
CustomAppearance.Popup.CheckedGradientType = bkSolid
CustomAppearance.Popup.DisabledCaptionColor = clSilver
CustomAppearance.Popup.DividerLineColor = 14922381
CustomAppearance.Popup.GutterFrameColor = 12961221
CustomAppearance.Popup.GutterGradientFromColor = 15658729
CustomAppearance.Popup.GutterGradientToColor = 15658729
CustomAppearance.Popup.GutterGradientType = bkSolid
CustomAppearance.Popup.HotTrackCaptionColor = 8864367
CustomAppearance.Popup.HotTrackFrameColor = 10079963
CustomAppearance.Popup.HotTrackGradientFromColor = 14351615
CustomAppearance.Popup.HotTrackGradientToColor = 5101567
CustomAppearance.Popup.HotTrackGradientType = bkConcave
CustomAppearance.Popup.IdleCaptionColor = 11631958
CustomAppearance.Popup.IdleGradientFromColor = 16448250
CustomAppearance.Popup.IdleGradientToColor = 16448250
CustomAppearance.Popup.IdleGradientType = bkConcave
CustomAppearance.Popup.Style = psGutter
Caption = 'Edit' Caption = 'Edit'
Panes = ( Panes = (
'SpkPane3' 'SpkPane3'
@ -488,6 +548,26 @@ object Form1: TForm1
CustomAppearance.Element.ActiveInnerDarkColor = 961020 CustomAppearance.Element.ActiveInnerDarkColor = 961020
CustomAppearance.Element.ActiveCaptionColor = 8405614 CustomAppearance.Element.ActiveCaptionColor = 8405614
CustomAppearance.Element.Style = esRounded CustomAppearance.Element.Style = esRounded
CustomAppearance.Popup.CheckedFrameColor = 3577330
CustomAppearance.Popup.CheckedGradientFromColor = 9823231
CustomAppearance.Popup.CheckedGradientToColor = 9823231
CustomAppearance.Popup.CheckedGradientType = bkSolid
CustomAppearance.Popup.DisabledCaptionColor = clSilver
CustomAppearance.Popup.DividerLineColor = 14922381
CustomAppearance.Popup.GutterFrameColor = 12961221
CustomAppearance.Popup.GutterGradientFromColor = 15658729
CustomAppearance.Popup.GutterGradientToColor = 15658729
CustomAppearance.Popup.GutterGradientType = bkSolid
CustomAppearance.Popup.HotTrackCaptionColor = 8864367
CustomAppearance.Popup.HotTrackFrameColor = 10079963
CustomAppearance.Popup.HotTrackGradientFromColor = 14351615
CustomAppearance.Popup.HotTrackGradientToColor = 5101567
CustomAppearance.Popup.HotTrackGradientType = bkConcave
CustomAppearance.Popup.IdleCaptionColor = 11631958
CustomAppearance.Popup.IdleGradientFromColor = 16448250
CustomAppearance.Popup.IdleGradientToColor = 16448250
CustomAppearance.Popup.IdleGradientType = bkConcave
CustomAppearance.Popup.Style = psGutter
Caption = 'Format' Caption = 'Format'
Panes = ( Panes = (
'SpkPane2' 'SpkPane2'
@ -620,6 +700,26 @@ object Form1: TForm1
CustomAppearance.Element.ActiveInnerDarkColor = 961020 CustomAppearance.Element.ActiveInnerDarkColor = 961020
CustomAppearance.Element.ActiveCaptionColor = 8405614 CustomAppearance.Element.ActiveCaptionColor = 8405614
CustomAppearance.Element.Style = esRounded CustomAppearance.Element.Style = esRounded
CustomAppearance.Popup.CheckedFrameColor = 3577330
CustomAppearance.Popup.CheckedGradientFromColor = 9823231
CustomAppearance.Popup.CheckedGradientToColor = 9823231
CustomAppearance.Popup.CheckedGradientType = bkSolid
CustomAppearance.Popup.DisabledCaptionColor = clSilver
CustomAppearance.Popup.DividerLineColor = 14922381
CustomAppearance.Popup.GutterFrameColor = 12961221
CustomAppearance.Popup.GutterGradientFromColor = 15658729
CustomAppearance.Popup.GutterGradientToColor = 15658729
CustomAppearance.Popup.GutterGradientType = bkSolid
CustomAppearance.Popup.HotTrackCaptionColor = 8864367
CustomAppearance.Popup.HotTrackFrameColor = 10079963
CustomAppearance.Popup.HotTrackGradientFromColor = 14351615
CustomAppearance.Popup.HotTrackGradientToColor = 5101567
CustomAppearance.Popup.HotTrackGradientType = bkConcave
CustomAppearance.Popup.IdleCaptionColor = 11631958
CustomAppearance.Popup.IdleGradientFromColor = 16448250
CustomAppearance.Popup.IdleGradientToColor = 16448250
CustomAppearance.Popup.IdleGradientType = bkConcave
CustomAppearance.Popup.Style = psGutter
Caption = 'Options' Caption = 'Options'
Panes = ( Panes = (
'SpkPane6' 'SpkPane6'
@ -746,6 +846,26 @@ object Form1: TForm1
CustomAppearance.Element.ActiveInnerDarkColor = 961020 CustomAppearance.Element.ActiveInnerDarkColor = 961020
CustomAppearance.Element.ActiveCaptionColor = 8405614 CustomAppearance.Element.ActiveCaptionColor = 8405614
CustomAppearance.Element.Style = esRounded CustomAppearance.Element.Style = esRounded
CustomAppearance.Popup.CheckedFrameColor = 3577330
CustomAppearance.Popup.CheckedGradientFromColor = 9823231
CustomAppearance.Popup.CheckedGradientToColor = 9823231
CustomAppearance.Popup.CheckedGradientType = bkSolid
CustomAppearance.Popup.DisabledCaptionColor = clSilver
CustomAppearance.Popup.DividerLineColor = 14922381
CustomAppearance.Popup.GutterFrameColor = 12961221
CustomAppearance.Popup.GutterGradientFromColor = 15658729
CustomAppearance.Popup.GutterGradientToColor = 15658729
CustomAppearance.Popup.GutterGradientType = bkSolid
CustomAppearance.Popup.HotTrackCaptionColor = 8864367
CustomAppearance.Popup.HotTrackFrameColor = 10079963
CustomAppearance.Popup.HotTrackGradientFromColor = 14351615
CustomAppearance.Popup.HotTrackGradientToColor = 5101567
CustomAppearance.Popup.HotTrackGradientType = bkConcave
CustomAppearance.Popup.IdleCaptionColor = 11631958
CustomAppearance.Popup.IdleGradientFromColor = 16448250
CustomAppearance.Popup.IdleGradientToColor = 16448250
CustomAppearance.Popup.IdleGradientType = bkConcave
CustomAppearance.Popup.Style = psGutter
Caption = 'Help' Caption = 'Help'
Panes = ( Panes = (
'SpkPane4' 'SpkPane4'
@ -995,34 +1115,6 @@ object Form1: TForm1
end end
end end
end end
object StyleMenu: TPopupMenu
Left = 352
Top = 216
object MenuItem17: TMenuItem
Caption = 'Office2007 blue'
OnClick = StyleMenuClick
end
object MenuItem18: TMenuItem
Tag = 1
Caption = 'Office2007 silver'
OnClick = StyleMenuClick
end
object MenuItem21: TMenuItem
Tag = 2
Caption = 'Office2007 silver / turquoise'
OnClick = StyleMenuClick
end
object MenuItem19: TMenuItem
Tag = 3
Caption = 'Metro light'
OnClick = StyleMenuClick
end
object MenuItem20: TMenuItem
Tag = 4
Caption = 'Metro dark'
OnClick = StyleMenuClick
end
end
object ImageList: TImageList object ImageList: TImageList
Left = 160 Left = 160
Top = 179 Top = 179
@ -1500,4 +1592,32 @@ object Form1: TForm1
DCB672DAA75A682DACFB3F460B036BFA763A7DAA51DBFF01579529BE DCB672DAA75A682DACFB3F460B036BFA763A7DAA51DBFF01579529BE
} }
end end
object StyleMenu: TSpkPopupMenu
Left = 352
Top = 216
object MenuItem17: TMenuItem
Caption = 'Office2007 blue'
OnClick = StyleMenuClick
end
object MenuItem18: TMenuItem
Tag = 1
Caption = 'Office2007 silver'
OnClick = StyleMenuClick
end
object MenuItem21: TMenuItem
Tag = 2
Caption = 'Office2007 silver / turquoise'
OnClick = StyleMenuClick
end
object MenuItem19: TMenuItem
Tag = 3
Caption = 'Metro light'
OnClick = StyleMenuClick
end
object MenuItem20: TMenuItem
Tag = 4
Caption = 'Metro dark'
OnClick = StyleMenuClick
end
end
end end

View File

@ -6,8 +6,8 @@ interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ActnList, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ActnList,
StdActns, StdCtrls, Menus, ComCtrls, ExtCtrls, StdActns, StdCtrls, Menus, ComCtrls, ExtCtrls, SpkToolbar, spkt_Buttons,
SpkToolbar, spkt_Buttons, spkt_Checkboxes, spkt_Pane, spkt_Tab, spkt_Appearance; spkt_Checkboxes, spkt_Pane, spkt_Tab, spkt_Appearance, SpkPopup;
type type
@ -85,7 +85,6 @@ type
SpkSmallButton9: TSpkSmallButton; SpkSmallButton9: TSpkSmallButton;
SpkTab4: TSpkTab; SpkTab4: TSpkTab;
SpkTab5: TSpkTab; SpkTab5: TSpkTab;
StyleMenu: TPopupMenu;
SpkCheckbox1: TSpkCheckbox; SpkCheckbox1: TSpkCheckbox;
SpkLargeButton1: TSpkLargeButton; SpkLargeButton1: TSpkLargeButton;
SpkLargeButton2: TSpkLargeButton; SpkLargeButton2: TSpkLargeButton;
@ -105,6 +104,7 @@ type
SpkTab2: TSpkTab; SpkTab2: TSpkTab;
SpkTab3: TSpkTab; SpkTab3: TSpkTab;
SpkToolbar1: TSpkToolbar; SpkToolbar1: TSpkToolbar;
StyleMenu: TSpkPopupMenu;
ToolBar1: TToolBar; ToolBar1: TToolBar;
ToolButton1: TToolButton; ToolButton1: TToolButton;
ToolButton10: TToolButton; ToolButton10: TToolButton;

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="11"/> <Version Value="12"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<General> <General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="project1"/> <Title Value="project1"/>
<ResourceType Value="res"/> <ResourceType Value="res"/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>

File diff suppressed because it is too large Load Diff

View File

@ -5,10 +5,11 @@ unit Unit1;
interface interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, SpkToolbar, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
SpkGUITools, SpkMath, SpkGraphTools, spkt_Tab, spkt_Pane, spkt_Types, ImgList, ComCtrls, Menus, Grids, ExtCtrls, StdCtrls,
spkt_Tools, ImgList, ComCtrls, Menus, Grids, ExtCtrls, StdCtrls, SpkToolbar, SpkGUITools, SpkMath, SpkGraphTools, SpkPopup, spkt_Tab,
spkt_BaseItem, spkt_Buttons, spkt_Checkboxes; spkt_Pane, spkt_Types, spkt_Tools, spkt_BaseItem, spkt_Buttons,
spkt_Checkboxes;
type type
@ -17,20 +18,9 @@ type
TForm1 = class(TForm) TForm1 = class(TForm)
ImageList: TImageList; ImageList: TImageList;
LargeImageList: TImageList; LargeImageList: TImageList;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MnuOffice2007Blue: TMenuItem;
MnuOffice2007Silver1: TMenuItem;
MnuOffice2007Silver2: TMenuItem;
MnuMetroLight: TMenuItem;
MnuMetroDark: TMenuItem;
Panel1: TPanel;
SpkLargeButton1: TSpkLargeButton; SpkLargeButton1: TSpkLargeButton;
SpkLargeButton2: TSpkLargeButton; SpkLargeButton2: TSpkLargeButton;
SpkPane2: TSpkPane; SpkPane2: TSpkPane;
StylePopupMenu: TPopupMenu;
RecentFilesPopupMenu: TPopupMenu;
SpkPane1: TSpkPane; SpkPane1: TSpkPane;
SpkSmallButton1: TSpkSmallButton; SpkSmallButton1: TSpkSmallButton;
SpkSmallButton2: TSpkSmallButton; SpkSmallButton2: TSpkSmallButton;
@ -39,17 +29,24 @@ type
StatusBar1: TStatusBar; StatusBar1: TStatusBar;
StringGrid1: TStringGrid; StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure StringGrid1PrepareCanvas(Sender: TObject; aCol, aRow: Integer;
aState: TGridDrawState);
procedure StyleChangeHandler(Sender: TObject); procedure StyleChangeHandler(Sender: TObject);
private private
{ private declarations } { private declarations }
SpkToolbar : TSpkToolbar; SpkToolbar : TSpkToolbar;
StylePopupMenu: TSpkPopupMenu;
RecentFilesPopupMenu: TSpkPopupMenu;
CbHorizGrid : TSpkCheckbox; CbHorizGrid : TSpkCheckbox;
CbVertGrid: TSpkCheckbox; CbVertGrid: TSpkCheckbox;
CbRowSelect: TSpkCheckbox; CbRowSelect: TSpkCheckbox;
procedure AboutHandler(Sender: TObject); procedure AboutHandler(Sender: TObject);
function CreateRecentFilesPopup: TSpkPopupMenu;
function CreateStylePopup: TSpkPopupMenu;
procedure FileOpenHandler(Sender: TObject); procedure FileOpenHandler(Sender: TObject);
procedure FileSaveHandler(Sender: TObject); procedure FileSaveHandler(Sender: TObject);
procedure FileQuitHandler(Sender: TObject); procedure FileQuitHandler(Sender: TObject);
procedure FormatGridHandler(Sender: TObject);
procedure HorizontalGridLinesHandler(Sender: TObject); procedure HorizontalGridLinesHandler(Sender: TObject);
procedure VerticalGridLinesHandler(Sender: TObject); procedure VerticalGridLinesHandler(Sender: TObject);
procedure RowSelectHandler(Sender: TObject); procedure RowSelectHandler(Sender: TObject);
@ -107,7 +104,6 @@ begin
with FIconLink do begin with FIconLink do begin
Caption := 'http://www.fatcow.com/free-icons'; Caption := 'http://www.fatcow.com/free-icons';
Font.Color := clBlue; Font.Color := clBlue;
//Font.Style := [fsUnderline];
Parent := self; Parent := self;
Align := alTop; Align := alTop;
Alignment := taCenter; Alignment := taCenter;
@ -157,6 +153,75 @@ begin
end; end;
end; end;
function TForm1.CreateRecentFilesPopup: TSpkPopupMenu;
var
item: TMenuItem;
begin
Result := TSpkPopupMenu.Create(Self);
item := TMenuItem.Create(Self);
item.Caption := 'First file';
item.ImageIndex := 15;
Result.Items.Add(item);
item := TMenuItem.Create(Self);
item.Caption := 'Second file';
item.ImageIndex := 16;
Result.Items.Add(item);
item := TMenuItem.Create(Self);
item.Caption := 'Third file';
item.ImageIndex := 17;
Result.Items.Add(item);
RecentFilesPopupMenu := Result;
end;
function TForm1.CreateStylePopup: TSpkPopupMenu;
var
item: TMenuItem;
begin
Result := TSpkPopupMenu.Create(Self);
item := TMenuItem.Create(Self);
item.Caption := 'Office2007 blue';
item.GroupIndex := 10;
item.Checked := true;
item.Tag := ord(spkOffice2007Blue);
item.OnClick := @StyleChangeHandler;
Result.Items.Add(item);
item := TMenuItem.Create(Self);
item.Caption := 'Office2007 silver (yellow highlight)';
item.GroupIndex := 10;
item.Tag := ord(spkOffice2007Silver);
item.OnClick := @StyleChangeHandler;
Result.Items.Add(item);
item := TMenuItem.Create(Self);
item.Caption := 'Office2007 silver (tuquoise highlight)';
item.GroupIndex := 10;
item.Tag := ord(spkOffice2007SilverTurquoise);
item.OnClick := @StyleChangeHandler;
Result.Items.Add(item);
item := TMenuItem.Create(Self);
item.Caption := 'Metro light';
item.GroupIndex := 10;
item.Tag := ord(spkMetroLight);
item.OnClick := @StyleChangeHandler;
Result.Items.Add(item);
item := TMenuItem.Create(Self);
item.Caption := 'Metro dark';
item.GroupIndex := 10;
item.Tag := ord(spkMetroDark);
item.OnClick := @StyleChangeHandler;
Result.Items.Add(item);
StylePopupMenu := Result;
end;
procedure TForm1.FileOpenHandler(Sender: TObject); procedure TForm1.FileOpenHandler(Sender: TObject);
begin begin
Statusbar1.SimpleText := '"File" / "Open" clicked'; Statusbar1.SimpleText := '"File" / "Open" clicked';
@ -172,6 +237,13 @@ begin
Close; Close;
end; end;
procedure TForm1.FormatGridHandler(Sender: TObject);
begin
// Formatting is handled by the grid's OnPrepareCanvas event immediately
// before painting.
StringGrid1.Invalidate;
end;
procedure TForm1.HorizontalGridLinesHandler(Sender: TObject); procedure TForm1.HorizontalGridLinesHandler(Sender: TObject);
begin begin
if CbHorizGrid.Checked then if CbHorizGrid.Checked then
@ -215,7 +287,7 @@ begin
with Items.AddLargeButton do begin with Items.AddLargeButton do begin
Caption := 'Open file'; Caption := 'Open file';
ButtonKind := bkButtonDropdown; ButtonKind := bkButtonDropdown;
DropdownMenu := RecentFilesPopupMenu; DropdownMenu := CreateRecentFilesPopup; //RecentFilesPopupMenu;
LargeImageIndex := 1; LargeImageIndex := 1;
Hint := 'Open a file'; Hint := 'Open a file';
OnClick := @FileOpenHandler; OnClick := @FileOpenHandler;
@ -276,6 +348,7 @@ begin
ShowCaption := false; ShowCaption := false;
AllowAllUp := true; AllowAllUp := true;
Hint := 'Bold'; Hint := 'Bold';
OnClick := @FormatGridHandler;
end; end;
with Items.AddSmallButton do begin with Items.AddSmallButton do begin
Caption := 'Italic'; Caption := 'Italic';
@ -286,6 +359,7 @@ begin
ShowCaption := false; ShowCaption := false;
AllowAllUp := true; AllowAllUp := true;
Hint := 'Italic'; Hint := 'Italic';
OnClick := @FormatGridHandler;
end; end;
with Items.AddSmallButton do begin with Items.AddSmallButton do begin
Caption := 'Underline'; Caption := 'Underline';
@ -296,6 +370,7 @@ begin
ShowCaption := false; ShowCaption := false;
AllowAllUp := true; AllowAllUp := true;
Hint := 'Underlined'; Hint := 'Underlined';
OnClick := @FormatGridHandler;
end; end;
with Items.AddSmallButton do begin with Items.AddSmallButton do begin
@ -308,6 +383,7 @@ begin
GroupIndex := 2; GroupIndex := 2;
Checked := true; Checked := true;
Hint := 'Left-aligned'; Hint := 'Left-aligned';
OnClick := @FormatGridHandler;
end; end;
with Items.AddSmallButton do begin with Items.AddSmallButton do begin
Caption := 'Centered'; Caption := 'Centered';
@ -319,6 +395,7 @@ begin
GroupIndex := 2; GroupIndex := 2;
Checked := false; Checked := false;
Hint := 'Centered'; Hint := 'Centered';
OnClick := @FormatGridHandler;
end; end;
with Items.AddSmallButton do begin with Items.AddSmallButton do begin
Caption := 'Right-aligned'; Caption := 'Right-aligned';
@ -329,7 +406,11 @@ begin
ShowCaption := false; ShowCaption := false;
GroupIndex := 2; GroupIndex := 2;
Hint := 'Right-aligned'; Hint := 'Right-aligned';
OnClick := @FormatGridHandler;
end; end;
{
// I don't have an event handler for these...
with Items.AddSmallButton do begin with Items.AddSmallButton do begin
Caption := 'Block'; Caption := 'Block';
ButtonKind := bkToggle; ButtonKind := bkToggle;
@ -370,6 +451,7 @@ begin
HideFrameWhenIdle := true; HideFrameWhenIdle := true;
Caption := ''; Caption := '';
end; end;
}
end; end;
end; end;
@ -408,7 +490,7 @@ begin
Caption := 'Change style'; Caption := 'Change style';
Hint := 'Change theme'; Hint := 'Change theme';
ButtonKind := bkDropdown; ButtonKind := bkDropdown;
DropdownMenu := StylePopupMenu; DropdownMenu := CreateStylePopup; //StylePopupMenu;
LargeImageIndex := 7; LargeImageIndex := 7;
end; end;
end; end;
@ -443,6 +525,53 @@ begin
end; end;
end; end;
procedure TForm1.StringGrid1PrepareCanvas(Sender: TObject; aCol, aRow: Integer;
aState: TGridDrawState);
var
grid: TStringGrid;
ts: TTextStyle;
R: TRect;
begin
if Sender is TStringGrid then
grid := TStringGrid(Sender)
else
exit;
if (ACol = 0) or (ARow = 0) then
exit;
// Button "bold"
if TSpkBaseButton(SpkToolbar.Tabs[2].Panes[0].Items[0]).Checked then
grid.Canvas.Font.Style := grid.Canvas.Font.Style + [fsBold]
else
grid.Canvas.Font.Style := grid.Canvas.Font.Style - [fsBold];
// Button "italic"
if TSpkBaseButton(SpkToolbar.Tabs[2].Panes[0].Items[1]).Checked then
grid.Canvas.Font.Style := grid.Canvas.Font.Style + [fsItalic]
else
grid.Canvas.Font.Style := grid.Canvas.Font.Style - [fsItalic];
// Button "underline"
if TSpkBaseButton(SpkToolbar.Tabs[2].Panes[0].Items[2]).Checked then
grid.Canvas.Font.Style := grid.Canvas.Font.Style + [fsUnderline]
else
grid.Canvas.Font.Style := grid.Canvas.Font.Style - [fsUnderline];
ts := grid.Canvas.TextStyle;
// Button "left-aligned"
if TSpkBaseButton(SpkToolbar.Tabs[2].Panes[0].Items[3]).Checked then
ts.Alignment := taLeftJustify;
// Button "centered"
if TSpkBaseButton(SpkToolbar.Tabs[2].Panes[0].Items[4]).Checked then
ts.Alignment := taCenter;
// Button "right-aligned"
if TSpkBaseButton(SpkToolbar.Tabs[2].Panes[0].Items[5]).Checked then
ts.Alignment := taRightJustify;
grid.Canvas.Textstyle := ts;
end;
procedure TForm1.StyleChangeHandler(Sender: TObject); procedure TForm1.StyleChangeHandler(Sender: TObject);
var var
i: Integer; i: Integer;

View File

@ -2,11 +2,11 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Left = 933 Left = 933
Height = 546 Height = 546
Top = 211 Top = 211
Width = 723 Width = 715
AutoSize = True AutoSize = True
Caption = 'Toolbar appearance editor' Caption = 'Toolbar appearance editor'
ClientHeight = 546 ClientHeight = 546
ClientWidth = 723 ClientWidth = 715
Color = clBtnFace Color = clBtnFace
Font.Color = clWindowText Font.Color = clWindowText
OnActivate = FormActivate OnActivate = FormActivate
@ -20,19 +20,19 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Left = 0 Left = 0
Height = 133 Height = 133
Top = 0 Top = 0
Width = 723 Width = 715
Align = alTop Align = alTop
AutoSize = True AutoSize = True
Caption = ' Preview ' Caption = ' Preview '
ClientHeight = 113 ClientHeight = 113
ClientWidth = 719 ClientWidth = 711
ParentBackground = False ParentBackground = False
TabOrder = 0 TabOrder = 0
object tbPreview: TSpkToolbar object tbPreview: TSpkToolbar
Left = 0 Left = 0
Height = 113 Height = 113
Top = 0 Top = 0
Width = 719 Width = 711
Color = clBtnFace Color = clBtnFace
Appearance.Tab.TabHeaderFont.Color = 9126421 Appearance.Tab.TabHeaderFont.Color = 9126421
Appearance.Tab.TabHeaderFont.Height = -13 Appearance.Tab.TabHeaderFont.Height = -13
@ -399,7 +399,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Left = 0 Left = 0
Height = 372 Height = 372
Top = 133 Top = 133
Width = 723 Width = 715
ActivePage = pgPopup ActivePage = pgPopup
Align = alClient Align = alClient
TabIndex = 4 TabIndex = 4
@ -407,7 +407,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object TabSheet6: TTabSheet object TabSheet6: TTabSheet
Caption = 'Menu Button' Caption = 'Menu Button'
ClientHeight = 344 ClientHeight = 344
ClientWidth = 715 ClientWidth = 707
object pMenuButtonIdleFrame: TPanel object pMenuButtonIdleFrame: TPanel
AnchorSideLeft.Control = lblMenuButtonFont AnchorSideLeft.Control = lblMenuButtonFont
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
@ -1146,7 +1146,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Left = 6 Left = 6
Height = 15 Height = 15
Top = 274 Top = 274
Width = 703 Width = 695
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 32 BorderSpacing.Top = 32
@ -1159,7 +1159,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object TabSheet1: TTabSheet object TabSheet1: TTabSheet
Caption = 'Tab' Caption = 'Tab'
ClientHeight = 344 ClientHeight = 344
ClientWidth = 715 ClientWidth = 707
object sTabRectangle: TShape object sTabRectangle: TShape
AnchorSideLeft.Control = lblTabFrame AnchorSideLeft.Control = lblTabFrame
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
@ -1599,7 +1599,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object TabSheet2: TTabSheet object TabSheet2: TTabSheet
Caption = 'Pane' Caption = 'Pane'
ClientHeight = 344 ClientHeight = 344
ClientWidth = 715 ClientWidth = 707
ImageIndex = 1 ImageIndex = 1
object lblPaneBorderDark: TLabel object lblPaneBorderDark: TLabel
AnchorSideTop.Control = pPaneBorderDark AnchorSideTop.Control = pPaneBorderDark
@ -2124,7 +2124,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object TabSheet3: TTabSheet object TabSheet3: TTabSheet
Caption = 'Item' Caption = 'Item'
ClientHeight = 344 ClientHeight = 344
ClientWidth = 715 ClientWidth = 707
ImageIndex = 2 ImageIndex = 2
object sItemRectangle: TShape object sItemRectangle: TShape
AnchorSideLeft.Control = lblItemIdleFrame AnchorSideLeft.Control = lblItemIdleFrame
@ -3177,7 +3177,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object pgPopup: TTabSheet object pgPopup: TTabSheet
Caption = 'Dropdown Menu' Caption = 'Dropdown Menu'
ClientHeight = 344 ClientHeight = 344
ClientWidth = 715 ClientWidth = 707
object lblPopupIdle: TLabel object lblPopupIdle: TLabel
AnchorSideLeft.Control = bvPopupIdleFrame AnchorSideLeft.Control = bvPopupIdleFrame
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
@ -3295,7 +3295,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 60 Left = 60
Height = 15 Height = 15
Top = 224 Top = 255
Width = 62 Width = 62
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Caption = 'Divider Line' Caption = 'Divider Line'
@ -3400,11 +3400,11 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object pPopupDividerLineColor: TPanel object pPopupDividerLineColor: TPanel
AnchorSideLeft.Control = lblPopupGradientTo AnchorSideLeft.Control = lblPopupGradientTo
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = pPopupDisabledCaptionColor AnchorSideTop.Control = pPopupFont
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 138 Left = 138
Height = 25 Height = 25
Top = 219 Top = 250
Width = 100 Width = 100
BorderSpacing.Left = 16 BorderSpacing.Left = 16
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -3431,11 +3431,11 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object pPopupFont: TPanel object pPopupFont: TPanel
AnchorSideLeft.Control = lblPopupGradientTo AnchorSideLeft.Control = lblPopupGradientTo
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = pPopupDividerLineColor AnchorSideTop.Control = pPopupDisabledCaptionColor
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 138 Left = 138
Height = 25 Height = 25
Top = 250 Top = 219
Width = 100 Width = 100
BorderSpacing.Left = 16 BorderSpacing.Left = 16
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -3453,7 +3453,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 71 Left = 71
Height = 15 Height = 15
Top = 255 Top = 224
Width = 51 Width = 51
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Caption = 'Item Font' Caption = 'Item Font'
@ -3535,7 +3535,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 240 Left = 240
Height = 24 Height = 24
Top = 219 Top = 250
Width = 25 Width = 25
AllowAllUp = True AllowAllUp = True
BorderSpacing.Left = 2 BorderSpacing.Left = 2
@ -3950,7 +3950,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object TabSheet4: TTabSheet object TabSheet4: TTabSheet
Caption = 'Import / Export' Caption = 'Import / Export'
ClientHeight = 344 ClientHeight = 344
ClientWidth = 715 ClientWidth = 707
ImageIndex = 3 ImageIndex = 3
object bImport: TButton object bImport: TButton
AnchorSideLeft.Control = bExportToXML AnchorSideLeft.Control = bExportToXML
@ -3993,7 +3993,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Left = 4 Left = 4
Height = 307 Height = 307
Top = 33 Top = 33
Width = 707 Width = 699
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 4 BorderSpacing.Left = 4
BorderSpacing.Top = 4 BorderSpacing.Top = 4
@ -4024,7 +4024,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
AnchorSideTop.Control = TabSheet4 AnchorSideTop.Control = TabSheet4
AnchorSideRight.Control = TabSheet4 AnchorSideRight.Control = TabSheet4
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 657 Left = 649
Height = 25 Height = 25
Top = 4 Top = 4
Width = 54 Width = 54
@ -4040,7 +4040,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object TabSheet5: TTabSheet object TabSheet5: TTabSheet
Caption = 'Tools' Caption = 'Tools'
ClientHeight = 344 ClientHeight = 344
ClientWidth = 715 ClientWidth = 707
ImageIndex = 4 ImageIndex = 4
object Label17: TLabel object Label17: TLabel
AnchorSideLeft.Control = TabSheet5 AnchorSideLeft.Control = TabSheet5
@ -4079,7 +4079,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Left = 8 Left = 8
Height = 33 Height = 33
Top = 509 Top = 509
Width = 706 Width = 698
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
BorderSpacing.Left = 8 BorderSpacing.Left = 8
@ -4088,7 +4088,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
BorderSpacing.Bottom = 4 BorderSpacing.Bottom = 4
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 33 ClientHeight = 33
ClientWidth = 706 ClientWidth = 698
Constraints.MinWidth = 75 Constraints.MinWidth = 75
ParentBackground = False ParentBackground = False
TabOrder = 2 TabOrder = 2
@ -4097,7 +4097,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
AnchorSideRight.Control = bCancel AnchorSideRight.Control = bCancel
AnchorSideBottom.Control = bCancel AnchorSideBottom.Control = bCancel
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 550 Left = 542
Height = 25 Height = 25
Top = 4 Top = 4
Width = 75 Width = 75
@ -4114,7 +4114,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = ButtonPanel AnchorSideRight.Control = ButtonPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 631 Left = 623
Height = 25 Height = 25
Top = 4 Top = 4
Width = 75 Width = 75
@ -4179,8 +4179,8 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
'ColorS=F0FBFF' 'ColorS=F0FBFF'
'ColorT=A4A0A0' 'ColorT=A4A0A0'
) )
Left = 280 Left = 400
Top = 504 Top = 416
end end
object fdFontDialog: TFontDialog object fdFontDialog: TFontDialog
Font.Color = clWindowText Font.Color = clWindowText
@ -4188,8 +4188,8 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Font.Name = 'Tahoma' Font.Name = 'Tahoma'
MinFontSize = 0 MinFontSize = 0
MaxFontSize = 0 MaxFontSize = 0
Left = 376 Left = 496
Top = 504 Top = 416
end end
object Images_200: TImageList object Images_200: TImageList
Height = 32 Height = 32