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