mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:39:25 +02:00
editortoolbar: fixed toolbar button order from Graeme (#8832)
git-svn-id: trunk@11101 -
This commit is contained in:
parent
555f6c9e4a
commit
30fc8f47b0
@ -55,6 +55,7 @@ type
|
|||||||
procedure DoConfigureToolbar(Sender: TObject);
|
procedure DoConfigureToolbar(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
procedure AddButton(AMenuItem: TIDEMenuItem);
|
procedure AddButton(AMenuItem: TIDEMenuItem);
|
||||||
|
procedure PositionAtEnd(AToolbar: TToolbar; AButton: TToolButton);
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -121,8 +122,8 @@ begin
|
|||||||
if TEdtTbConfigForm.Execute then
|
if TEdtTbConfigForm.Execute then
|
||||||
begin
|
begin
|
||||||
ClearToolbar;
|
ClearToolbar;
|
||||||
AddCustomItems;
|
|
||||||
AddStaticItems;
|
AddStaticItems;
|
||||||
|
AddCustomItems;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -153,17 +154,15 @@ begin
|
|||||||
PM.Items.Add(CreateJumpItem(T,W));
|
PM.Items.Add(CreateJumpItem(T,W));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AddCustomItems;
|
|
||||||
AddStaticItems;
|
AddStaticItems;
|
||||||
|
AddCustomItems;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorToolbar.AddButton(AMenuItem: TIDEMenuItem);
|
procedure TEditorToolbar.AddButton(AMenuItem: TIDEMenuItem);
|
||||||
var
|
var
|
||||||
B: TToolButton;
|
B: TToolButton;
|
||||||
i: integer;
|
|
||||||
begin
|
begin
|
||||||
B := TToolButton.Create(TB);
|
B := TToolButton.Create(TB);
|
||||||
B.Parent := TB;
|
|
||||||
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.
|
||||||
@ -174,6 +173,21 @@ begin
|
|||||||
|
|
||||||
B.Style := tbsButton;
|
B.Style := tbsButton;
|
||||||
B.OnClick := AMenuItem.OnClick;
|
B.OnClick := AMenuItem.OnClick;
|
||||||
|
PositionAtEnd(TB, B);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// position the button next to the last button
|
||||||
|
procedure TEditorToolbar.PositionAtEnd(AToolbar: TToolbar; AButton: TToolButton);
|
||||||
|
var
|
||||||
|
SiblingButton: TToolButton;
|
||||||
|
begin
|
||||||
|
if AToolbar.ButtonCount > 0 then
|
||||||
|
begin
|
||||||
|
SiblingButton := AToolbar.Buttons[AToolbar.ButtonCount-1];
|
||||||
|
AButton.SetBounds(SiblingButton.Left + SiblingButton.Width,
|
||||||
|
SiblingButton.Top, AButton.Width, AButton.Height);
|
||||||
|
end;
|
||||||
|
AButton.Parent := AToolbar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorToolbar.AddCustomItems;
|
procedure TEditorToolbar.AddCustomItems;
|
||||||
@ -188,9 +202,9 @@ begin
|
|||||||
TB.BeginUpdate;
|
TB.BeginUpdate;
|
||||||
try
|
try
|
||||||
c := cfg.GetValue('Count', 0);
|
c := cfg.GetValue('Count', 0);
|
||||||
for i := c - 1 downto 0 do
|
for i := 1 to c do
|
||||||
begin
|
begin
|
||||||
value := cfg.GetValue('Button' + Format('%2.2d', [i+1]) + '/Value', '');
|
value := cfg.GetValue('Button' + Format('%2.2d', [i]) + '/Value', '');
|
||||||
if value = cDivider then
|
if value = cDivider then
|
||||||
AddDivider
|
AddDivider
|
||||||
else
|
else
|
||||||
@ -211,8 +225,8 @@ var
|
|||||||
B: TToolButton;
|
B: TToolButton;
|
||||||
begin
|
begin
|
||||||
B := TToolbutton.Create(TB);
|
B := TToolbutton.Create(TB);
|
||||||
B.Parent := TB;
|
B.Style := tbsDivider;
|
||||||
B.Style := tbsDivider;
|
PositionAtEnd(TB, B);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorToolbar.AddStaticItems;
|
procedure TEditorToolbar.AddStaticItems;
|
||||||
@ -221,32 +235,30 @@ var
|
|||||||
begin
|
begin
|
||||||
TB.BeginUpdate;
|
TB.BeginUpdate;
|
||||||
try
|
try
|
||||||
if TB.ButtonCount <> 0 then
|
|
||||||
AddDivider;
|
|
||||||
|
|
||||||
// JumpTo Button
|
|
||||||
B := TToolbutton.Create(TB);
|
|
||||||
B.Parent := TB;
|
|
||||||
B.Caption := 'Jump To';
|
|
||||||
B.Hint := B.Caption;
|
|
||||||
B.ImageIndex := IDEImages.LoadImage(16, 'jumpto16');
|
|
||||||
B.Style := tbsDropDown;
|
|
||||||
B.OnClick := @FJumpHandler.DoJumpToImplementation;
|
|
||||||
|
|
||||||
B.DropdownMenu := PM;
|
|
||||||
|
|
||||||
AddDivider;
|
|
||||||
|
|
||||||
// Config Button
|
// Config Button
|
||||||
if CfgButton = nil then
|
if CfgButton = nil then
|
||||||
CfgButton := TToolbutton.Create(TB);
|
CfgButton := TToolbutton.Create(TB);
|
||||||
|
|
||||||
CfgButton.Parent := TB;
|
|
||||||
CfgButton.Caption := 'Configure Toolbar';
|
CfgButton.Caption := 'Configure Toolbar';
|
||||||
CfgButton.Hint := B.Caption;
|
CfgButton.Hint := CfgButton.Caption;
|
||||||
CfgButton.ImageIndex := IDEImages.LoadImage(16, 'preferences16');
|
CfgButton.ImageIndex := IDEImages.LoadImage(16, 'preferences16');
|
||||||
CfgButton.Style := tbsButton;
|
CfgButton.Style := tbsButton;
|
||||||
CfgButton.OnClick := @DoConfigureToolbar;
|
CfgButton.OnClick := @DoConfigureToolbar;
|
||||||
|
PositionAtEnd(TB, CfgButton);
|
||||||
|
|
||||||
|
AddDivider;
|
||||||
|
|
||||||
|
// JumpTo Button
|
||||||
|
B := TToolbutton.Create(TB);
|
||||||
|
B.Caption := 'Jump To';
|
||||||
|
B.Hint := B.Caption;
|
||||||
|
B.ImageIndex := IDEImages.LoadImage(16, 'jumpto16');
|
||||||
|
B.Style := tbsDropDown;
|
||||||
|
B.OnClick := @FJumpHandler.DoJumpToImplementation;
|
||||||
|
B.DropdownMenu := PM;
|
||||||
|
PositionAtEnd(TB, B);
|
||||||
|
|
||||||
|
if TB.ButtonCount <> 0 then
|
||||||
|
AddDivider;
|
||||||
finally
|
finally
|
||||||
TB.EndUpdate;
|
TB.EndUpdate;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user