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.DragAndDrop; 26 27 private import cairo.Context; 28 private import cairo.Surface; 29 private import gdk.DragContext; 30 private import gdkpixbuf.Pixbuf; 31 private import gio.IconIF; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 private import gtk.Widget; 35 private import gtkc.gtk; 36 public import gtkc.gtktypes; 37 38 39 public struct DragAndDrop 40 { 41 /** 42 */ 43 44 /** 45 * Cancels an ongoing drag operation on the source side. 46 * 47 * If you want to be able to cancel a drag operation in this way, 48 * you need to keep a pointer to the drag context, either from an 49 * explicit call to gtk_drag_begin_with_coordinates(), or by 50 * connecting to #GtkWidget::drag-begin. 51 * 52 * If @context does not refer to an ongoing drag operation, this 53 * function does nothing. 54 * 55 * If a drag is cancelled in this way, the @result argument of 56 * #GtkWidget::drag-failed is set to @GTK_DRAG_RESULT_ERROR. 57 * 58 * Params: 59 * context = a #GdkDragContext, as e.g. returned by gtk_drag_begin_with_coordinates() 60 * 61 * Since: 3.16 62 */ 63 public static void dragCancel(DragContext context) 64 { 65 gtk_drag_cancel((context is null) ? null : context.getDragContextStruct()); 66 } 67 68 /** 69 * Informs the drag source that the drop is finished, and 70 * that the data of the drag will no longer be required. 71 * 72 * Params: 73 * context = the drag context 74 * success = a flag indicating whether the drop was successful 75 * del = a flag indicating whether the source should delete the 76 * original data. (This should be %TRUE for a move) 77 * time = the timestamp from the #GtkWidget::drag-drop signal 78 */ 79 public static void dragFinish(DragContext context, bool success, bool del, uint time) 80 { 81 gtk_drag_finish((context is null) ? null : context.getDragContextStruct(), success, del, time); 82 } 83 84 /** 85 * Determines the source widget for a drag. 86 * 87 * Params: 88 * context = a (destination side) drag context 89 * 90 * Return: if the drag is occurring 91 * within a single application, a pointer to the source widget. 92 * Otherwise, %NULL. 93 */ 94 public static Widget dragGetSourceWidget(DragContext context) 95 { 96 auto p = gtk_drag_get_source_widget((context is null) ? null : context.getDragContextStruct()); 97 98 if(p is null) 99 { 100 return null; 101 } 102 103 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 104 } 105 106 /** 107 * Sets the icon for a particular drag to the default 108 * icon. 109 * 110 * Params: 111 * context = the context for a drag (This must be called 112 * with a context for the source side of a drag) 113 */ 114 public static void dragSetIconDefault(DragContext context) 115 { 116 gtk_drag_set_icon_default((context is null) ? null : context.getDragContextStruct()); 117 } 118 119 /** 120 * Sets the icon for a given drag from the given @icon. 121 * See the documentation for gtk_drag_set_icon_name() 122 * for more details about using icons in drag and drop. 123 * 124 * Params: 125 * context = the context for a drag (This must be called 126 * with a context for the source side of a drag) 127 * icon = a #GIcon 128 * hotX = the X offset of the hotspot within the icon 129 * hotY = the Y offset of the hotspot within the icon 130 * 131 * Since: 3.2 132 */ 133 public static void dragSetIconGicon(DragContext context, IconIF icon, int hotX, int hotY) 134 { 135 gtk_drag_set_icon_gicon((context is null) ? null : context.getDragContextStruct(), (icon is null) ? null : icon.getIconStruct(), hotX, hotY); 136 } 137 138 /** 139 * Sets the icon for a given drag from a named themed icon. See 140 * the docs for #GtkIconTheme for more details. Note that the 141 * size of the icon depends on the icon theme (the icon is 142 * loaded at the symbolic size #GTK_ICON_SIZE_DND), thus 143 * @hot_x and @hot_y have to be used with care. 144 * 145 * Params: 146 * context = the context for a drag (This must be called 147 * with a context for the source side of a drag) 148 * iconName = name of icon to use 149 * hotX = the X offset of the hotspot within the icon 150 * hotY = the Y offset of the hotspot within the icon 151 * 152 * Since: 2.8 153 */ 154 public static void dragSetIconName(DragContext context, string iconName, int hotX, int hotY) 155 { 156 gtk_drag_set_icon_name((context is null) ? null : context.getDragContextStruct(), Str.toStringz(iconName), hotX, hotY); 157 } 158 159 /** 160 * Sets @pixbuf as the icon for a given drag. 161 * 162 * Params: 163 * context = the context for a drag (This must be called 164 * with a context for the source side of a drag) 165 * pixbuf = the #GdkPixbuf to use as the drag icon 166 * hotX = the X offset within @widget of the hotspot 167 * hotY = the Y offset within @widget of the hotspot 168 */ 169 public static void dragSetIconPixbuf(DragContext context, Pixbuf pixbuf, int hotX, int hotY) 170 { 171 gtk_drag_set_icon_pixbuf((context is null) ? null : context.getDragContextStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), hotX, hotY); 172 } 173 174 /** 175 * Sets the icon for a given drag from a stock ID. 176 * 177 * Deprecated: Use gtk_drag_set_icon_name() instead. 178 * 179 * Params: 180 * context = the context for a drag (This must be called 181 * with a context for the source side of a drag) 182 * stockId = the ID of the stock icon to use for the drag 183 * hotX = the X offset within the icon of the hotspot 184 * hotY = the Y offset within the icon of the hotspot 185 */ 186 public static void dragSetIconStock(DragContext context, string stockId, int hotX, int hotY) 187 { 188 gtk_drag_set_icon_stock((context is null) ? null : context.getDragContextStruct(), Str.toStringz(stockId), hotX, hotY); 189 } 190 191 /** 192 * Sets @surface as the icon for a given drag. GTK+ retains 193 * references for the arguments, and will release them when 194 * they are no longer needed. 195 * 196 * To position the surface relative to the mouse, use 197 * cairo_surface_set_device_offset() on @surface. The mouse 198 * cursor will be positioned at the (0,0) coordinate of the 199 * surface. 200 * 201 * Params: 202 * context = the context for a drag (This must be called 203 * with a context for the source side of a drag) 204 * surface = the surface to use as icon 205 */ 206 public static void dragSetIconSurface(DragContext context, Surface surface) 207 { 208 gtk_drag_set_icon_surface((context is null) ? null : context.getDragContextStruct(), (surface is null) ? null : surface.getSurfaceStruct()); 209 } 210 211 /** 212 * Changes the icon for a widget to a given widget. 213 * GTK+ will not destroy the icon, so if you don’t want 214 * it to persist, you should connect to the “drag-end” 215 * signal and destroy it yourself. 216 * 217 * GTK+ will, however, change the opacity and position of 218 * the window as part of the drag animation. If you want 219 * to reuse the window, you have to restore these to 220 * the values you need after each drag operation. 221 * 222 * Params: 223 * context = the context for a drag. (This must be called 224 * with a context for the source side of a drag) 225 * widget = a toplevel window to use as an icon 226 * hotX = the X offset within @widget of the hotspot 227 * hotY = the Y offset within @widget of the hotspot 228 */ 229 public static void dragSetIconWidget(DragContext context, Widget widget, int hotX, int hotY) 230 { 231 gtk_drag_set_icon_widget((context is null) ? null : context.getDragContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), hotX, hotY); 232 } 233 234 /** 235 * Draws a text caret on @cr at @location. This is not a style function 236 * but merely a convenience function for drawing the standard cursor shape. 237 * 238 * Deprecated: Use gtk_render_insertion_cursor() instead. 239 * 240 * Params: 241 * widget = a #GtkWidget 242 * cr = cairo context to draw to 243 * location = location where to draw the cursor (@location->width is ignored) 244 * isPrimary = if the cursor should be the primary cursor color. 245 * direction = whether the cursor is left-to-right or 246 * right-to-left. Should never be #GTK_TEXT_DIR_NONE 247 * drawArrow = %TRUE to draw a directional arrow on the 248 * cursor. Should be %FALSE unless the cursor is split. 249 * 250 * Since: 3.0 251 */ 252 public static void drawInsertionCursor(Widget widget, Context cr, GdkRectangle* location, bool isPrimary, GtkTextDirection direction, bool drawArrow) 253 { 254 gtk_draw_insertion_cursor((widget is null) ? null : widget.getWidgetStruct(), (cr is null) ? null : cr.getContextStruct(), location, isPrimary, direction, drawArrow); 255 } 256 }