Inheritance: Gtk.EventBox, IMenuItemContainer
コード例 #1
0
ファイル: ActionMenuItem.cs プロジェクト: orf53975/stetic
        public void ShowSubmenu(IDesignArea area, Gtk.Widget refWidget)
        {
            HideSubmenu();
            Gdk.Rectangle rect = area.GetCoordinates(refWidget);
            ActionMenu    menu = new ActionMenu(wrapper, parentMenu, node);

            menu.ShowAll();
            area.AddWidget(menu, rect.Right, rect.Top);
            menu.TrackWidgetPosition(refWidget, parentMenu.IsTopMenu);

            parentMenu.OpenSubmenu = menu;
        }
コード例 #2
0
 void SelectLastItem()
 {
     if (menuItems.Count > 0)
     {
         ((ActionMenuItem)menuItems [menuItems.Count - 1]).Select();
     }
     else if (parentMenu.Widget is ActionMenuBar)
     {
         ActionMenuBar bar = (ActionMenuBar)parentMenu.Widget;
         bar.Select(parentNode);
     }
     else if (parentMenu.Widget is ActionMenu)
     {
         ActionMenu parentAM = (ActionMenu)parentMenu.Widget;
         parentAM.Select(parentNode);
     }
 }
コード例 #3
0
ファイル: ActionMenuItem.cs プロジェクト: Kalnor/monodevelop
		public void ShowSubmenu (IDesignArea area, Gtk.Widget refWidget)
		{
			HideSubmenu ();
			Gdk.Rectangle rect = area.GetCoordinates (refWidget);
			ActionMenu menu = new ActionMenu (wrapper, parentMenu, node);
			menu.ShowAll ();
			area.AddWidget (menu, rect.Right, rect.Top);
			menu.TrackWidgetPosition (refWidget, parentMenu.IsTopMenu);
			
			parentMenu.OpenSubmenu = menu;
		}
コード例 #4
0
		void ProcessKey (ActionMenuItem item, Gdk.Key key, Gdk.ModifierType modifier)
		{
			int pos = menuItems.IndexOf (item);
			
			switch (key) {
				case Gdk.Key.Up:
					if (pos > 0)
						((ActionMenuItem)menuItems[pos - 1]).Select ();
					else if (parentMenu.Widget is ActionMenuBar) {
						ActionMenuBar bar = (ActionMenuBar) parentMenu.Widget;
						bar.Select (parentNode);
					}
					break;
				case Gdk.Key.Down:
					if (pos < menuItems.Count - 1)
						((ActionMenuItem)menuItems[pos + 1]).Select ();
					else if (pos == menuItems.Count - 1) {
						InsertAction (menuItems.Count);
					}
					break;
				case Gdk.Key.Right:
					if ((modifier & Gdk.ModifierType.ControlMask) != 0 && item.Node.Type == Gtk.UIManagerItemType.Menuitem) {
						// Create a submenu
						using (item.Node.Action.UndoManager.AtomicChange) {
							item.Node.Type = Gtk.UIManagerItemType.Menu;
						}
						item.Node.Action.NotifyChanged ();
					}
					if (item.HasSubmenu) {
						item.ShowSubmenu ();
						if (openSubmenu != null)
							openSubmenu.Select (null);
					} else if (parentNode != null) {
						ActionMenuBar parentMB = parentMenu.Widget as ActionMenuBar;
						if (parentMB != null) {
							int i = parentNode.ParentNode.Children.IndexOf (parentNode);
							if (i < parentNode.ParentNode.Children.Count - 1)
								parentMB.DropMenu (parentNode.ParentNode.Children [i + 1]);
						}
					}
					break;
				case Gdk.Key.Left:
					if ((modifier & Gdk.ModifierType.ControlMask) != 0 && item.Node.Type == Gtk.UIManagerItemType.Menu) {
						// Remove the submenu
						OpenSubmenu = null;
						using (item.Node.Action.UndoManager.AtomicChange) {
							item.Node.Type = Gtk.UIManagerItemType.Menuitem;
							item.Node.Children.Clear ();
						}
						item.Node.Action.NotifyChanged ();
						break;
					}
					if (parentNode != null) {
						ActionMenu parentAM = parentMenu.Widget as ActionMenu;
						if (parentAM != null) {
							parentAM.Select (parentNode);
						}
						ActionMenuBar parentMB = parentMenu.Widget as ActionMenuBar;
						if (parentMB != null) {
							int i = parentNode.ParentNode.Children.IndexOf (parentNode);
							if (i > 0)
								parentMB.DropMenu (parentNode.ParentNode.Children [i - 1]);
						}
					}
					break;
				case Gdk.Key.Return:
					item.EditingDone += OnEditingDone;
					item.StartEditing ();
					break;
				case Gdk.Key.Insert:
					if ((modifier & Gdk.ModifierType.ControlMask) != 0)
						InsertActionAt (item, true, true);
					else
						InsertActionAt (item, false, false);
					break;
				case Gdk.Key.Delete:
					DeleteAction (item);
					break;
			}
		}
