// 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(); if (ctx.SourceWindow != null) { 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 Gdk.Rectangle GetTopLevelPosition(Gtk.Widget w) { foreach (TopLevelChild info in topLevels) { if (info.Child == w) { Gtk.Requisition req = w.SizeRequest(); return(new Gdk.Rectangle(info.X, info.Y, req.Width, req.Height)); } } return(new Gdk.Rectangle(0, 0, 0, 0)); }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { if (child != null) { requisition = child.SizeRequest(); } else { requisition.Width = 0; requisition.Height = 0; } }
void AttachChildren(Gtk.Table table, uint row, uint col) { if (icon != null) { table.Attach(icon, col, col + 1, row, row + 1); Gtk.Table.TableChild tc = (Gtk.Table.TableChild)table [icon]; if (!editing) { tc.YPadding = itemSpacing; } } if (label != null) { table.Attach(label, col + 1, col + 2, row, row + 1); Gtk.Table.TableChild tc = (Gtk.Table.TableChild)table [label]; if (!editing) { tc.YPadding = itemSpacing; } label.GrabFocus(); } if (accel != null) { table.Attach(accel, col + 2, col + 3, row, row + 1); } if (minWidth > 0 && label != null) { if (label.SizeRequest().Width < minWidth) { label.WidthRequest = minWidth; } } bool sens = editing || node.Action == null || node.Action.GtkAction.Sensitive; if (icon != null) { icon.Sensitive = sens; } if (label != null) { label.Sensitive = sens; } if (accel != null) { accel.Sensitive = sens; } }
// 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 static Gtk.Requisition GetPreferredSize(this Gtk.Widget widget) { return(widget.SizeRequest()); }