TAChart: Use toolbar instead of menu in subcomponent editor to improve interface in Macs

git-svn-id: trunk@26963 -
This commit is contained in:
ask 2010-08-01 11:17:33 +00:00
parent be52fd6bf5
commit c7b5612c6c
2 changed files with 85 additions and 54 deletions

View File

@ -4,17 +4,17 @@ object ComponentListEditorForm: TComponentListEditorForm
Top = 283
Width = 320
Caption = 'ComponentListEditorForm'
ClientHeight = 221
ClientHeight = 240
ClientWidth = 320
Menu = MainMenu1
OnClose = FormClose
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poScreenCenter
LCLVersion = '0.9.29'
object ChildrenListBox: TListBox
Left = 0
Height = 221
Top = 0
Height = 198
Top = 42
Width = 320
Align = alClient
ItemHeight = 0
@ -22,23 +22,43 @@ object ComponentListEditorForm: TComponentListEditorForm
OnClick = ChildrenListBoxClick
TabOrder = 0
end
object MainMenu1: TMainMenu
left = 88
top = 160
object miAdd: TMenuItem
object tbCommands: TToolBar
Left = 0
Height = 42
Top = 0
Width = 320
AutoSize = True
ButtonHeight = 40
ButtonWidth = 44
ShowCaptions = True
TabOrder = 1
object tbAdd: TToolButton
Left = 1
Top = 2
Caption = 'Add'
DropdownMenu = menuAddItem
end
object miDelete: TMenuItem
object tbDelete: TToolButton
Left = 45
Top = 2
Caption = 'Delete'
OnClick = miDeleteClick
OnClick = tbDeleteClick
end
object miMoveUp: TMenuItem
Caption = 'Move up'
OnClick = miMoveUpClick
object tbMoveUp: TToolButton
Left = 89
Top = 2
Caption = 'Up'
OnClick = tbMoveUpClick
end
object miMoveDown: TMenuItem
Caption = 'Move down'
OnClick = miMoveDownClick
object tbMoveDown: TToolButton
Left = 133
Top = 2
Caption = 'Down'
OnClick = tbMoveDownClick
end
end
object menuAddItem: TPopupMenu
left = 88
top = 96
end
end

View File

@ -20,7 +20,7 @@ unit TASubcomponentsEditor;
interface
uses
Classes, ComponentEditors, Forms, Menus, PropEdits, StdCtrls;
Classes, ComCtrls, ComponentEditors, Forms, Menus, PropEdits, StdCtrls;
type
@ -56,18 +56,20 @@ type
TComponentListEditorForm = class(TForm)
ChildrenListBox: TListBox;
MainMenu1: TMainMenu;
miMoveUp: TMenuItem;
miMoveDown: TMenuItem;
miAdd: TMenuItem;
miDelete: TMenuItem;
menuAddItem: TPopupMenu;
tbCommands: TToolBar;
tbAdd: TToolButton;
tbDelete: TToolButton;
tbMoveUp: TToolButton;
tbMoveDown: TToolButton;
procedure ChildrenListBoxClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure miAddClick(Sender: TObject);
procedure miDeleteClick(Sender: TObject);
procedure miMoveDownClick(Sender: TObject);
procedure miMoveUpClick(Sender: TObject);
procedure tbDeleteClick(Sender: TObject);
procedure tbMoveDownClick(Sender: TObject);
procedure tbMoveUpClick(Sender: TObject);
private
FComponentEditor: TSubComponentListEditor;
FDesigner: TComponentEditorDesigner;
@ -101,7 +103,7 @@ type
implementation
uses
Math, SysUtils, TAChartUtils;
IDEImagesIntf, Math, SysUtils, TAChartUtils;
{$R *.lfm}
@ -173,7 +175,7 @@ begin
mi.OnClick := @miAddClick;
mi.Caption := ACaption;
mi.Tag := ATag;
miAdd.Add(mi);
menuAddItem.Items.Add(mi);
end;
procedure TComponentListEditorForm.ChildrenListBoxClick(Sender: TObject);
@ -223,6 +225,15 @@ begin
CloseAction := caFree;
end;
procedure TComponentListEditorForm.FormCreate(Sender: TObject);
begin
tbCommands.Images := IDEImages.Images_16;
tbAdd.ImageIndex := IDEImages.LoadImage(16, 'laz_add');
tbDelete.ImageIndex := IDEImages.LoadImage(16, 'laz_delete');
tbMoveDown.ImageIndex := IDEImages.LoadImage(16, 'arrow_down');
tbMoveUp.ImageIndex := IDEImages.LoadImage(16, 'arrow_up');
end;
procedure TComponentListEditorForm.FormDestroy(Sender: TObject);
begin
if FComponentEditor <> nil then begin
@ -258,33 +269,6 @@ begin
end;
end;
procedure TComponentListEditorForm.miDeleteClick(Sender: TObject);
var
i: Integer;
s: TComponent;
begin
if ChildrenListBox.SelCount = 0 then exit;
for i := ChildrenListBox.Items.Count - 1 downto 0 do
if ChildrenListBox.Selected[i] then begin
s := TComponent(ChildrenListBox.Items.Objects[i]);
ChildrenListBox.Items.Delete(i);
FDesigner.PropertyEditorHook.PersistentDeleting(s);
s.Free;
end;
FDesigner.Modified;
SelectionChanged;
end;
procedure TComponentListEditorForm.miMoveDownClick(Sender: TObject);
begin
MoveSelection(ChildrenListBox.Count - 1, 1);
end;
procedure TComponentListEditorForm.miMoveUpClick(Sender: TObject);
begin
MoveSelection(0, -1);
end;
procedure TComponentListEditorForm.MoveSelection(AStart, ADir: Integer);
var
i: Integer;
@ -399,5 +383,32 @@ begin
end;
end;
procedure TComponentListEditorForm.tbDeleteClick(Sender: TObject);
var
i: Integer;
s: TComponent;
begin
if ChildrenListBox.SelCount = 0 then exit;
for i := ChildrenListBox.Items.Count - 1 downto 0 do
if ChildrenListBox.Selected[i] then begin
s := TComponent(ChildrenListBox.Items.Objects[i]);
ChildrenListBox.Items.Delete(i);
FDesigner.PropertyEditorHook.PersistentDeleting(s);
s.Free;
end;
FDesigner.Modified;
SelectionChanged;
end;
procedure TComponentListEditorForm.tbMoveDownClick(Sender: TObject);
begin
MoveSelection(ChildrenListBox.Count - 1, 1);
end;
procedure TComponentListEditorForm.tbMoveUpClick(Sender: TObject);
begin
MoveSelection(0, -1);
end;
end.