mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 21:59:14 +02:00
EditorToolbar: Update icon state to match the IDE command state. Issue #25228, patch from G. Colla.
git-svn-id: trunk@46416 -
This commit is contained in:
parent
6e72c3b809
commit
101f210424
@ -24,11 +24,11 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes
|
Classes
|
||||||
,CodeToolManager
|
|
||||||
,jumpto_impl
|
,jumpto_impl
|
||||||
,Forms
|
,Forms
|
||||||
,ComCtrls
|
,ComCtrls
|
||||||
,Controls
|
,Controls
|
||||||
|
,ExtCtrls
|
||||||
,Menus
|
,Menus
|
||||||
,MenuIntf
|
,MenuIntf
|
||||||
,IDEImagesIntf
|
,IDEImagesIntf
|
||||||
@ -58,10 +58,13 @@ type
|
|||||||
PM: TPopupMenu;
|
PM: TPopupMenu;
|
||||||
PPUP: TPopupMenu;
|
PPUP: TPopupMenu;
|
||||||
CfgButton: TToolButton;
|
CfgButton: TToolButton;
|
||||||
|
FButtonList: TList;
|
||||||
|
UpdateTimer: TTimer;
|
||||||
procedure CreateEditorToolbar(AW: TForm; var ATB: TToolbar);
|
procedure CreateEditorToolbar(AW: TForm; var ATB: TToolbar);
|
||||||
function CreateJumpItem(AJumpType: TJumpType; O: TComponent): TMenuItem;
|
function CreateJumpItem(AJumpType: TJumpType; O: TComponent): TMenuItem;
|
||||||
function CreateProfileItem(ProfIndx: Integer; O: TComponent): TMenuItem;
|
function CreateProfileItem(ProfIndx: Integer; O: TComponent): TMenuItem;
|
||||||
procedure DoConfigureToolbar(Sender: TObject);
|
procedure DoConfigureToolbar(Sender: TObject);
|
||||||
|
procedure UpdateBar(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
procedure MenuItemClick (Sender: TObject);
|
procedure MenuItemClick (Sender: TObject);
|
||||||
procedure AddButton(AMenuItem: TIDEMenuItem);
|
procedure AddButton(AMenuItem: TIDEMenuItem);
|
||||||
@ -112,9 +115,7 @@ implementation
|
|||||||
{$R toolbar.res} // all required images
|
{$R toolbar.res} // all required images
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LazIDEIntf
|
Dialogs
|
||||||
,CustomCodeTool
|
|
||||||
,Dialogs
|
|
||||||
,SysUtils
|
,SysUtils
|
||||||
,LResources
|
,LResources
|
||||||
,EdtTbConfigFrm
|
,EdtTbConfigFrm
|
||||||
@ -131,7 +132,7 @@ type
|
|||||||
FMenuItem: TIDEMenuItem;
|
FMenuItem: TIDEMenuItem;
|
||||||
public
|
public
|
||||||
procedure Click; override;
|
procedure Click; override;
|
||||||
property MenuItem: TIDEMenuItem read FMenuItem write FMenuItem;
|
property IdeMenuItem: TIDEMenuItem read FMenuItem write FMenuItem;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -266,6 +267,27 @@ begin
|
|||||||
uEditorToolbarList.ReloadAll;
|
uEditorToolbarList.ReloadAll;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TEditorToolbar.UpdateBar(Sender: TObject);
|
||||||
|
var
|
||||||
|
i,j: integer;
|
||||||
|
mi: TIDEMenuItem;
|
||||||
|
begin
|
||||||
|
TB.BeginUpdate;
|
||||||
|
try
|
||||||
|
for i := TB.ButtonCount - 1 downto 0 do begin
|
||||||
|
if TB.Buttons[I].tag <> 0 then begin
|
||||||
|
j := TB.Buttons[I].tag-1;
|
||||||
|
mi := TIDEMenuItem(FButtonList.Items[j]);
|
||||||
|
if mi <> nil then begin
|
||||||
|
TB.Buttons[I].Enabled := mi.Enabled;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
TB.EndUpdate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TEditorToolbar.MenuItemClick(Sender: TObject);
|
procedure TEditorToolbar.MenuItemClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
cfg: TConfigStorage;
|
cfg: TConfigStorage;
|
||||||
@ -295,6 +317,8 @@ begin
|
|||||||
uEditorToolbarList.AddBar(Self);
|
uEditorToolbarList.AddBar(Self);
|
||||||
if assigned(TB) then exit;
|
if assigned(TB) then exit;
|
||||||
|
|
||||||
|
FButtonList := TList.Create;
|
||||||
|
|
||||||
sLocalizedProfileNames[0] := rsAll;
|
sLocalizedProfileNames[0] := rsAll;
|
||||||
sLocalizedProfileNames[1] := rsDesign;
|
sLocalizedProfileNames[1] := rsDesign;
|
||||||
sLocalizedProfileNames[2] := rsDebug;
|
sLocalizedProfileNames[2] := rsDebug;
|
||||||
@ -328,12 +352,17 @@ begin
|
|||||||
TEdtTbConfigForm.Setup;
|
TEdtTbConfigForm.Setup;
|
||||||
|
|
||||||
AddCustomItems;
|
AddCustomItems;
|
||||||
|
UpdateTimer := TTimer.Create(Self);
|
||||||
|
UpdateTimer.Interval := 500;
|
||||||
|
UpdateTimer.OnTimer := @UpdateBar;
|
||||||
|
UpdateTimer.Enabled := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TEditorToolbar.Destroy;
|
destructor TEditorToolbar.Destroy;
|
||||||
begin
|
begin
|
||||||
uEditorToolbarList.DelBar(Self);
|
uEditorToolbarList.DelBar(Self);
|
||||||
FJumpHandler.Free;
|
FJumpHandler.Free;
|
||||||
|
FButtonList.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -347,6 +376,7 @@ procedure TEditorToolbar.AddButton(AMenuItem: TIDEMenuItem);
|
|||||||
var
|
var
|
||||||
B: TEditToolBarToolButton;
|
B: TEditToolBarToolButton;
|
||||||
ACaption: string;
|
ACaption: string;
|
||||||
|
iPos: Integer;
|
||||||
begin
|
begin
|
||||||
B := TEditToolBarToolButton.Create(TB);
|
B := TEditToolBarToolButton.Create(TB);
|
||||||
ACaption := AMenuItem.Caption;
|
ACaption := AMenuItem.Caption;
|
||||||
@ -362,7 +392,9 @@ begin
|
|||||||
B.ImageIndex := IDEImages.LoadImage(16, 'execute16');
|
B.ImageIndex := IDEImages.LoadImage(16, 'execute16');
|
||||||
|
|
||||||
B.Style := tbsButton;
|
B.Style := tbsButton;
|
||||||
B.MenuItem := AMenuItem;
|
B.IdeMenuItem := AMenuItem;
|
||||||
|
iPos := FButtonList.Add(AMenuItem);
|
||||||
|
B.Tag:= iPos+1;
|
||||||
//B.OnClick := AMenuItem.OnClick;
|
//B.OnClick := AMenuItem.OnClick;
|
||||||
PositionAtEnd(TB, B);
|
PositionAtEnd(TB, B);
|
||||||
end;
|
end;
|
||||||
@ -481,9 +513,8 @@ begin
|
|||||||
CfgButton.Style := tbsButton;
|
CfgButton.Style := tbsButton;
|
||||||
CfgButton.OnClick := @DoConfigureToolbar;
|
CfgButton.OnClick := @DoConfigureToolbar;
|
||||||
PositionAtEnd(TB, CfgButton);
|
PositionAtEnd(TB, CfgButton);
|
||||||
|
|
||||||
AddDivider;
|
AddDivider;
|
||||||
|
|
||||||
// JumpTo Button
|
// JumpTo Button
|
||||||
B := TToolbutton.Create(TB);
|
B := TToolbutton.Create(TB);
|
||||||
B.Caption := rsJumpTo;
|
B.Caption := rsJumpTo;
|
||||||
|
Loading…
Reference in New Issue
Block a user