editortoolbar: Treeview revised to make it more readable, and translatable. New Icons for Jump Forward/Jump Back, New Icon for Set Free Bookmark, issue #26557, patch from G. Colla

git-svn-id: trunk@46009 -
This commit is contained in:
mattias 2014-08-04 14:39:28 +00:00
parent 93aea56c3b
commit 4999b94886
12 changed files with 262 additions and 81 deletions

1
.gitattributes vendored
View File

@ -5885,6 +5885,7 @@ images/menu/menu_search_next_bookmark.png -text
images/menu/menu_search_openfile_atcursor.png -text svneol=unset#image/png
images/menu/menu_search_previous_bookmark.png -text
images/menu/menu_search_replace.png -text svneol=unset#image/png
images/menu/menu_search_set_bookmark.png -text svneol=unset#image/png
images/menu/menu_select_all.png -text svneol=unset#image/png
images/menu/menu_stepinto.png -text svneol=unset#image/png
images/menu/menu_stepinto_instr.png -text svneol=unset#image/png

View File

@ -15,11 +15,11 @@
</SyntaxOptions>
</Parsing>
</CompilerOptions>
<Description Value="Editor Toolbar
<Description Value="Provides a configurable Toolbar in the source editor window, which can be positioned at any side. The toolbar comes with a predefined Jump button, and then Jump Forward and Jump Back buttons.
"/>
<License Value="GPL
"/>
<Version Minor="5" Release="2"/>
<Version Minor="6" Release="1"/>
<Files Count="4">
<Item1>
<Filename Value="jumpto_impl.pas"/>

View File

@ -107,7 +107,7 @@ uses
,EdtTbConfigFrm
,LazConfigStorage
,BaseIDEIntf
;
,LCLProc;
type
@ -272,10 +272,13 @@ end;
procedure TEditorToolbar.AddButton(AMenuItem: TIDEMenuItem);
var
B: TEditToolBarToolButton;
ACaption: string;
begin
B := TEditToolBarToolButton.Create(TB);
B.Caption := AMenuItem.Caption;
B.Hint := AMenuItem.Caption; // or should we use AMenuItem.Hint?
ACaption := AMenuItem.Caption;
DeleteAmpersands(ACaption);
B.Caption := ACaption;
B.Hint := ACaption; // or should we use AMenuItem.Hint?
// If we have a image, us it. Otherwise supply a default.
if AMenuItem.ImageIndex <> -1 then
B.ImageIndex := AMenuItem.ImageIndex

View File

@ -27,12 +27,18 @@ resourcestring
rsBottom = 'Bottom';
rsLeft = 'Left';
rsRight = 'Right';
rsVisible = 'Visible';
rsShowHide = 'Show/Hide Toolbar';
rsWarning = 'You''ve chosen to hide the toolbar. ' +
'You may access the toolbar configuration via "%s" -> "%s" main menu.';
rsEditorToolbar = 'Editor ToolBar';
rsMenuView = 'View';
// Root Node Captions
rsIDEMainMenu = 'IDE Main Menu';
rsSourceTab = 'Source Tab';
rsSourceEditor = 'Source Editor';
rsMessages = 'Messages';
rsCodeExplorer = 'Code Explorer';
rsCodeTemplates = 'Code Templates';
rsDesigner = 'Designer';
rsPackageEditor = 'Package Editor';
rsPackageEditorFiles = 'Package Editor Files';
implementation

View File

