// 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; } }
// Drag function for automatic sources, called from DragBegin public static void Drag(Gtk.Widget source, Gdk.DragContext ctx, WidgetDropCallback dropCallback, string label) { Gtk.Frame fr = new Gtk.Frame(); fr.ShadowType = Gtk.ShadowType.Out; Gtk.HBox box = new Gtk.HBox(); box.Spacing = 3; box.BorderWidth = 3; box.PackStart(new Gtk.Image(widgetIcon), false, false, 0); Gtk.Label lab = new Gtk.Label(label); lab.Xalign = 0; box.PackStart(lab, true, true, 0); fr.Add(box); fr.ShowAll(); Drag(source, ctx, dropCallback, fr); }
// Drag function for automatic sources, called from DragBegin public static void Drag (Gtk.Widget source, Gdk.DragContext ctx, WidgetDropCallback dropCallback, string label) { Gtk.Frame fr = new Gtk.Frame (); fr.ShadowType = Gtk.ShadowType.Out; Gtk.HBox box = new Gtk.HBox (); box.Spacing = 3; box.BorderWidth = 3; box.PackStart (new Gtk.Image (widgetIcon), false, false, 0); Gtk.Label lab = new Gtk.Label (label); lab.Xalign = 0; box.PackStart (lab, true, true, 0); fr.Add (box); fr.ShowAll (); Drag (source, ctx, dropCallback, fr); }
// 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; } }