1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.DragIcon; 26 27 private import gdk.Drag; 28 private import gdk.PaintableIF; 29 private import gobject.ObjectG; 30 private import gobject.Value; 31 private import gtk.NativeIF; 32 private import gtk.NativeT; 33 private import gtk.RootIF; 34 private import gtk.RootT; 35 private import gtk.Widget; 36 private import gtk.c.functions; 37 public import gtk.c.types; 38 39 40 /** 41 * `GtkDragIcon` is a `GtkRoot` implementation for drag icons. 42 * 43 * A drag icon moves with the pointer during a Drag-and-Drop operation 44 * and is destroyed when the drag ends. 45 * 46 * To set up a drag icon and associate it with an ongoing drag operation, 47 * use [func@Gtk.DragIcon.get_for_drag] to get the icon for a drag. You can 48 * then use it like any other widget and use [method@Gtk.DragIcon.set_child] 49 * to set whatever widget should be used for the drag icon. 50 * 51 * Keep in mind that drag icons do not allow user input. 52 */ 53 public class DragIcon : Widget, NativeIF, RootIF 54 { 55 /** the main Gtk struct */ 56 protected GtkDragIcon* gtkDragIcon; 57 58 /** Get the main Gtk struct */ 59 public GtkDragIcon* getDragIconStruct(bool transferOwnership = false) 60 { 61 if (transferOwnership) 62 ownedRef = false; 63 return gtkDragIcon; 64 } 65 66 /** the main Gtk struct as a void* */ 67 protected override void* getStruct() 68 { 69 return cast(void*)gtkDragIcon; 70 } 71 72 /** 73 * Sets our main struct and passes it to the parent class. 74 */ 75 public this (GtkDragIcon* gtkDragIcon, bool ownedRef = false) 76 { 77 this.gtkDragIcon = gtkDragIcon; 78 super(cast(GtkWidget*)gtkDragIcon, ownedRef); 79 } 80 81 // add the Native capabilities 82 mixin NativeT!(GtkDragIcon); 83 84 // add the Root capabilities 85 mixin RootT!(GtkDragIcon); 86 87 88 /** */ 89 public static GType getType() 90 { 91 return gtk_drag_icon_get_type(); 92 } 93 94 /** 95 * Creates a widget that can be used as a drag icon for the given 96 * @value. 97 * 98 * Supported types include strings, `GdkRGBA` and `GtkTextBuffer`. 99 * If GTK does not know how to create a widget for a given value, 100 * it will return %NULL. 101 * 102 * This method is used to set the default drag icon on drag'n'drop 103 * operations started by `GtkDragSource`, so you don't need to set 104 * a drag icon using this function there. 105 * 106 * Params: 107 * value = a `GValue` 108 * 109 * Returns: A new `GtkWidget` 110 * for displaying @value as a drag icon. 111 */ 112 public static Widget createWidgetForValue(Value value) 113 { 114 auto __p = gtk_drag_icon_create_widget_for_value((value is null) ? null : value.getValueStruct()); 115 116 if(__p is null) 117 { 118 return null; 119 } 120 121 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p, true); 122 } 123 124 /** 125 * Gets the `GtkDragIcon` in use with @drag. 126 * 127 * If no drag icon exists yet, a new one will be created 128 * and shown. 129 * 130 * Params: 131 * drag = a `GdkDrag` 132 * 133 * Returns: the `GtkDragIcon` 134 */ 135 public static Widget getForDrag(Drag drag) 136 { 137 auto __p = gtk_drag_icon_get_for_drag((drag is null) ? null : drag.getDragStruct()); 138 139 if(__p is null) 140 { 141 return null; 142 } 143 144 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 145 } 146 147 /** 148 * Creates a `GtkDragIcon` that shows @paintable, and associates 149 * it with the drag operation. 150 * 151 * The hotspot position on the paintable is aligned with the 152 * hotspot of the cursor. 153 * 154 * Params: 155 * drag = a `GdkDrag` 156 * paintable = a `GdkPaintable` to display 157 * hotX = X coordinate of the hotspot 158 * hotY = Y coordinate of the hotspot 159 */ 160 public static void setFromPaintable(Drag drag, PaintableIF paintable, int hotX, int hotY) 161 { 162 gtk_drag_icon_set_from_paintable((drag is null) ? null : drag.getDragStruct(), (paintable is null) ? null : paintable.getPaintableStruct(), hotX, hotY); 163 } 164 165 /** 166 * Gets the widget currently used as drag icon. 167 * 168 * Returns: The drag icon or %NULL if none. 169 */ 170 public Widget getChild() 171 { 172 auto __p = gtk_drag_icon_get_child(gtkDragIcon); 173 174 if(__p is null) 175 { 176 return null; 177 } 178 179 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 180 } 181 182 /** 183 * Sets the widget to display as the drag icon. 184 * 185 * Params: 186 * child = a `GtkWidget` or %NULL 187 */ 188 public void setChild(Widget child) 189 { 190 gtk_drag_icon_set_child(gtkDragIcon, (child is null) ? null : child.getWidgetStruct()); 191 } 192 }