void OnChildRemoved(object ob, ActionTreeNodeArgs args)
        {
            Widget           wrapper = Stetic.Wrapper.Widget.Lookup(this);
            IDesignArea      area    = wrapper.GetDesignArea();
            IObjectSelection asel    = area.GetSelection();
            ActionToolItem   curSel  = asel != null ? asel.DataObject as ActionToolItem : null;
            int pos = toolItems.IndexOf(curSel);

            foreach (Gtk.Widget w in Children)
            {
                if (w is CustomToolbarItem && ((CustomToolbarItem)w).ActionToolItem.Node == args.Node)
                {
                    Remove(w);
                    toolItems.Remove(((CustomToolbarItem)w).ActionToolItem);
                    w.Destroy();
                    if (!showPlaceholder && toolItems.Count == 0)
                    {
                        AddSpacerItem();
                    }
                    break;
                }
            }

            if (pos != -1 && pos < toolItems.Count)
            {
                ((ActionToolItem)toolItems[pos]).Select();
            }
            else if (toolItems.Count > 0)
            {
                ((ActionToolItem)toolItems[toolItems.Count - 1]).Select();
            }
        }
示例#2
0
        public void StartEditing()
        {
            IDesignArea designArea = GetDesignArea();

            designArea.SetSelection(headerLabel, null);
            headerLabel.StartEditing();
        }
        void Refresh()
        {
            IDesignArea    area    = wrapper.GetDesignArea();
            ActionTreeNode selNode = null;

            foreach (Gtk.Widget w in table.Children)
            {
                ActionMenuItem ami = w as ActionMenuItem;
                if (area.IsSelected(w) && ami != null)
                {
                    selNode = ami.Node;
                    area.ResetSelection(w);
                }
                table.Remove(w);
            }

            Fill();

            ActionMenuItem mi = FindMenuItem(selNode);

            if (mi != null)
            {
                mi.Select();
            }

            GLib.Timeout.Add(50, new GLib.TimeoutHandler(RepositionSubmenu));
        }
示例#4
0
        protected override bool OnButtonPressEvent(Gdk.EventButton ev)
        {
            IDesignArea designArea = GetDesignArea();

            designArea.SetSelection(null, null);
            return(true);
        }
示例#5
0
        public bool ProcessButtonPress(Gdk.EventButton ev)
        {
            if (GtkWorkarounds.TriggersContextMenu(ev))
            {
                parentMenu.ShowContextMenu(this);
            }
            else if (ev.Button == 1)
            {
                IDesignArea area = GetDesignArea();
                if (area == null)
                {
                    return(true);
                }

                // Clicking a selected item starts the edit mode
                if (area.IsSelected(this))
                {
                    editOnRelease = true;
                    return(true);
                }
            }

            Select();
            return(true);
        }
示例#6
0
        void OnChildRemoved(object ob, ActionTreeNodeArgs args)
        {
            OpenSubmenu = null;

            Widget           wrapper = Widget.Lookup(this);
            IDesignArea      area    = wrapper.GetDesignArea();
            IObjectSelection asel    = area.GetSelection();
            ActionMenuItem   curSel  = asel != null ? asel.DataObject as ActionMenuItem : null;
            int pos = menuItems.IndexOf(curSel);

            foreach (Gtk.Widget w in Children)
            {
                if (w is CustomMenuBarItem && ((CustomMenuBarItem)w).ActionMenuItem.Node == args.Node)
                {
                    Remove(w);
                    menuItems.Remove(((CustomMenuBarItem)w).ActionMenuItem);
                    if (menuItems.Count == 0 && !showPlaceholder)
                    {
                        AddSpacerItem();
                    }
                    break;
                }
            }
            if (pos != -1 && pos < menuItems.Count)
            {
                ((ActionMenuItem)menuItems[pos]).Select();
            }
            else if (menuItems.Count > 0)
            {
                ((ActionMenuItem)menuItems[menuItems.Count - 1]).Select();
            }
        }
