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(); } }
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)); }
protected override bool OnButtonPressEvent(Gdk.EventButton ev) { IDesignArea designArea = GetDesignArea(); designArea.SetSelection(null, null); return(true); }
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); }
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(); } }
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 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(); } } }
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); } } }
internal protected override void OnDesignerDetach(IDesignArea designer) { base.OnDesignerDetach(designer); foreach (string property in GladePropertyNames) { ((GLib.Object)Wrapped).RemoveNotification(property, NotifyHandler); } }
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(); }
IDesignArea GetDesignArea() { if (darea != null) { return(darea); } darea = WidgetUtils.GetDesignArea(this); darea.SelectionChanged += OnSelectionChanged; return(darea); }
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; }
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")); } }
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(); }
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); } } }
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); } } } }
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(); } }
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); }
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); } } } }
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)); } }
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); } } }
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; }
public void AttachDesigner (IDesignArea designer) { OnDesignerAttach (designer); }
protected internal virtual void OnDesignerAttach(IDesignArea designer) { }
internal ActionMenuItem(IDesignArea designArea, IProject project, IMenuItemContainer parent, ActionTreeNode node) : this(null, parent, node, 6) { this.project = project; this.designArea = designArea; }
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; }
internal ActionMenuItem (IDesignArea designArea, IProject project, IMenuItemContainer parent, ActionTreeNode node) : this (null, parent, node, 6) { this.project = project; this.designArea = designArea; }
internal protected virtual void OnDesignerDetach(IDesignArea designer) { }
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; }
internal protected virtual void OnDesignerDetach (IDesignArea designer) { }
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")); }
IDesignArea GetDesignArea() { if (darea != null) return darea; darea = WidgetUtils.GetDesignArea (this); darea.SelectionChanged += OnSelectionChanged; return darea; }
internal protected override void OnDesignerAttach (IDesignArea designer) { base.OnDesignerAttach (designer); NotifyWorkaround.AddNotification ((GLib.Object)Wrapped, NotifyHandler); }
public void DetachDesigner (IDesignArea designer) { OnDesignerDetach (designer); }
internal protected override void OnDesignerDetach (IDesignArea designer) { base.OnDesignerDetach (designer); foreach (string property in GladePropertyNames) ((GLib.Object)Wrapped).RemoveNotification (property, NotifyHandler); }
internal protected override void OnDesignerDetach (IDesignArea designer) { base.OnDesignerDetach (designer); ((GLib.Object)Wrapped).RemoveNotification (NotifyHandler); }