Example #1
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();
                }
            }
        }
        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));
        }
Example #3
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);
        }
Example #4
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();
        }
Example #5
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();
        }
Example #6
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);
        }