示例#7
0
        public override void Dispose()
        {
            if (disposed)
            {
                return;
            }
            disposed             = true;
            headerLabel.Changed -= OnGroupNameChanged;
            if (emptyLabel != null)
            {
                emptyLabel.ButtonPressEvent -= OnAddClicked;
            }

            foreach (ActionMenuItem aitem in items)
            {
                aitem.KeyPressEvent -= OnItemKeyPress;
                aitem.Node.Dispose();
                aitem.Detach();
                aitem.Destroy();
            }
            items.Clear();
            ActionGroup = null;
            project     = null;
            headerLabel = null;

            if (darea != null)
            {
                darea.SelectionChanged -= OnSelectionChanged;
                darea = null;
            }

            base.Dispose();
        }
示例#8
0
        void Refresh()
        {
            Widget      wrapper = Widget.Lookup(this);
            IDesignArea area    = wrapper.GetDesignArea();

            if (area == null)
            {
                return;
            }

            ActionTreeNode selNode = null;

            foreach (Gtk.Widget w in Children)
            {
                CustomMenuBarItem it = w as CustomMenuBarItem;
                if (it != null && area.IsSelected(it.ActionMenuItem))
                {
                    selNode = it.ActionMenuItem.Node;
                    area.ResetSelection(it.ActionMenuItem);
                }
                Remove(w);
            }

            FillMenu(actionTree);

            if (selNode != null)
            {
                ActionMenuItem mi = FindMenuItem(selNode);
                if (mi != null)
                {
                    mi.Select();
                }
            }
        }
示例#9
0
		public override void Dispose ()
		{
			if (disposed)
				return;
			disposed = true;
			headerLabel.Changed -= OnGroupNameChanged;
			if (emptyLabel != null)
				emptyLabel.ButtonPressEvent -= OnAddClicked;
			
			foreach (ActionMenuItem aitem in items) {
				aitem.KeyPressEvent -= OnItemKeyPress;
				aitem.Node.Dispose ();
				aitem.Detach ();
				aitem.Destroy ();
			}
			items.Clear ();
			ActionGroup = null;
			project = null;
			headerLabel = null;
			
			if (darea != null) {
				darea.SelectionChanged -= OnSelectionChanged;
				darea = null;
			}

			base.Dispose ();
		}
        void OnEditingDone(object ob, EventArgs args)
        {
            Widget wrapper = Stetic.Wrapper.Widget.Lookup(this);

            if (wrapper == null)
            {
                return;
            }

            IDesignArea area = wrapper.GetDesignArea();

            if (area == null)   // The toolbar may be disposed before ending editing
            {
                return;
            }

            ActionToolItem item = (ActionToolItem)ob;

            item.EditingDone -= OnEditingDone;

            if (item.Node.Action.GtkAction.Label.Length == 0 && item.Node.Action.GtkAction.StockId == null)
            {
                area.ResetSelection(item);
                using (wrapper.UndoManager.AtomicChange)
                {
                    actionTree.Children.Remove(item.Node);
                    wrapper.LocalActionGroups [0].Actions.Remove(item.Node.Action);
                }
            }
        }
示例#11
0
 internal protected override void OnDesignerDetach(IDesignArea designer)
 {
     base.OnDesignerDetach(designer);
     foreach (string property in GladePropertyNames)
     {
         ((GLib.Object)Wrapped).RemoveNotification(property, NotifyHandler);
     }
 }
示例#12
0
        void Fill()
        {
            IDesignArea designArea = GetDesignArea();

            if (designArea == null)
            {
                return;
            }

            Wrapper.Action selAction = null;

            foreach (ActionMenuItem item in items)
            {
                if (designArea.IsSelected(item))
                {
                    selAction = item.Node.Action;
                }
                item.Node.Dispose();
                item.Detach();
                item.Destroy();
            }
            items.Clear();

            if (actionGroup != null)
            {
                Wrapper.Action[] sortedActions = new Wrapper.Action [actionGroup.Actions.Count];
                actionGroup.Actions.CopyTo(sortedActions, 0);
                Array.Sort(sortedActions, new ActionComparer());
                for (int n = 0; n < sortedActions.Length; n++)
                {
                    Wrapper.Action action = (Wrapper.Action)sortedActions [n];
                    ActionMenuItem item   = InsertAction(action, n);
                    if (selAction == action)
                    {
                        item.Select();
                    }
                }

                if (selAction == null)
                {
                    designArea.SetSelection(null, null);
                }

                headerLabel.Sensitive = true;
                PlaceAddLabel(actionGroup.Actions.Count);
            }
            else
            {
                HideAddLabel();
                headerLabel.Text      = Catalog.GetString("No selection");
                headerLabel.Sensitive = false;
            }
            ShowAll();
        }