@ -10,9 +10,9 @@ object EdtTbConfigForm: TEdtTbConfigForm
LCLVersion = '1.3'
object lblMenuTree: TLabel
Left = 16
Height = 15
Height = 17
Top = 14
Width = 74
Width = 81
Caption = 'lblMenuTree'
ParentColor = False
end
@ -20,9 +20,9 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideLeft.Control = lbToolbar
AnchorSideTop.Control = lblMenuTree
Left = 443
Height = 15
Height = 17
Top = 14
Width = 59
Width = 62
Caption = 'lblToolbar'
ParentColor = False
end
@ -32,7 +32,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideTop.Side = asrBottom
Left = 415
Height = 26
Top = 118
Top = 120
Width = 22
BorderSpacing.Top = 1
Enabled = False
@ -46,7 +46,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideTop.Control = TV
Left = 415
Height = 26
Top = 91
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 = 169
Top = 171
Width = 22
BorderSpacing.Top = 25
Enabled = False
@ -75,7 +75,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideTop.Side = asrBottom
Left = 415
Height = 26
Top = 196
Top = 198
Width = 22
BorderSpacing.Top = 1
Enabled = False
@ -106,7 +106,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideRight.Control = btnCancel
AnchorSideBottom.Control = pnlButtons
AnchorSideBottom.Side = asrBottom
Left = 600
Left = 595
Height = 25
Top = 11
Width = 75
@ -128,10 +128,10 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = pnlButtons
AnchorSideBottom.Side = asrBottom
Left = 681
Left = 676
Height = 25
Top = 11
Width = 85
Width = 90
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 6
@ -145,6 +145,73 @@ object EdtTbConfigForm: TEdtTbConfigForm
ModalResult = 2
TabOrder = 1
end
object btnExpert: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideBottom.Control = pnlButtons
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 11
Width = 75
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Bottom = 6
Caption = 'Expert'
OnClick = btnExpertClick
TabOrder = 2
Visible = False
end
object btnExpand: TButton
AnchorSideLeft.Control = btnExpert
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = pnlButtons
AnchorSideBottom.Side = asrBottom
Left = 87
Height = 25
Top = 11
Width = 75
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Bottom = 6
Caption = 'Expand'
OnClick = btnExpandClick
TabOrder = 3
Visible = False
end
object btnSections: TButton
AnchorSideLeft.Control = btnExpand
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = pnlButtons
AnchorSideBottom.Side = asrBottom
Left = 168
Height = 25
Top = 11
Width = 75
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Bottom = 6
Caption = 'Sections'
OnClick = btnSectionsClick
TabOrder = 4
Visible = False
end
object btnCompress: TButton
AnchorSideLeft.Control = btnSections
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = pnlButtons
AnchorSideBottom.Side = asrBottom
Left = 249
Height = 25
Top = 11
Width = 75
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Bottom = 6
Caption = 'Compress'
OnClick = btnCompressClick
TabOrder = 5
Visible = False
end
end
object btnAddDivider: TButton
AnchorSideLeft.Control = lblToolbar
@ -152,7 +219,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
Left = 443
Height = 25
Top = 384
Width = 109
Width = 116
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Bottom = 6
@ -170,8 +237,8 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideTop.Control = TV
AnchorSideBottom.Control = btnAddDivider
Left = 443
Height = 312
Top = 66
Height = 310
Top = 68
Width = 318
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 6
@ -187,14 +254,13 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideRight.Control = Splitter1
AnchorSideBottom.Control = pnlButtons
Left = 16
Height = 343
Top = 66
Height = 341
Top = 68
Width = 381
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 6
BorderSpacing.Right = 3
BorderSpacing.Bottom = 6
DefaultItemHeight = 18
ReadOnly = True
ScrollBars = ssAutoBoth
TabOrder = 1
@ -207,7 +273,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideTop.Side = asrBottom
Left = 16
Height = 25
Top = 35
Top = 37
Width = 192
UseFormActivate = True
ButtonWidth = 23
@ -248,27 +314,15 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideTop.Control = cbPos
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cbPos
Left = 618
Height = 15
Top = 389
Width = 37
Left = 617
Height = 17
Top = 388
Width = 38
Anchors = [akTop, akRight]
BorderSpacing.Right = 6
Caption = 'lblpos'
ParentColor = False
end
object cbVisible: TCheckBox
Left = 232
Height = 21
Top = 39
Width = 64
Caption = 'Visible'
OnChange = cbVisibleChange
ParentShowHint = False
ShowHint = True
TabOrder = 6
Visible = False
end
object Splitter1: TSplitter
AnchorSideLeft.Control = TV
AnchorSideLeft.Side = asrBottom
@ -276,8 +330,8 @@ object EdtTbConfigForm: TEdtTbConfigForm
AnchorSideBottom.Control = TV
AnchorSideBottom.Side = asrBottom
Left = 400
Height = 343
Top = 66
Height = 341
Top = 68
Width = 9
Align = alNone
Anchors = [akTop, akBottom]

View File

