ideintf: add Z-Order menu section to the component treeview

git-svn-id: trunk@23202 -
This commit is contained in:
paul 2009-12-20 11:08:19 +00:00
parent 40f7e80de6
commit 2ec1f7c029
3 changed files with 69 additions and 6 deletions

View File

@ -519,7 +519,7 @@ begin
DesignerMenuSize:=RegisterIDEMenuCommand(DesignerMenuSectionAlign,
'Size',fdmSizeWord, nil, nil, nil, 'size');
// register tab and order section
// register tab and z-order section
DesignerMenuSectionOrder:=RegisterIDEMenuSection(DesignerMenuRoot,
'Order section');
DesignerMenuTabOrder:=RegisterIDEMenuCommand(DesignerMenuSectionOrder,

View File

@ -686,6 +686,7 @@ type
ABox: TPaintBox; const ARestrictions: TWidgetSetRestrictionsArray);
procedure DoComponentEditorVerbMenuItemClick(Sender: TObject);
procedure DoCollectionAddItem(Sender: TObject);
procedure DoZOrderItemClick(Sender: TObject);
protected
function PersistentToString(APersistent: TPersistent): string;
procedure AddPersistentToList(APersistent: TPersistent; List: TStrings);
@ -4903,6 +4904,8 @@ begin
end;
procedure TObjectInspectorDlg.OnMainPopupMenuPopup(Sender: TObject);
var
EditorVerbSeparator: TMenuItem;
procedure RemoveComponentEditorMenuItems;
var
@ -4929,9 +4932,9 @@ procedure TObjectInspectorDlg.OnMainPopupMenuPopup(Sender: TObject);
// insert the separator
if VerbCount > 0 then
begin
Item := NewLine;
Item.Name := 'ComponentEditorVerbMenuItem' + IntToStr(VerbCount);
MainPopupMenu.Items.Insert(VerbCount, Item);
EditorVerbSeparator := NewLine;
EditorVerbSeparator.Name := 'ComponentEditorVerbMenuItem' + IntToStr(VerbCount);
MainPopupMenu.Items.Insert(VerbCount, EditorVerbSeparator);
end;
end;
@ -4942,9 +4945,39 @@ procedure TObjectInspectorDlg.OnMainPopupMenuPopup(Sender: TObject);
Item := NewItem(oisAddCollectionItem, 0, False, True,
@DoCollectionAddItem, 0, 'ComponentEditorVerbMenuItem0');
MainPopupMenu.Items.Insert(0, Item);
EditorVerbSeparator := NewLine;
EditorVerbSeparator.Name := 'ComponentEditorVerbMenuItem1';
MainPopupMenu.Items.Insert(1, EditorVerbSeparator);
end;
procedure AddZOrderMenuItems;
var
ZItem, Item: TMenuItem;
begin
ZItem := NewSubMenu(oisZOrder, 0, 'ComponentEditorVerbMenuItemZOrder', [], True);
Item := NewItem(oisOrderMoveToFront, 0, True, True, @DoZOrderItemClick, 0, '');
Item.ImageIndex := IDEImages.LoadImage(16, 'Order_move_front');
Item.Tag := 0;
ZItem.Add(Item);
Item := NewItem(oisOrderMoveToBack, 0, True, True, @DoZOrderItemClick, 0, '');
Item.ImageIndex := IDEImages.LoadImage(16, 'Order_move_back');
Item.Tag := 1;
ZItem.Add(Item);
Item := NewItem(oisOrderForwardOne, 0, True, True, @DoZOrderItemClick, 0, '');
Item.ImageIndex := IDEImages.LoadImage(16, 'Order_forward_one');
Item.Tag := 2;
ZItem.Add(Item);
Item := NewItem(oisOrderBackOne, 0, True, True, @DoZOrderItemClick, 0, '');
Item.ImageIndex := IDEImages.LoadImage(16, 'Order_back_one');
Item.Tag := 3;
ZItem.Add(Item);
if EditorVerbSeparator <> nil then
MainPopupMenu.Items.Insert(EditorVerbSeparator.MenuIndex + 1, ZItem)
else
MainPopupMenu.Items.Insert(0, ZItem);
Item := NewLine;
Item.Name := 'ComponentEditorVerbMenuItem1';
MainPopupMenu.Items.Insert(1, Item);
Item.Name := 'ComponentEditorVerbMenuItemZOrderSeparator';
MainPopupMenu.Items.Insert(ZItem.MenuIndex + 1, Item);
end;
var
@ -4957,6 +4990,7 @@ begin
// show component editors only for component treeview
if MainPopupMenu.PopupComponent = ComponentTree then
begin
EditorVerbSeparator := nil;
ComponentEditor := GetComponentEditorForSelection;
if ComponentEditor <> nil then
AddComponentEditorMenuItems
@ -4971,6 +5005,11 @@ begin
AddCollectionEditorMenuItems(TCollectionItem(Persistent).Collection);
end;
// add Z-Order menu
if (Selection.Count = 1) and (Selection[0] is TControl) then
AddZOrderMenuItems;
CutPopupMenuItem.Visible := (Selection.Count > 0) and (Selection[0] is TComponent);
CopyPopupMenuItem.Visible := (Selection.Count > 0) and (Selection[0] is TComponent);
PastePopupMenuItem.Visible := (Selection.Count > 0) and (Selection[0] is TComponent);
@ -5078,6 +5117,25 @@ begin
end;
end;
procedure TObjectInspectorDlg.DoZOrderItemClick(Sender: TObject);
var
Control: TControl;
begin
if not (Sender is TMenuItem) then Exit;
if (Selection.Count <> 1) or
not (Selection[0] is TControl) then Exit;
Control := TControl(Selection[0]);
if Control.Parent = nil then Exit;
case TMenuItem(Sender).Tag of
0: Control.BringToFront;
1: Control.SendToBack;
2: Control.Parent.SetControlIndex(Control, Control.Parent.GetControlIndex(Control) + 1);
3: Control.Parent.SetControlIndex(Control, Control.Parent.GetControlIndex(Control) - 1);
end;
DoModified(Self);
end;
procedure TObjectInspectorDlg.HookRefreshPropertyValues;
begin
RefreshPropertyValues;

View File

@ -59,6 +59,11 @@ resourcestring
//Object Inspector Popup Menu
oisZOrder = 'Z-order';
oisOrderMoveToFront = 'Move to Front';
oisOrderMoveToBack = 'Move to Back';
oisOrderForwardOne = 'Forward One';
oisOrderBackOne = 'Back One';
oisSetToDefault = 'Set to default: %s';
oisSetToDefaultValue = 'Set to default value';
oisAddToFavorites = 'Add to Favorites';