Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

Gdk::Cursor

class Gdk::Cursor

Standard and pixmap cursors.

This class is useful 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#default_cursor_size and Gdk::Display#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#cursor= or by setting the cursor member of the Gdk::WindowAttr struct passed to Gdk::Window#new.

Class Methods

Gdk::Cursor.new(cursor_type)
Creates a new cursor from the set of builtin cursors.
  • cursor_type: cursor to create
  • Returns: a new Gdk::Cursor
Gdk::Cursor.new(display, type_or_name)
If type_or_name is a String, creates a new cursor by looking up type_or_name in the current cursor theme (Since 2.8); else type_or_name is considered a (GdkCursorType) and the new cursor is created from the set of builtin cursors (Since 2.2).
  • display: the Gdk::Display for which the cursor will be created
  • type_or_name: a String to create the cursor by name lookup in the current cursor theme (since 2.8), or a (GdkCursorType) to create from the set of builtin cursors (since 2.2)
  • Returns: a new Gdk::Cursor
Gdk::Cursor.new(display, pixbuf, x, y)
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#default_cursor_size and Gdk::Display#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. Since 2.4
  • pixbuf: the Gdk::Pixbuf 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 Gdk::Cursor
Gdk::Cursor.new(source, mask, fg, bg, x, y)
Creates a new cursor from a given pixmap and mask. 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.
  • source: the Gdk::Pixmap specifying the cursor.
  • mask: the Gdk::Pixmap specifying the mask, which must be the same size as source.
  • fg: the foreground color(Gdk::Color), used for the bits in the source which are 1. The color does not have to be allocated first.
  • bg: the background color(Gdk::Color), used for the bits in the source which are 0. The color does not have to be allocated first.
  • x: the horizontal offset of the 'hotspot' of the cursor.
  • y: the vertical offset of the 'hotspot' of the cursor.
  • Returns : a new Gdk::Cursor.

Instance Methods

pixmap?
Retrieves whether the Gdk::Cursor is pixmap or builtin.
cursor_type
Retrieves the cursor type.
display
Returns the display on which the Gdk::Cursor is defined. Since 2.2
image
Returns a Gdk::Pixbuf 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, nil is returned. Since 2.8