alternative to assert
[gtkD.git] / src / gdk / Cursor.d
blobab87542d209bec6b5612032fc72b7ad64329e836
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gdk-Cursors.html
26 * outPack = gdk
27 * outFile = Cursor
28 * strct = GdkCursor
29 * realStrct=
30 * ctorStrct=
31 * clss = Cursor
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_cursor_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * - gdk.Pixmap
46 * - gdk.Color
47 * - gdk.Display
48 * - gdk.Pixbuf
49 * - gdk.Cursor
50 * structWrap:
51 * - GdkColor* -> Color
52 * - GdkCursor* -> Cursor
53 * - GdkDisplay* -> Display
54 * - GdkPixbuf* -> Pixbuf
55 * - GdkPixmap* -> Pixmap
56 * local aliases:
59 module gdk.Cursor;
61 private import gdk.gdktypes;
63 private import lib.gdk;
65 private import glib.Str;
66 private import gdk.Pixmap;
67 private import gdk.Color;
68 private import gdk.Display;
69 private import gdk.Pixbuf;
70 private import gdk.Cursor;
72 /**
73 * Description
74 * These functions are used to create and destroy cursors.
75 * There is a number of standard cursors, but it is also
76 * possible to construct new cursors from pixmaps and
77 * pixbufs. There may be limitations as to what kinds of
78 * cursors can be constructed on a given display, see
79 * gdk_display_supports_cursor_alpha(),
80 * gdk_display_supports_cursor_color(),
81 * gdk_display_get_default_cursor_size() and
82 * gdk_display_get_maximal_cursor_size().
83 * Cursors by themselves are not very interesting, they must be be
84 * bound to a window for users to see them. This is done with
85 * gdk_window_set_cursor() or by setting the cursor member of the
86 * GdkWindowAttr struct passed to gdk_window_new().
88 public class Cursor
91 /** the main Gtk struct */
92 protected GdkCursor* gdkCursor;
95 public GdkCursor* getCursorStruct()
97 return gdkCursor;
101 /** the main Gtk struct as a void* */
102 protected void* getStruct()
104 return cast(void*)gdkCursor;
108 * Sets our main struct and passes it to the parent class
110 public this (GdkCursor* gdkCursor)
112 this.gdkCursor = gdkCursor;
121 * Creates a new cursor from the set of builtin cursors for the default display.
122 * See gdk_cursor_new_for_display().
123 * To make the cursor invisible, use gdk_cursor_new_from_pixmap() to create
124 * a cursor with no pixels in it.
125 * cursor_type:
126 * cursor to create
127 * Returns:
128 * a new GdkCursor
130 public this (GdkCursorType cursorType)
132 // GdkCursor* gdk_cursor_new (GdkCursorType cursor_type);
133 this(cast(GdkCursor*)gdk_cursor_new(cursorType) );
137 * Creates a new cursor from a given pixmap and mask. Both the pixmap and mask
138 * must have a depth of 1 (i.e. each pixel has only 2 values - on or off).
139 * The standard cursor size is 16 by 16 pixels. You can create a bitmap
140 * from inline data as in the below example.
141 * Example6.Creating a custom cursor
142 * /+* This data is in X bitmap format, and can be created with the 'bitmap'
143 * utility. +/
144 * #define cursor1_width 16
145 * #define cursor1_height 16
146 * static unsigned char cursor1_bits[] = {
147 * 0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x20,
148 * 0x82, 0x41, 0x41, 0x82, 0x41, 0x82, 0x82, 0x41, 0x04, 0x20, 0x08, 0x10,
149 * 0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0x80, 0x01};
150 * static unsigned char cursor1mask_bits[] = {
151 * 0x80, 0x01, 0xc0, 0x03, 0x60, 0x06, 0x30, 0x0c, 0x18, 0x18, 0x8c, 0x31,
152 * 0xc6, 0x63, 0x63, 0xc6, 0x63, 0xc6, 0xc6, 0x63, 0x8c, 0x31, 0x18, 0x18,
153 * 0x30, 0x0c, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01};
154 * GdkCursor *cursor;
155 * GdkPixmap *source, *mask;
156 * GdkColor fg = { 0, 65535, 0, 0 }; /+* Red. +/
157 * GdkColor bg = { 0, 0, 0, 65535 }; /+* Blue. +/
158 * source = gdk_bitmap_create_from_data (NULL, cursor1_bits,
159 * cursor1_width, cursor1_height);
160 * mask = gdk_bitmap_create_from_data (NULL, cursor1mask_bits,
161 * cursor1_width, cursor1_height);
162 * cursor = gdk_cursor_new_from_pixmap (source, mask, fg, bg, 8, 8);
163 * gdk_pixmap_unref (source);
164 * gdk_pixmap_unref (mask);
165 * gdk_window_set_cursor (widget->window, cursor);
166 * source:
167 * the pixmap specifying the cursor.
168 * mask:
169 * the pixmap specifying the mask, which must be the same size as
170 * source.
171 * fg:
172 * the foreground color, used for the bits in the source which are 1.
173 * The color does not have to be allocated first.
174 * bg:
175 * the background color, used for the bits in the source which are 0.
176 * The color does not have to be allocated first.
177 * x:
178 * the horizontal offset of the 'hotspot' of the cursor.
179 * y:
180 * the vertical offset of the 'hotspot' of the cursor.
181 * Returns:
182 * a new GdkCursor.
184 public this (Pixmap source, Pixmap mask, Color fg, Color bg, int x, int y)
186 // GdkCursor* gdk_cursor_new_from_pixmap (GdkPixmap *source, GdkPixmap *mask, const GdkColor *fg, const GdkColor *bg, gint x, gint y);
187 this(cast(GdkCursor*)gdk_cursor_new_from_pixmap((source is null) ? null : source.getPixmapStruct(), (mask is null) ? null : mask.getPixmapStruct(), (fg is null) ? null : fg.getColorStruct(), (bg is null) ? null : bg.getColorStruct(), x, y) );
191 * Creates a new cursor from a pixbuf.
192 * Not all GDK backends support RGBA cursors. If they are not
193 * supported, a monochrome approximation will be displayed.
194 * The functions gdk_display_supports_cursor_alpha() and
195 * gdk_display_supports_cursor_color() can be used to determine
196 * whether RGBA cursors are supported;
197 * gdk_display_get_default_cursor_size() and
198 * gdk_display_get_maximal_cursor_size() give information about
199 * cursor sizes.
200 * On the X backend, support for RGBA cursors requires a
201 * sufficently new version of the X Render extension.
202 * display:
203 * the GdkDisplay for which the cursor will be created
204 * pixbuf:
205 * the GdkPixbuf containing the cursor image
206 * x:
207 * the horizontal offset of the 'hotspot' of the cursor.
208 * y:
209 * the vertical offset of the 'hotspot' of the cursor.
210 * Returns:
211 * a new GdkCursor.
212 * Since 2.4
214 public this (Display display, Pixbuf pixbuf, int x, int y)
216 // GdkCursor* gdk_cursor_new_from_pixbuf (GdkDisplay *display, GdkPixbuf *pixbuf, gint x, gint y);
217 this(cast(GdkCursor*)gdk_cursor_new_from_pixbuf((display is null) ? null : display.getDisplayStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), x, y) );
221 * Creates a new cursor by looking up name in the current cursor
222 * theme.
223 * display:
224 * the GdkDisplay for which the cursor will be created
225 * name:
226 * the name of the cursor
227 * Returns:
228 * a new GdkCursor, or NULL if there is no cursor with
229 * the given name
230 * Since 2.8
232 public this (Display display, char[] name)
234 // GdkCursor* gdk_cursor_new_from_name (GdkDisplay *display, const gchar *name);
235 this(cast(GdkCursor*)gdk_cursor_new_from_name((display is null) ? null : display.getDisplayStruct(), Str.toStringz(name)) );
239 * Creates a new cursor from the set of builtin cursors.
240 * Some useful ones are:
241 * GDK_RIGHT_PTR (right-facing arrow)
242 * GDK_CROSSHAIR (crosshair)
243 * GDK_XTERM (I-beam)
244 * GDK_WATCH (busy)
245 * GDK_FLEUR (for moving objects)
246 * GDK_HAND1 (a right-pointing hand)
247 * GDK_HAND2 (a left-pointing hand)
248 * GDK_LEFT_SIDE (resize left side)
249 * GDK_RIGHT_SIDE (resize right side)
250 * GDK_TOP_LEFT_CORNER (resize northwest corner)
251 * GDK_TOP_RIGHT_CORNER (resize northeast corner)
252 * GDK_BOTTOM_LEFT_CORNER (resize southwest corner)
253 * GDK_BOTTOM_RIGHT_CORNER (resize southeast corner)
254 * GDK_TOP_SIDE (resize top side)
255 * GDK_BOTTOM_SIDE (resize bottom side)
256 * GDK_SB_H_DOUBLE_ARROW (move vertical splitter)
257 * GDK_SB_V_DOUBLE_ARROW (move horizontal splitter)
258 * To make the cursor invisible, use gdk_cursor_new_from_pixmap() to create
259 * a cursor with no pixels in it.
260 * display:
261 * the GdkDisplay for which the cursor will be created
262 * cursor_type:
263 * cursor to create
264 * Returns:
265 * a new GdkCursor
266 * Since 2.2
268 public this (Display display, GdkCursorType cursorType)
270 // GdkCursor* gdk_cursor_new_for_display (GdkDisplay *display, GdkCursorType cursor_type);
271 this(cast(GdkCursor*)gdk_cursor_new_for_display((display is null) ? null : display.getDisplayStruct(), cursorType) );
275 * Returns the display on which the GdkCursor is defined.
276 * cursor:
277 * a GdkCursor.
278 * Returns:
279 * the GdkDisplay associated to cursor
280 * Since 2.2
282 public Display getDisplay()
284 // GdkDisplay* gdk_cursor_get_display (GdkCursor *cursor);
285 return new Display( gdk_cursor_get_display(gdkCursor) );
289 * Returns a GdkPixbuf with the image used to display the cursor.
290 * Note that depending on the capabilities of the windowing system and
291 * on the cursor, GDK may not be able to obtain the image data. In this
292 * case, NULL is returned.
293 * cursor:
294 * a GdkCursor
295 * Returns:
296 * a GdkPixbuf representing cursor, or NULL
297 * Since 2.8
299 public Pixbuf getImage()
301 // GdkPixbuf* gdk_cursor_get_image (GdkCursor *cursor);
302 return new Pixbuf( gdk_cursor_get_image(gdkCursor) );
306 * Adds a reference to cursor.
307 * cursor:
308 * a GdkCursor
309 * Returns:
310 * Same cursor that was passed in
312 public Cursor ref()
314 // GdkCursor* gdk_cursor_ref (GdkCursor *cursor);
315 return new Cursor( gdk_cursor_ref(gdkCursor) );
319 * Removes a reference from cursor, deallocating the cursor
320 * if no references remain.
321 * cursor:
322 * a GdkCursor
324 public void unref()
326 // void gdk_cursor_unref (GdkCursor *cursor);
327 gdk_cursor_unref(gdkCursor);