Standard and pixmap cursors
Class GdkCursor( cursor_type )
cursor_type | cursor to create (GdkCursorType). |
These functions are used to create and destroy cursors. There is a number of standard cursors, but it is also possible to construct new cursors from pixmaps and pixbufs. There may be limitations as to what kinds of cursors can be constructed on a given display, see gdk_display_supports_cursor_alpha(), gdk_display_supports_cursor_color(), gdk_display_get_default_cursor_size() and gdk_display_get_maximal_cursor_size().
Cursors by themselves are not very interesting, they must be be bound to a window for users to see them. This is done with gdk_window_set_cursor() or by setting the cursor member of the GdkWindowAttr struct passed to gdk_window_new().
Methods | |
get_display | Returns the display on which the GdkCursor is defined. |
get_image | Returns a GdkPixbuf with the image used to display the cursor. |
new_for_display | Creates a new cursor from the set of builtin cursors. |
new_from_name | Creates a new cursor by looking up name in the current cursor theme. |
new_from_pixbuf | Creates a new cursor from a pixbuf. |
new_from_pixmap | Creates a new cursor from a given pixmap and mask. |
Returns the display on which the GdkCursor is defined.
GdkCursor.get_display()
Return | the GdkDisplay associated to cursor |
Returns a GdkPixbuf with the image used to display the cursor.
GdkCursor.get_image()
Return | a GdkPixbuf representing cursor, or NULL |
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.
Creates a new cursor from the set of builtin cursors.
GdkCursor.new_for_display( display, cursor_type )
display | the GdkDisplay for which the cursor will be created |
cursor_type | cursor to create (GdkCursorType) |
Creates a new cursor by looking up name in the current cursor theme.
GdkCursor.new_from_name( name )
name | the name of the cursor |
Return | a new GdkCursor, or NULL if there is no cursor with the given name |
Creates a new cursor from a pixbuf.
GdkCursor.new_from_pixbuf( display, pixbuf, x, y )
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. |
Return | a new GdkCursor. |
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.
Creates a new cursor from a given pixmap and mask.
GdkCursor.new_from_pixmap( source, mask, fg, bg, x, y )
source | the pixmap specifying the cursor (GdkPixmap). |
mask | the pixmap specifying the mask, which must be the same size as source (GdkPixmap). |
fg | the foreground color, used for the bits in the source which are 1 (GdkColor). |
bg | the background color, used for the bits in the source which are 0 (GdkColor). |
x | the horizontal offset of the 'hotspot' of the cursor. |
y | the vertical offset of the 'hotspot' of the cursor. |
Return | a new GdkCursor. |
Both the pixmap and mask must have a depth of 1 (i.e. each pixel has only 2 values - on or off). The standard cursor size is 16 by 16 pixels. You can create a bitmap from inline data as in the below example.
[...]