mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-16 05:00:46 +01:00
Improve component EditorToolbar. Use TreeFilterEdit to filter the menuitem tree
git-svn-id: trunk@34664 -
This commit is contained in:
parent
6066424d39
commit
97cf2bf30c
@ -1,13 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<Package Version="3">
|
||||
<Package Version="4">
|
||||
<Name Value="editortoolbar"/>
|
||||
<AddToProjectUsesSection Value="True"/>
|
||||
<Author Value="Graeme Geldenhuys"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<Version Value="11"/>
|
||||
<SearchPaths>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
@ -41,20 +47,23 @@
|
||||
<OutDir Value="languages"/>
|
||||
</i18n>
|
||||
<Type Value="DesignTime"/>
|
||||
<RequiredPkgs Count="4">
|
||||
<RequiredPkgs Count="5">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
<PackageName Value="LazControls"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="FCL"/>
|
||||
<MinVersion Major="1" Valid="True"/>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<PackageName Value="CodeTools"/>
|
||||
<PackageName Value="FCL"/>
|
||||
<MinVersion Major="1" Valid="True"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
<PackageName Value="CodeTools"/>
|
||||
</Item5>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)/"/>
|
||||
|
||||
@ -14,9 +14,13 @@ resourcestring
|
||||
rsEditorToolbarConfigForm = 'Editor Toolbar Configuration';
|
||||
rsOK = 'OK';
|
||||
rsCancel = 'Cancel';
|
||||
rsToolbar = 'Toolbar';
|
||||
rsMenuTree = 'Menu Tree';
|
||||
rsToolbar = 'Toolbar Items';
|
||||
rsMenuTree = 'Available Menu Items';
|
||||
rsAddDivider = 'Add Divider';
|
||||
rsAddSelected = 'Add selected item to toolbar';
|
||||
rsRemoveSelected = 'Remove selected item from toolbar';
|
||||
rsMoveSelectedUp = 'Move selected toolbar item up';
|
||||
rsMoveSelectedDown = 'Move selected toolbar item down';
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -1,70 +1,96 @@
|
||||
object EdtTbConfigForm: TEdtTbConfigForm
|
||||
Left = 375
|
||||
Height = 330
|
||||
Height = 437
|
||||
Top = 200
|
||||
Width = 651
|
||||
ActiveControl = btnOK
|
||||
Caption = 'EdtTbConfigForm'
|
||||
ClientHeight = 330
|
||||
ClientHeight = 437
|
||||
ClientWidth = 651
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '0.9.27'
|
||||
LCLVersion = '0.9.31'
|
||||
object lblMenuTree: TLabel
|
||||
Left = 16
|
||||
Height = 18
|
||||
Height = 15
|
||||
Top = 10
|
||||
Width = 76
|
||||
Width = 69
|
||||
Caption = 'lblMenuTree'
|
||||
ParentColor = False
|
||||
end
|
||||
object lblToolbar: TLabel
|
||||
AnchorSideLeft.Control = btnAdd
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 456
|
||||
Height = 18
|
||||
Height = 15
|
||||
Top = 10
|
||||
Width = 60
|
||||
Width = 55
|
||||
BorderSpacing.Left = 13
|
||||
Caption = 'lblToolbar'
|
||||
ParentColor = False
|
||||
end
|
||||
object btnRemove: TSpeedButton
|
||||
Left = 432
|
||||
AnchorSideLeft.Control = btnAdd
|
||||
AnchorSideTop.Control = btnAdd
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 421
|
||||
Height = 26
|
||||
Top = 101
|
||||
Width = 22
|
||||
BorderSpacing.Top = 1
|
||||
Enabled = False
|
||||
NumGlyphs = 0
|
||||
OnClick = btnRemoveClick
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
end
|
||||
object btnAdd: TSpeedButton
|
||||
AnchorSideLeft.Control = TV
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 421
|
||||
Height = 26
|
||||
Top = 74
|
||||
Width = 22
|
||||
Color = clBtnFace
|
||||
NumGlyphs = 0
|
||||
OnClick = btnRemoveClick
|
||||
end
|
||||
object btnAdd: TSpeedButton
|
||||
Left = 432
|
||||
Height = 26
|
||||
Top = 99
|
||||
Width = 22
|
||||
Color = clBtnFace
|
||||
Anchors = [akLeft]
|
||||
BorderSpacing.Left = 13
|
||||
BorderSpacing.Top = 1
|
||||
Enabled = False
|
||||
NumGlyphs = 0
|
||||
OnClick = btnAddClick
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
end
|
||||
object btnMoveUp: TSpeedButton
|
||||
Left = 432
|
||||
AnchorSideLeft.Control = btnRemove
|
||||
Left = 421
|
||||
Height = 26
|
||||
Top = 157
|
||||
Width = 22
|
||||
Color = clBtnFace
|
||||
Enabled = False
|
||||
NumGlyphs = 0
|
||||
OnClick = btnMoveUpClick
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
end
|
||||
object btnMoveDown: TSpeedButton
|
||||
Left = 432
|
||||
AnchorSideLeft.Control = btnMoveUp
|
||||
AnchorSideTop.Control = btnMoveUp
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 421
|
||||
Height = 26
|
||||
Top = 182
|
||||
Top = 184
|
||||
Width = 22
|
||||
Color = clBtnFace
|
||||
BorderSpacing.Top = 1
|
||||
Enabled = False
|
||||
NumGlyphs = 0
|
||||
OnClick = btnMoveDownClick
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
end
|
||||
object pnlButtons: TPanel
|
||||
Left = 0
|
||||
Height = 42
|
||||
Top = 288
|
||||
Top = 395
|
||||
Width = 651
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
@ -72,7 +98,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
ClientWidth = 651
|
||||
Color = clGreen
|
||||
ParentColor = False
|
||||
TabOrder = 0
|
||||
TabOrder = 4
|
||||
object Bevel1: TBevel
|
||||
Left = 0
|
||||
Height = 2
|
||||
@ -84,7 +110,7 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideRight.Control = btnCancel
|
||||
AnchorSideBottom.Control = pnlButtons
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 480
|
||||
Left = 488
|
||||
Height = 25
|
||||
Top = 11
|
||||
Width = 75
|
||||
@ -106,10 +132,10 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = pnlButtons
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 561
|
||||
Left = 569
|
||||
Height = 25
|
||||
Top = 11
|
||||
Width = 84
|
||||
Width = 76
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 6
|
||||
@ -125,39 +151,68 @@ object EdtTbConfigForm: TEdtTbConfigForm
|
||||
end
|
||||
end
|
||||
object btnAddDivider: TButton
|
||||
Left = 497
|
||||
AnchorSideBottom.Control = pnlButtons
|
||||
Left = 504
|
||||
Height = 25
|
||||
Top = 256
|
||||
Width = 110
|
||||
Top = 364
|
||||
Width = 96
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'btnAddDivider'
|
||||
Constraints.MaxHeight = 25
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 75
|
||||
OnClick = btnAddDividerClick
|
||||
TabOrder = 1
|
||||
TabOrder = 3
|
||||
end
|
||||
object lbToolbar: TListBox
|
||||
AnchorSideLeft.Control = lblToolbar
|
||||
AnchorSideTop.Control = TV
|
||||
AnchorSideBottom.Control = btnAddDivider
|
||||
Left = 456
|
||||
Height = 225
|
||||
Top = 28
|
||||
Height = 301
|
||||
Top = 57
|
||||
Width = 183
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Bottom = 6
|
||||
ItemHeight = 0
|
||||
OnSelectionChange = lbToolbarSelectionChange
|
||||
TabOrder = 2
|
||||
TopIndex = -1
|
||||
end
|
||||
object TV: TTreeView
|
||||
AnchorSideLeft.Control = lblMenuTree
|
||||
AnchorSideTop.Control = FilterEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideBottom.Control = pnlButtons
|
||||
Left = 16
|
||||
Height = 253
|
||||
Top = 28
|
||||
Height = 332
|
||||
Top = 57
|
||||
Width = 392
|
||||
DefaultItemHeight = 19
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Bottom = 6
|
||||
DefaultItemHeight = 16
|
||||
ReadOnly = True
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 3
|
||||
OnChange = TVChange
|
||||
TabOrder = 1
|
||||
OnSelectionChanged = TVSelectionChanged
|
||||
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
|
||||
end
|
||||
object FilterEdit: TTreeFilterEdit
|
||||
AnchorSideLeft.Control = lblMenuTree
|
||||
AnchorSideTop.Control = lblMenuTree
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 16
|
||||
Height = 20
|
||||
Top = 31
|
||||
Width = 192
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 0
|
||||
BorderSpacing.Top = 6
|
||||
MaxLength = 0
|
||||
TabOrder = 0
|
||||
FilteredTreeview = TV
|
||||
end
|
||||
end
|
||||
|
||||
@ -24,9 +24,12 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
Buttons, StdCtrls, ComCtrls, MenuIntf, editortoolbar_str;
|
||||
Buttons, StdCtrls, ComCtrls, MenuIntf, editortoolbar_str, TreeFilterEdit;
|
||||
|
||||
type
|
||||
|
||||
{ TEdtTbConfigForm }
|
||||
|
||||
TEdtTbConfigForm = class(TForm)
|
||||
Bevel1: TBevel;
|
||||
btnAdd: TSpeedButton;
|
||||
@ -40,15 +43,17 @@ type
|
||||
lblToolbar: TLabel;
|
||||
lbToolbar: TListBox;
|
||||
pnlButtons: TPanel;
|
||||
FilterEdit: TTreeFilterEdit;
|
||||
TV: TTreeView;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure TVChange(Sender: TObject; Node: TTreeNode);
|
||||
procedure lbToolbarSelectionChange(Sender: TObject; User: boolean);
|
||||
procedure btnAddClick(Sender: TObject);
|
||||
procedure btnAddDividerClick(Sender: TObject);
|
||||
procedure btnMoveDownClick(Sender: TObject);
|
||||
procedure btnMoveUpClick(Sender: TObject);
|
||||
procedure btnOKClick(Sender: TObject);
|
||||
procedure btnRemoveClick(Sender: TObject);
|
||||
procedure TVSelectionChanged(Sender: TObject);
|
||||
private
|
||||
procedure SetupCaptions;
|
||||
procedure LoadCategories;
|
||||
@ -80,25 +85,38 @@ begin
|
||||
pnlButtons.Color := clBtnFace;
|
||||
|
||||
// load button images
|
||||
btnRemove.LoadGlyphFromLazarusResource('arrow_left');
|
||||
btnAdd.LoadGlyphFromLazarusResource('arrow_right');
|
||||
btnRemove.LoadGlyphFromLazarusResource('arrow_left');
|
||||
btnMoveUp.LoadGlyphFromLazarusResource('arrow_up');
|
||||
btnMoveDown.LoadGlyphFromLazarusResource('arrow_down');
|
||||
|
||||
btnAdd.Hint := rsAddSelected;
|
||||
btnRemove.Hint := rsRemoveSelected;
|
||||
btnMoveUp.Hint := rsMoveSelectedUp;
|
||||
btnMoveDown.Hint := rsMoveSelectedDown;
|
||||
|
||||
TV.Images := IDEImages.Images_16;
|
||||
SetupCaptions;
|
||||
LoadCategories;
|
||||
LoadSettings;
|
||||
TV.FullExpand;
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.TVChange(Sender: TObject; Node: TTreeNode);
|
||||
procedure TEdtTbConfigForm.lbToolbarSelectionChange(Sender: TObject; User: boolean);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
i := lbToolbar.ItemIndex;
|
||||
btnRemove.Enabled := i > -1;
|
||||
btnMoveUp.Enabled := i > 0;
|
||||
btnMoveDown.Enabled := (i > -1) and (i < lbToolbar.Items.Count-1);
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.TVSelectionChanged(Sender: TObject);
|
||||
var
|
||||
n: TTreeNode;
|
||||
begin
|
||||
if Sender = nil then ;
|
||||
if Node = nil then ;
|
||||
n := TV.Selected;
|
||||
|
||||
btnAdd.Enabled := (Assigned(n) and Assigned(n.Data));
|
||||
end;
|
||||
|
||||
@ -109,7 +127,19 @@ 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));
|
||||
lbToolbar.ItemIndex := lbToolbar.Items.Count-1;
|
||||
lbToolbarSelectionChange(lblToolbar, False);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.btnRemoveClick(Sender: TObject);
|
||||
begin
|
||||
if lbToolbar.ItemIndex > -1 then begin
|
||||
lbToolbar.Items.Delete(lbToolbar.ItemIndex);
|
||||
lbToolbarSelectionChange(lbToolbar, False);
|
||||
TVSelectionChanged(TV);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -145,12 +175,6 @@ begin
|
||||
SaveSettings;
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.btnRemoveClick(Sender: TObject);
|
||||
begin
|
||||
if lbToolbar.ItemIndex > -1 then
|
||||
lbToolbar.Items.Delete(lbToolbar.ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.SetupCaptions;
|
||||
begin
|
||||
Caption := rsEditorToolbarConfigForm;
|
||||
@ -228,8 +252,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEdtTbConfigForm.AddMenuItem(ParentNode: TTreeNode;
|
||||
Item: TIDEMenuItem);
|
||||
procedure TEdtTbConfigForm.AddMenuItem(ParentNode: TTreeNode; Item: TIDEMenuItem);
|
||||
var
|
||||
n: TTreeNode;
|
||||
i: integer;
|
||||
@ -238,13 +261,14 @@ begin
|
||||
n := TV.Items.AddChild(ParentNode, Format('%s', [Item.Caption]));
|
||||
n.ImageIndex := Item.ImageIndex;
|
||||
n.SelectedIndex := Item.ImageIndex;
|
||||
n.Data := Item;
|
||||
if Item is TIDEMenuSection then
|
||||
begin
|
||||
sec := (Item as TIDEMenuSection);
|
||||
for i := 0 to sec.Count-1 do
|
||||
AddMenuItem(n, sec.Items[i]);
|
||||
end;
|
||||
end
|
||||
else
|
||||
n.Data := Item;
|
||||
end;
|
||||
|
||||
class function TEdtTbConfigForm.Execute: boolean;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user