mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 19:40:19 +02:00
EditorToolbar improvements. Issue #26524, patch from G. Colla.
git-svn-id: trunk@45975 -
This commit is contained in:
parent
68dff727a5
commit
84240315c3
@ -19,7 +19,7 @@
|
||||
"/>
|
||||
<License Value="GPL
|
||||
"/>
|
||||
<Version Minor="5"/>
|
||||
<Version Minor="5" Release="2"/>
|
||||
<Files Count="4">
|
||||
<Item1>
|
||||
<Filename Value="jumpto_impl.pas"/>
|
||||
|
@ -92,6 +92,7 @@ procedure Register;
|
||||
var
|
||||
sToolbarPos: string;
|
||||
bToolBarShow: boolean;
|
||||
EditorMenuCommand:TIDEMenuCommand;
|
||||
|
||||
implementation
|
||||
|
||||
@ -130,6 +131,17 @@ begin
|
||||
uEditorToolbarList.ReloadAll;
|
||||
end;
|
||||
|
||||
procedure ToggleToolbar (Sender:TObject);
|
||||
var
|
||||
ToolBarVisible: Boolean;
|
||||
begin
|
||||
ToolBarVisible:= not bToolBarShow;
|
||||
EditorMenuCommand.Checked:= ToolBarVisible;
|
||||
bToolBarShow:= ToolBarVisible;
|
||||
TEdtTbConfigForm.UpdateVisible(ToolBarVisible);
|
||||
uEditorToolbarList.ReloadAll;
|
||||
end;
|
||||
|
||||
procedure TEditToolBarToolButton.Click;
|
||||
begin
|
||||
inherited Click;
|
||||
@ -194,6 +206,7 @@ begin
|
||||
ATB.Flat := True;
|
||||
ATB.Images := IDEImages.Images_16;
|
||||
ATB.ShowHint := True;
|
||||
ATB.Hint := rsHint;
|
||||
end;
|
||||
|
||||
function TEditorToolbar.CreateJumpItem(AJumpType: TJumpType; O: TComponent): TMenuItem;
|
||||
@ -348,6 +361,7 @@ begin
|
||||
end;
|
||||
sToolbarPos := cfg.GetValue('Position','Top');
|
||||
bToolBarShow:= cfg.GetValue('Visible',true);
|
||||
EditorMenuCommand.Checked:= bToolBarShow;
|
||||
SetTbPos;
|
||||
finally
|
||||
cfg.Free;
|
||||
@ -418,15 +432,21 @@ end;
|
||||
|
||||
procedure Register;
|
||||
var
|
||||
MenuCommand:TIDEMenuCommand;
|
||||
MenuIcon: string;
|
||||
begin
|
||||
MenuIcon:= 'menu_editor_options';
|
||||
//MenuIcon:= 'menu_editor_toolbar'; TODO!
|
||||
if uEditorToolbarList = nil then begin
|
||||
TEditorToolbarList.Create;
|
||||
MenuCommand:= RegisterIDEMenuCommand(itmViewSecondaryWindows,'EditorToolBar',rsEditorToolbar,nil,@ConfigureToolbar);
|
||||
MenuCommand.ImageIndex := IDEImages.LoadImage(16, MenuIcon);
|
||||
EditorMenuCommand:= RegisterIDEMenuCommand(itmViewSecondaryWindows,'EditorToolBar',
|
||||
rsEditorToolbar,nil,@ToggleToolbar);
|
||||
EditorMenuCommand.Checked:= True;
|
||||
EditorMenuCommand.Enabled:= True;
|
||||
//EditorMenuCommand:= RegisterIDEMenuCommand(itmViewSecondaryWindows,'EditorToolBar',rsEditorToolbar,nil,@ConfigureToolbar);
|
||||
{$IFNDEF LCLGTK2}
|
||||
// GTK2 Doesn't show both Icon and checkbox. Qt Does - Windows?
|
||||
EditorMenuCommand.ImageIndex := IDEImages.LoadImage(16, MenuIcon);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
end;
|
||||
|
@ -21,6 +21,7 @@ resourcestring
|
||||
rsRemoveSelected = 'Remove selected item from toolbar';
|
||||
rsMoveSelectedUp = 'Move selected toolbar item up';
|
||||
rsMoveSelectedDown = 'Move selected toolbar item down';
|
||||
rsHint = 'You may add here your favorite commands';
|
||||
rsPosition = 'Position';
|
||||
rsTop = 'Top';
|
||||
rsBottom = 'Bottom';
|
||||
|
@ -10,9 +10,9 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
LCLVersion = '1.3'
|
||||
object lblMenuTree: TLabel
|
||||
Left = 16
|
||||
Height = 20
|
||||
Height = 17
|
||||
Top = 14
|
||||
Width = 83
|
||||
Width = 81
|
||||
Caption = 'lblMenuTree'
|
||||
ParentColor = False
|
||||
end
|
||||
@ -20,9 +20,9 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideLeft.Control = lbToolbar
|
||||
AnchorSideTop.Control = lblpos
|
||||
Left = 443
|
||||
Height = 20
|
||||
Height = 17
|
||||
Top = 14
|
||||
Width = 69
|
||||
Width = 62
|
||||
Caption = 'lblToolbar'
|
||||
ParentColor = False
|
||||
end
|
||||
@ -32,7 +32,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 415
|
||||
Height = 26
|
||||
Top = 126
|
||||
Top = 120
|
||||
Width = 22
|
||||
BorderSpacing.Top = 1
|
||||
Enabled = False
|
||||
@ -46,7 +46,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideTop.Control = TV
|
||||
Left = 415
|
||||
Height = 26
|
||||
Top = 99
|
||||
Top = 93
|
||||
Width = 22
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 25
|
||||
@ -61,7 +61,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 415
|
||||
Height = 26
|
||||
Top = 177
|
||||
Top = 171
|
||||
Width = 22
|
||||
BorderSpacing.Top = 25
|
||||
Enabled = False
|
||||
@ -75,7 +75,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 415
|
||||
Height = 26
|
||||
Top = 204
|
||||
Top = 198
|
||||
Width = 22
|
||||
BorderSpacing.Top = 1
|
||||
Enabled = False
|
||||
@ -106,10 +106,10 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideRight.Control = btnCancel
|
||||
AnchorSideBottom.Control = pnlButtons
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 534
|
||||
Left = 545
|
||||
Height = 25
|
||||
Top = 11
|
||||
Width = 76
|
||||
Width = 75
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 6
|
||||
@ -128,10 +128,10 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = pnlButtons
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 616
|
||||
Left = 626
|
||||
Height = 25
|
||||
Top = 11
|
||||
Width = 100
|
||||
Width = 90
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 6
|
||||
@ -143,7 +143,6 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 75
|
||||
ModalResult = 2
|
||||
OnClick = btnCancelClick
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
@ -153,7 +152,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
Left = 443
|
||||
Height = 25
|
||||
Top = 384
|
||||
Width = 132
|
||||
Width = 116
|
||||
Anchors = [akLeft, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Bottom = 6
|
||||
@ -171,8 +170,8 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideTop.Control = TV
|
||||
AnchorSideBottom.Control = btnAddDivider
|
||||
Left = 443
|
||||
Height = 304
|
||||
Top = 74
|
||||
Height = 310
|
||||
Top = 68
|
||||
Width = 268
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 6
|
||||
@ -188,14 +187,13 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideRight.Control = Splitter1
|
||||
AnchorSideBottom.Control = pnlButtons
|
||||
Left = 16
|
||||
Height = 335
|
||||
Top = 74
|
||||
Height = 341
|
||||
Top = 68
|
||||
Width = 381
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Right = 3
|
||||
BorderSpacing.Bottom = 6
|
||||
DefaultItemHeight = 22
|
||||
ReadOnly = True
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 1
|
||||
@ -207,8 +205,8 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideTop.Control = lblMenuTree
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 16
|
||||
Height = 28
|
||||
Top = 40
|
||||
Height = 25
|
||||
Top = 37
|
||||
Width = 192
|
||||
UseFormActivate = True
|
||||
ButtonWidth = 23
|
||||
@ -222,10 +220,10 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
end
|
||||
object cbPos: TComboBox
|
||||
Left = 293
|
||||
Height = 28
|
||||
Height = 25
|
||||
Top = 10
|
||||
Width = 100
|
||||
ItemHeight = 20
|
||||
ItemHeight = 0
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'Top'
|
||||
@ -240,15 +238,15 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
object lblpos: TLabel
|
||||
AnchorSideTop.Control = lblMenuTree
|
||||
Left = 232
|
||||
Height = 20
|
||||
Height = 17
|
||||
Top = 14
|
||||
Width = 41
|
||||
Width = 38
|
||||
Caption = 'lblpos'
|
||||
ParentColor = False
|
||||
end
|
||||
object cbVisible: TCheckBox
|
||||
Left = 316
|
||||
Height = 24
|
||||
Height = 21
|
||||
Top = 45
|
||||
Width = 68
|
||||
Caption = 'Visible'
|
||||
@ -264,8 +262,8 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideBottom.Control = TV
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 400
|
||||
Height = 335
|
||||
Top = 74
|
||||
Height = 341
|
||||
Top = 68
|
||||
Width = 9
|
||||
Align = alNone
|
||||
Anchors = [akTop, akBottom]
|
||||
|
@ -49,7 +49,6 @@ type
|
||||
FilterEdit: TTreeFilterEdit;
|
||||
Splitter1: TSplitter;
|
||||
TV: TTreeView;
|
||||
procedure btnCancelClick(Sender: TObject);
|
||||
procedure cbPosChange(Sender: TObject);
|
||||
procedure cbVisibleChange(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
@ -69,14 +68,17 @@ type
|
||||
procedure LoadSettings;
|
||||
procedure SaveSettings;
|
||||
procedure AddMenuItem(ParentNode: TTreeNode; Item: TIDEMenuItem);
|
||||
procedure AddToolBarItem(Item: TIDEMenuItem);
|
||||
public
|
||||
class function Execute: boolean;
|
||||
class procedure Setup;
|
||||
class procedure UpdateVisible(NewStatus: Boolean);
|
||||
end;
|
||||
|
||||
Var
|
||||
sPosValues: array[0..3] of string = ('Top','Bottom','Right','Left');
|
||||
sLocalizedPosValues: array[0..3] of string;
|
||||
sMenuView: string = 'View';
|
||||
|
||||
implementation
|
||||
|
||||
@ -148,10 +150,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.btnCancelClick(Sender: TObject);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.cbVisibleChange(Sender: TObject);
|
||||
begin
|
||||
FToolBarShow:= cbVisible.Checked;
|
||||
@ -186,14 +184,25 @@ begin
|
||||
lbToolbar.Items.AddObject(TIDEMenuItem(n.Data).Caption, TObject(n.Data));
|
||||
lbToolbar.ItemIndex := lbToolbar.Items.Count-1;
|
||||
lbToolbarSelectionChange(lblToolbar, False);
|
||||
TV.Selected.Visible:= False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.btnRemoveClick(Sender: TObject);
|
||||
Var
|
||||
mi: TIDEMenuItem;
|
||||
n: TTreeNode;
|
||||
I: Integer;
|
||||
begin
|
||||
if lbToolbar.ItemIndex > -1 then begin
|
||||
I := lbToolbar.ItemIndex;
|
||||
if I > -1 then begin
|
||||
mi := TIDEMenuItem(lbToolbar.Items.Objects[I]);
|
||||
lbToolbar.Items.Delete(lbToolbar.ItemIndex);
|
||||
lbToolbarSelectionChange(lbToolbar, False);
|
||||
if assigned(mi) then begin
|
||||
n:= TV.Items.FindNodeWithData(mi);
|
||||
n.Visible:= True;
|
||||
end;
|
||||
TVSelectionChanged(TV);
|
||||
end;
|
||||
end;
|
||||
@ -228,7 +237,7 @@ end;
|
||||
procedure TEdtTbConfigForm.btnOKClick(Sender: TObject);
|
||||
begin
|
||||
SaveSettings;
|
||||
if not FToolBarShow then ShowMessageFmt(rsWarning,[rsMenuView,rsEditorToolbar]);
|
||||
if not FToolBarShow then ShowMessage(Format(rsWarning,[sMenuView,rsEditorToolbar]));
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.SetupCaptions;
|
||||
@ -274,23 +283,23 @@ var
|
||||
cfg: TConfigStorage;
|
||||
value: string;
|
||||
mi: TIDEMenuItem;
|
||||
ms: TIDEMenuSection;
|
||||
begin
|
||||
cfg := GetIDEConfigStorage(cSettingsFile, True);
|
||||
try
|
||||
c := cfg.GetValue('Count', 0);
|
||||
|
||||
if c = 0 then begin
|
||||
// Let's provide a Jump Back/Jump Forward as a starting default
|
||||
ms := itmJumpings;
|
||||
mi := ms.FindByName('itmJumpBack');
|
||||
if Assigned(mi) then
|
||||
lbToolbar.Items.AddObject(mi.Caption, TObject(mi));
|
||||
mi := ms.FindByName('itmJumpForward');
|
||||
if Assigned(mi) then
|
||||
lbToolbar.Items.AddObject(mi.Caption, TObject(mi));
|
||||
value := 'IDEMainMenu/Search/itmJumpings/itmJumpBack';
|
||||
mi := IDEMenuRoots.FindByPath(value, false);
|
||||
AddToolBarItem(mi);
|
||||
{if Assigned(mi) then
|
||||
lbToolbar.Items.AddObject(mi.Caption, TObject(mi));}
|
||||
value := 'IDEMainMenu/Search/itmJumpings/itmJumpForward';
|
||||
mi := IDEMenuRoots.FindByPath(value, false);
|
||||
AddToolBarItem(mi);
|
||||
{if Assigned(mi) then
|
||||
lbToolbar.Items.AddObject(mi.Caption, TObject(mi));}
|
||||
end
|
||||
|
||||
else begin
|
||||
for i := 0 to c - 1 do
|
||||
begin
|
||||
@ -304,8 +313,9 @@ begin
|
||||
end;
|
||||
|
||||
mi := IDEMenuRoots.FindByPath(value, false);
|
||||
if Assigned(mi) then
|
||||
lbToolbar.Items.AddObject(mi.Caption, TObject(mi));
|
||||
AddToolBarItem(mi);
|
||||
{if Assigned(mi) then
|
||||
lbToolbar.Items.AddObject(mi.Caption, TObject(mi));}
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -348,12 +358,15 @@ var
|
||||
n: TTreeNode;
|
||||
i: integer;
|
||||
sec: TIDEMenuSection;
|
||||
ACaption: string;
|
||||
begin
|
||||
n := TV.Items.AddChild(ParentNode, Format('%s', [Item.Caption]));
|
||||
n.ImageIndex := Item.ImageIndex;
|
||||
n.SelectedIndex := Item.ImageIndex;
|
||||
if Item is TIDEMenuSection then
|
||||
begin
|
||||
// get the caption of the View entry for the appropriate Warning
|
||||
if Item.Name = 'View' then sMenuView:= Item.Caption;
|
||||
sec := (Item as TIDEMenuSection);
|
||||
for i := 0 to sec.Count-1 do
|
||||
AddMenuItem(n, sec.Items[i]);
|
||||
@ -362,6 +375,17 @@ begin
|
||||
n.Data := Item;
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.AddToolBarItem(Item: TIDEMenuItem);
|
||||
Var
|
||||
n: TTreeNode;
|
||||
begin
|
||||
if Assigned(Item) then begin
|
||||
lbToolbar.Items.AddObject(Item.Caption, TObject(Item));
|
||||
n:= TV.Items.FindNodeWithData(Item);
|
||||
n.Visible:= False;
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TEdtTbConfigForm.Execute: boolean;
|
||||
var
|
||||
frm: TEdtTbConfigForm;
|
||||
@ -374,15 +398,26 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{TEdtTbConfigForm.Setup - called if no user items in config. }
|
||||
class procedure TEdtTbConfigForm.Setup;
|
||||
var
|
||||
frm: TEdtTbConfigForm;
|
||||
begin
|
||||
// Create inserts the default Items
|
||||
frm := TEdtTbConfigForm.Create(nil);
|
||||
try
|
||||
// Must save them, less they're inserted twice
|
||||
frm.SaveSettings;
|
||||
finally
|
||||
frm.Free;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
class procedure TEdtTbConfigForm.UpdateVisible(NewStatus: Boolean);
|
||||
var
|
||||
frm: TEdtTbConfigForm;
|
||||
begin
|
||||
frm := TEdtTbConfigForm.Create(nil);
|
||||
try
|
||||
frm.FToolBarShow:= NewStatus;
|
||||
frm.SaveSettings;
|
||||
finally
|
||||
frm.Free;
|
||||
|
Loading…
Reference in New Issue
Block a user