Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gdk::Cursor Class Reference

A GdkCursor C++ wrapper class. More...

#include <xfc/gdk/cursor.hh>

Inheritance diagram for Xfc::Gdk::Cursor:

Xfc::G::Boxed Xfc::Object Xfc::Trackable List of all members.

Public Member Functions

Constructors
Accessors

Detailed Description

A GdkCursor C++ wrapper class.

The Cursor object represents a cursor. A cursor is a pixmap with a depth of one, known as a bitmap. The cursor displayed inside a window's area is an attribute of the window and can be modified. The initial value of a window's cursor attribute is null, indicating the parent window's cursor should be used.

There are several ways to construct a Cursor. You can specify one of the system's predefined cursor types in the GdkCursorType enumeration or you can create your own using pixmaps.

Note: dynamically allocated objects must either be unreferenced or assigned to a smart pointer. Stack objects are automatically unreferenced when they go out of scope.


Constructor & Destructor Documentation

Xfc::Gdk::Cursor::Cursor GdkCursorType  cursor_type,
const Display display = 0
 

Constructs a new cursor for the specified display from the set of builtin cursors.

Parameters:
cursor_type The cursor to create.
display The Display to create the cursor for, or null for the default display.
To make the cursor invisible, construct it from pixmaps with no pixels in them. Cursor is created with a reference count of 1 that the caller owns.

Xfc::Gdk::Cursor::Cursor const Pixmap source,
const Pixmap mask,
const Color fg,
const Color bg,
int  x,
int  y
 

Constructs a new cursor from a given pixmap and mask.

Parameters:
source The pixmap specifying the cursor.
mask The pixmap specifying the mask, which must be the same size as source.
fg The foreground color, used for the bits in the source which are 1.
bg The background color, used for the bits in the source which are 0.
x The horizontal offset of the 'hotspot' of the cursor.
y The vertical offset of the 'hotspot' of the cursor.
The foreground and background colors don't need to be allocated first. 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.

Example: Creating a custom cursor

             // This data is in X bitmap format, and can be created with the 'bitmap' utility.
            
             const int cursor1_width 16;
             const int cursor1_height 16;
            
             static unsigned char cursor1_bits[] = {
               0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x20,
               0x82, 0x41, 0x41, 0x82, 0x41, 0x82, 0x82, 0x41, 0x04, 0x20, 0x08, 0x10,
               0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0x80, 0x01};
            
             static unsigned char cursor1mask_bits[] = {
               0x80, 0x01, 0xc0, 0x03, 0x60, 0x06, 0x30, 0x0c, 0x18, 0x18, 0x8c, 0x31,
               0xc6, 0x63, 0x63, 0xc6, 0x63, 0xc6, 0xc6, 0x63, 0x8c, 0x31, 0x18, 0x18,
               0x30, 0x0c, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01};
            
             Gdk::Color fg(65535, 0, 0); // Red
             Gdk::Color bg(0, 0, 65535 }; // Blue
            
             Pointer<Gdk::Bitmap> source = new Gdk::Bitmap(cursor1_bits, cursor1_width, cursor1_height);
             Pointer<Gdk::Bitmap> mask = new Gdk::Bitmap(cursor1mask_bits, cursor1_width, cursor1_height);
            
             Gdk::Cursor *cursor = new Gdk::Cursor(source, mask, fg, bg, 8, 8);
             widget->get_window()->set_cursor(cursor);

Cursor is created with a reference count of 1 that the caller owns.

Xfc::Gdk::Cursor::Cursor const Pixbuf pixbuf,
int  x,
int  y,
const Display display = 0
 

Constructs a new cursor from a pixbuf.

Parameters:
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.
display The Display to create the cursor for, or null for the default display.
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. Cursor is created with a reference count of 1 that the caller owns.

Xfc::Gdk::Cursor::Cursor GdkCursor *  cursor  )  [explicit]
 

Construct a new cursor from an existing GdkCursor.

Parameters:
cursor A pointer to a GdkCursor.
The cursor can be a newly created GdkCursor or an existing GdkCursor. The Cursor object created is a temporary object. It doesn't take over the ownership of GdkCursor and GdkCursor is not freed by the destructor. Cursor is created with a reference count of 1 that the caller owns.

Xfc::Gdk::Cursor::Cursor GdkCursor *  cursor,
bool  copy
 

Construct a new cursor from an existing GdkCursor.

Parameters:
cursor A pointer to a GdkCursor.
copy Whether the Cursor object should make a copy of GdkCursor or not.
The cursor can be a newly created GdkCursor or an existing GdkCursor. If copy is true Cursor will make a copy of GdkCursor. If copy is false Cursor wont make a copy but instead takes over the ownership of GdkCursor. Either way, the destructor will free GdkCursor when the Cursor object is destroyed. This constructor is used by G::Boxed::wrap() to wrap GdkCursor objects in a C++ wrapper. Cursor is created with a reference count of 1 that the caller owns.

Xfc::Gdk::Cursor::Cursor const Cursor src  ) 
 

Copy constructor.

Parameters:
src The source cursor.


Member Function Documentation

Display* Xfc::Gdk::Cursor::get_display  )  const
 

Gets the display on which the cursor is defined.

Returns:
The Display associated with the cursor.

Cursor& Xfc::Gdk::Cursor::operator= const Cursor src  ) 
 

Assignment operator.

Parameters:
src The source cursor.

GdkCursorType Xfc::Gdk::Cursor::type  )  const
 

Returns the type of this cursor.

This will usually be one of the standard cursor types, such as GDK_ARROW or GDK_CROSSHAIR, or GDK_CURSOR_IS_PIXMAP is you constructed your cursor from pixmaps.


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3