]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/cursors.sgml
Initial revision
[~andy/gtk] / docs / reference / gdk / tmpl / cursors.sgml
1 <!-- ##### SECTION Title ##### -->
2 Cursors
3
4 <!-- ##### SECTION Short_Description ##### -->
5
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 </para>
44 <example><title>Creating a custom cursor.</title>
45 <programlisting>
46 /* This data is in X bitmap format, and can be created with the 'bitmap'
47    utility. */
48 #define cursor1_width 16
49 #define cursor1_height 16
50 static unsigned char cursor1_bits[] = {
51    0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x20,
52    0x82, 0x41, 0x41, 0x82, 0x41, 0x82, 0x82, 0x41, 0x04, 0x20, 0x08, 0x10,
53    0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0x80, 0x01};
54
55 static unsigned char cursor1mask_bits[] = {
56    0x80, 0x01, 0xc0, 0x03, 0x60, 0x06, 0x30, 0x0c, 0x18, 0x18, 0x8c, 0x31,
57    0xc6, 0x63, 0x63, 0xc6, 0x63, 0xc6, 0xc6, 0x63, 0x8c, 0x31, 0x18, 0x18,
58    0x30, 0x0c, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01};
59
60
61   GdkCursor *cursor;
62   GdkPixmap *source, *mask;
63   GdkColor fg = { 0, 65535, 0, 0 }; /* Red. */
64   GdkColor bg = { 0, 0, 0, 65535 }; /* Blue. */
65
66
67   source = gdk_bitmap_create_from_data (NULL, cursor1_bits,
68                                         cursor1_width, cursor1_height);
69   mask = gdk_bitmap_create_from_data (NULL, cursor1mask_bits,
70                                       cursor1_width, cursor1_height);
71   cursor = gdk_cursor_new_from_pixmap (source, mask, &amp;fg, &amp;bg, 8, 8);
72   gdk_pixmap_unref (source);
73   gdk_pixmap_unref (mask);
74
75
76   gdk_window_set_cursor (widget->window, cursor);
77 </programlisting>
78 </example>
79
80 @source: the pixmap specifying the cursor.
81 @mask: the pixmap specifying the mask, which must be the same size as @source.
82 @fg: the foreground color, used for the bits in the source which are 1.
83 The color does not have to be allocated first.
84 @bg: the background color, used for the bits in the source which are 0.
85 The color does not have to be allocated first.
86 @x: the horizontal offset of the 'hotspot' of the cursor.
87 @y: the vertical offset of the 'hotspot' of the cursor.
88 @Returns: a new #GdkCursor.
89
90
91 <!-- ##### FUNCTION gdk_cursor_destroy ##### -->
92 <para>
93 Destroys a cursor, freeing any resources allocated for it.
94 </para>
95
96 @cursor: a #GdkCursor.
97
98