gtkmm 3.24.7
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gdk::Cursor Class Reference

This represents a cursor. More...

#include <gdkmm/cursor.h>

Inherits Glib::Object.

Public Member Functions

 Cursor (Cursor && src) noexcept
 
Cursoroperator= (Cursor && src) noexcept
 
 ~Cursor () noexcept override
 
GdkCursor * gobj ()
 Provides access to the underlying C GObject. More...
 
const GdkCursor * gobj () const
 Provides access to the underlying C GObject. More...
 
GdkCursor * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
Glib::RefPtr< Displayget_display ()
 Returns the display on which the Gdk::Cursor is defined. More...
 
Glib::RefPtr< const Displayget_display () const
 Returns the display on which the Gdk::Cursor is defined. More...
 
Glib::RefPtr< Gdk::Pixbufget_image ()
 Returns a Gdk::Pixbuf with the image used to display the cursor. More...
 
Glib::RefPtr< const Gdk::Pixbufget_image () const
 Returns a Gdk::Pixbuf with the image used to display the cursor. More...
 
::Cairo::RefPtr< ::Cairo::Surface > get_surface (double & x_hot, double & y_hot)
 Returns a cairo image surface with the image used to display the cursor. More...
 
::Cairo::RefPtr< const ::Cairo::Surface > get_surface (double & x_hot, double & y_hot) const
 Returns a cairo image surface with the image used to display the cursor. More...
 
CursorType get_cursor_type () const
 Returns the cursor type for this cursor. More...
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static Glib::RefPtr< Cursorcreate (CursorType cursor_type)
 Creates a new cursor from the set of builtin cursors for the default display. More...
 
static Glib::RefPtr< Cursorcreate (const Glib::RefPtr< Display > & display, CursorType cursor_type)
 Creates a new cursor from the set of builtin cursors. More...
 
static Glib::RefPtr< Cursorcreate (const Glib::RefPtr< Display > & display, const Glib::RefPtr< Pixbuf > & pixbuf, int x, int y)
 Creates a new cursor from a pixbuf. More...
 
static Glib::RefPtr< Cursorcreate (const Glib::RefPtr< Display > & display, const ::Cairo::RefPtr< ::Cairo::Surface > & surface, double x, double y)
 Creates a new cursor from a cairo image surface. More...
 
static Glib::RefPtr< Cursorcreate (const Glib::RefPtr< Display > & display, const Glib::ustring & name)
 Creates a new cursor by looking up name in the current cursor theme. More...
 