コード例 #5
0
        void ProcessKey(ActionMenuItem item, Gdk.Key key, Gdk.ModifierType modifier)
        {
            int pos = menuItems.IndexOf(item);

            switch (key)
            {
            case Gdk.Key.Up:
                if (pos > 0)
                {
                    ((ActionMenuItem)menuItems[pos - 1]).Select();
                }
                else if (parentMenu.Widget is ActionMenuBar)
                {
                    ActionMenuBar bar = (ActionMenuBar)parentMenu.Widget;
                    bar.Select(parentNode);
                }
                break;

            case Gdk.Key.Down:
                if (pos < menuItems.Count - 1)
                {
                    ((ActionMenuItem)menuItems[pos + 1]).Select();
                }
                else if (pos == menuItems.Count - 1)
                {
                    InsertAction(menuItems.Count);
                }
                break;

            case Gdk.Key.Right:
                if ((modifier & Gdk.ModifierType.ControlMask) != 0 && item.Node.Type == Gtk.UIManagerItemType.Menuitem)
                {
                    // Create a submenu
                    using (item.Node.Action.UndoManager.AtomicChange)
                    {
                        item.Node.Type = Gtk.UIManagerItemType.Menu;
                    }
                    item.Node.Action.NotifyChanged();
                }
                if (item.HasSubmenu)
                {
                    item.ShowSubmenu();
                    if (openSubmenu != null)
                    {
                        openSubmenu.Select(null);
                    }
                }
                else if (parentNode != null)
                {
                    ActionMenuBar parentMB = parentMenu.Widget as ActionMenuBar;
                    if (parentMB != null)
                    {
                        int i = parentNode.ParentNode.Children.IndexOf(parentNode);
                        if (i < parentNode.ParentNode.Children.Count - 1)
                        {
                            parentMB.DropMenu(parentNode.ParentNode.Children [i + 1]);
                        }
                    }
                }
                break;

            case Gdk.Key.Left:
                if ((modifier & Gdk.ModifierType.ControlMask) != 0 && item.Node.Type == Gtk.UIManagerItemType.Menu)
                {
                    // Remove the submenu
                    OpenSubmenu = null;
                    using (item.Node.Action.UndoManager.AtomicChange)
                    {
                        item.Node.Type = Gtk.UIManagerItemType.Menuitem;
                        item.Node.Children.Clear();
                    }
                    item.Node.Action.NotifyChanged();
                    break;
                }
                if (parentNode != null)
                {
                    ActionMenu parentAM = parentMenu.Widget as ActionMenu;
                    if (parentAM != null)
                    {
                        parentAM.Select(parentNode);
                    }
                    ActionMenuBar parentMB = parentMenu.Widget as ActionMenuBar;
                    if (parentMB != null)
                    {
                        int i = parentNode.ParentNode.Children.IndexOf(parentNode);
                        if (i > 0)
                        {
                            parentMB.DropMenu(parentNode.ParentNode.Children [i - 1]);
                        }
                    }
                }
                break;

            case Gdk.Key.Return:
                item.EditingDone += OnEditingDone;
                item.StartEditing();
                break;

            case Gdk.Key.Insert:
                if ((modifier & Gdk.ModifierType.ControlMask) != 0)
                {
                    InsertActionAt(item, true, true);
                }
                else
                {
                    InsertActionAt(item, false, false);
                }
                break;

            case Gdk.Key.Delete:
                DeleteAction(item);
                break;
            }
        }