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 * Conversion parameters: 26 * inFile = gdk3-Cursors.html 27 * outPack = gdk 28 * outFile = Cursor 29 * strct = GdkCursor 30 * realStrct= 31 * ctorStrct= 32 * clss = Cursor 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_cursor_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * - gdk_cursor_ref 45 * - gdk_cursor_unref 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - cairo.Surface 50 * - gdk.Display 51 * - gdk.Pixbuf 52 * structWrap: 53 * - GdkDisplay* -> Display 54 * - GdkPixbuf* -> Pixbuf 55 * - cairo_surface_t* -> Surface 56 * module aliases: 57 * local aliases: 58 * overrides: 59 */ 60 61 module gdk.Cursor; 62 63 public import gtkc.gdktypes; 64 65 private import gtkc.gdk; 66 private import glib.ConstructionException; 67 private import gobject.ObjectG; 68 69 70 private import glib.Str; 71 private import cairo.Surface; 72 private import gdk.Display; 73 private import gdk.Pixbuf; 74 75 76 77 private import gobject.ObjectG; 78 79 /** 80 * These functions are used to create and destroy cursors. 81 * There is a number of standard cursors, but it is also 82 * possible to construct new cursors from pixbufs. There 83 * may be limitations as to what kinds of cursors can be 84 * constructed on a given display, see 85 * gdk_display_supports_cursor_alpha(), 86 * gdk_display_supports_cursor_color(), 87 * gdk_display_get_default_cursor_size() and 88 * gdk_display_get_maximal_cursor_size(). 89 * 90 * Cursors by themselves are not very interesting, they must be be 91 * bound to a window for users to see them. This is done with 92 * gdk_window_set_cursor() or by setting the cursor member of the 93 * GdkWindowAttr struct passed to gdk_window_new(). 94 */ 95 public class Cursor : ObjectG 96 { 97 98 /** the main Gtk struct */ 99 protected GdkCursor* gdkCursor; 100 101 102 public GdkCursor* getCursorStruct() 103 { 104 return gdkCursor; 105 } 106 107 108 /** the main Gtk struct as a void* */ 109 protected override void* getStruct() 110 { 111 return cast(void*)gdkCursor; 112 } 113 114 /** 115 * Sets our main struct and passes it to the parent class 116 */ 117 public this (GdkCursor* gdkCursor) 118 { 119 super(cast(GObject*)gdkCursor); 120 this.gdkCursor = gdkCursor; 121 } 122 123 protected override void setStruct(GObject* obj) 124 { 125 super.setStruct(obj); 126 gdkCursor = cast(GdkCursor*)obj; 127 } 128 129 /** 130 */ 131 132 /** 133 * Creates a new cursor from the set of builtin cursors for the default display. 134 * See gdk_cursor_new_for_display(). 135 * To make the cursor invisible, use GDK_BLANK_CURSOR. 136 * Params: 137 * cursorType = cursor to create 138 * Throws: ConstructionException GTK+ fails to create the object. 139 */ 140 public this (GdkCursorType cursorType) 141 { 142 // GdkCursor * gdk_cursor_new (GdkCursorType cursor_type); 143 auto p = gdk_cursor_new(cursorType); 144 if(p is null) 145 { 146 throw new ConstructionException("null returned by gdk_cursor_new(cursorType)"); 147 } 148 this(cast(GdkCursor*) p); 149 } 150 151 /** 152 * Creates a new cursor from a pixbuf. 153 * Not all GDK backends support RGBA cursors. If they are not 154 * supported, a monochrome approximation will be displayed. 155 * The functions gdk_display_supports_cursor_alpha() and 156 * gdk_display_supports_cursor_color() can be used to determine 157 * whether RGBA cursors are supported; 158 * gdk_display_get_default_cursor_size() and 159 * gdk_display_get_maximal_cursor_size() give information about 160 * cursor sizes. 161 * If x or y are -1, the pixbuf must have 162 * options named "x_hot" and "y_hot", resp., containing 163 * integer values between 0 and the width resp. height of 164 * the pixbuf. (Since: 3.0) 165 * On the X backend, support for RGBA cursors requires a 166 * sufficently new version of the X Render extension. 167 * Since 2.4 168 * Params: 169 * display = the GdkDisplay for which the cursor will be created 170 * pixbuf = the GdkPixbuf containing the cursor image 171 * x = the horizontal offset of the 'hotspot' of the cursor. 172 * y = the vertical offset of the 'hotspot' of the cursor. 173 * Throws: ConstructionException GTK+ fails to create the object. 174 */ 175 public this (Display display, Pixbuf pixbuf, int x, int y) 176 { 177 // GdkCursor * gdk_cursor_new_from_pixbuf (GdkDisplay *display, GdkPixbuf *pixbuf, gint x, gint y); 178 auto p = gdk_cursor_new_from_pixbuf((display is null) ? null : display.getDisplayStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), x, y); 179 if(p is null) 180 { 181 throw new ConstructionException("null returned by gdk_cursor_new_from_pixbuf((display is null) ? null : display.getDisplayStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), x, y)"); 182 } 183 this(cast(GdkCursor*) p); 184 } 185 186 /** 187 * Creates a new cursor from a cairo image surface. 188 * Not all GDK backends support RGBA cursors. If they are not 189 * supported, a monochrome approximation will be displayed. 190 * The functions gdk_display_supports_cursor_alpha() and 191 * gdk_display_supports_cursor_color() can be used to determine 192 * whether RGBA cursors are supported; 193 * gdk_display_get_default_cursor_size() and 194 * gdk_display_get_maximal_cursor_size() give information about 195 * cursor sizes. 196 * On the X backend, support for RGBA cursors requires a 197 * sufficently new version of the X Render extension. 198 * Params: 199 * display = the GdkDisplay for which the cursor will be created 200 * surface = the cairo image surface containing the cursor pixel data 201 * x = the horizontal offset of the 'hotspot' of the cursor 202 * y = the vertical offset of the 'hotspot' of the cursor 203 * Throws: ConstructionException GTK+ fails to create the object. 204 */ 205 public this (Display display, Surface surface, double x, double y) 206 { 207 // GdkCursor * gdk_cursor_new_from_surface (GdkDisplay *display, cairo_surface_t *surface, gdouble x, gdouble y); 208 auto p = gdk_cursor_new_from_surface((display is null) ? null : display.getDisplayStruct(), (surface is null) ? null : surface.getSurfaceStruct(), x, y); 209 if(p is null) 210 { 211 throw new ConstructionException("null returned by gdk_cursor_new_from_surface((display is null) ? null : display.getDisplayStruct(), (surface is null) ? null : surface.getSurfaceStruct(), x, y)"); 212 } 213 this(cast(GdkCursor*) p); 214 } 215 216 /** 217 * Creates a new cursor by looking up name in the current cursor 218 * theme. 219 * Since 2.8 220 * Params: 221 * display = the GdkDisplay for which the cursor will be created 222 * name = the name of the cursor 223 * Throws: ConstructionException GTK+ fails to create the object. 224 */ 225 public this (Display display, string name) 226 { 227 // GdkCursor * gdk_cursor_new_from_name (GdkDisplay *display, const gchar *name); 228 auto p = gdk_cursor_new_from_name((display is null) ? null : display.getDisplayStruct(), Str.toStringz(name)); 229 if(p is null) 230 { 231 throw new ConstructionException("null returned by gdk_cursor_new_from_name((display is null) ? null : display.getDisplayStruct(), Str.toStringz(name))"); 232 } 233 this(cast(GdkCursor*) p); 234 } 235 236 /** 237 * Creates a new cursor from the set of builtin cursors. 238 * Since 2.2 239 * Params: 240 * display = the GdkDisplay for which the cursor will be created 241 * cursorType = cursor to create 242 * Throws: ConstructionException GTK+ fails to create the object. 243 */ 244 public this (Display display, GdkCursorType cursorType) 245 { 246 // GdkCursor * gdk_cursor_new_for_display (GdkDisplay *display, GdkCursorType cursor_type); 247 auto p = gdk_cursor_new_for_display((display is null) ? null : display.getDisplayStruct(), cursorType); 248 if(p is null) 249 { 250 throw new ConstructionException("null returned by gdk_cursor_new_for_display((display is null) ? null : display.getDisplayStruct(), cursorType)"); 251 } 252 this(cast(GdkCursor*) p); 253 } 254 255 /** 256 * Returns the display on which the GdkCursor is defined. 257 * Since 2.2 258 * Returns: the GdkDisplay associated to cursor. [transfer none] 259 */ 260 public Display getDisplay() 261 { 262 // GdkDisplay * gdk_cursor_get_display (GdkCursor *cursor); 263 auto p = gdk_cursor_get_display(gdkCursor); 264 265 if(p is null) 266 { 267 return null; 268 } 269 270 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 271 } 272 273 /** 274 * Returns a GdkPixbuf with the image used to display the cursor. 275 * Note that depending on the capabilities of the windowing system and 276 * on the cursor, GDK may not be able to obtain the image data. In this 277 * case, NULL is returned. 278 * Since 2.8 279 * Returns: a GdkPixbuf representing cursor, or NULL. [transfer full] 280 */ 281 public Pixbuf getImage() 282 { 283 // GdkPixbuf * gdk_cursor_get_image (GdkCursor *cursor); 284 auto p = gdk_cursor_get_image(gdkCursor); 285 286 if(p is null) 287 { 288 return null; 289 } 290 291 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 292 } 293 294 /** 295 * Returns a cairo image surface with the image used to display the cursor. 296 * Note that depending on the capabilities of the windowing system and 297 * on the cursor, GDK may not be able to obtain the image data. In this 298 * case, NULL is returned. 299 * Params: 300 * xHot = Location to store the hotspot x position, or NULL 301 * yHot = Location to store the hotspot y position, or NULL 302 * Returns: a cairo_surface_t representing cursor, or NULL. [transfer full] Since 3.10 303 */ 304 public Surface getSurface(out double xHot, out double yHot) 305 { 306 // cairo_surface_t * gdk_cursor_get_surface (GdkCursor *cursor, gdouble *x_hot, gdouble *y_hot); 307 auto p = gdk_cursor_get_surface(gdkCursor, &xHot, &yHot); 308 309 if(p is null) 310 { 311 return null; 312 } 313 314 return ObjectG.getDObject!(Surface)(cast(cairo_surface_t*) p); 315 } 316 317 /** 318 * Returns the cursor type for this cursor. 319 * Since 2.22 320 * Returns: a GdkCursorType 321 */ 322 public GdkCursorType getCursorType() 323 { 324 // GdkCursorType gdk_cursor_get_cursor_type (GdkCursor *cursor); 325 return gdk_cursor_get_cursor_type(gdkCursor); 326 } 327 }