Protected Member Functions

 Cursor (const Glib::RefPtr< Display > & display, const Glib::ustring & name)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gdk::Cursorwrap (GdkCursor * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

This represents a cursor.

Constructor & Destructor Documentation

◆ Cursor() [1/2]

Gdk::Cursor::Cursor ( Cursor &&  src)
noexcept

◆ ~Cursor()

Gdk::Cursor::~Cursor ( )
overridenoexcept

◆ Cursor() [2/2]

Gdk::Cursor::Cursor ( const Glib::RefPtr< Display > &  display,
const Glib::ustring &  name 
)
explicitprotected

Member Function Documentation

◆ create() [1/5]

static Glib::RefPtr< Cursor > Gdk::Cursor::create ( const Glib::RefPtr< Display > &  display,
const ::Cairo::RefPtr< ::Cairo::Surface > &  surface,
double  x,
double  y 
)
static

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.

Since gtkmm 3.10:
Parameters
displayThe Gdk::Display for which the cursor will be created.
surfaceThe cairo image surface containing the cursor pixel data.
xThe horizontal offset of the “hotspot” of the cursor.
yThe vertical offset of the “hotspot” of the cursor.
Returns
A new Gdk::Cursor.

◆ create() [2/5]

static Glib::RefPtr< Cursor > Gdk::Cursor::create ( const Glib::RefPtr< Display > &  display,
const Glib::RefPtr< Pixbuf > &  pixbuf,
int  x,
int  y 
)
static

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.

Since gtkmm 2.4:
Parameters
displayThe Gdk::Display for which the cursor will be created.
pixbufThe Gdk::Pixbuf containing the cursor image.
xThe horizontal offset of the “hotspot” of the cursor.
yThe vertical offset of the “hotspot” of the cursor.
Returns
A new Gdk::Cursor.

◆ create() [3/5]

static Glib::RefPtr< Cursor > Gdk::Cursor::create ( const Glib::RefPtr< Display > &  display,
const Glib::ustring &  name 
)
static

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"

    Since gtkmm 2.8:
Parameters
displayThe Gdk::Display for which the cursor will be created.
nameThe name of the cursor.
Returns
A new Gdk::Cursor, or nullptr if there is no cursor with the given name.

◆ create() [4/5]

static Glib::RefPtr< Cursor > Gdk::Cursor::create ( const Glib::RefPtr< Display > &  display,
CursorType  cursor_type 
)
static

Creates a new cursor from the set of builtin cursors.

Since gtkmm 2.2:
Parameters
displayThe Gdk::Display for which the cursor will be created.
cursor_typeCursor to create.
Returns
A new Gdk::Cursor.

◆ create() [5/5]

static Glib::RefPtr< Cursor > Gdk::Cursor::create ( CursorType  cursor_type)
static

Creates a new cursor from the set of builtin cursors for the default display.

See new_for_display().

To make the cursor invisible, use Gdk::BLANK_CURSOR.

Deprecated: 3.16: Use new_for_display() instead.

Deprecated:
Use the constructor that takes a Display instead.
Parameters
cursor_typeCursor to create.
Returns
A new Gdk::Cursor.

◆ get_cursor_type()

CursorType Gdk::Cursor::get_cursor_type ( ) const

Returns the cursor type for this cursor.

Since gtkmm 2.22:
Returns
A Gdk::CursorType.

◆ get_display() [1/2]

Glib::RefPtr< Display > Gdk::Cursor::get_display ( )

Returns the display on which the Gdk::Cursor is defined.

Since gtkmm 2.2:
Returns
The Gdk::Display associated to cursor.

◆ get_display() [2/2]

Glib::RefPtr< const Display > Gdk::Cursor::get_display ( ) const

Returns the display on which the Gdk::Cursor is defined.

Since gtkmm 2.2:
Returns
The Gdk::Display associated to cursor.

◆ get_image() [1/2]

Glib::RefPtr< Gdk::Pixbuf > Gdk::Cursor::get_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, nullptr is returned.

Since gtkmm 2.8:
Returns
A Gdk::Pixbuf representing cursor, or nullptr.

◆ get_image() [2/2]

Glib::RefPtr< const Gdk::Pixbuf > Gdk::Cursor::get_image ( ) const

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, nullptr is returned.

Since gtkmm 2.8:
Returns
A Gdk::Pixbuf representing cursor, or nullptr.

◆ get_surface() [1/2]

::Cairo::RefPtr< ::Cairo::Surface > Gdk::Cursor::get_surface ( double &  x_hot,
double &  y_hot 
)

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, nullptr is returned.

Since gtkmm 3.10:
Parameters
x_hotLocation to store the hotspot x position, or nullptr.
y_hotLocation to store the hotspot y position, or nullptr.
Returns
A #cairo_surface_t representing cursor, or nullptr.

◆ get_surface() [2/2]

::Cairo::RefPtr< const ::Cairo::Surface > Gdk::Cursor::get_surface ( double &  x_hot,
double &  y_hot 
) const

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, nullptr is returned.

Since gtkmm 3.10:
Parameters
x_hotLocation to store the hotspot x position, or nullptr.
y_hotLocation to store the hotspot y position, or nullptr.
Returns
A #cairo_surface_t representing cursor, or nullptr.

◆ get_type()

static GType Gdk::Cursor::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GdkCursor * Gdk::Cursor::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GdkCursor * Gdk::Cursor::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GdkCursor * Gdk::Cursor::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ operator=()

Cursor & Gdk::Cursor::operator= ( Cursor &&  src)
noexcept

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gdk::Cursor > wrap ( GdkCursor *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.