示例#13
0
        IDesignArea GetDesignArea()
        {
            if (darea != null)
            {
                return(darea);
            }

            darea = WidgetUtils.GetDesignArea(this);
            darea.SelectionChanged += OnSelectionChanged;
            return(darea);
        }
示例#14
0
        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;
        }
示例#15
0
        internal protected override void OnDesignerAttach(IDesignArea designer)
        {
            base.OnDesignerAttach(designer);
            BuildTree();
            Loading = true;
            menu.FillMenu(actionTree);
            Loading = false;

            if (LocalActionGroups.Count == 0)
            {
                LocalActionGroups.Add(new ActionGroup("Default"));
            }
        }
示例#16
0
        public virtual void Select()
        {
            IDesignArea area = GetDesignArea();

            if (area.IsSelected(this))
            {
                return;
            }
            IObjectSelection sel = area.SetSelection(this, node.Action != null ? node.Action.GtkAction : null);

            sel.Drag     += HandleItemDrag;
            sel.Disposed += OnSelectionDisposed;
            GrabFocus();
        }
示例#17
0
        protected void UpdateSelectionStatus()
        {
            IDesignArea      area = GetDesignArea();
            IObjectSelection sel  = area.GetSelection();

            sel.Disposed -= OnSelectionDisposed;
            sel.Drag     -= HandleItemDrag;

            area.ResetSelection(this);

            sel           = area.SetSelection(this, this);
            sel.Drag     += HandleItemDrag;
            sel.Disposed += OnSelectionDisposed;
        }
        public void TrackWidgetPosition(Gtk.Widget refWidget, bool topMenu)
        {
            IDesignArea area = wrapper.GetDesignArea();

            Gdk.Rectangle rect = area.GetCoordinates(refWidget);
            if (topMenu)
            {
                area.MoveWidget(this, rect.X, rect.Bottom);
            }
            else
            {
                area.MoveWidget(this, rect.Right, rect.Top);
            }

            GLib.Timeout.Add(50, new GLib.TimeoutHandler(RepositionSubmenu));
        }
        protected override void EndEditing(Gdk.Key exitKey)
        {
            if (editing)
            {
                Gtk.Entry entry = label as Gtk.Entry;
                if (entry != null && exitKey != Gdk.Key.Escape)
                {
                    localUpdate = true;
                    if (entry.Text.Trim().Length > 0 || node.Action.GtkAction.StockId != null)
                    {
                        using (node.Action.UndoManager.AtomicChange)
                        {
                            node.Action.Label = entry.Text;
                            node.Action.NotifyChanged();
                        }
                    }
                    localUpdate = false;
                }

                editing = false;
                Refresh();
                while (Gtk.Application.EventsPending())
                {
                    Gtk.Application.RunIteration();
                }
                if (node.Type == Gtk.UIManagerItemType.Menu)
                {
                    if (wrapper != null)
                    {
                        IDesignArea area = wrapper.GetDesignArea();
                        if (area != null)
                        {
                            ShowSubmenu(area, this);
                        }
                    }
                }
                GrabFocus();
                UpdateSelectionStatus();

                if (EditingDone != null)
                {
                    MenuItemEditEventArgs args = new MenuItemEditEventArgs();
                    args.ExitKey = exitKey;
                    EditingDone(this, args);
                }
            }
        }
示例#20
0
        void OnEditingDone(object ob, EventArgs args)
        {
            ActionMenuItem item = (ActionMenuItem)ob;

            item.EditingDone -= OnEditingDone;
            Widget wrapper = Widget.Lookup(this);

            if (item.Node.Action.GtkAction.Label.Length == 0 && item.Node.Action.GtkAction.StockId == null)
            {
                IDesignArea area = wrapper.GetDesignArea();
                area.ResetSelection(item);
                using (wrapper.UndoManager.AtomicChange) {
                    actionTree.Children.Remove(item.Node);
                    wrapper.LocalActionGroups [0].Actions.Remove(item.Node.Action);
                }
            }
        }
        public void Unselect()
        {
            // Unselects any selected item
            Widget      wrapper = Stetic.Wrapper.Widget.Lookup(this);
            IDesignArea area    = wrapper.GetDesignArea();

            if (area != null)
            {
                foreach (Gtk.Widget w in Children)
                {
                    CustomToolbarItem it = w as CustomToolbarItem;
                    if (it != null)
                    {
                        area.ResetSelection(it.ActionToolItem);
                    }
                }
            }
        }
