1 /*
2 cursor.c
3
4 For Tux Paint
5 Bitmapped mouse pointer (cursor)
6
7 Copyright (c) 2002-2007 by Bill Kendrick and others
8 bill@newbreedsoftware.com
9 http://www.tuxpaint.org/
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 (See COPYING.txt)
25
26 June 14, 2002 - May 15, 2007
27 $Id$
28 */
29
30 #include "cursor.h"
31 #include "debug.h"
32
33 #define UNUSED(arg) ((void)(arg))
34
35 SDL_Cursor *cursor_hand, *cursor_arrow, *cursor_watch,
36 *cursor_up, *cursor_down, *cursor_tiny, *cursor_crosshair,
37 *cursor_brush, *cursor_wand, *cursor_insertion, *cursor_rotate;
38
39 #ifdef NOKIA_770
40 int hide_cursor = 1;
41 #else
42 int hide_cursor;
43 #endif
44
45 #if defined(NOKIA_770) || defined(__BEOS__) || defined(__HAIKU__)
46 // Fancy cursors on BeOS are buggy in SDL
47 int no_fancy_cursors = 1;
48 #else
49 int no_fancy_cursors;
50 #endif
51
52 /**
53 * Set the current cursor shape.
54 *
55 * @param c The cursor shape to use.
56 */
do_setcursor(SDL_Cursor * c)57 void do_setcursor(SDL_Cursor * c)
58 {
59 /* Shut GCC up over the fact that the XBMs are #included within cursor.h
60 but used in tuxpaint.c (and not cursor.c) */
61
62 UNUSED(watch_bits);
63 UNUSED(watch_mask_bits);
64 UNUSED(hand_bits);
65 UNUSED(hand_mask_bits);
66 UNUSED(wand_bits);
67 UNUSED(wand_mask_bits);
68 UNUSED(insertion_bits);
69 UNUSED(insertion_mask_bits);
70 UNUSED(brush_bits);
71 UNUSED(brush_mask_bits);
72 UNUSED(crosshair_bits);
73 UNUSED(crosshair_mask_bits);
74 UNUSED(rotate_bits);
75 UNUSED(rotate_mask_bits);
76 UNUSED(up_bits);
77 UNUSED(up_mask_bits);
78 UNUSED(down_bits);
79 UNUSED(down_mask_bits);
80 UNUSED(tiny_bits);
81 UNUSED(tiny_mask_bits);
82 UNUSED(arrow_bits);
83 UNUSED(arrow_mask_bits);
84
85 if (!hide_cursor && !no_fancy_cursors)
86 SDL_SetCursor(c);
87 }
88
89 /**
90 * Free (deallocate) a cursor.
91 *
92 * @param cursor Pointer to a cursor to free; will be set to point to NULL afterwards.
93 */
free_cursor(SDL_Cursor ** cursor)94 void free_cursor(SDL_Cursor ** cursor)
95 {
96 if (*cursor)
97 {
98 SDL_FreeCursor(*cursor);
99 *cursor = NULL;
100 }
101 }
102