Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Inti::Gdk::Cursor Class Reference

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

#include <inti/gdk/cursor.h>

Inheritance diagram for Inti::Gdk::Cursor:

Inti::G::Boxed Inti::ReferencedObject Inti::ReferencedBase 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.


Constructor & Destructor Documentation

Inti::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.

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

Creates 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);

Inti::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.

Inti::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.

Inti::Gdk::Cursor::Cursor const Cursor src  ) 
 

Copy constructor.

Parameters:
src The source cursor.


Member Function Documentation

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

Gets the display on which the cursor is defined.

Returns:
The Display associated with the cursor.

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

Assignment operator.

Parameters:
src The source cursor.

GdkCursorType Inti::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: Main Page - Footer


Generated on Sun Sep 14 20:08:10 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002