mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 02:39:23 +02:00
ideintf: redo collection editor form to use actions + shortcuts
git-svn-id: trunk@24948 -
This commit is contained in:
parent
84f083d83e
commit
f766d27054
@ -1,11 +1,10 @@
|
|||||||
object CollectionPropertyEditorForm: TCollectionPropertyEditorForm
|
object CollectionPropertyEditorForm: TCollectionPropertyEditorForm
|
||||||
Left = 176
|
Left = 742
|
||||||
Height = 300
|
Height = 300
|
||||||
Top = 232
|
Top = 232
|
||||||
Width = 190
|
Width = 190
|
||||||
HorzScrollBar.Page = 189
|
HorzScrollBar.Page = 189
|
||||||
VertScrollBar.Page = 299
|
VertScrollBar.Page = 299
|
||||||
ActiveControl = CollectionListBox
|
|
||||||
BorderStyle = bsSizeToolWin
|
BorderStyle = bsSizeToolWin
|
||||||
Caption = 'CollectionPropertyEditorForm'
|
Caption = 'CollectionPropertyEditorForm'
|
||||||
ClientHeight = 300
|
ClientHeight = 300
|
||||||
@ -30,33 +29,37 @@ object CollectionPropertyEditorForm: TCollectionPropertyEditorForm
|
|||||||
object AddButton: TToolButton
|
object AddButton: TToolButton
|
||||||
Left = 1
|
Left = 1
|
||||||
Top = 2
|
Top = 2
|
||||||
Caption = 'Add'
|
Action = actAdd
|
||||||
OnClick = AddButtonClick
|
ParentShowHint = False
|
||||||
|
ShowHint = True
|
||||||
end
|
end
|
||||||
object DeleteButton: TToolButton
|
object DeleteButton: TToolButton
|
||||||
Left = 45
|
Left = 45
|
||||||
Top = 2
|
Top = 2
|
||||||
Caption = 'Delete'
|
Action = actDel
|
||||||
OnClick = DeleteButtonClick
|
ParentShowHint = False
|
||||||
|
ShowHint = True
|
||||||
end
|
end
|
||||||
object ToolButton3: TToolButton
|
object ToolButton3: TToolButton
|
||||||
Left = 89
|
Left = 89
|
||||||
Top = 2
|
Top = 2
|
||||||
Width = 3
|
Width = 4
|
||||||
Caption = 'ToolButton3'
|
Caption = 'ToolButton3'
|
||||||
Style = tbsDivider
|
Style = tbsDivider
|
||||||
end
|
end
|
||||||
object MoveUpButton: TToolButton
|
object MoveUpButton: TToolButton
|
||||||
Left = 92
|
Left = 93
|
||||||
Top = 2
|
Top = 2
|
||||||
Caption = 'Up'
|
Action = actMoveUp
|
||||||
OnClick = MoveUpButtonClick
|
ParentShowHint = False
|
||||||
|
ShowHint = True
|
||||||
end
|
end
|
||||||
object MoveDownButton: TToolButton
|
object MoveDownButton: TToolButton
|
||||||
Left = 136
|
Left = 137
|
||||||
Top = 2
|
Top = 2
|
||||||
Caption = 'Down'
|
Action = actMoveDown
|
||||||
OnClick = MoveDownButtonClick
|
ParentShowHint = False
|
||||||
|
ShowHint = True
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object CollectionListBox: TListBox
|
object CollectionListBox: TListBox
|
||||||
@ -69,4 +72,26 @@ object CollectionPropertyEditorForm: TCollectionPropertyEditorForm
|
|||||||
OnClick = CollectionListBoxClick
|
OnClick = CollectionListBoxClick
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
|
object ActionList1: TActionList
|
||||||
|
left = 61
|
||||||
|
top = 109
|
||||||
|
object actAdd: TAction
|
||||||
|
Caption = 'Add'
|
||||||
|
OnExecute = actAddExecute
|
||||||
|
ShortCut = 45
|
||||||
|
end
|
||||||
|
object actDel: TAction
|
||||||
|
Caption = 'Del'
|
||||||
|
OnExecute = actDelExecute
|
||||||
|
ShortCut = 46
|
||||||
|
end
|
||||||
|
object actMoveUp: TAction
|
||||||
|
Caption = 'Up'
|
||||||
|
OnExecute = actMoveUpExecute
|
||||||
|
end
|
||||||
|
object actMoveDown: TAction
|
||||||
|
Caption = 'Down'
|
||||||
|
OnExecute = actMoveDownExecute
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,12 +5,17 @@ unit CollectionPropEditForm;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Forms, ComCtrls, StdCtrls;
|
Classes, SysUtils, Forms, ComCtrls, StdCtrls, ActnList, LCLType;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TCollectionPropertyEditorForm }
|
{ TCollectionPropertyEditorForm }
|
||||||
|
|
||||||
TCollectionPropertyEditorForm = class(TForm)
|
TCollectionPropertyEditorForm = class(TForm)
|
||||||
|
actAdd: TAction;
|
||||||
|
actDel: TAction;
|
||||||
|
actMoveUp: TAction;
|
||||||
|
actMoveDown: TAction;
|
||||||
|
ActionList1: TActionList;
|
||||||
CollectionListBox: TListBox;
|
CollectionListBox: TListBox;
|
||||||
ToolBar1: TToolBar;
|
ToolBar1: TToolBar;
|
||||||
AddButton: TToolButton;
|
AddButton: TToolButton;
|
||||||
@ -18,13 +23,13 @@ type
|
|||||||
ToolButton3: TToolButton;
|
ToolButton3: TToolButton;
|
||||||
MoveUpButton: TToolButton;
|
MoveUpButton: TToolButton;
|
||||||
MoveDownButton: TToolButton;
|
MoveDownButton: TToolButton;
|
||||||
procedure AddButtonClick(Sender: TObject);
|
procedure actAddExecute(Sender: TObject);
|
||||||
|
procedure actDelExecute(Sender: TObject);
|
||||||
|
procedure actMoveDownExecute(Sender: TObject);
|
||||||
|
procedure actMoveUpExecute(Sender: TObject);
|
||||||
procedure CollectionListBoxClick(Sender: TObject);
|
procedure CollectionListBoxClick(Sender: TObject);
|
||||||
procedure DeleteButtonClick(Sender: TObject);
|
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure MoveDownButtonClick(Sender: TObject);
|
|
||||||
procedure MoveUpButtonClick(Sender: TObject);
|
|
||||||
private
|
private
|
||||||
FCollection: TCollection;
|
FCollection: TCollection;
|
||||||
FOwnerPersistent: TPersistent;
|
FOwnerPersistent: TPersistent;
|
||||||
@ -57,14 +62,21 @@ uses
|
|||||||
procedure TCollectionPropertyEditorForm.FormCreate(Sender: TObject);
|
procedure TCollectionPropertyEditorForm.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
ToolBar1.Images := IDEImages.Images_16;
|
ToolBar1.Images := IDEImages.Images_16;
|
||||||
AddButton.Caption := oiColEditAdd;
|
actAdd.Caption := oiColEditAdd;
|
||||||
DeleteButton.Caption := oiColEditDelete;
|
actDel.Caption := oiColEditDelete;
|
||||||
MoveUpButton.Caption := oiColEditUp;
|
actMoveUp.Caption := oiColEditUp;
|
||||||
MoveDownButton.Caption := oiColEditDown;
|
actMoveDown.Caption := oiColEditDown;
|
||||||
AddButton.ImageIndex := IDEImages.LoadImage(16, 'laz_add');
|
actAdd.ImageIndex := IDEImages.LoadImage(16, 'laz_add');
|
||||||
DeleteButton.ImageIndex := IDEImages.LoadImage(16, 'laz_delete');
|
actDel.ImageIndex := IDEImages.LoadImage(16, 'laz_delete');
|
||||||
MoveUpButton.ImageIndex := IDEImages.LoadImage(16, 'arrow_up');
|
actMoveUp.ImageIndex := IDEImages.LoadImage(16, 'arrow_up');
|
||||||
MoveDownButton.ImageIndex := IDEImages.LoadImage(16, 'arrow_down');
|
actMoveDown.ImageIndex := IDEImages.LoadImage(16, 'arrow_down');
|
||||||
|
actMoveUp.ShortCut := scCtrl or VK_UP;
|
||||||
|
actMoveDown.ShortCut := scCtrl or VK_DOWN;
|
||||||
|
|
||||||
|
actAdd.Hint := oiColEditAdd;
|
||||||
|
actDel.Hint := oiColEditDelete;
|
||||||
|
actMoveUp.Hint := oiColEditUp;
|
||||||
|
actMoveDown.Hint := oiColEditDown;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.FormDestroy(Sender: TObject);
|
procedure TCollectionPropertyEditorForm.FormDestroy(Sender: TObject);
|
||||||
@ -73,41 +85,14 @@ begin
|
|||||||
GlobalDesignHook.RemoveAllHandlersForObject(Self);
|
GlobalDesignHook.RemoveAllHandlersForObject(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.MoveDownButtonClick(Sender: TObject);
|
procedure TCollectionPropertyEditorForm.CollectionListBoxClick(Sender: TObject);
|
||||||
var
|
|
||||||
I: Integer;
|
|
||||||
begin
|
begin
|
||||||
if Collection = nil then Exit;
|
UpdateButtons;
|
||||||
|
UpdateCaption;
|
||||||
I := CollectionListBox.ItemIndex;
|
SelectInObjectInspector(False, False);
|
||||||
if I >= Collection.Count - 1 then Exit;
|
|
||||||
|
|
||||||
Collection.Items[I].Index := I + 1;
|
|
||||||
CollectionListBox.ItemIndex := I + 1;
|
|
||||||
|
|
||||||
FillCollectionListBox;
|
|
||||||
SelectInObjectInspector(True, False);
|
|
||||||
Modified;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.MoveUpButtonClick(Sender: TObject);
|
procedure TCollectionPropertyEditorForm.actAddExecute(Sender: TObject);
|
||||||
var
|
|
||||||
I: Integer;
|
|
||||||
begin
|
|
||||||
if Collection = nil then Exit;
|
|
||||||
|
|
||||||
I := CollectionListBox.ItemIndex;
|
|
||||||
if I < 0 then Exit;
|
|
||||||
|
|
||||||
Collection.Items[I].Index := I - 1;
|
|
||||||
CollectionListBox.ItemIndex := I - 1;
|
|
||||||
|
|
||||||
FillCollectionListBox;
|
|
||||||
SelectInObjectInspector(True, False);
|
|
||||||
Modified;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.AddButtonClick(Sender: TObject);
|
|
||||||
begin
|
begin
|
||||||
if Collection = nil then Exit;
|
if Collection = nil then Exit;
|
||||||
Collection.Add;
|
Collection.Add;
|
||||||
@ -121,14 +106,7 @@ begin
|
|||||||
Modified;
|
Modified;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.CollectionListBoxClick(Sender: TObject);
|
procedure TCollectionPropertyEditorForm.actDelExecute(Sender: TObject);
|
||||||
begin
|
|
||||||
UpdateButtons;
|
|
||||||
UpdateCaption;
|
|
||||||
SelectInObjectInspector(False, False);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.DeleteButtonClick(Sender: TObject);
|
|
||||||
var
|
var
|
||||||
I : Integer;
|
I : Integer;
|
||||||
NewItemIndex: Integer;
|
NewItemIndex: Integer;
|
||||||
@ -180,6 +158,40 @@ begin
|
|||||||
UpdateCaption;
|
UpdateCaption;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCollectionPropertyEditorForm.actMoveDownExecute(Sender: TObject);
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
if Collection = nil then Exit;
|
||||||
|
|
||||||
|
I := CollectionListBox.ItemIndex;
|
||||||
|
if I >= Collection.Count - 1 then Exit;
|
||||||
|
|
||||||
|
Collection.Items[I].Index := I + 1;
|
||||||
|
CollectionListBox.ItemIndex := I + 1;
|
||||||
|
|
||||||
|
FillCollectionListBox;
|
||||||
|
SelectInObjectInspector(True, False);
|
||||||
|
Modified;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCollectionPropertyEditorForm.actMoveUpExecute(Sender: TObject);
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
if Collection = nil then Exit;
|
||||||
|
|
||||||
|
I := CollectionListBox.ItemIndex;
|
||||||
|
if I < 0 then Exit;
|
||||||
|
|
||||||
|
Collection.Items[I].Index := I - 1;
|
||||||
|
CollectionListBox.ItemIndex := I - 1;
|
||||||
|
|
||||||
|
FillCollectionListBox;
|
||||||
|
SelectInObjectInspector(True, False);
|
||||||
|
Modified;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.UpdateCaption;
|
procedure TCollectionPropertyEditorForm.UpdateCaption;
|
||||||
var
|
var
|
||||||
NewCaption: String;
|
NewCaption: String;
|
||||||
@ -207,10 +219,10 @@ var
|
|||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
I := CollectionListBox.ItemIndex;
|
I := CollectionListBox.ItemIndex;
|
||||||
AddButton.Enabled := Collection <> nil;
|
actAdd.Enabled := Collection <> nil;
|
||||||
DeleteButton.Enabled := I > -1;
|
actDel.Enabled := I > -1;
|
||||||
MoveUpButton.Enabled := I > 0;
|
actMoveUp.Enabled := I > 0;
|
||||||
MoveDownButton.Enabled := (I >= 0) and (I < Collection.Count - 1);
|
actMoveDown.Enabled := (I >= 0) and (I < Collection.Count - 1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.ComponentRenamed(AComponent: TComponent);
|
procedure TCollectionPropertyEditorForm.ComponentRenamed(AComponent: TComponent);
|
||||||
|
Loading…
Reference in New Issue
Block a user