RxToolbar - add property CustomizeShortCut - allow change ShortCut in config dialog

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4421 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-01-14 10:13:52 +00:00
parent 91a51d1759
commit bda0aeb336
11 changed files with 381 additions and 120 deletions

View File

@ -2,7 +2,6 @@
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="9"/> <Version Value="9"/>
<PathDelim Value="\"/>
<General> <General>
<Flags> <Flags>
<LRSInOutputDirectory Value="False"/> <LRSInOutputDirectory Value="False"/>
@ -34,10 +33,10 @@
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="3"> <RequiredPackages Count="2">
<Item1> <Item1>
<PackageName Value="RxNew"/> <PackageName Value="RxNew"/>
<MinVersion Major="1" Release="5" Build="11" Valid="True"/> <MinVersion Major="1" Release="5" Build="11" Valid="True"/>
@ -45,10 +44,6 @@
<Item2> <Item2>
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item2> </Item2>
<Item3>
<PackageName Value="IDEIntf"/>
<MinVersion Major="1" Valid="True"/>
</Item3>
</RequiredPackages> </RequiredPackages>
<Units Count="2"> <Units Count="2">
<Unit0> <Unit0>
@ -75,11 +70,6 @@
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
<SrcPath Value="$(LazarusDir)\lcl;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)"/> <SrcPath Value="$(LazarusDir)\lcl;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)"/>
</SearchPaths> </SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking> <Linking>
<Options> <Options>
<Win32> <Win32>

View File

@ -10,7 +10,7 @@ object MainForm: TMainForm
Position = poDesktopCenter Position = poDesktopCenter
SessionProperties = 'Width;Height;Left;Top' SessionProperties = 'Width;Height;Left;Top'
ShowHint = True ShowHint = True
Visible = False LCLVersion = '1.7'
object ToolPanel1: TToolPanel object ToolPanel1: TToolPanel
Left = 0 Left = 0
Height = 32 Height = 32
@ -23,7 +23,7 @@ object MainForm: TMainForm
Left = 5 Left = 5
Height = 22 Height = 22
Top = 5 Top = 5
Width = 52 Width = 59
DropDownMenu = PopupMenu1 DropDownMenu = PopupMenu1
ShowCaption = True ShowCaption = True
ButtonStyle = tbrDropDown ButtonStyle = tbrDropDown
@ -31,16 +31,16 @@ object MainForm: TMainForm
item item
Action = actCustom Action = actCustom
Visible = True Visible = True
Left = 123 Left = 142
Height = 22 Height = 22
Top = 5 Top = 5
Width = 70 Width = 79
ShowCaption = True ShowCaption = True
end end
item item
Action = actNext Action = actNext
Visible = True Visible = True
Left = 246 Left = 279
Height = 22 Height = 22
Top = 5 Top = 5
Width = 39 Width = 39
@ -51,29 +51,29 @@ object MainForm: TMainForm
item item
Action = actPrior Action = actPrior
Visible = True Visible = True
Left = 193 Left = 221
Height = 22 Height = 22
Top = 5 Top = 5
Width = 53 Width = 58
DropDownMenu = PopupMenu2 DropDownMenu = PopupMenu2
ShowCaption = True ShowCaption = True
end end
item item
Action = actExit Action = actExit
Visible = True Visible = True
Left = 285 Left = 318
Height = 22 Height = 22
Top = 5 Top = 5
Width = 46 Width = 53
ShowCaption = True ShowCaption = True
end end
item item
Action = actSysMenu Action = actSysMenu
Visible = True Visible = True
Left = 57 Left = 64
Height = 22 Height = 22
Top = 5 Top = 5
Width = 66 Width = 78
DropDownMenu = PopupMenu1 DropDownMenu = PopupMenu1
ShowCaption = True ShowCaption = True
ButtonStyle = tbrDropDown ButtonStyle = tbrDropDown
@ -81,10 +81,10 @@ object MainForm: TMainForm
item item
Action = sysAbout Action = sysAbout
Visible = True Visible = True
Left = 331 Left = 371
Height = 22 Height = 22
Top = 5 Top = 5
Width = 61 Width = 67
ShowCaption = True ShowCaption = True
end> end>
ImageList = ImageList1 ImageList = ImageList1
@ -94,6 +94,7 @@ object MainForm: TMainForm
ToolBarStyle = tbsWindowsXP ToolBarStyle = tbsWindowsXP
Options = [tpFlatBtns, tpCustomizable, tpGlyphPopup, tpCaptionPopup] Options = [tpFlatBtns, tpCustomizable, tpGlyphPopup, tpCaptionPopup]
Version = 4 Version = 4
CustomizeShortCut = True
Align = alTop Align = alTop
BorderWidth = 4 BorderWidth = 4
ClientHeight = 32 ClientHeight = 32
@ -103,63 +104,18 @@ object MainForm: TMainForm
end end
object SpeedButton1: TSpeedButton object SpeedButton1: TSpeedButton
Left = 440 Left = 440
Height = 24 Height = 26
Top = 88 Top = 88
Width = 50 Width = 77
Action = actCustom
AutoSize = True AutoSize = True
Caption = 'Test'
Glyph.Data = {
46050000424D4605000000000000360000002800000012000000120000000100
2000000000001005000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00F8F8
F8FFE8E8E8FFE7E7E7FFF6F6F6FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00F8F8F8FFC3ACACFFAF7F7AFFB19594FFDDDDDDFFF6F6F6FFFFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00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F
FF00FFFFFF00FFFFFF00
}
Margin = 3 Margin = 3
end end
object BitBtn1: TBitBtn object BitBtn1: TBitBtn
Left = 440 Left = 440
Height = 28 Height = 32
Top = 128 Top = 128
Width = 86 Width = 84
AutoSize = True AutoSize = True
Caption = 'BitBtn1' Caption = 'BitBtn1'
Glyph.Data = { Glyph.Data = {
@ -207,6 +163,7 @@ object MainForm: TMainForm
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00 FF00FFFFFF00FFFFFF00
} }
OnClick = BitBtn1Click
TabOrder = 1 TabOrder = 1
end end
object ImageList1: TImageList object ImageList1: TImageList
@ -488,6 +445,7 @@ object MainForm: TMainForm
Caption = 'About' Caption = 'About'
ImageIndex = 6 ImageIndex = 6
OnExecute = sysAboutExecute OnExecute = sysAboutExecute
ShortCut = 16456
end end
end end
object PopupMenu1: TPopupMenu object PopupMenu1: TPopupMenu