@ -39,8 +39,11 @@ type
btnCancel: TButton;
btnAddDivider: TButton;
btnRemove: TSpeedButton;
btnExpert: TButton;
btnExpand: TButton;
btnSections: TButton;
btnCompress: TButton;
cbPos: TComboBox;
cbVisible: TCheckBox;
lblpos: TLabel;
lblMenuTree: TLabel;
lblToolbar: TLabel;
@ -49,8 +52,11 @@ type
FilterEdit: TTreeFilterEdit;
Splitter1: TSplitter;
TV: TTreeView;
procedure btnCompressClick(Sender: TObject);
procedure btnExpandClick(Sender: TObject);
procedure btnExpertClick(Sender: TObject);
procedure btnSectionsClick(Sender: TObject);
procedure cbPosChange(Sender: TObject);
procedure cbVisibleChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure lbToolbarSelectionChange(Sender: TObject; User: boolean);
procedure btnAddClick(Sender: TObject);
@ -63,11 +69,17 @@ type
private
FToolBarPos: string;
FToolBarShow: boolean;
FExpert: boolean;
FExpandAll: boolean;
FShowSections: boolean;
FCompressSections: boolean;
procedure SetupCaptions;
procedure LoadCategories;
procedure LoadSettings;
procedure LoadStyleSettings;
procedure SaveSettings;
procedure AddMenuItem(ParentNode: TTreeNode; Item: TIDEMenuItem);
procedure AddMenuItem(ParentNode: TTreeNode; Item: TIDEMenuItem; Level: Integer);
function RootNodeCaption(Item: TIDEMenuItem): string;
procedure AddToolBarItem(Item: TIDEMenuItem);
public
class function Execute: boolean;
@ -78,14 +90,13 @@ type
Var
sPosValues: array[0..3] of string = ('Top','Bottom','Right','Left');
sLocalizedPosValues: array[0..3] of string;
sMenuView: string = 'View';
implementation
{$R *.lfm}
uses
editortoolbar_impl, LazConfigStorage, BaseIDEIntf, LazIDEIntf, IDEImagesIntf;
editortoolbar_impl, LazConfigStorage, BaseIDEIntf, LazIDEIntf, IDEImagesIntf,LCLProc;
{
Function IndexFromLocalized (var AValue: string): Integer;
@ -132,9 +143,9 @@ begin
btnRemove.Hint := rsRemoveSelected;
btnMoveUp.Hint := rsMoveSelectedUp;
btnMoveDown.Hint := rsMoveSelectedDown;
cbVisible.Hint := rsShowHide;
TV.Images := IDEImages.Images_16;
LoadStyleSettings;
SetupCaptions;
LoadCategories;
LoadSettings;
@ -150,9 +161,33 @@ begin
end;
end;
procedure TEdtTbConfigForm.cbVisibleChange(Sender: TObject);
procedure TEdtTbConfigForm.btnExpandClick(Sender: TObject);
begin
FToolBarShow:= cbVisible.Checked;
FExpandAll:= not FExpandAll;
if FExpandAll then btnExpand.Caption:= 'Collapse'
else btnExpand.Caption:= 'Expand';
LoadCategories;
end;
procedure TEdtTbConfigForm.btnExpertClick(Sender: TObject);
begin
FExpert:= not FExpert;
SetupCaptions;
LoadCategories;
end;
procedure TEdtTbConfigForm.btnCompressClick(Sender: TObject);
begin
FCompressSections:= not FCompressSections;
SetupCaptions;
LoadCategories;
end;
procedure TEdtTbConfigForm.btnSectionsClick(Sender: TObject);
begin
FShowSections:= not FShowSections;
SetupCaptions;
LoadCategories;
end;
procedure TEdtTbConfigForm.lbToolbarSelectionChange(Sender: TObject; User: boolean);
@ -176,12 +211,15 @@ end;
procedure TEdtTbConfigForm.btnAddClick(Sender: TObject);
var
n: TTreeNode;
ACaption: string;
begin
n := TV.Selected;
if (Assigned(n) and Assigned(n.Data)) then
begin
btnAdd.Enabled := False;
lbToolbar.Items.AddObject(TIDEMenuItem(n.Data).Caption, TObject(n.Data));
ACaption:= TIDEMenuItem(n.Data).Caption;
DeleteAmpersands(ACaption);
lbToolbar.Items.AddObject(ACaption, TObject(n.Data));
lbToolbar.ItemIndex := lbToolbar.Items.Count-1;
lbToolbarSelectionChange(lblToolbar, False);
TV.Selected.Visible:= False;
@ -237,7 +275,6 @@ end;
procedure TEdtTbConfigForm.btnOKClick(Sender: TObject);
begin
SaveSettings;
if not FToolBarShow then ShowMessage(Format(rsWarning,[sMenuView,rsEditorToolbar]));
end;
procedure TEdtTbConfigForm.SetupCaptions;
@ -251,7 +288,6 @@ begin
lblMenuTree.Caption := rsMenuTree;
lblToolbar.Caption := rsToolbar;
lblpos.Caption := rsPosition;
cbVisible.Caption := rsVisible;
sLocalizedPosValues[0] := rsTop;
sLocalizedPosValues[1] := rsBottom;
sLocalizedPosValues[2] := rsRight;
@ -260,6 +296,26 @@ begin
begin
cbPos.Items[i] := sLocalizedPosValues[i]; // localized
end;
{$IFDEF DebugOptions}
btnExpert.Show;
btnExpand.Show;
if FExpandAll then btnExpand.Caption:= 'Collapse'
else btnExpand.Caption:= 'Expand';
if FExpert then begin
btnExpert.Caption:= 'Normal';
btnSections.Hide;
btnCompress.Hide;
end
else begin
btnExpert.Caption:= 'Expert';
btnSections.Show;
btnCompress.Show;
end;
if FCompressSections then btnCompress.Color:= clRed
else btnCompress.Color:= clBtnFace;
if FShowSections then btnSections.Color:= clRed
else btnSections.Color:= clBtnFace;
{$ENDIF}
end;
procedure TEdtTbConfigForm.LoadCategories;
@ -270,10 +326,11 @@ begin
try
TV.Items.Clear;
for i := 0 to IDEMenuRoots.Count-1 do
AddMenuItem(nil, IDEMenuRoots[i]);
AddMenuItem(nil, IDEMenuRoots[i],0);
finally
TV.Items.EndUpdate;
end;
if FExpandAll then TV.FullExpand;
end;
procedure TEdtTbConfigForm.LoadSettings;
@ -283,22 +340,18 @@ 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
value := 'IDEMainMenu/Search/itmJumpings/itmJumpBack';
mi := IDEMenuRoots.FindByPath(value, false);
ms := itmJumpings;
mi := ms.FindByName('itmJumpBack');
AddToolBarItem(mi);
{if Assigned(mi) then
lbToolbar.Items.AddObject(mi.Caption, TObject(mi));}
value := 'IDEMainMenu/Search/itmJumpings/itmJumpForward';
mi := IDEMenuRoots.FindByPath(value, false);
mi := ms.FindByName('itmJumpForward');
AddToolBarItem(mi);
{if Assigned(mi) then
lbToolbar.Items.AddObject(mi.Caption, TObject(mi));}
end
else begin
for i := 0 to c - 1 do
@ -314,20 +367,36 @@ begin
mi := IDEMenuRoots.FindByPath(value, false);
AddToolBarItem(mi);
{if Assigned(mi) then
lbToolbar.Items.AddObject(mi.Caption, TObject(mi));}
end;
end;
end;
value := cfg.GetValue('Position','Top');
FToolbarPos:= value;
FToolBarShow:= cfg.GetValue('Visible',true);
FToolbarPos := value;
FToolBarShow := cfg.GetValue('Visible',true);
FExpert := cfg.GetValue('Options/Expert',false);
FExpandAll := cfg.GetValue('Options/Expand',false);
FShowSections := cfg.GetValue('Options/Sections',false);
FCompressSections := cfg.GetValue('Options/Compress',true);
finally
cfg.Free;
end;
i := IndexFromEnglish(FToolBarPos);
cbPos.Text:= sLocalizedPosValues[i];
cbVisible.Checked:= FToolBarShow;
end;
procedure TEdtTbConfigForm.LoadStyleSettings;
var
cfg: TConfigStorage;
begin
cfg := GetIDEConfigStorage(cSettingsFile, True);
try
FExpert := cfg.GetValue('Options/Expert',false);
FExpandAll := cfg.GetValue('Options/Expand',false);
FShowSections := cfg.GetValue('Options/Sections',false);
FCompressSections := cfg.GetValue('Options/Compress',true);
finally
cfg.Free;
end;
end;
procedure TEdtTbConfigForm.SaveSettings;
@ -347,40 +416,87 @@ begin
end;
cfg.SetValue('Position', FToolbarPos);
cfg.SetValue('Visible',FToolBarShow);
cfg.SetValue('Options/Expert',FExpert);
cfg.SetValue('Options/Expand',FExpandAll);
cfg.SetValue('Options/Sections',FShowSections);
cfg.SetValue('Options/Compress',FCompressSections);
cfg.WriteToDisk;
finally
cfg.Free;
end;
end;
procedure TEdtTbConfigForm.AddMenuItem(ParentNode: TTreeNode; Item: TIDEMenuItem);
procedure TEdtTbConfigForm.AddMenuItem(ParentNode: TTreeNode; Item: TIDEMenuItem; Level: Integer);
var
n: TTreeNode;
i: integer;
sec: TIDEMenuSection;
ACaption: string;
hasCaption: boolean;
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;
if Item.Name <> Item.Caption then hasCaption:= true
else hasCaption:= false;
sec := (Item as TIDEMenuSection);
for i := 0 to sec.Count-1 do
AddMenuItem(n, sec.Items[i]);
if sec.Count > 0 then begin // skip empty sections
if FExpert or (Level= 0) {or (FShowSections)} then ACaption:= RootNodeCaption(Item)
else begin
if hasCaption then ACaption:= Item.Caption
else ACaption:= '---';
end;
DeleteAmpersands(ACaption);
if FCompressSections and (Level > 0) and ( not hasCaption) then begin
if FShowSections then TV.Items.AddChild(ParentNode, Format('%s', [ACaption]));
n:= ParentNode
end
else begin
n := TV.Items.AddChild(ParentNode, Format('%s', [ACaption]));
n.ImageIndex := Item.ImageIndex;
n.SelectedIndex := Item.ImageIndex;
end;
for i := 0 to sec.Count-1 do
AddMenuItem(n, sec.Items[i],Level+1);
end;
end
else
else begin
ACaption:= Item.Caption;
DeleteAmpersands(ACaption);
n := TV.Items.AddChild(ParentNode, Format('%s', [ACaption]));
n.ImageIndex := Item.ImageIndex;
n.SelectedIndex := Item.ImageIndex;
n.Data := Item;
end;
end;
function TEdtTbConfigForm.RootNodeCaption(Item: TIDEMenuItem): string;
var
AName: string;
begin
AName:= Item.Caption;
case AName of
'IDEMainMenu': Result := rsIDEMainMenu; // mnuMain
'SourceTab': Result := rsSourceTab; // SourceTabMenuRootName
'SourceEditor': Result := rsSourceEditor; // SourceEditorMenuRootName
'Messages': Result := rsMessages; // MessagesMenuRootName
'Code Explorer': Result := rsCodeExplorer; // CodeExplorerMenuRootName
'CodeTemplates': Result := rsCodeTemplates; // CodeTemplatesMenuRootName
'Designer': Result := rsDesigner; // DesignerMenuRootName
'PackageEditor': Result := rsPackageEditor; // PackageEditorMenuRootName
'PackageEditorFiles': Result := rsPackageEditorFiles // PackageEditorMenuFilesRootName
else Result := Item.Caption;
end;
end;
procedure TEdtTbConfigForm.AddToolBarItem(Item: TIDEMenuItem);
Var
n: TTreeNode;
ACaption: string;
begin
if Assigned(Item) then begin
lbToolbar.Items.AddObject(Item.Caption, TObject(Item));
ACaption:= Item.Caption;
DeleteAmpersands(ACaption);
lbToolbar.Items.AddObject(ACaption, TObject(Item));
n:= TV.Items.FindNodeWithData(Item);
n.Visible:= False;
end;

View File

@ -697,7 +697,7 @@ begin
CreateMenuSeparatorSection(mnuSearch,itmBookmarks,'itmBookmarks');
ParentMI:=itmBookmarks;
CreateMenuItem(ParentMI,itmSetFreeBookmark,'itmSetFreeBookmark',lisMenuSetFreeBookmark);
CreateMenuItem(ParentMI,itmSetFreeBookmark,'itmSetFreeBookmark',lisMenuSetFreeBookmark, 'menu_search_set_bookmark');
CreateMenuItem(ParentMI,itmJumpToNextBookmark,'itmJumpToNextBookmark',lisMenuJumpToNextBookmark, 'menu_search_next_bookmark');
CreateMenuItem(ParentMI,itmJumpToPrevBookmark,'itmJumpToPrevBookmark',lisMenuJumpToPrevBookmark, 'menu_search_previous_bookmark');

Binary file not shown.

View File

@ -86,6 +86,7 @@ menu/menu_search_jumpforward.png
menu/menu_search_next_bookmark.png
menu/menu_search_openfile_atcursor.png
menu/menu_search_previous_bookmark.png
menu/menu_search_set_bookmark.png
menu/menu_search_replace.png
menu/menu_select_all.png
menu/menu_stepinto.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 B

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 565 B

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B