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