View File

@ -46,6 +46,7 @@ type
procedure Action1Execute(Sender: TObject); procedure Action1Execute(Sender: TObject);
procedure actCustomExecute(Sender: TObject); procedure actCustomExecute(Sender: TObject);
procedure actExitExecute(Sender: TObject); procedure actExitExecute(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure sysAboutExecute(Sender: TObject); procedure sysAboutExecute(Sender: TObject);
private private
// //
@ -59,6 +60,8 @@ var
implementation implementation
uses rxShortCutUnit;
{$R *.lfm} {$R *.lfm}
{ TMainForm } { TMainForm }
@ -79,6 +82,15 @@ begin
Close; Close;
end; end;
procedure TMainForm.BitBtn1Click(Sender: TObject);
var
A: TShortCut;
begin
A:=sysAbout.ShortCut;
if RxSelectShortCut(A) then
sysAbout.ShortCut:=A;
end;
procedure TMainForm.sysAboutExecute(Sender: TObject); procedure TMainForm.sysAboutExecute(Sender: TObject);
begin begin
RxAboutDialog1.Execute; RxAboutDialog1.Execute;

View File

@ -236,6 +236,7 @@ const
sIndex = '.Index'; sIndex = '.Index';
sSortMarker = '.SortMarker'; sSortMarker = '.SortMarker';
sSortField = '.SortField'; sSortField = '.SortField';
sShortCut = '.ShortCut';
implementation implementation

View File

@ -25,7 +25,7 @@ translate to Lazarus by alexs in 2005 - 2015
"/> "/>
<License Value="LGPL"/> <License Value="LGPL"/>
<Version Major="2" Minor="8" Release="2" Build="181"/> <Version Major="2" Minor="8" Release="2" Build="181"/>
<Files Count="72"> <Files Count="74">
<Item1> <Item1>
<Filename Value="autopanel.pas"/> <Filename Value="autopanel.pas"/>
<UnitName Value="AutoPanel"/> <UnitName Value="AutoPanel"/>
@ -317,6 +317,14 @@ translate to Lazarus by alexs in 2005 - 2015
<Filename Value="rxdbgridfootertools_setup.pas"/> <Filename Value="rxdbgridfootertools_setup.pas"/>
<UnitName Value="rxdbgridfootertools_setup"/> <UnitName Value="rxdbgridfootertools_setup"/>
</Item72> </Item72>
<Item73>
<Filename Value="rxshortcutunit.lfm"/>
<Type Value="LFM"/>
</Item73>
<Item74>
<Filename Value="rxshortcutunit.pas"/>
<UnitName Value="rxshortcutunit"/>
</Item74>
</Files> </Files>
<LazDoc Paths="docs;\usr\local\share\lazarus\components\rxnew\docs"/> <LazDoc Paths="docs;\usr\local\share\lazarus\components\rxnew\docs"/>
<i18n> <i18n>

View File

@ -19,7 +19,7 @@ uses
tooledit, vclutils, RxCloseFormValidator, RxHistoryNavigator, tooledit, vclutils, RxCloseFormValidator, RxHistoryNavigator,
ex_rx_bin_datapacket, ex_rx_datapacket, ex_rx_xml_datapacket, rxsortby, ex_rx_bin_datapacket, ex_rx_datapacket, ex_rx_xml_datapacket, rxsortby,
RxMDI, RxIniPropStorage, rxDateRangeEditUnit, RxDBGridFooterTools, RxMDI, RxIniPropStorage, rxDateRangeEditUnit, RxDBGridFooterTools,
rxdbgridfootertools_setup, LazarusPackageIntf; rxdbgridfootertools_setup, rxShortCutUnit, LazarusPackageIntf;
implementation implementation

View File

@ -0,0 +1,99 @@
object rxShortCutForm: TrxShortCutForm
Left = 505
Height = 104
Top = 526
Width = 463
Caption = 'ShortCut'
ClientHeight = 104
ClientWidth = 463
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.7'
object ButtonPanel1: TButtonPanel
Left = 6
Height = 42
Top = 56
Width = 451
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 0
ShowButtons = [pbOK, pbCancel, pbHelp]
end
object CheckBox1: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ComboBox1
AnchorSideTop.Side = asrCenter
Left = 6
Height = 24
Top = 10
Width = 55
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Shift'
TabOrder = 1
end
object CheckBox2: TCheckBox
AnchorSideLeft.Control = CheckBox1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ComboBox1
AnchorSideTop.Side = asrCenter
Left = 67
Height = 24
Top = 10
Width = 43
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Alt'
TabOrder = 2
end
object CheckBox3: TCheckBox
AnchorSideLeft.Control = CheckBox2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ComboBox1
AnchorSideTop.Side = asrCenter
Left = 116
Height = 24
Top = 10
Width = 49
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Ctrl'
TabOrder = 3
end
object ComboBox1: TComboBox
AnchorSideLeft.Control = CheckBox3
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Button1
Left = 171
Height = 32
Top = 6
Width = 211
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
ItemHeight = 0
TabOrder = 4
Text = 'ComboBox1'
end
object Button1: TButton
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 388
Height = 32
Top = 6
Width = 69
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Grab key'
OnClick = Button1Click
TabOrder = 5
end
end

View File

@ -0,0 +1,156 @@
unit rxShortCutUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
StdCtrls;
type
{ TrxShortCutForm }
TrxShortCutForm = class(TForm)
Button1: TButton;
ButtonPanel1: TButtonPanel;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
function GetShortCut: TShortCut;
procedure SetShortCut(AValue: TShortCut);
public
property ShortCut:TShortCut read GetShortCut write SetShortCut;
end;
function RxSelectShortCut(var AShortCut:TShortCut):boolean;
implementation
uses LCLProc, LCLType, LCLStrConsts;
{$R *.lfm}
function RxSelectShortCut(var AShortCut: TShortCut): boolean;
var
rxShortCutForm: TrxShortCutForm;
begin
rxShortCutForm:=TrxShortCutForm.Create(Application);
rxShortCutForm.ShortCut:=AShortCut;
if rxShortCutForm.ShowModal = mrOk then
AShortCut:=rxShortCutForm.ShortCut;
rxShortCutForm.Free;
end;
type
{ TGrabForm }
TGrabForm = class(TForm)
private
FShortCutEdt:TShortCut;
protected
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
public
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
end;
{ TGrabForm }
procedure TGrabForm.KeyDown(var Key: Word; Shift: TShiftState);
begin
inherited KeyDown(Key, Shift);
if (Key = VK_ESCAPE) and (Shift = []) then
ModalResult:=mrCancel
else
if (Key <> VK_CONTROL) and (Key <> VK_SHIFT) and (Key <> VK_MENU) then
begin
FShortCutEdt:=KeyToShortCut(Key, Shift);
ModalResult:=mrOK;
end;
end;
constructor TGrabForm.CreateNew(AOwner: TComponent; Num: Integer);
var
L: TLabel;
begin
inherited CreateNew(AOwner, Num);
Position:=poScreenCenter;
Width:=200;
Height:=80;
Caption:='Press the key';
BorderStyle:=bsDialog;
KeyPreview:=true;
L:=TLabel.Create(Self);
L.Parent:=Self;
L.Caption:=Caption;
L.AnchorSide[akTop].Control:=Self;
L.AnchorSide[akTop].Side:=asrCenter;
L.AnchorSide[akLeft].Control:=Self;
L.AnchorSide[akLeft].Side:=asrCenter;
end;
{ TrxShortCutForm }
procedure TrxShortCutForm.FormCreate(Sender: TObject);
var
S: String;
i:Word;
begin
for i:=0 to $FF do
begin
S:=ShortCutToText(i);
if S<>'' then
ComboBox1.Items.Add(S);
end;
end;
procedure TrxShortCutForm.Button1Click(Sender: TObject);
var
F:TGrabForm;
begin
F:=TGrabForm.CreateNew(Self);
if F.ShowModal = mrOk then
SetShortCut(F.FShortCutEdt);
F.Free;
end;
procedure TrxShortCutForm.SetShortCut(AValue: TShortCut);
begin
ComboBox1.Text:=ShortCutToText(AValue and $FF);
CheckBox1.Checked:=AValue and scShift <> 0;
CheckBox2.Checked:=AValue and scAlt <> 0;
CheckBox3.Checked:=AValue and scCtrl <> 0;
///if ShortCut and scMeta <> 0 then Result := Result + MenuKeyCaps[mkcMeta];
end;
function TrxShortCutForm.GetShortCut: TShortCut;
var
S: String;
begin
S:='';
if CheckBox1.Checked then
S:=SmkcShift + S;
if CheckBox2.Checked then
S:=SmkcAlt + S;
if CheckBox3.Checked then
S:=SmkcCtrl + S;
//SmkcMeta = 'Meta+';
S:=S + ComboBox1.Text;
Result:=TextToShortCut(S);
end;
end.

View File

@ -12,10 +12,10 @@ object ToolPanelSetupForm: TToolPanelSetupForm
OnDestroy = FormDestroy OnDestroy = FormDestroy
OnResize = FormResize OnResize = FormResize
Position = poScreenCenter Position = poScreenCenter
Visible = False LCLVersion = '1.7'
object PageControl1: TPageControl object PageControl1: TPageControl
Left = 0 Left = 0
Height = 441 Height = 433
Top = 0 Top = 0
Width = 657 Width = 657
ActivePage = TabSheet1 ActivePage = TabSheet1
@ -24,16 +24,16 @@ object ToolPanelSetupForm: TToolPanelSetupForm
TabOrder = 0 TabOrder = 0
object TabSheet1: TTabSheet object TabSheet1: TTabSheet
Caption = 'Visible buttons' Caption = 'Visible buttons'
ClientHeight = 413 ClientHeight = 395
ClientWidth = 649 ClientWidth = 651
object Label1: TLabel object Label1: TLabel
AnchorSideLeft.Control = BitBtn3 AnchorSideLeft.Control = BitBtn3
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TabSheet1 AnchorSideTop.Control = TabSheet1
Left = 353 Left = 347
Height = 15 Height = 20
Top = 6 Top = 6
Width = 92 Width = 112
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Avaliable buttons' Caption = 'Avaliable buttons'
FocusControl = ListBtnAvaliable FocusControl = ListBtnAvaliable
@ -42,9 +42,9 @@ object ToolPanelSetupForm: TToolPanelSetupForm
object Label2: TLabel object Label2: TLabel
AnchorSideTop.Control = TabSheet1 AnchorSideTop.Control = TabSheet1
Left = 8 Left = 8
Height = 15 Height = 20
Top = 6 Top = 6
Width = 78 Width = 97
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Visible buttons' Caption = 'Visible buttons'
FocusControl = ListBtnVisible FocusControl = ListBtnVisible
@ -56,10 +56,10 @@ object ToolPanelSetupForm: TToolPanelSetupForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = BitBtn6 AnchorSideRight.Control = BitBtn6
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 301 Left = 309
Height = 30 Height = 30
Top = 141 Top = 160
Width = 46 Width = 32
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.InnerBorder = 2 BorderSpacing.InnerBorder = 2
@ -73,10 +73,10 @@ object ToolPanelSetupForm: TToolPanelSetupForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = BitBtn6 AnchorSideRight.Control = BitBtn6
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 301 Left = 309
Height = 29 Height = 36
Top = 106 Top = 118
Width = 46 Width = 32
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -91,10 +91,10 @@ object ToolPanelSetupForm: TToolPanelSetupForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = BitBtn6 AnchorSideRight.Control = BitBtn6
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 301 Left = 309
Height = 38 Height = 38
Top = 62 Top = 74
Width = 46 Width = 32
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.InnerBorder = 2 BorderSpacing.InnerBorder = 2
@ -106,10 +106,10 @@ object ToolPanelSetupForm: TToolPanelSetupForm
AnchorSideLeft.Control = TabSheet1 AnchorSideLeft.Control = TabSheet1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ListBtnAvaliable AnchorSideTop.Control = ListBtnAvaliable
Left = 301 Left = 309
Height = 29 Height = 36
Top = 27 Top = 32
Width = 46 Width = 32
AutoSize = True AutoSize = True
BorderSpacing.InnerBorder = 2 BorderSpacing.InnerBorder = 2
Caption = '>>' Caption = '>>'
@ -124,10 +124,10 @@ object ToolPanelSetupForm: TToolPanelSetupForm
AnchorSideRight.Control = TabSheet1 AnchorSideRight.Control = TabSheet1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = cbShowCaption AnchorSideBottom.Control = cbShowCaption
Left = 353 Left = 347
Height = 287 Height = 259
Top = 27 Top = 32
Width = 290 Width = 298
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
IntegralHeight = True IntegralHeight = True
@ -142,8 +142,9 @@ object ToolPanelSetupForm: TToolPanelSetupForm
) )
ItemHeight = 0 ItemHeight = 0
OnClick = ListBtnAvaliableClick OnClick = ListBtnAvaliableClick
OnDblClick = ListBtnVisibleDblClick
OnDrawItem = ListBox1DrawItem OnDrawItem = ListBox1DrawItem
ScrollWidth = 294 ScrollWidth = 296
Style = lbOwnerDrawFixed Style = lbOwnerDrawFixed
TabOrder = 4 TabOrder = 4
end end
@ -154,25 +155,27 @@ object ToolPanelSetupForm: TToolPanelSetupForm
AnchorSideRight.Control = BitBtn6 AnchorSideRight.Control = BitBtn6
AnchorSideBottom.Control = cbShowCaption AnchorSideBottom.Control = cbShowCaption
Left = 14 Left = 14
Height = 287 Height = 259
Top = 27 Top = 32
Width = 281 Width = 289
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
ItemHeight = 0 ItemHeight = 0
OnClick = ListBtnAvaliableClick OnClick = ListBtnAvaliableClick
OnDblClick = ListBtnVisibleDblClick
OnDrawItem = ListBox1DrawItem OnDrawItem = ListBox1DrawItem
ScrollWidth = 285 ScrollWidth = 287
Style = lbOwnerDrawFixed Style = lbOwnerDrawFixed
TabOrder = 5 TabOrder = 5
TopIndex = -1
end end
object Panel1: TPanel object Panel1: TPanel
AnchorSideBottom.Control = TabSheet1 AnchorSideBottom.Control = TabSheet1
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 3 Left = 3
Height = 62 Height = 62
Top = 345 Top = 327
Width = 637 Width = 639
Alignment = taLeftJustify Alignment = taLeftJustify
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -184,9 +187,9 @@ object ToolPanelSetupForm: TToolPanelSetupForm
AnchorSideLeft.Control = TabSheet1 AnchorSideLeft.Control = TabSheet1
AnchorSideBottom.Control = Panel1 AnchorSideBottom.Control = Panel1
Left = 6 Left = 6
Height = 19 Height = 24
Top = 320 Top = 297
Width = 92 Width = 112
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Show caption' Caption = 'Show caption'
@ -196,7 +199,7 @@ object ToolPanelSetupForm: TToolPanelSetupForm
end end
object TabSheet2: TTabSheet object TabSheet2: TTabSheet
Caption = 'Options' Caption = 'Options'
ClientHeight = 400 ClientHeight = 395
ClientWidth = 651 ClientWidth = 651
object cbShowHint: TCheckBox object cbShowHint: TCheckBox
AnchorSideLeft.Control = TabSheet2 AnchorSideLeft.Control = TabSheet2
@ -255,7 +258,7 @@ object ToolPanelSetupForm: TToolPanelSetupForm
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 75 ClientHeight = 73
ClientWidth = 308 ClientWidth = 308
Items.Strings = ( Items.Strings = (
'None' 'None'
@ -286,7 +289,7 @@ object ToolPanelSetupForm: TToolPanelSetupForm
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 75 ClientHeight = 73
ClientWidth = 308 ClientWidth = 308
Items.Strings = ( Items.Strings = (
'Standart' 'Standart'
@ -314,8 +317,8 @@ object ToolPanelSetupForm: TToolPanelSetupForm
end end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 34 Height = 42
Top = 447 Top = 439
Width = 645 Width = 645
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True

View File

@ -76,6 +76,7 @@ type
ARect: TRect; State: TOwnerDrawState); ARect: TRect; State: TOwnerDrawState);
procedure ListBtnAvaliableClick(Sender: TObject); procedure ListBtnAvaliableClick(Sender: TObject);
procedure cbShowCaptionChange(Sender: TObject); procedure cbShowCaptionChange(Sender: TObject);
procedure ListBtnVisibleDblClick(Sender: TObject);
private private
procedure FillItems(List:TStrings; AVisible:boolean); procedure FillItems(List:TStrings; AVisible:boolean);
procedure UpdateStates; procedure UpdateStates;
@ -89,7 +90,7 @@ var
ToolPanelSetupForm: TToolPanelSetupForm; ToolPanelSetupForm: TToolPanelSetupForm;
implementation implementation
uses vclutils, ActnList, boxprocs, rxconst, LCLProc; uses vclutils, ActnList, boxprocs, rxconst, LCLProc, rxShortCutUnit;
{$R *.lfm} {$R *.lfm}
@ -182,6 +183,29 @@ begin
TToolbarItem(ListBtnVisible.Items.Objects[ListBtnVisible.ItemIndex]).ShowCaption:=cbShowCaption.Checked; TToolbarItem(ListBtnVisible.Items.Objects[ListBtnVisible.ItemIndex]).ShowCaption:=cbShowCaption.Checked;
end; end;
procedure TToolPanelSetupForm.ListBtnVisibleDblClick(Sender: TObject);
var
Act: TBasicAction;
A: TShortCut;
begin
if FToolPanel.CustomizeShortCut then
if (TListBox(Sender).ItemIndex>-1) and (TListBox(Sender).ItemIndex<TListBox(Sender).Items.Count) then
begin
Act:=TToolbarItem(TListBox(Sender).Items.Objects[TListBox(Sender).ItemIndex]).Action;
if Act is TCustomAction then
begin
A:=TCustomAction(Act).ShortCut;
Hide;
if RxSelectShortCut(A) then
begin
TCustomAction(Act).ShortCut:=A;
TListBox(Sender).Invalidate;
end;
Show;
end;
end;
end;
procedure TToolPanelSetupForm.FillItems(List: TStrings; AVisible: boolean); procedure TToolPanelSetupForm.FillItems(List: TStrings; AVisible: boolean);
var var
i, p:integer; i, p:integer;

View File

@ -184,6 +184,7 @@ type
TToolPanel = class(TCustomPanel) TToolPanel = class(TCustomPanel)
private private
FButtonAllign: TToolButtonAllign; FButtonAllign: TToolButtonAllign;
FCustomizeShortCut: boolean;
FImageList: TImageList; FImageList: TImageList;
FImageListSelected: TImageList; FImageListSelected: TImageList;
FOptions: TToolPanelOptions; FOptions: TToolPanelOptions;
@ -235,6 +236,7 @@ type
property Options:TToolPanelOptions read FOptions write SetOptions; property Options:TToolPanelOptions read FOptions write SetOptions;
property Version: Integer read FVersion write FVersion default 0; property Version: Integer read FVersion write FVersion default 0;
property ButtonAllign:TToolButtonAllign read FButtonAllign write SetButtonAllign default tbaLeft; property ButtonAllign:TToolButtonAllign read FButtonAllign write SetButtonAllign default tbaLeft;
property CustomizeShortCut:boolean read FCustomizeShortCut write FCustomizeShortCut;
property Align; property Align;
property Alignment; property Alignment;
@ -987,6 +989,8 @@ begin
FPropertyStorageLink.Storage.WriteInteger(S1+sTop, FToolbarItems[i].Top); FPropertyStorageLink.Storage.WriteInteger(S1+sTop, FToolbarItems[i].Top);
FPropertyStorageLink.Storage.WriteInteger(S1+sLeft, FToolbarItems[i].Left); FPropertyStorageLink.Storage.WriteInteger(S1+sLeft, FToolbarItems[i].Left);
FPropertyStorageLink.Storage.WriteInteger(S1+sWidth, FToolbarItems[i].Width); FPropertyStorageLink.Storage.WriteInteger(S1+sWidth, FToolbarItems[i].Width);
if FCustomizeShortCut and Assigned(FToolbarItems[i].Action) then
FPropertyStorageLink.Storage.WriteString(S1+sShortCut, ShortCutToText(TCustomAction(FToolbarItems[i].Action).ShortCut));
end; end;
end; end;
end; end;
@ -1026,6 +1030,11 @@ begin
AItem.Width:=FPropertyStorageLink.Storage.ReadInteger(S1+sWidth, AItem.Width); AItem.Width:=FPropertyStorageLink.Storage.ReadInteger(S1+sWidth, AItem.Width);
AItem.Visible:=FPropertyStorageLink.Storage.ReadInteger(S1+sVisible, ord(AItem.Visible)) <> 0; AItem.Visible:=FPropertyStorageLink.Storage.ReadInteger(S1+sVisible, ord(AItem.Visible)) <> 0;
AItem.ShowCaption:=FPropertyStorageLink.Storage.ReadInteger(S1+sShowCaption, ord(AItem.ShowCaption)) <> 0; AItem.ShowCaption:=FPropertyStorageLink.Storage.ReadInteger(S1+sShowCaption, ord(AItem.ShowCaption)) <> 0;
if FCustomizeShortCut and Assigned(AItem.Action) then
begin
S2:=FPropertyStorageLink.Storage.ReadString(S1+sShortCut, ShortCutToText(TCustomAction(AItem.Action).ShortCut));
TCustomAction(AItem.Action).ShortCut:=TextToShortCut(S2);
end;
end; end;
end; end;
end; end;
@ -1145,6 +1154,7 @@ constructor TToolPanel.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FArrowBmp:=CreateArrowBitmap; FArrowBmp:=CreateArrowBitmap;
FCustomizeShortCut:=false;
AutoSize:=false; AutoSize:=false;
FButtonAllign:=tbaLeft; FButtonAllign:=tbaLeft;
FToolbarItems:=TToolbarItems.Create(Self); FToolbarItems:=TToolbarItems.Create(Self);