1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 standard and pixmap cursors.
7 <!-- ##### SECTION Long_Description ##### -->
12 <!-- ##### SECTION See_Also ##### -->
17 <!-- ##### STRUCT GdkCursor ##### -->
24 <!-- ##### ENUM GdkCursorType ##### -->
26 The standard cursors available.
30 <!-- ##### FUNCTION gdk_cursor_new ##### -->
32 Creates a new standard cursor.
35 @cursor_type: the type of the cursor.
36 @Returns: a new #GdkCursor.
39 <!-- ##### FUNCTION gdk_cursor_new_from_pixmap ##### -->
41 Creates a new cursor from a given pixmap and mask. Both the pixmap and mask
42 must have a depth of 1 (i.e. each pixel has only 2 values - on or off).
43 The standard cursor size is 16 by 16 pixels.
45 <example><title>Creating a custom cursor.</title>
47 /* This data is in X bitmap format, and can be created with the 'bitmap'
49 #define cursor1_width 16
50 #define cursor1_height 16
51 static unsigned char cursor1_bits[] = {
52 0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x20,
53 0x82, 0x41, 0x41, 0x82, 0x41, 0x82, 0x82, 0x41, 0x04, 0x20, 0x08, 0x10,
54 0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0x80, 0x01};
56 static unsigned char cursor1mask_bits[] = {
57 0x80, 0x01, 0xc0, 0x03, 0x60, 0x06, 0x30, 0x0c, 0x18, 0x18, 0x8c, 0x31,
58 0xc6, 0x63, 0x63, 0xc6, 0x63, 0xc6, 0xc6, 0x63, 0x8c, 0x31, 0x18, 0x18,
59 0x30, 0x0c, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01};
63 GdkPixmap *source, *mask;
64 GdkColor fg = { 0, 65535, 0, 0 }; /* Red. */
65 GdkColor bg = { 0, 0, 0, 65535 }; /* Blue. */
68 source = gdk_bitmap_create_from_data (NULL, cursor1_bits,
69 cursor1_width, cursor1_height);
70 mask = gdk_bitmap_create_from_data (NULL, cursor1mask_bits,
71 cursor1_width, cursor1_height);
72 cursor = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, 8, 8);
73 gdk_pixmap_unref (source);
74 gdk_pixmap_unref (mask);
77 gdk_window_set_cursor (widget->window, cursor);
81 @source: the pixmap specifying the cursor.
82 @mask: the pixmap specifying the mask, which must be the same size as @source.
83 @fg: the foreground color, used for the bits in the source which are 1.
84 The color does not have to be allocated first.
85 @bg: the background color, used for the bits in the source which are 0.
86 The color does not have to be allocated first.
87 @x: the horizontal offset of the 'hotspot' of the cursor.
88 @y: the vertical offset of the 'hotspot' of the cursor.
89 @Returns: a new #GdkCursor.
92 <!-- ##### FUNCTION gdk_cursor_destroy ##### -->
94 Destroys a cursor, freeing any resources allocated for it.
97 @cursor: a #GdkCursor.