public SizingHelper(Gtk.Widget window, Gtk.Widget border, bool allow_sizing, uint marginSize) { this._window = window; this._border = border; this._marginSize = marginSize; this._allow_sizing = allow_sizing; // check size request { int vw, vh; this._window.GetSizeRequest(out vw, out vh); vw = vw <= 0 ? 100 : vw; vh = vh <= 0 ? 100 : vh; this._window.SetSizeRequest(100, 100); } if (_allow_sizing) { this._border.AddEvents((int)Gdk.EventMask.PointerMotionMask); this._border.EnterNotifyEvent += HandleEnterNotifyEvent; this._border.LeaveNotifyEvent += HandleLeaveNotifyEvent; this._border.ButtonPressEvent += HandleButtonPressEvent; this._border.ButtonReleaseEvent += HandleButtonReleaseEvent; this._border.MotionNotifyEvent += HandleMotionNotifyEvent; } // Set style for border from resource style Gdk.Color bgc = this._window.Style.Background(Gtk.StateType.Selected); //Gdk.Color.Parse("black", ref bgc); this._border.ModifyBg(Gtk.StateType.Normal, bgc); }
public void Dispose () { if (styleSource != null) { IdeApp.Preferences.CustomPadFont.Changed -= PropertyChanged; styleSource = null; } }
public bool Visit (object ob) { if (activeWidget == null && ob is Gtk.Widget) activeWidget = (Gtk.Widget) ob; if (ob == ((DefaultWorkbench)IdeApp.Workbench.RootWindow).ActiveWorkbenchWindow) visitedCurrentDoc = true; if (ob is MonoDevelop.Components.Docking.AutoHideBox) { found = true; return true; } if (ob is PropertyPad) { // Don't change the property grid selection when the focus is inside the property grid itself found = true; return true; } else if (ob is IPropertyPadProvider) { DesignerSupport.Service.SetPadContent ((IPropertyPadProvider)ob, activeWidget); found = true; return true; } else if (ob is ICustomPropertyPadProvider) { DesignerSupport.Service.SetPadContent ((ICustomPropertyPadProvider)ob, activeWidget); found = true; return true; } else return false; }
public EditorView(ViewContent content) { try { this.content = content; var editorWidget = content.Control.GetNativeWidget<Gtk.Widget> (); editorWidget.ShowAll (); MonoDevelop.Components.Control previewNative; if (Platform.Instance.IsMac) { var editor = new GtkEmbed2(editorWidget); var editorEto = editor.ToEto(); preview = new PreviewEditorView(editorEto, null, null, () => content?.WorkbenchWindow?.Document?.Editor?.Text); var nspreview = XamMac2Helpers.ToNative(preview, true); var nsviewContainer = new NSViewContainer2(nspreview); previewNative = nsviewContainer; } else { preview = new PreviewEditorView(editorWidget.ToEto(), null, null, () => content?.WorkbenchWindow?.Document?.Editor?.Text); previewNative = Gtk2Helpers.ToNative(preview, true); } var commandRouterContainer = new CommandRouterContainer (previewNative, content, true); commandRouterContainer.ShowAll (); control = commandRouterContainer; content.DirtyChanged += content_DirtyChanged; IdeApp.Workbench.ActiveDocumentChanged += Workbench_ActiveDocumentChanged; ContentName = content.ContentName; } catch (Exception ex) { Debug.WriteLine ($"{ex}"); } }
public ExtensionModelBrowserWidget () { this.Build (); NodeBuilder[] builders = new NodeBuilder [] { new ExtensionNodeBuilder (), new ExtensionNodeNodeBuilder (), new ExtensionPointNodeBuilder (), new AddinNodeBuilder (), new SolutionNodeBuilder (true), new RegistryNodeBuilder (), new AddinCategoryNodeBuilder (), new MonoDevelop.Ide.Gui.Pads.ProjectPad.WorkspaceNodeBuilder (), new MonoDevelop.Ide.Gui.Pads.ProjectPad.SolutionFolderNodeBuilder () }; TreePadOption[] options = new TreePadOption [] { new TreePadOption ("ShowExistingNodes", GettextCatalog.GetString ("Show existing nodes"), true) }; tree = new ExtensibleTreeView (builders, options); tree.ShowAll (); paned.Add1 (tree); foreach (Solution sol in IdeApp.Workspace.GetAllSolutions ()) AddSolution (sol); docView = new Gtk.Label (); paned.Add2 (docView); tree.ShadowType = Gtk.ShadowType.In; tree.Tree.Selection.Changed += HandleSelectionChanged; AddinAuthoringService.RegistryChanged += OnRegistryChanged; IdeApp.Workspace.WorkspaceItemLoaded += OnSolutionLoaded; IdeApp.Workspace.WorkspaceItemUnloaded += OnSolutionUnloaded; }
public CustomListModel(IListDataSource source, Gtk.Widget w) { parent = w; this.source = source; adapter = new Gtk.TreeModelAdapter (this); colTypes = source.ColumnTypes; source.RowChanged += HandleRowChanged; source.RowDeleted += HandleRowDeleted; source.RowInserted += HandleRowInserted; source.RowsReordered += HandleRowsReordered; }
public BaseWidgetAccessible(Gtk.Widget widget) { this.widget = widget; widget.SizeAllocated += OnAllocated; widget.Mapped += OnMap; widget.Unmapped += OnMap; widget.FocusInEvent += OnFocus; widget.FocusOutEvent += OnFocus; widget.AddNotification ("sensitive", (o, a) => NotifyStateChange (StateType.Sensitive, widget.Sensitive)); widget.AddNotification ("visible", (o, a) => NotifyStateChange (StateType.Visible, widget.Visible)); }
public PadFontChanger (Gtk.Widget styleSource, Action<FontDescription> updater, Action resizer) { this.styleSource = styleSource; this.updater = updater; this.resizer = resizer; if (styleSource != null) { IdeApp.Preferences.CustomPadFont.Changed += PropertyChanged; } Update (); }
public PListEditorViewContent (IPlistEditingHandler handler, Project proj) { if (handler != null) { widget = new PListEditorWidget (handler, proj); control = (Gtk.Widget) widget; } else { widget = new CustomPropertiesWidget (); var csw = new MonoDevelop.Components.CompactScrolledWindow (); csw.Show (); csw.AddWithViewport ((Gtk.Widget)widget); control = csw; } }
public EditorView(IViewContent content) { this.content = content; preview = new PreviewEditorView(content.Control.ToEto(), () => content?.WorkbenchWindow?.Document?.Editor?.Text); content.ContentChanged += content_ContentChanged; content.DirtyChanged += content_DirtyChanged; var commandRouterContainer = new CommandRouterContainer(preview.ToNative(true), content, true); commandRouterContainer.Show(); control = commandRouterContainer; IdeApp.Workbench.ActiveDocumentChanged += Workbench_ActiveDocumentChanged; base.ContentName = content.ContentName; }
protected virtual void OnComboVisualizersChanged (object sender, System.EventArgs e) { if (currentWidget != null) mainBox.Remove (currentWidget); if (comboVisualizers.Active == -1) { buttonOk.Sensitive = false; return; } buttonOk.Sensitive = true; currentVisualizer = visualizers [comboVisualizers.Active]; currentWidget = currentVisualizer.GetVisualizerWidget (value); mainBox.PackStart (currentWidget, true, true, 0); currentWidget.Show (); }
public void FillMenu (ActionTree actionTree) { addLabel = null; if (this.actionTree != null) { this.actionTree.ChildNodeAdded -= OnChildAdded; this.actionTree.ChildNodeRemoved -= OnChildRemoved; } this.actionTree = actionTree; if (actionTree == null) { AddSpacerItem (); return; } actionTree.ChildNodeAdded += OnChildAdded; actionTree.ChildNodeRemoved += OnChildRemoved; HideSpacerItem (); toolItems.Clear (); Widget wrapper = Stetic.Wrapper.Widget.Lookup (this); foreach (Gtk.Widget w in Children) { Remove (w); w.Destroy (); } foreach (ActionTreeNode node in actionTree.Children) { ActionToolItem aitem = new ActionToolItem (wrapper, this, node); AddItem (aitem, -1); toolItems.Add (aitem); } if (actionTree.Children.Count == 0) { // If there are no buttons in the toolbar, give it some height so it is selectable. AddSpacerItem (); } if (showPlaceholder) { AddCreateItemLabel (); } }
internal static void RegisterWidgets(Gtk.Widget source, params Gtk.Widget[] widgets) { if(_widgets == null) _widgets = new Dictionary<ResourceManager, List<Gtk.Widget>>(); var sourceType = source.GetType(); var baseName = string.Format("xCom.CamManager.Resources.{0}Strings", sourceType.Name); var rm = new ResourceManager(baseName, sourceType.Assembly); if(source is Gtk.Dialog) { if(widgets == null) widgets = new Gtk.Widget[] { }; var widgetsAsList = widgets.ToList(); widgetsAsList.Add(source); widgets = widgetsAsList.ToArray(); } _widgets.Add(rm, new List<Gtk.Widget>(widgets)); }
public void FillMenu (ActionTree actionTree) { addLabel = null; if (this.actionTree != null) { this.actionTree.ChildNodeAdded -= OnChildAdded; this.actionTree.ChildNodeRemoved -= OnChildRemoved; } this.actionTree = actionTree; if (actionTree == null) { AddSpacerItem (); return; } actionTree.ChildNodeAdded += OnChildAdded; actionTree.ChildNodeRemoved += OnChildRemoved; HideSpacerItem (); menuItems.Clear (); Widget wrapper = Widget.Lookup (this); foreach (Gtk.Widget w in Children) { Remove (w); w.Destroy (); } foreach (ActionTreeNode node in actionTree.Children) { ActionMenuItem aitem = new ActionMenuItem (wrapper, this, node); AddItem (aitem, -1); menuItems.Add (aitem); } if (showPlaceholder) { AddCreateItemLabel (); } else if (actionTree.Children.Count == 0) { // Give some height to the toolbar AddSpacerItem (); } }
public void SetChild (IWidgetBackend child) { RemoveChildPlacement (currentChild); if (Widget.Child != null) { if (Widget.Child is Gtk.Bin) { Gtk.Bin vp = (Gtk.Bin) Widget.Child; vp.Remove (vp.Child); } Widget.Remove (Widget.Child); } if (child != null) { var w = currentChild = GetWidgetWithPlacement (child); WidgetBackend wb = (WidgetBackend) child; if (wb.EventSink.SupportsCustomScrolling ()) { CustomViewPort vp = new CustomViewPort (wb.EventSink); vp.Show (); vp.Add (w); Widget.Child = vp; } else if (w is Gtk.Viewport) Widget.Child = w; else { Gtk.Viewport vp = new Gtk.Viewport (); vp.Show (); vp.Add (w); Widget.Child = vp; } } UpdateBorder (); }
public void SetChildNonHomogeneous(Gtk.Widget child, bool non_homogeneous) { gtk_button_box_set_child_non_homogeneous(Handle, child == null ? IntPtr.Zero : child.Handle, non_homogeneous); }
protected override void OnAdded(Gtk.Widget child) { mainHBox.PackStart(child, true, true, 0); }
protected internal ButtonBoxChild(Gtk.Container parent, Gtk.Widget child) : base(parent, child) { }
void AddSpacerItem() { if (spacerItem == null) { Gtk.Label emptyLabel = new Gtk.Label (); emptyLabel.Xalign = 0; emptyLabel.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("Empty menu bar") + "</span></i>"; Gtk.MenuItem mit = new Gtk.MenuItem (); mit.Child = emptyLabel; Insert (mit, -1); spacerItem = mit; ShowAll (); } }
protected override void OnRemoved(Gtk.Widget widget) { children.Remove(widget); widget.Unparent(); }
protected override void OnAdded(Gtk.Widget widget) { children.Add(widget, new Rectangle(0, 0, 0, 0)); widget.Parent = this; QueueResize(); }
public PadFontChanger(Gtk.Widget styleSource, Action <FontDescription> updater) : this(styleSource, updater, null) { }
public void Put(Gtk.Widget widget, int x, int y) { gtk_fixed_put(Handle, widget == null ? IntPtr.Zero : widget.Handle, x, y); }
public void SetChildPacking(Gtk.Widget child, bool expand, bool fill, uint padding, Gtk.PackType pack_type) { gtk_box_set_child_packing(Handle, child == null ? IntPtr.Zero : child.Handle, expand, fill, padding, (int)pack_type); }
public void Add(Gtk.Widget widget) { Children.Add(widget); }
public void ReorderChild(Gtk.Widget child, int position) { gtk_box_reorder_child(Handle, child == null ? IntPtr.Zero : child.Handle, position); }
public void PackStart(Gtk.Widget child, bool expand, bool fill, uint padding) { gtk_box_pack_start(Handle, child == null ? IntPtr.Zero : child.Handle, expand, fill, padding); }
protected override void OnAdded(Gtk.Widget widget) { base.OnAdded(widget); child = widget; }
public static XmlDocument Export(Gtk.Widget widget) { Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup(widget); if (wrapper == null) { return(null); } XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; XmlElement toplevel = doc.CreateElement("glade-interface"); doc.AppendChild(toplevel); // For toplevel widgets, glade just saves it as-is. For // non-toplevels, it puts the widget into a dummy GtkWindow, // but using the packing attributes of the widget's real // container (so as to preserve expand/fill settings and the // like). XmlElement elem; Stetic.Wrapper.Container parent = wrapper.ParentWrapper; ObjectWriter writer = new ObjectWriter(doc, FileFormat.Glade); if (parent == null) { elem = wrapper.Write(writer); if (elem == null) { return(null); } if (!(widget is Gtk.Window)) { XmlElement window = doc.CreateElement("widget"); window.SetAttribute("class", "GtkWindow"); window.SetAttribute("id", "glade-dummy-container"); XmlElement child = doc.CreateElement("child"); window.AppendChild(child); child.AppendChild(elem); elem = window; } } else { elem = doc.CreateElement("widget"); // Set the class correctly (temporarily) so the XSL // transforms will work correctly. ClassDescriptor klass = parent.ClassDescriptor; elem.SetAttribute("class", klass.CName); elem.AppendChild(parent.WriteContainerChild(writer, wrapper)); } toplevel.AppendChild(elem); doc = XslExportTransform(doc); if (parent != null) { elem = (XmlElement)doc.SelectSingleNode("glade-interface/widget"); elem.SetAttribute("class", "GtkWindow"); elem.SetAttribute("id", "glade-dummy-container"); } return(doc); }
internal static Point GetPosition(Gtk.Widget widget) { widget.GetPointer(out int x, out int y); return(new Point(x, y)); }
public void SetAllocation(Gtk.Widget w, Rectangle rect) { children [w] = rect; QueueResize(); }
protected internal FixedChild(Gtk.Container parent, Gtk.Widget child) : base(parent, child) { }
protected virtual void OnDisconnectProxy(Gtk.Action action, Gtk.Widget proxy) { InternalDisconnectProxy(action, proxy); }
static string PropToString(ObjectWrapper wrapper, TypedPropertyDescriptor prop) { object value; if (!prop.GladeOverride) { Stetic.Wrapper.Container.ContainerChild ccwrap = wrapper as Stetic.Wrapper.Container.ContainerChild; GLib.Value gval; if (ccwrap != null) { Gtk.Container.ContainerChild cc = (Gtk.Container.ContainerChild)ccwrap.Wrapped; gval = new GLib.Value((GLib.GType)prop.PropertyType); gtk_container_child_get_property(cc.Parent.Handle, cc.Child.Handle, prop.GladeName, ref gval); } else { Gtk.Widget widget = wrapper.Wrapped as Gtk.Widget; gval = new GLib.Value(widget, prop.GladeName); g_object_get_property(widget.Handle, prop.GladeName, ref gval); } value = gval.Val; } else { value = prop.GetValue(wrapper.Wrapped); } if (value == null) { return(null); } // If the property has its default value, we don't need to write it if (prop.HasDefault && prop.ParamSpec.IsDefaultValue(value)) { return(null); } if (value is Gtk.Adjustment) { Gtk.Adjustment adj = value as Gtk.Adjustment; return(String.Format("{0:G} {1:G} {2:G} {3:G} {4:G} {5:G}", adj.Value, adj.Lower, adj.Upper, adj.StepIncrement, adj.PageIncrement, adj.PageSize)); } else if (value is Enum && prop.ParamSpec != null) { IntPtr klass = g_type_class_ref(((GLib.GType)prop.PropertyType).Val); if (prop.PropertyType.IsDefined(typeof(FlagsAttribute), false)) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); uint val = (uint)System.Convert.ChangeType(value, typeof(uint)); while (val != 0) { IntPtr flags_value = g_flags_get_first_value(klass, val); if (flags_value == IntPtr.Zero) { break; } IntPtr fval = Marshal.ReadIntPtr(flags_value); val &= ~(uint)fval; IntPtr name = Marshal.ReadIntPtr(flags_value, Marshal.SizeOf(typeof(IntPtr))); if (name != IntPtr.Zero) { if (sb.Length != 0) { sb.Append('|'); } sb.Append(GLib.Marshaller.Utf8PtrToString(name)); } } g_type_class_unref(klass); return(sb.ToString()); } else { int val = (int)System.Convert.ChangeType(value, typeof(int)); IntPtr enum_value = g_enum_get_value(klass, val); g_type_class_unref(klass); IntPtr name = Marshal.ReadIntPtr(enum_value, Marshal.SizeOf(typeof(IntPtr))); return(GLib.Marshaller.Utf8PtrToString(name)); } } else if (value is bool) { return((bool)value ? "True" : "False"); } else { return(value.ToString()); } }
void SetLayout() { var vbox = new VBox(); vbox.Accessible.Role = Xwt.Accessibility.Role.Filler; vbox.MinWidth = 450; var actionLabel = new Label(GettextCatalog.GetString("Breakpoint Action")) { Font = vbox.Font.WithWeight(FontWeight.Bold) }; vbox.PackStart(actionLabel); var breakpointActionGroup = new VBox { MarginLeft = 12 }; breakpointActionGroup.Accessible.Role = Xwt.Accessibility.Role.Filler; breakpointActionGroup.PackStart(breakpointActionPause); breakpointActionGroup.PackStart(breakpointActionPrint); var printExpressionGroup = new HBox { MarginLeft = 18 }; printExpressionGroup.Accessible.Role = Xwt.Accessibility.Role.Filler; printExpressionGroup.PackStart(entryPrintExpression, true); // We'll ignore this label because the content of the label is included in the accessibility Help text of the // entryPrintExpression widget warningPrintExpression.Accessible.Role = Xwt.Accessibility.Role.Filler; printExpressionGroup.PackStart(warningPrintExpression); breakpointActionGroup.PackStart(printExpressionGroup); breakpointActionGroup.PackEnd(printMessageTip); vbox.PackStart(breakpointActionGroup); var whenLabel = new Label(GettextCatalog.GetString("When to Take Action")) { Font = vbox.Font.WithWeight(FontWeight.Bold) }; vbox.PackStart(whenLabel); var whenToTakeActionRadioGroup = new VBox { MarginLeft = 12 }; whenToTakeActionRadioGroup.Accessible.Role = Xwt.Accessibility.Role.Filler; // Function group { whenToTakeActionRadioGroup.PackStart(stopOnFunction); hboxFunction.PackStart(entryFunctionName, true); hboxFunction.PackEnd(warningFunction); whenToTakeActionRadioGroup.PackStart(hboxFunction); } // Exception group { whenToTakeActionRadioGroup.PackStart(stopOnException); hboxException = new HBox(); hboxException.Accessible.Role = Xwt.Accessibility.Role.Filler; hboxException.PackStart(entryExceptionType, true); hboxException.PackEnd(warningException); vboxException.PackStart(hboxException); vboxException.PackStart(checkIncludeSubclass); whenToTakeActionRadioGroup.PackStart(vboxException); } // Location group { whenToTakeActionRadioGroup.PackStart(stopOnLocation); hboxLocation.PackStart(entryLocationFile, true); hboxLocation.PackStart(warningLocation); vboxLocation.PackEnd(hboxLocation); whenToTakeActionRadioGroup.PackStart(vboxLocation); } vbox.PackStart(whenToTakeActionRadioGroup); var advancedLabel = new Label(GettextCatalog.GetString("Advanced Conditions")) { Font = vbox.Font.WithWeight(FontWeight.Bold) }; vbox.PackStart(advancedLabel); var vboxAdvancedConditions = new VBox { MarginLeft = 30 }; vboxAdvancedConditions.Accessible.Role = Xwt.Accessibility.Role.Filler; var hboxHitCount = new HBox(); hboxHitCount.Accessible.Role = Xwt.Accessibility.Role.Filler; hboxHitCount.PackStart(ignoreHitType, true); hboxHitCount.PackStart(ignoreHitCount); vboxAdvancedConditions.PackStart(hboxHitCount); vboxAdvancedConditions.PackStart(conditionalHitType); hboxCondition = new HBox(); hboxCondition.Accessible.Role = Xwt.Accessibility.Role.Filler; hboxCondition.PackStart(entryConditionalExpression, true); hboxCondition.PackStart(warningCondition); vboxAdvancedConditions.PackStart(hboxCondition); conditionalExpressionTip.Accessible.Role = Xwt.Accessibility.Role.Filler; vboxAdvancedConditions.PackEnd(conditionalExpressionTip); vbox.PackStart(vboxAdvancedConditions); Buttons.Add(new DialogButton(Command.Cancel)); Buttons.Add(buttonOk); Content = vbox; if (IdeApp.Workbench != null) { Gtk.Widget parent = ((Gtk.Widget)Xwt.Toolkit.CurrentEngine.GetNativeWidget(vbox)).Parent; while (parent != null && !(parent is Gtk.Window)) { parent = parent.Parent; } if (parent is Gtk.Window) { ((Gtk.Window)parent).TransientFor = IdeApp.Workbench.RootWindow; } } OnUpdateControls(null, null); }
public ThreadedRenderer (Gtk.Widget owner) { this.owner = owner; runningSignal = new ManualResetEventSlim (true); }
Gtk.Widget GetActiveWidget (Gtk.Window win) { win = GetActiveWindow (win); Gtk.Widget widget = win; if (win != null) { while (widget is Gtk.Container) { Gtk.Widget child = ((Gtk.Container)widget).FocusChild; if (child != null) widget = child; else break; } } if (widget != lastActiveWidget) { if (ActiveWidgetChanged != null) ActiveWidgetChanged (this, new ActiveWidgetEventArgs () { OldActiveWidget = lastActiveWidget, NewActiveWidget = widget }); lastActiveWidget = widget; } return widget; }
public void SetChildSecondary(Gtk.Widget child, bool is_secondary) { gtk_button_box_set_child_secondary(Handle, child == null ? IntPtr.Zero : child.Handle, is_secondary); }
void CreateControls () { Gtk.Widget icon = null; Gtk.Widget label = null; dropButton = null; if (Child != null) { Gtk.Widget w = Child; Remove (w); w.Destroy (); } if (node.Type == Gtk.UIManagerItemType.Separator) { Gtk.Widget sep; if (parentToolbar.Orientation == Gtk.Orientation.Horizontal) { sep = new Gtk.VSeparator (); } else { sep = new Gtk.HSeparator (); } Gtk.HBox box = new Gtk.HBox (); box.BorderWidth = 6; box.PackStart (sep, true, true, 0); Add (box); return; } if (node.Action == null) return; Gtk.Action gaction = node.Action.GtkAction; bool showText = parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.Text; bool showIcon = parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.Icons; if (parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.Both) { showText = showIcon = true; } else if (parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.BothHoriz) { showText = parentToolbar.Orientation == Gtk.Orientation.Vertical || gaction.IsImportant; showIcon = true; } string text = node.Action.ToolLabel; showingText = showText; if (showIcon) { if (gaction.StockId != null) { icon = node.Action.CreateIcon (parentToolbar.IconSize); } else if (!gaction.IsImportant) { icon = CreateFakeItem (); } } if (editing) { Gtk.HBox bbox = new Gtk.HBox (); bbox.Spacing = 3; if (icon != null) { bbox.PackStart (icon, false, false, 0); } bbox.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.In), false, false, 0); Gtk.Button b = new Gtk.Button (bbox); b.TooltipText = Catalog.GetString ("Select action type"); b.Relief = Gtk.ReliefStyle.None; b.ButtonPressEvent += OnSelectIcon; dropButton = b; icon = b; if (showText) { Gtk.Entry entry = new Gtk.Entry (); entry.Text = text; entry.Changed += OnLabelChanged; entry.Activated += OnLabelActivated; entry.HasFrame = false; label = entry; entry.TooltipText = Catalog.GetString ("Action label"); } } else if (showText && text != null && text.Length > 0) { label = new Gtk.Label (text); label.Sensitive = editing || node.Action == null || node.Action.GtkAction.Sensitive; } if (icon != null && label != null) { if (parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.BothHoriz) { Gtk.HBox box = new Gtk.HBox (); box.PackStart (icon, false, false, 0); box.PackStart (label, true, true, 0); icon = box; } else if (parentToolbar.ToolbarStyle == Gtk.ToolbarStyle.Both) { Gtk.VBox box = new Gtk.VBox (); Gtk.Alignment al = new Gtk.Alignment (0.5f, 0f, 0f, 0f); al.Add (icon); box.PackStart (al, false, false, 0); box.PackStart (label, true, true, 0); icon = box; } } else if (label != null) { icon = label; } if (icon == null) { icon = CreateFakeItem (); } icon.Sensitive = editing || node.Action == null || node.Action.GtkAction.Sensitive; if (!editing) { Gtk.Button but = new Gtk.Button (icon); but.Relief = Gtk.ReliefStyle.None; but.ButtonPressEvent += OnToolItemPress; but.ButtonReleaseEvent += OnMemuItemRelease; but.MotionNotifyEvent += OnMotionNotify; but.Events |= Gdk.EventMask.PointerMotionMask; icon = but; } Add (icon); ShowAll (); }
public static Gdk.Pixbuf LoadIcon (string name, Gtk.IconSize size) { if (renderer == null) renderer = new Gtk.HBox (); Gdk.Pixbuf image = renderer.RenderIcon (name, size, null); if (image != null) return image; int w, h; Gtk.Icon.SizeLookup (size, out w, out h); try { return Gtk.IconTheme.Default.LoadIcon (name, w, 0); } catch { // Icon not in theme return MissingIcon; } }
void AddCreateItemLabel() { HideSpacerItem (); Gtk.Label emptyLabel = new Gtk.Label (); emptyLabel.Xalign = 0; emptyLabel.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("Click to create menu") + "</span></i>"; Gtk.MenuItem mit = new Gtk.MenuItem (); mit.Child = emptyLabel; mit.ButtonPressEvent += OnNewItemPress; Insert (mit, -1); mit.ShowAll (); addLabel = mit; }
public GraphicsHandler(Gtk.Widget widget, Gdk.Window drawable) { this.widget = widget; this.Control = Gdk.CairoHelper.Create(drawable); }
void HideSpacerItem() { if (spacerItem != null) { Remove (spacerItem); spacerItem = null; } }
public override Gtk.Container.ContainerChild this [Gtk.Widget child] { get { return(new ButtonBoxChild(this, child)); } }
// Call this from a DragDrop event to receive the dragged widget public static void Drop(Gdk.DragContext ctx, uint time, ObjectWrapper targetWrapper, string dropData) { if (dropCallback == null) { Gtk.Widget w = Drop (ctx, (Gtk.Widget) targetWrapper.Wrapped, time); targetWrapper.DropObject (dropData, w); return; } Cancel (); Gtk.Drag.Finish (ctx, true, true, time); Gtk.Application.Invoke (delegate { IProject project = targetWrapper.Project; string uid = targetWrapper.UndoId; string tname = ((Wrapper.Widget)targetWrapper).GetTopLevel ().Wrapped.Name; // This call may cause the project to be reloaded dragWidget = dropCallback (); if (dragWidget == null) return; if (targetWrapper.IsDisposed) { // The project has been reloaded. Find the wrapper again. Gtk.Widget twidget = project.GetTopLevel (tname); ObjectWrapper ow = ObjectWrapper.Lookup (twidget); if (ow != null) targetWrapper = ow.FindObjectByUndoId (uid); else targetWrapper = null; if (targetWrapper == null) { // Target wrapper not found. Just ignore the drop. return; } } targetWrapper.DropObject (dropData, dragWidget); }); }
// Drag function for automatic sources, called from DragBegin static void Drag(Gtk.Widget source, Gdk.DragContext ctx, WidgetDropCallback dropCallback, Gtk.Widget dragWidget) { if (ctx == null) return; Gtk.Window dragWin; Gtk.Requisition req; ShowFaults (); DND.dragWidget = dragWidget; DND.dropCallback = dropCallback; dragWin = new Gtk.Window (Gtk.WindowType.Popup); dragWin.Add (dragWidget); req = dragWidget.SizeRequest (); if (req.Width < 20 && req.Height < 20) dragWin.SetSizeRequest (20, 20); else if (req.Width < 20) dragWin.SetSizeRequest (20, -1); else if (req.Height < 20) dragWin.SetSizeRequest (-1, 20); req = dragWin.SizeRequest (); int px, py, rx, ry; Gdk.ModifierType pmask; ctx.SourceWindow.GetPointer (out px, out py, out pmask); ctx.SourceWindow.GetRootOrigin (out rx, out ry); dragWin.Move (rx + px, ry + py); dragWin.Show (); dragHotX = req.Width / 2; dragHotY = -3; Gtk.Drag.SetIconWidget (ctx, dragWin, dragHotX, dragHotY); if (source != null) { source.DragDataGet += DragDataGet; source.DragEnd += DragEnded; } }
public override void GetSize(Gtk.Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height) { base.GetSize(widget, ref cell_area, out x_offset, out y_offset, out width, out height); height = Math.Max(height, Handler.Source.RowHeight); }
internal protected virtual Gtk.ToolItem CreateToolItem(CommandManager manager) { if (cmdId == CommandManager.ToCommandId(Command.Separator)) { return(new Gtk.SeparatorToolItem()); } Command cmd = GetCommand(manager); if (cmd == null) { return(new Gtk.ToolItem()); } if (cmd is CustomCommand) { Gtk.Widget child = (Gtk.Widget)Activator.CreateInstance(((CustomCommand)cmd).WidgetType); Gtk.ToolItem ti; if (child is Gtk.ToolItem) { ti = (Gtk.ToolItem)child; } else { ti = new Gtk.ToolItem(); ti.Child = child; } if (cmd.Text != null && cmd.Text.Length > 0) { //strip "_" accelerators from tooltips string text = cmd.Text; while (true) { int underscoreIndex = text.IndexOf('_'); if (underscoreIndex > -1) { text = text.Remove(underscoreIndex, 1); } else { break; } } ti.TooltipText = text; } return(ti); } ActionCommand acmd = cmd as ActionCommand; if (acmd == null) { throw new InvalidOperationException("Unknown cmd type."); } if (acmd.CommandArray) { CommandMenu menu = new CommandMenu(manager); menu.Append(CreateMenuItem(manager)); return(new MenuToolButton(menu, acmd.Icon)); } else if (acmd.ActionType == ActionType.Normal) { return(new CommandToolButton(cmdId, manager)); } else { return(new CommandToggleToolButton(cmdId, manager)); } }
protected override void OnAdded(Gtk.Widget widget) { base.OnAdded (widget); child = widget; }
protected override void SetContainerContent(Gtk.Widget content) { this.content.Add(content); }
Control IOptionsPanel.CreatePanelWidget () { Gtk.VBox cbox = new Gtk.VBox (false, 6); Gtk.HBox combosBox = new Gtk.HBox (false, 6); cbox.PackStart (combosBox, false, false, 0); combosBox.PackStart (new Gtk.Label (GettextCatalog.GetString ("Configuration:")), false, false, 0); configListStore = new Gtk.ListStore (typeof(string), typeof(string)); configCombo = new Gtk.ComboBox (configListStore); var cell = new Gtk.CellRendererText (); configCombo.PackStart (cell, true); configCombo.AddAttribute (cell, "text", 0); combosBox.PackStart (configCombo, false, false, 0); combosBox.PackStart (new Gtk.Label (GettextCatalog.GetString ("Platform:")), false, false, 0); platformCombo = Gtk.ComboBox.NewText (); combosBox.PackStart (platformCombo, false, false, 0); cbox.PackStart (new Gtk.HSeparator (), false, false, 0); cbox.ShowAll (); cbox.Hidden += OnPageHidden; cbox.Shown += OnPageShown; lastConfigSelection = -1; lastPlatformSelection = -1; FillConfigurations (); UpdateSelection (); configCombo.Changed += OnConfigChanged; platformCombo.Changed += OnConfigChanged; bool oldMixed = allowMixedConfigurations; Gtk.Widget child = CreatePanelWidget (); //HACK: work around bug 469427 - broken themes match on widget names if (child.Name.IndexOf ("Panel") > 0) child.Name = child.Name.Replace ("Panel", "_"); cbox.PackStart (child, true, true, 0); if (allowMixedConfigurations != oldMixed) { // If mixed mode has changed, update the configuration list FillConfigurations (); UpdateSelection (); } widgetCreated = true; panelWidget = child; if (currentConfigs.Count > 0) { panelWidget.Sensitive = true; LoadConfigData (); } else panelWidget.Sensitive = false; return cbox; }
public Gdk.Pixbuf ToPixbuf(ApplicationContext actx, Gtk.Widget w) { return(GetBestFrame(actx, Util.GetScaleFactor(w), DefaultSize.Width, DefaultSize.Height, true)); }
// Call this from a DragEnd event to check if the widget wasn't dropped public static Gtk.Widget Cancel() { if (dragWidget == null) return null; Gtk.Widget w = dragWidget; dragWidget = null; // Remove the widget from its dragWindow Gtk.Container parent = w.Parent as Gtk.Container; if (parent != null) { parent.Remove (w); parent.Destroy (); } return w; }
public Gdk.Pixbuf GetBestFrame(ApplicationContext actx, Gtk.Widget w, double width, double height, bool forceExactSize) { return(GetBestFrame(actx, Util.GetScaleFactor(w), width, height, forceExactSize)); }
public static Gtk.Widget Drop(Gdk.DragContext ctx, Gtk.Widget target, uint time) { if (dropCallback != null) { dragWidget = dropCallback (); } if (dragWidget == null) { Gtk.Drag.GetData (target, ctx, GladeUtils.ApplicationXGladeAtom, time); return null; } Gtk.Widget w = Cancel (); Gtk.Drag.Finish (ctx, true, true, time); return w; }
void Update(CommandInfo cmdInfo) { lastCmdInfo = cmdInfo; Gtk.Widget child = Child; if (child == null) { return; } updating = true; Gtk.Label accel_label = null; Gtk.Label label = null; if (!(child is Gtk.HBox)) { child = new Gtk.HBox(false, 0); accel_label = new Gtk.Label(""); accel_label.UseUnderline = false; accel_label.Xalign = 1.0f; accel_label.Show(); label = new Gtk.Label(""); label.UseUnderline = true; label.Xalign = 0.0f; label.Show(); ((Gtk.Box)child).PackStart(label); ((Gtk.Box)child).PackStart(accel_label); child.Show(); this.Remove(Child); this.Add(child); } else { accel_label = (Gtk.Label)((Gtk.Box)child).Children[1]; label = (Gtk.Label)((Gtk.Box)child).Children[0]; } if (cmdInfo.AccelKey != null) { accel_label.Text = " " + KeyBindingManager.BindingToDisplayLabel(cmdInfo.AccelKey, true); } else { accel_label.Text = String.Empty; } if (cmdInfo.UseMarkup) { label.Markup = overrideLabel ?? cmdInfo.Text; label.UseMarkup = true; } else { label.Text = overrideLabel ?? cmdInfo.Text; label.UseMarkup = false; } label.UseUnderline = true; Sensitive = cmdInfo.Enabled; Visible = cmdInfo.Visible && (disabledVisible || cmdInfo.Enabled); Active = cmdInfo.Checked; Inconsistent = cmdInfo.CheckedInconsistent; updating = false; }
static void DragEnded(object obj, Gtk.DragEndArgs args) { dragWidget = null; HideFaults (); ((Gtk.Widget)obj).DragEnd -= DragEnded; ((Gtk.Widget)obj).DragDataGet -= DragDataGet; }
public static WidgetMap GenerateCreationCode(CodeNamespace cns, CodeTypeDeclaration type, Gtk.Widget w, CodeExpression widgetVarExp, CodeStatementCollection statements, GenerationOptions options, ArrayList warnings) { statements.Add(new CodeCommentStatement("Widget " + w.Name)); GeneratorContext ctx = new ProjectGeneratorContext(cns, type, statements, options); Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup(w); ctx.GenerateCreationCode(ww, widgetVarExp); ctx.EndGeneration(); warnings.AddRange(ctx.Warnings); return(ctx.WidgetMap); }
private void OnAdded (object sender, Gtk.AddedArgs args) { this.child = args.Widget; }
private void OnAdded(object sender, Gtk.AddedArgs args) { this.child = args.Widget; }