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 gtk.c.functions;
36 public  import gtk.c.types;
37 public  import gtkc.gtktypes;
38 
39 
40 /** */
41 public struct DragAndDrop
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 	 * Returns: 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 drag operation to a given widget.
213 	 * GTK+ will not destroy the widget, 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 	 * Params:
218 	 *     context = the context for a drag. (This must be called
219 	 *         with a context for the source side of a drag)
220 	 *     widget = a widget to use as an icon
221 	 *     hotX = the X offset within @widget of the hotspot
222 	 *     hotY = the Y offset within @widget of the hotspot
223 	 */
224 	public static void dragSetIconWidget(DragContext context, Widget widget, int hotX, int hotY)
225 	{
226 		gtk_drag_set_icon_widget((context is null) ? null : context.getDragContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), hotX, hotY);
227 	}
228 
229 	/**
230 	 * Draws a text caret on @cr at @location. This is not a style function
231 	 * but merely a convenience function for drawing the standard cursor shape.
232 	 *
233 	 * Deprecated: Use gtk_render_insertion_cursor() instead.
234 	 *
235 	 * Params:
236 	 *     widget = a #GtkWidget
237 	 *     cr = cairo context to draw to
238 	 *     location = location where to draw the cursor (@location->width is ignored)
239 	 *     isPrimary = if the cursor should be the primary cursor color.
240 	 *     direction = whether the cursor is left-to-right or
241 	 *         right-to-left. Should never be #GTK_TEXT_DIR_NONE
242 	 *     drawArrow = %TRUE to draw a directional arrow on the
243 	 *         cursor. Should be %FALSE unless the cursor is split.
244 	 *
245 	 * Since: 3.0
246 	 */
247 	public static void drawInsertionCursor(Widget widget, Context cr, GdkRectangle* location, bool isPrimary, GtkTextDirection direction, bool drawArrow)
248 	{
249 		gtk_draw_insertion_cursor((widget is null) ? null : widget.getWidgetStruct(), (cr is null) ? null : cr.getContextStruct(), location, isPrimary, direction, drawArrow);
250 	}
251 }