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 gdk.Cursor; 26 27 private import cairo.Surface; 28 private import gdk.Display; 29 private import gdkpixbuf.Pixbuf; 30 private import glib.ConstructionException; 31 private import glib.Str; 32 private import gobject.ObjectG; 33 private import gtkc.gdk; 34 public import gtkc.gdktypes; 35 36 37 /** 38 * A #GdkCursor represents a cursor. Its contents are private. 39 */ 40 public class Cursor : ObjectG 41 { 42 /** the main Gtk struct */ 43 protected GdkCursor* gdkCursor; 44 45 /** Get the main Gtk struct */ 46 public GdkCursor* getCursorStruct() 47 { 48 return gdkCursor; 49 } 50 51 /** the main Gtk struct as a void* */ 52 protected override void* getStruct() 53 { 54 return cast(void*)gdkCursor; 55 } 56 57 protected override void setStruct(GObject* obj) 58 { 59 gdkCursor = cast(GdkCursor*)obj; 60 super.setStruct(obj); 61 } 62 63 /** 64 * Sets our main struct and passes it to the parent class. 65 */ 66 public this (GdkCursor* gdkCursor, bool ownedRef = false) 67 { 68 this.gdkCursor = gdkCursor; 69 super(cast(GObject*)gdkCursor, ownedRef); 70 } 71 72 /** 73 */ 74 75 public static GType getType() 76 { 77 return gdk_cursor_get_type(); 78 } 79 80 /** 81 * Creates a new cursor from the set of builtin cursors for the default display. 82 * See gdk_cursor_new_for_display(). 83 * 84 * To make the cursor invisible, use %GDK_BLANK_CURSOR. 85 * 86 * Params: 87 * cursorType = cursor to create 88 * 89 * Return: a new #GdkCursor 90 * 91 * Throws: ConstructionException GTK+ fails to create the object. 92 */ 93 public this(GdkCursorType cursorType) 94 { 95 auto p = gdk_cursor_new(cursorType); 96 97 if(p is null) 98 { 99 throw new ConstructionException("null returned by new"); 100 } 101 102 this(cast(GdkCursor*) p, true); 103 } 104 105 /** 106 * Creates a new cursor from the set of builtin cursors. 107 * Some useful ones are: 108 * - ![](right_ptr.png) #GDK_RIGHT_PTR (right-facing arrow) 109 * - ![](crosshair.png) #GDK_CROSSHAIR (crosshair) 110 * - ![](xterm.png) #GDK_XTERM (I-beam) 111 * - ![](watch.png) #GDK_WATCH (busy) 112 * - ![](fleur.png) #GDK_FLEUR (for moving objects) 113 * - ![](hand1.png) #GDK_HAND1 (a right-pointing hand) 114 * - ![](hand2.png) #GDK_HAND2 (a left-pointing hand) 115 * - ![](left_side.png) #GDK_LEFT_SIDE (resize left side) 116 * - ![](right_side.png) #GDK_RIGHT_SIDE (resize right side) 117 * - ![](top_left_corner.png) #GDK_TOP_LEFT_CORNER (resize northwest corner) 118 * - ![](top_right_corner.png) #GDK_TOP_RIGHT_CORNER (resize northeast corner) 119 * - ![](bottom_left_corner.png) #GDK_BOTTOM_LEFT_CORNER (resize southwest corner) 120 * - ![](bottom_right_corner.png) #GDK_BOTTOM_RIGHT_CORNER (resize southeast corner) 121 * - ![](top_side.png) #GDK_TOP_SIDE (resize top side) 122 * - ![](bottom_side.png) #GDK_BOTTOM_SIDE (resize bottom side) 123 * - ![](sb_h_double_arrow.png) #GDK_SB_H_DOUBLE_ARROW (move vertical splitter) 124 * - ![](sb_v_double_arrow.png) #GDK_SB_V_DOUBLE_ARROW (move horizontal splitter) 125 * - #GDK_BLANK_CURSOR (Blank cursor). Since 2.16 126 * 127 * Params: 128 * display = the #GdkDisplay for which the cursor will be created 129 * cursorType = cursor to create 130 * 131 * Return: a new #GdkCursor 132 * 133 * Since: 2.2 134 * 135 * Throws: ConstructionException GTK+ fails to create the object. 136 */ 137 public this(Display display, GdkCursorType cursorType) 138 { 139 auto p = gdk_cursor_new_for_display((display is null) ? null : display.getDisplayStruct(), cursorType); 140 141 if(p is null) 142 { 143 throw new ConstructionException("null returned by new_for_display"); 144 } 145 146 this(cast(GdkCursor*) p, true); 147 } 148 149 /** 150 * Creates a new cursor by looking up @name in the current cursor 151 * theme. 152 * 153 * Params: 154 * display = the #GdkDisplay for which the cursor will be created 155 * name = the name of the cursor 156 * 157 * Return: a new #GdkCursor, or %NULL if there is no 158 * cursor with the given name 159 * 160 * Since: 2.8 161 * 162 * Throws: ConstructionException GTK+ fails to create the object. 163 */ 164 public this(Display display, string name) 165 { 166 auto p = gdk_cursor_new_from_name((display is null) ? null : display.getDisplayStruct(), Str.toStringz(name)); 167 168 if(p is null) 169 { 170 throw new ConstructionException("null returned by new_from_name"); 171 } 172 173 this(cast(GdkCursor*) p, true); 174 } 175 176 /** 177 * Creates a new cursor from a pixbuf. 178 * 179 * Not all GDK backends support RGBA cursors. If they are not 180 * supported, a monochrome approximation will be displayed. 181 * The functions gdk_display_supports_cursor_alpha() and 182 * gdk_display_supports_cursor_color() can be used to determine 183 * whether RGBA cursors are supported; 184 * gdk_display_get_default_cursor_size() and 185 * gdk_display_get_maximal_cursor_size() give information about 186 * cursor sizes. 187 * 188 * If @x or @y are `-1`, the pixbuf must have 189 * options named “x_hot” and “y_hot”, resp., containing 190 * integer values between `0` and the width resp. height of 191 * the pixbuf. (Since: 3.0) 192 * 193 * On the X backend, support for RGBA cursors requires a 194 * sufficently new version of the X Render extension. 195 * 196 * Params: 197 * display = the #GdkDisplay for which the cursor will be created 198 * pixbuf = the #GdkPixbuf containing the cursor image 199 * x = the horizontal offset of the “hotspot” of the cursor. 200 * y = the vertical offset of the “hotspot” of the cursor. 201 * 202 * Return: a new #GdkCursor. 203 * 204 * Since: 2.4 205 * 206 * Throws: ConstructionException GTK+ fails to create the object. 207 */ 208 public this(Display display, Pixbuf pixbuf, int x, int y) 209 { 210 auto p = gdk_cursor_new_from_pixbuf((display is null) ? null : display.getDisplayStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), x, y); 211 212 if(p is null) 213 { 214 throw new ConstructionException("null returned by new_from_pixbuf"); 215 } 216 217 this(cast(GdkCursor*) p, true); 218 } 219 220 /** 221 * Creates a new cursor from a cairo image surface. 222 * 223 * Not all GDK backends support RGBA cursors. If they are not 224 * supported, a monochrome approximation will be displayed. 225 * The functions gdk_display_supports_cursor_alpha() and 226 * gdk_display_supports_cursor_color() can be used to determine 227 * whether RGBA cursors are supported; 228 * gdk_display_get_default_cursor_size() and 229 * gdk_display_get_maximal_cursor_size() give information about 230 * cursor sizes. 231 * 232 * On the X backend, support for RGBA cursors requires a 233 * sufficently new version of the X Render extension. 234 * 235 * Params: 236 * display = the #GdkDisplay for which the cursor will be created 237 * surface = the cairo image surface containing the cursor pixel data 238 * x = the horizontal offset of the “hotspot” of the cursor 239 * y = the vertical offset of the “hotspot” of the cursor 240 * 241 * Return: a new #GdkCursor. 242 * 243 * Since: 3.10 244 * 245 * Throws: ConstructionException GTK+ fails to create the object. 246 */ 247 public this(Display display, Surface surface, double x, double y) 248 { 249 auto p = gdk_cursor_new_from_surface((display is null) ? null : display.getDisplayStruct(), (surface is null) ? null : surface.getSurfaceStruct(), x, y); 250 251 if(p is null) 252 { 253 throw new ConstructionException("null returned by new_from_surface"); 254 } 255 256 this(cast(GdkCursor*) p, true); 257 } 258 259 /** 260 * Returns the cursor type for this cursor. 261 * 262 * Return: a #GdkCursorType 263 * 264 * Since: 2.22 265 */ 266 public GdkCursorType getCursorType() 267 { 268 return gdk_cursor_get_cursor_type(gdkCursor); 269 } 270 271 /** 272 * Returns the display on which the #GdkCursor is defined. 273 * 274 * Return: the #GdkDisplay associated to @cursor 275 * 276 * Since: 2.2 277 */ 278 public Display getDisplay() 279 { 280 auto p = gdk_cursor_get_display(gdkCursor); 281 282 if(p is null) 283 { 284 return null; 285 } 286 287 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 288 } 289 290 /** 291 * Returns a #GdkPixbuf with the image used to display the cursor. 292 * 293 * Note that depending on the capabilities of the windowing system and 294 * on the cursor, GDK may not be able to obtain the image data. In this 295 * case, %NULL is returned. 296 * 297 * Return: a #GdkPixbuf representing 298 * @cursor, or %NULL 299 * 300 * Since: 2.8 301 */ 302 public Pixbuf getImage() 303 { 304 auto p = gdk_cursor_get_image(gdkCursor); 305 306 if(p is null) 307 { 308 return null; 309 } 310 311 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true); 312 } 313 314 /** 315 * Returns a cairo image surface with the image used to display the cursor. 316 * 317 * Note that depending on the capabilities of the windowing system and 318 * on the cursor, GDK may not be able to obtain the image data. In this 319 * case, %NULL is returned. 320 * 321 * Params: 322 * xHot = Location to store the hotspot x position, 323 * or %NULL 324 * yHot = Location to store the hotspot y position, 325 * or %NULL 326 * 327 * Return: a #cairo_surface_t 328 * representing @cursor, or %NULL 329 * 330 * Since: 3.10 331 */ 332 public Surface getSurface(out double xHot, out double yHot) 333 { 334 auto p = gdk_cursor_get_surface(gdkCursor, &xHot, &yHot); 335 336 if(p is null) 337 { 338 return null; 339 } 340 341 return new Surface(cast(cairo_surface_t*) p); 342 } 343 344 /** 345 * Adds a reference to @cursor. 346 * 347 * Deprecated: Use g_object_ref() instead 348 * 349 * Return: Same @cursor that was passed in 350 */ 351 public override Cursor doref() 352 { 353 auto p = gdk_cursor_ref(gdkCursor); 354 355 if(p is null) 356 { 357 return null; 358 } 359 360 return ObjectG.getDObject!(Cursor)(cast(GdkCursor*) p, true); 361 } 362 363 /** 364 * Removes a reference from @cursor, deallocating the cursor 365 * if no references remain. 366 * 367 * Deprecated: Use g_object_unref() instead 368 */ 369 public override void unref() 370 { 371 gdk_cursor_unref(gdkCursor); 372 } 373 }