]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/cursors.sgml
new section from Lee Mallabone.
[~andy/gtk] / docs / reference / gdk / tmpl / cursors.sgml
1 <!-- ##### SECTION Title ##### -->
2 Cursors
3
4 <!-- ##### SECTION Short_Description ##### -->
5 standard and pixmap cursors.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9
10 </para>
11
12 <!-- ##### SECTION See_Also ##### -->
13 <para>
14
15 </para>
16
17 <!-- ##### STRUCT GdkCursor ##### -->
18 <para>
19
20 </para>
21
22 @type: 
23
24 <!-- ##### ENUM GdkCursorType ##### -->
25 <para>
26 The standard cursors available.
27 </para>
28
29
30 <!-- ##### FUNCTION gdk_cursor_new ##### -->
31 <para>
32 Creates a new standard cursor.
33 </para>
34
35 @cursor_type: the type of the cursor.
36 @Returns: a new #GdkCursor.
37
38
39 <!-- ##### FUNCTION gdk_cursor_new_from_pixmap ##### -->
40 <para>
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.
44 </para>
45 <example><title>Creating a custom cursor.</title>
46 <programlisting>
47 /* This data is in X bitmap format, and can be created with the 'bitmap'
48    utility. */
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};
55
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};
60
61
62   GdkCursor *cursor;
63   GdkPixmap *source, *mask;
64   GdkColor fg = { 0, 65535, 0, 0 }; /* Red. */
65   GdkColor bg = { 0, 0, 0, 65535 }; /* Blue. */
66
67
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, &amp;fg, &amp;bg, 8, 8);
73   gdk_pixmap_unref (source);
74   gdk_pixmap_unref (mask);
75
76
77   gdk_window_set_cursor (widget->window, cursor);
78 </programlisting>
79 </example>
80
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.
90
91
92 <!-- ##### FUNCTION gdk_cursor_destroy ##### -->
93 <para>
94 Destroys a cursor, freeing any resources allocated for it.
95 </para>
96
97 @cursor: a #GdkCursor.
98
99