mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 07:40:37 +02:00
editor toolbar changes:
- buttons destruction after config dialog (no more button doubling) - closing config dialog by ESC - switched from menuitem.bitmap to menuitem.imageindex due to yesterday changes git-svn-id: trunk@11055 -
This commit is contained in:
parent
830233dac3
commit
32a03c1212
@ -32,6 +32,7 @@ uses
|
|||||||
,Controls
|
,Controls
|
||||||
,Menus
|
,Menus
|
||||||
,MenuIntf
|
,MenuIntf
|
||||||
|
,IDEImagesIntf
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -47,8 +48,9 @@ type
|
|||||||
FJumpHandler: TJumpHandler;
|
FJumpHandler: TJumpHandler;
|
||||||
W: TForm;
|
W: TForm;
|
||||||
TB: TToolbar;
|
TB: TToolbar;
|
||||||
BI: TImageList;
|
PM: TPopupMenu;
|
||||||
procedure CreateEditorToolbar(AW: TForm; var ATB: TToolbar; var ABI: TImageList);
|
CfgButton: TToolButton;
|
||||||
|
procedure CreateEditorToolbar(AW: TForm; var ATB: TToolbar);
|
||||||
function CreateJumpItem(AJumpType: TJumpType; O: TComponent): TMenuItem;
|
function CreateJumpItem(AJumpType: TJumpType; O: TComponent): TMenuItem;
|
||||||
procedure DoConfigureToolbar(Sender: TObject);
|
procedure DoConfigureToolbar(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
@ -95,15 +97,14 @@ begin
|
|||||||
result := uEditorToolbar;
|
result := uEditorToolbar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorToolbar.CreateEditorToolbar(AW: TForm; var ATB: TToolbar; var ABI: TImageList);
|
procedure TEditorToolbar.CreateEditorToolbar(AW: TForm; var ATB: TToolbar);
|
||||||
begin
|
begin
|
||||||
ABI := TImageList.Create(AW);
|
|
||||||
ATB := TToolbar.Create(AW);
|
ATB := TToolbar.Create(AW);
|
||||||
ATB.Parent := AW;
|
ATB.Parent := AW;
|
||||||
ATB.Height := 26;
|
ATB.Height := 26;
|
||||||
ATB.Align := alTop;
|
ATB.Align := alTop;
|
||||||
ATB.Flat := True;
|
ATB.Flat := True;
|
||||||
ATB.Images := ABI;
|
ATB.Images := IDEImages.Images_16;
|
||||||
ATB.ShowHint := True;
|
ATB.ShowHint := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -117,7 +118,12 @@ end;
|
|||||||
|
|
||||||
procedure TEditorToolbar.DoConfigureToolbar(Sender: TObject);
|
procedure TEditorToolbar.DoConfigureToolbar(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
TEdtTbConfigForm.Execute;
|
if TEdtTbConfigForm.Execute then
|
||||||
|
begin
|
||||||
|
ClearToolbar;
|
||||||
|
AddCustomItems;
|
||||||
|
AddStaticItems;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TEditorToolbar.Create;
|
constructor TEditorToolbar.Create;
|
||||||
@ -132,13 +138,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorToolbar.InitEditorToolBar;
|
procedure TEditorToolbar.InitEditorToolBar;
|
||||||
|
var
|
||||||
|
T: TJumpType;
|
||||||
begin
|
begin
|
||||||
if not Assigned(W) then
|
if not Assigned(W) then
|
||||||
begin
|
begin
|
||||||
W := SourceEditorWindow;
|
W := SourceEditorWindow;
|
||||||
BI := nil;
|
|
||||||
TB := nil;
|
TB := nil;
|
||||||
CreateEditorToolBar(W, TB, BI);
|
CfgButton := nil;
|
||||||
|
CreateEditorToolBar(W, TB);
|
||||||
|
|
||||||
|
PM := TPopupMenu.Create(W);
|
||||||
|
for T := Low(TJumpType) to High(TJumpType) do
|
||||||
|
PM.Items.Add(CreateJumpItem(T,W));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AddCustomItems;
|
AddCustomItems;
|
||||||
@ -155,13 +167,10 @@ begin
|
|||||||
B.Caption := AMenuItem.Caption;
|
B.Caption := AMenuItem.Caption;
|
||||||
B.Hint := AMenuItem.Caption; // or should we use AMenuItem.Hint?
|
B.Hint := AMenuItem.Caption; // or should we use AMenuItem.Hint?
|
||||||
// If we have a image, us it. Otherwise supply a default.
|
// If we have a image, us it. Otherwise supply a default.
|
||||||
if AMenuItem.HasBitmap then
|
if AMenuItem.ImageIndex <> -1 then
|
||||||
begin
|
B.ImageIndex := AMenuItem.ImageIndex
|
||||||
i := BI.Add(AMenuItem.Bitmap, AMenuItem.Bitmap);
|
|
||||||
B.ImageIndex := i;
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
B.ImageIndex := BI.AddLazarusResource('execute16');
|
B.ImageIndex := IDEImages.LoadImage(16, 'execute16');
|
||||||
|
|
||||||
B.Style := tbsButton;
|
B.Style := tbsButton;
|
||||||
B.OnClick := AMenuItem.OnClick;
|
B.OnClick := AMenuItem.OnClick;
|
||||||
@ -176,6 +185,7 @@ var
|
|||||||
mi: TIDEMenuItem;
|
mi: TIDEMenuItem;
|
||||||
begin
|
begin
|
||||||
cfg := GetIDEConfigStorage(cSettingsFile, True);
|
cfg := GetIDEConfigStorage(cSettingsFile, True);
|
||||||
|
TB.BeginUpdate;
|
||||||
try
|
try
|
||||||
c := cfg.GetValue('Count', 0);
|
c := cfg.GetValue('Count', 0);
|
||||||
for i := c - 1 downto 0 do
|
for i := c - 1 downto 0 do
|
||||||
@ -192,6 +202,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
cfg.Free;
|
cfg.Free;
|
||||||
|
TB.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -206,9 +217,7 @@ end;
|
|||||||
|
|
||||||
procedure TEditorToolbar.AddStaticItems;
|
procedure TEditorToolbar.AddStaticItems;
|
||||||
var
|
var
|
||||||
B: TToolButton;
|
B: TToolButton;
|
||||||
PM: TPopupMenu;
|
|
||||||
T: TJumpType;
|
|
||||||
begin
|
begin
|
||||||
TB.BeginUpdate;
|
TB.BeginUpdate;
|
||||||
try
|
try
|
||||||
@ -220,26 +229,24 @@ begin
|
|||||||
B.Parent := TB;
|
B.Parent := TB;
|
||||||
B.Caption := 'Jump To';
|
B.Caption := 'Jump To';
|
||||||
B.Hint := B.Caption;
|
B.Hint := B.Caption;
|
||||||
B.ImageIndex := BI.AddLazarusResource('jumpto16');
|
B.ImageIndex := IDEImages.LoadImage(16, 'jumpto16');
|
||||||
B.Style := tbsDropDown;
|
B.Style := tbsDropDown;
|
||||||
B.OnClick := @FJumpHandler.DoJumpToImplementation;
|
B.OnClick := @FJumpHandler.DoJumpToImplementation;
|
||||||
|
|
||||||
PM := TPopupMenu.Create(W);
|
|
||||||
B.DropdownMenu := PM;
|
B.DropdownMenu := PM;
|
||||||
|
|
||||||
for T := Low(TJumpType) to High(TJumpType) do
|
|
||||||
PM.Items.Add(CreateJumpItem(T,W));
|
|
||||||
|
|
||||||
AddDivider;
|
AddDivider;
|
||||||
|
|
||||||
// Config Button
|
// Config Button
|
||||||
B := TToolbutton.Create(TB);
|
if CfgButton = nil then
|
||||||
B.Parent := TB;
|
CfgButton := TToolbutton.Create(TB);
|
||||||
B.Caption := 'Configure Toolbar';
|
|
||||||
B.Hint := B.Caption;
|
CfgButton.Parent := TB;
|
||||||
B.ImageIndex := BI.AddLazarusResource('preferences16');
|
CfgButton.Caption := 'Configure Toolbar';
|
||||||
B.Style := tbsButton;
|
CfgButton.Hint := B.Caption;
|
||||||
B.OnClick := @DoConfigureToolbar;
|
CfgButton.ImageIndex := IDEImages.LoadImage(16, 'preferences16');
|
||||||
|
CfgButton.Style := tbsButton;
|
||||||
|
CfgButton.OnClick := @DoConfigureToolbar;
|
||||||
finally
|
finally
|
||||||
TB.EndUpdate;
|
TB.EndUpdate;
|
||||||
end;
|
end;
|
||||||
@ -251,9 +258,11 @@ var
|
|||||||
begin
|
begin
|
||||||
TB.BeginUpdate;
|
TB.BeginUpdate;
|
||||||
try
|
try
|
||||||
for i := TB.ButtonCount-1 downto 0 do
|
for i := TB.ButtonCount - 1 downto 0 do
|
||||||
TB.Buttons[i].Visible := False;
|
if TB.Buttons[i] <> CfgButton then
|
||||||
// TB.Controls[i].Free; // This causes a crash!
|
TB.Buttons[i].Free
|
||||||
|
else
|
||||||
|
TB.Buttons[i].Parent := nil;
|
||||||
finally
|
finally
|
||||||
TB.EndUpdate;
|
TB.EndUpdate;
|
||||||
end;
|
end;
|
||||||
|
@ -75,6 +75,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
|||||||
BorderSpacing.Right = 6
|
BorderSpacing.Right = 6
|
||||||
BorderSpacing.Bottom = 6
|
BorderSpacing.Bottom = 6
|
||||||
BorderSpacing.InnerBorder = 4
|
BorderSpacing.InnerBorder = 4
|
||||||
|
Cancel = True
|
||||||
Caption = 'btnCancel'
|
Caption = 'btnCancel'
|
||||||
Constraints.MaxHeight = 25
|
Constraints.MaxHeight = 25
|
||||||
Constraints.MinHeight = 25
|
Constraints.MinHeight = 25
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
{ This is an automatically generated lazarus resource file }
|
|
||||||
|
|
||||||
LazarusResources.Add('TEdtTbConfigForm','FORMDATA',[
|
LazarusResources.Add('TEdtTbConfigForm','FORMDATA',[
|
||||||
'TPF0'#16'TEdtTbConfigForm'#15'EdtTbConfigForm'#4'Left'#3'w'#1#6'Height'#3'J'
|
'TPF0'#16'TEdtTbConfigForm'#15'EdtTbConfigForm'#4'Left'#3'w'#1#6'Height'#3'J'
|
||||||
+#1#3'Top'#3#200#0#5'Width'#3#139#2#18'HorzScrollBar.Page'#3#138#2#18'VertScr'
|
+#1#3'Top'#3#200#0#5'Width'#3#139#2#18'HorzScrollBar.Page'#3#138#2#18'VertScr'
|
||||||
@ -24,23 +22,23 @@ LazarusResources.Add('TEdtTbConfigForm','FORMDATA',[
|
|||||||
+#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#3'.'#2#6'Height'#2#25#3'To'
|
+#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#3'.'#2#6'Height'#2#25#3'To'
|
||||||
+'p'#2#11#5'Width'#2'W'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9
|
+'p'#2#11#5'Width'#2'W'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9
|
||||||
+#19'BorderSpacing.Right'#2#6#20'BorderSpacing.Bottom'#2#6#25'BorderSpacing.I'
|
+#19'BorderSpacing.Right'#2#6#20'BorderSpacing.Bottom'#2#6#25'BorderSpacing.I'
|
||||||
+'nnerBorder'#2#4#7'Caption'#6#9'btnCancel'#21'Constraints.MaxHeight'#2#25#21
|
+'nnerBorder'#2#4#6'Cancel'#9#7'Caption'#6#9'btnCancel'#21'Constraints.MaxHei'
|
||||||
+'Constraints.MinHeight'#2#25#20'Constraints.MinWidth'#2'K'#11'ModalResult'#2
|
+'ght'#2#25#21'Constraints.MinHeight'#2#25#20'Constraints.MinWidth'#2'K'#11'M'
|
||||||
+#2#8'TabOrder'#2#1#0#0#0#7'TButton'#13'btnAddDivider'#4'Left'#3#236#1#6'Heig'
|
+'odalResult'#2#2#8'TabOrder'#2#1#0#0#0#7'TButton'#13'btnAddDivider'#4'Left'#3
|
||||||
+'ht'#2#25#3'Top'#3#0#1#5'Width'#2's'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8
|
+#236#1#6'Height'#2#25#3'Top'#3#0#1#5'Width'#2's'#7'Anchors'#11#7'akRight'#8
|
||||||
+'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#13'btnAddDivider'
|
+'akBottom'#0#8'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#13
|
||||||
+#21'Constraints.MaxHeight'#2#25#21'Constraints.MinHeight'#2#25#20'Constraint'
|
+'btnAddDivider'#21'Constraints.MaxHeight'#2#25#21'Constraints.MinHeight'#2#25
|
||||||
+'s.MinWidth'#2'K'#7'OnClick'#7#18'btnAddDividerClick'#8'TabOrder'#2#1#0#0#8
|
+#20'Constraints.MinWidth'#2'K'#7'OnClick'#7#18'btnAddDividerClick'#8'TabOrde'
|
||||||
+'TListBox'#9'lbToolbar'#4'Left'#3#200#1#6'Height'#3#225#0#3'Top'#2#28#5'Widt'
|
+'r'#2#1#0#0#8'TListBox'#9'lbToolbar'#4'Left'#3#200#1#6'Height'#3#225#0#3'Top'
|
||||||
+'h'#3#183#0#8'TabOrder'#2#2#8'TopIndex'#2#255#0#0#7'TBitBtn'#9'btnRemove'#4
|
+#2#28#5'Width'#3#183#0#8'TabOrder'#2#2#8'TopIndex'#2#255#0#0#7'TBitBtn'#9'bt'
|
||||||
+'Left'#3#176#1#6'Height'#2#26#3'Top'#2'J'#5'Width'#2#22#9'NumGlyphs'#2#0#7'O'
|
+'nRemove'#4'Left'#3#176#1#6'Height'#2#26#3'Top'#2'J'#5'Width'#2#22#9'NumGlyp'
|
||||||
+'nClick'#7#14'btnRemoveClick'#8'TabOrder'#2#3#0#0#7'TBitBtn'#6'btnAdd'#4'Lef'
|
+'hs'#2#0#7'OnClick'#7#14'btnRemoveClick'#8'TabOrder'#2#3#0#0#7'TBitBtn'#6'bt'
|
||||||
+'t'#3#176#1#6'Height'#2#26#3'Top'#2'c'#5'Width'#2#22#9'NumGlyphs'#2#0#7'OnCl'
|
+'nAdd'#4'Left'#3#176#1#6'Height'#2#26#3'Top'#2'c'#5'Width'#2#22#9'NumGlyphs'
|
||||||
+'ick'#7#11'btnAddClick'#8'TabOrder'#2#4#0#0#7'TBitBtn'#9'btnMoveUp'#4'Left'#3
|
+#2#0#7'OnClick'#7#11'btnAddClick'#8'TabOrder'#2#4#0#0#7'TBitBtn'#9'btnMoveUp'
|
||||||
+#176#1#6'Height'#2#26#3'Top'#3#157#0#5'Width'#2#22#9'NumGlyphs'#2#0#7'OnClic'
|
+#4'Left'#3#176#1#6'Height'#2#26#3'Top'#3#157#0#5'Width'#2#22#9'NumGlyphs'#2#0
|
||||||
+'k'#7#14'btnMoveUpClick'#8'TabOrder'#2#5#0#0#7'TBitBtn'#11'btnMoveDown'#4'Le'
|
+#7'OnClick'#7#14'btnMoveUpClick'#8'TabOrder'#2#5#0#0#7'TBitBtn'#11'btnMoveDo'
|
||||||
+'ft'#3#176#1#6'Height'#2#26#3'Top'#3#182#0#5'Width'#2#22#9'NumGlyphs'#2#0#7
|
+'wn'#4'Left'#3#176#1#6'Height'#2#26#3'Top'#3#182#0#5'Width'#2#22#9'NumGlyphs'
|
||||||
+'OnClick'#7#16'btnMoveDownClick'#8'TabOrder'#2#6#0#0#9'TTreeView'#2'TV'#4'Le'
|
+#2#0#7'OnClick'#7#16'btnMoveDownClick'#8'TabOrder'#2#6#0#0#9'TTreeView'#2'TV'
|
||||||
+'ft'#2#16#6'Height'#3#253#0#3'Top'#2#28#5'Width'#3#136#1#17'DefaultItemHeigh'
|
+#4'Left'#2#16#6'Height'#3#253#0#3'Top'#2#28#5'Width'#3#136#1#17'DefaultItemH'
|
||||||
+'t'#2#18#8'TabOrder'#2#7#8'OnChange'#7#8'TVChange'#0#0#0
|
+'eight'#2#18#8'TabOrder'#2#7#8'OnChange'#7#8'TVChange'#0#0#0
|
||||||
]);
|
]);
|
||||||
|
@ -67,6 +67,7 @@ uses
|
|||||||
,LazConfigStorage
|
,LazConfigStorage
|
||||||
,BaseIDEIntf
|
,BaseIDEIntf
|
||||||
,LazIDEIntf
|
,LazIDEIntf
|
||||||
|
,IDEImagesIntf
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -91,6 +92,7 @@ begin
|
|||||||
btnMoveUp.Glyph.LoadFromLazarusResource('arrowup_blue16');
|
btnMoveUp.Glyph.LoadFromLazarusResource('arrowup_blue16');
|
||||||
btnMoveDown.Glyph.LoadFromLazarusResource('arrowdown_blue16');
|
btnMoveDown.Glyph.LoadFromLazarusResource('arrowdown_blue16');
|
||||||
|
|
||||||
|
TV.Images := IDEImages.Images_16;
|
||||||
SetupCaptions;
|
SetupCaptions;
|
||||||
LoadCategories;
|
LoadCategories;
|
||||||
LoadSettings;
|
LoadSettings;
|
||||||
@ -146,22 +148,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEdtTbConfigForm.btnOKClick(Sender: TObject);
|
procedure TEdtTbConfigForm.btnOKClick(Sender: TObject);
|
||||||
var
|
|
||||||
i: integer;
|
|
||||||
begin
|
begin
|
||||||
SaveSettings;
|
SaveSettings;
|
||||||
|
|
||||||
if lbToolbar.Items.Count = 0 then
|
|
||||||
begin
|
|
||||||
{ resets the toolbar to only contain static (default) items }
|
|
||||||
gEditorToolbar.ClearToolbar;
|
|
||||||
gEditorToolbar.AddStaticItems;
|
|
||||||
Exit; //==>
|
|
||||||
end;
|
|
||||||
|
|
||||||
gEditorToolbar.ClearToolbar;
|
|
||||||
gEditorToolbar.AddCustomItems;
|
|
||||||
gEditorToolbar.AddStaticItems;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEdtTbConfigForm.btnRemoveClick(Sender: TObject);
|
procedure TEdtTbConfigForm.btnRemoveClick(Sender: TObject);
|
||||||
@ -252,6 +240,7 @@ var
|
|||||||
sec: TIDEMenuSection;
|
sec: TIDEMenuSection;
|
||||||
begin
|
begin
|
||||||
n := TV.Items.AddChild(ParentNode, Format('%s', [Item.Caption]));
|
n := TV.Items.AddChild(ParentNode, Format('%s', [Item.Caption]));
|
||||||
|
n.ImageIndex := Item.ImageIndex;
|
||||||
n.Data := Item;
|
n.Data := Item;
|
||||||
if Item is TIDEMenuSection then
|
if Item is TIDEMenuSection then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user