1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
|
/*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gdk.Cursor;
private import cairo.Surface;
private import gdk.Display;
private import gdk.c.functions;
public import gdk.c.types;
private import gdkpixbuf.Pixbuf;
private import glib.ConstructionException;
private import glib.Str;
private import gobject.ObjectG;
public import gtkc.gdktypes;
/**
* A #GdkCursor represents a cursor. Its contents are private.
*/
public class Cursor : ObjectG
{
/** the main Gtk struct */
protected GdkCursor* gdkCursor;
/** Get the main Gtk struct */
public GdkCursor* getCursorStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gdkCursor;
}
/** the main Gtk struct as a void* */
protected override void* getStruct()
{
return cast(void*)gdkCursor;
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GdkCursor* gdkCursor, bool ownedRef = false)
{
this.gdkCursor = gdkCursor;
super(cast(GObject*)gdkCursor, ownedRef);
}
/** */
public static GType getType()
{
return gdk_cursor_get_type();
}
/**
* Creates a new cursor from the set of builtin cursors for the default display.
* See gdk_cursor_new_for_display().
*
* To make the cursor invisible, use %GDK_BLANK_CURSOR.
*
* Deprecated: Use gdk_cursor_new_for_display() instead.
*
* Params:
* cursorType = cursor to create
*
* Returns: a new #GdkCursor
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(GdkCursorType cursorType)
{
auto p = gdk_cursor_new(cursorType);
if(p is null)
{
throw new ConstructionException("null returned by new");
}
this(cast(GdkCursor*) p, true);
}
/**
* Creates a new cursor from the set of builtin cursors.
*
* Params:
* display = the #GdkDisplay for which the cursor will be created
* cursorType = cursor to create
*
* Returns: a new #GdkCursor
*
* Since: 2.2
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(Display display, GdkCursorType cursorType)
{
auto p = gdk_cursor_new_for_display((display is null) ? null : display.getDisplayStruct(), cursorType);
if(p is null)
{
throw new ConstructionException("null returned by new_for_display");
}
this(cast(GdkCursor*) p, true);
}
/**
* Creates a new cursor by looking up @name in the current cursor
* theme.
*
* A recommended set of cursor names that will work across different
* platforms can be found in the CSS specification:
* - "none"
* -  "default"
* -  "help"
* -  "pointer"
* -  "context-menu"
* -  "progress"
* -  "wait"
* -  "cell"
* -  "crosshair"
* -  "text"
* -  "vertical-text"
* -  "alias"
* -  "copy"
* -  "no-drop"
* -  "move"
* -  "not-allowed"
* -  "grab"
* -  "grabbing"
* -  "all-scroll"
* -  "col-resize"
* -  "row-resize"
* -  "n-resize"
* -  "e-resize"
* -  "s-resize"
* -  "w-resize"
* -  "ne-resize"
* -  "nw-resize"
* -  "sw-resize"
* -  "se-resize"
* -  "ew-resize"
* -  "ns-resize"
* -  "nesw-resize"
* -  "nwse-resize"
* -  "zoom-in"
* -  "zoom-out"
*
* Params:
* display = the #GdkDisplay for which the cursor will be created
* name = the name of the cursor
*
* Returns: a new #GdkCursor, or %NULL if there is no
* cursor with the given name
*
* Since: 2.8
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(Display display, string name)
{
auto p = gdk_cursor_new_from_name((display is null) ? null : display.getDisplayStruct(), Str.toStringz(name));
if(p is null)
{
throw new ConstructionException("null returned by new_from_name");
}
this(cast(GdkCursor*) p, true);
}
/**
* Creates a new cursor from a pixbuf.
*
* Not all GDK backends support RGBA cursors. If they are not
* supported, a monochrome approximation will be displayed.
* The functions gdk_display_supports_cursor_alpha() and
* gdk_display_supports_cursor_color() can be used to determine
* whether RGBA cursors are supported;
* gdk_display_get_default_cursor_size() and
* gdk_display_get_maximal_cursor_size() give information about
* cursor sizes.
*
* If @x or @y are `-1`, the pixbuf must have
* options named “x_hot” and “y_hot”, resp., containing
* integer values between `0` and the width resp. height of
* the pixbuf. (Since: 3.0)
*
* On the X backend, support for RGBA cursors requires a
* sufficently new version of the X Render extension.
*
* Params:
* display = the #GdkDisplay for which the cursor will be created
* pixbuf = the #GdkPixbuf containing the cursor image
* x = the horizontal offset of the “hotspot” of the cursor.
* y = the vertical offset of the “hotspot” of the cursor.
*
* Returns: a new #GdkCursor.
*
* Since: 2.4
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(Display display, Pixbuf pixbuf, int x, int y)
{
auto p = gdk_cursor_new_from_pixbuf((display is null) ? null : display.getDisplayStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), x, y);
if(p is null)
{
throw new ConstructionException("null returned by new_from_pixbuf");
}
this(cast(GdkCursor*) p, true);
}
/**
* Creates a new cursor from a cairo image surface.
*
* Not all GDK backends support RGBA cursors. If they are not
* supported, a monochrome approximation will be displayed.
* The functions gdk_display_supports_cursor_alpha() and
* gdk_display_supports_cursor_color() can be used to determine
* whether RGBA cursors are supported;
* gdk_display_get_default_cursor_size() and
* gdk_display_get_maximal_cursor_size() give information about
* cursor sizes.
*
* On the X backend, support for RGBA cursors requires a
* sufficently new version of the X Render extension.
*
* Params:
* display = the #GdkDisplay for which the cursor will be created
* surface = the cairo image surface containing the cursor pixel data
* x = the horizontal offset of the “hotspot” of the cursor
* y = the vertical offset of the “hotspot” of the cursor
*
* Returns: a new #GdkCursor.
*
* Since: 3.10
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(Display display, Surface surface, double x, double y)
{
auto p = gdk_cursor_new_from_surface((display is null) ? null : display.getDisplayStruct(), (surface is null) ? null : surface.getSurfaceStruct(), x, y);
if(p is null)
{
throw new ConstructionException("null returned by new_from_surface");
}
this(cast(GdkCursor*) p, true);
}
/**
* Returns the cursor type for this cursor.
*
* Returns: a #GdkCursorType
*
* Since: 2.22
*/
public GdkCursorType getCursorType()
{
return gdk_cursor_get_cursor_type(gdkCursor);
}
/**
* Returns the display on which the #GdkCursor is defined.
*
* Returns: the #GdkDisplay associated to @cursor
*
* Since: 2.2
*/
public Display getDisplay()
{
auto p = gdk_cursor_get_display(gdkCursor);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p);
}
/**
* Returns a #GdkPixbuf with the image used to display the cursor.
*
* Note that depending on the capabilities of the windowing system and
* on the cursor, GDK may not be able to obtain the image data. In this
* case, %NULL is returned.
*
* Returns: a #GdkPixbuf representing
* @cursor, or %NULL
*
* Since: 2.8
*/
public Pixbuf getImage()
{
auto p = gdk_cursor_get_image(gdkCursor);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
}
/**
* Returns a cairo image surface with the image used to display the cursor.
*
* Note that depending on the capabilities of the windowing system and
* on the cursor, GDK may not be able to obtain the image data. In this
* case, %NULL is returned.
*
* Params:
* xHot = Location to store the hotspot x position,
* or %NULL
* yHot = Location to store the hotspot y position,
* or %NULL
*
* Returns: a #cairo_surface_t
* representing @cursor, or %NULL
*
* Since: 3.10
*/
public Surface getSurface(out double xHot, out double yHot)
{
auto p = gdk_cursor_get_surface(gdkCursor, &xHot, &yHot);
if(p is null)
{
return null;
}
return new Surface(cast(cairo_surface_t*) p);
}
alias doref = ref_;
/**
* Adds a reference to @cursor.
*
* Deprecated: Use g_object_ref() instead
*
* Returns: Same @cursor that was passed in
*/
public override Cursor ref_()
{
auto p = gdk_cursor_ref(gdkCursor);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Cursor)(cast(GdkCursor*) p, true);
}
/**
* Removes a reference from @cursor, deallocating the cursor
* if no references remain.
*
* Deprecated: Use g_object_unref() instead
*/
public override void unref()
{
gdk_cursor_unref(gdkCursor);
}
}
|