示例#22
0
        public void StartEditing()
        {
            if (Child is Gtk.Label)
            {
                IDesignArea      d   = WidgetUtils.GetDesignArea(this);
                IObjectSelection sel = d.GetSelection(this);
                if (sel == null)
                {
                    sel = d.SetSelection(this, null);
                }

                sel.Disposed += SelectionDisposed;

                Remove(Child);
                Add(CreateEntry());
                ShowAll();
                Child.GrabFocus();
            }
        }
示例#23
0
        protected override bool OnButtonPressEvent(Gdk.EventButton ev)
        {
            IDesignArea d = WidgetUtils.GetDesignArea(this);

            if (d.IsSelected(this))
            {
                if (Child is Gtk.Label)
                {
                    StartEditing();
                    return(true);
                }
            }
            else
            {
                d.SetSelection(this, null);
                return(true);
            }
            return(false);
        }
示例#24
0
        ActionMenuItem InsertAction(Wrapper.Action action, int n)
        {
            uint row = (uint)n / columns;
            uint col = (uint)(n % columns) * 3;

            IDesignArea    designArea = GetDesignArea();
            ActionTreeNode node       = new ActionTreeNode(Gtk.UIManagerItemType.Menuitem, "", action);
            ActionMenuItem aitem      = new ActionMenuItem(designArea, project, this, node);

            aitem.KeyPressEvent += OnItemKeyPress;
            aitem.MinWidth       = 150;
            aitem.Attach(table, row, col);

            Gtk.Frame fr = new Gtk.Frame();
            fr.Shadow = Gtk.ShadowType.Out;
            aitem.Add(fr);

            items.Add(aitem);
            return(aitem);
        }
        internal void ResetSelection()
        {
            if (OpenSubmenu != null)
            {
                OpenSubmenu.ResetSelection();
            }
            IDesignArea area = wrapper.GetDesignArea();

            if (area != null)
            {
                foreach (Gtk.Widget w in table.Children)
                {
                    ActionMenuItem ami = w as ActionMenuItem;
                    if (ami != null)
                    {
                        area.ResetSelection(w);
                    }
                }
            }
        }
示例#26
0
        void OnEditDone(object sender, EventArgs args)
        {
            ActionMenuItem item = (ActionMenuItem)sender;

            item.EditingDone -= OnEditDone;
            if (item.Node.Action.GtkAction.Label.Length > 0 || item.Node.Action.GtkAction.StockId != null)
            {
                actionGroup.Actions.Add(item.Node.Action);
            }
            else
            {
                IDesignArea designArea = GetDesignArea();
                designArea.ResetSelection(item);
                item.Detach();
                item.Node.Dispose();
                items.Remove(item);
                item.Destroy();
                PlaceAddLabel(actionGroup.Actions.Count);
                ShowAll();
            }
        }
        void OnChildRemoved(object ob, ActionTreeNodeArgs args)
        {
            IDesignArea      area   = wrapper.GetDesignArea();
            IObjectSelection asel   = area.GetSelection();
            ActionMenuItem   curSel = asel != null ? asel.DataObject as ActionMenuItem : null;
            int pos = menuItems.IndexOf(curSel);

            ActionMenuItem mi = FindMenuItem(args.Node);

            if (mi != null)
            {
                // Remove the table row that contains the menu item
                Gtk.Table.TableChild tc = (Gtk.Table.TableChild)table [mi];
                uint row = tc.TopAttach;
                mi.Detach();
                menuItems.Remove(mi);
                foreach (Gtk.Widget w in table.Children)
                {
                    tc = (Gtk.Table.TableChild)table [w];
                    if (tc.TopAttach >= row)
                    {
                        tc.TopAttach--;
                    }
                    if (tc.BottomAttach > row)
                    {
                        tc.BottomAttach--;
                    }
                }
                if (pos != -1 && pos < menuItems.Count)
                {
                    ((ActionMenuItem)menuItems[pos]).Select();
                }
                else
                {
                    SelectLastItem();
                }
                GLib.Timeout.Add(50, new GLib.TimeoutHandler(RepositionSubmenu));
            }
        }
示例#28
0
        void OnEditingDone(object ob, MenuItemEditEventArgs args)
        {
            ActionMenuItem item = (ActionMenuItem)ob;

            item.EditingDone -= OnEditingDone;
            if (item.Node.Action.GtkAction.Label.Length == 0 && item.Node.Action.GtkAction.StockId == null)
            {
                IDesignArea area = wrapper.GetDesignArea();
                area.ResetSelection(item);
                using (wrapper.UndoManager.AtomicChange) {
                    nodes.Remove(item.Node);
                    wrapper.LocalActionGroups [0].Actions.Remove(item.Node.Action);
                }
                SelectLastItem();
            }
            else
            {
                if (args.ExitKey == Gdk.Key.Up || args.ExitKey == Gdk.Key.Down)
                {
                    ProcessKey(item, args.ExitKey, Gdk.ModifierType.None);
                }
            }
        }
示例#29
0
        public void Unselect()
        {
            // Unselects any selected item and hides any open submenu menu
            Widget wrapper = Widget.Lookup(this);

            if (OpenSubmenu != null)
            {
                OpenSubmenu.ResetSelection();
            }
            IDesignArea area = wrapper.GetDesignArea();

            if (area != null)
            {
                foreach (Gtk.Widget w in Children)
                {
                    CustomMenuBarItem it = w as CustomMenuBarItem;
                    if (it != null)
                    {
                        area.ResetSelection(it.ActionMenuItem);
                    }
                }
            }
            OpenSubmenu = null;
        }
示例#30
0
		public void AttachDesigner (IDesignArea designer)
		{
			OnDesignerAttach (designer);
		}
示例#31
0
 protected internal virtual void OnDesignerAttach(IDesignArea designer)
 {
 }
示例#32
0
 internal ActionMenuItem(IDesignArea designArea, IProject project, IMenuItemContainer parent, ActionTreeNode node)
     : this(null, parent, node, 6)
 {
     this.project    = project;
     this.designArea = designArea;
 }
示例#33
0
		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;
		}
示例#34
0
		internal ActionMenuItem (IDesignArea designArea, IProject project, IMenuItemContainer parent, ActionTreeNode node)
		: this (null, parent, node, 6)
		{
			this.project = project;
			this.designArea = designArea;
		}
示例#35
0
 internal protected virtual void OnDesignerDetach(IDesignArea designer)
 {
 }
示例#36
0
		internal protected override void OnDesignerDetach (IDesignArea designer)
		{
			base.OnDesignerDetach (designer);
			foreach (Gtk.Widget w in RealChildren) {
				ObjectWrapper wr = ObjectWrapper.Lookup (w);
				if (wr != null)
					wr.OnDesignerDetach (designer);
			}
			this.designer = null;
		}
示例#37
0
		internal protected virtual void OnDesignerDetach (IDesignArea designer)
		{
		}
示例#38
0
文件: MenuBar.cs 项目: mono/stetic
        protected internal override void OnDesignerAttach(IDesignArea designer)
        {
            base.OnDesignerAttach (designer);
            BuildTree ();
            Loading = true;
            menu.FillMenu (actionTree);
            Loading = false;

            if (LocalActionGroups.Count == 0)
                LocalActionGroups.Add (new ActionGroup ("Default"));
        }
示例#39
0
        IDesignArea GetDesignArea()
        {
            if (darea != null)
                return darea;

            darea = WidgetUtils.GetDesignArea (this);
            darea.SelectionChanged += OnSelectionChanged;
            return darea;
        }
示例#40
0
		internal protected override void OnDesignerAttach (IDesignArea designer)
		{
			base.OnDesignerAttach (designer);
			NotifyWorkaround.AddNotification ((GLib.Object)Wrapped, NotifyHandler);
		}
示例#41
0
		public void DetachDesigner (IDesignArea designer)
		{
			OnDesignerDetach (designer);
		}
示例#42
0
		internal protected override void OnDesignerDetach (IDesignArea designer)
		{
			base.OnDesignerDetach (designer);
			foreach (string property in GladePropertyNames)
				((GLib.Object)Wrapped).RemoveNotification (property, NotifyHandler);
		}
示例#43
0
		internal protected override void OnDesignerDetach (IDesignArea designer)
		{
			base.OnDesignerDetach (designer);
			((GLib.Object)Wrapped).RemoveNotification (NotifyHandler);
		}