]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: cursor.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
6 | // Id: | |
7 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "cursor.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/cursor.h" | |
17 | ||
18 | //----------------------------------------------------------------------------- | |
19 | // wxCursor | |
20 | //----------------------------------------------------------------------------- | |
21 | ||
22 | class wxCursorRefData: public wxObjectRefData | |
23 | { | |
24 | public: | |
25 | ||
26 | wxCursorRefData(void); | |
27 | ~wxCursorRefData(void); | |
28 | ||
29 | GdkCursor *m_cursor; | |
30 | }; | |
31 | ||
32 | wxCursorRefData::wxCursorRefData(void) | |
33 | { | |
34 | m_cursor = (GdkCursor *) NULL; | |
35 | } | |
36 | ||
37 | wxCursorRefData::~wxCursorRefData(void) | |
38 | { | |
39 | if (m_cursor) gdk_cursor_destroy( m_cursor ); | |
40 | } | |
41 | ||
42 | //----------------------------------------------------------------------------- | |
43 | ||
44 | #define M_CURSORDATA ((wxCursorRefData *)m_refData) | |
45 | ||
46 | IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject) | |
47 | ||
48 | wxCursor::wxCursor(void) | |
49 | { | |
50 | } | |
51 | ||
52 | wxCursor::wxCursor( int cursorId ) | |
53 | { | |
54 | m_refData = new wxCursorRefData(); | |
55 | ||
56 | GdkCursorType gdk_cur = GDK_LEFT_PTR; | |
57 | switch (cursorId) | |
58 | { | |
59 | case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break; | |
60 | case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break; | |
61 | case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break; | |
62 | case wxCURSOR_SIZENS: gdk_cur = GDK_SB_V_DOUBLE_ARROW; break; | |
63 | case wxCURSOR_WAIT: gdk_cur = GDK_WATCH; break; | |
64 | case wxCURSOR_WATCH: gdk_cur = GDK_WATCH; break; | |
65 | case wxCURSOR_SIZING: gdk_cur = GDK_SIZING; break; | |
66 | case wxCURSOR_SPRAYCAN: gdk_cur = GDK_SPRAYCAN; break; | |
67 | case wxCURSOR_IBEAM: gdk_cur = GDK_XTERM; break; | |
68 | case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; | |
69 | case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; | |
70 | } | |
71 | ||
72 | M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); | |
73 | ||
74 | /* | |
75 | do that yourself | |
76 | ||
77 | wxCURSOR_BULLSEYE, | |
78 | wxCURSOR_CHAR, | |
79 | wxCURSOR_LEFT_BUTTON, | |
80 | wxCURSOR_MAGNIFIER, | |
81 | wxCURSOR_MIDDLE_BUTTON, | |
82 | wxCURSOR_NO_ENTRY, | |
83 | wxCURSOR_PAINT_BRUSH, | |
84 | wxCURSOR_POINT_LEFT, | |
85 | wxCURSOR_POINT_RIGHT, | |
86 | wxCURSOR_QUESTION_ARROW, | |
87 | wxCURSOR_RIGHT_BUTTON, | |
88 | wxCURSOR_SIZENESW, | |
89 | wxCURSOR_SIZENS, | |
90 | wxCURSOR_SIZENWSE, | |
91 | wxCURSOR_SIZEWE, | |
92 | wxCURSOR_BLANK | |
93 | , | |
94 | wxCURSOR_CROSS_REVERSE, | |
95 | wxCURSOR_DOUBLE_ARROW, | |
96 | wxCURSOR_BASED_ARROW_UP, | |
97 | wxCURSOR_BASED_ARROW_DOWN | |
98 | */ | |
99 | ||
100 | } | |
101 | ||
102 | wxCursor::wxCursor( const wxCursor &cursor ) | |
103 | { | |
104 | Ref( cursor ); | |
105 | } | |
106 | ||
107 | wxCursor::wxCursor( const wxCursor *cursor ) | |
108 | { | |
109 | UnRef(); | |
110 | if (cursor) Ref( *cursor ); | |
111 | } | |
112 | ||
113 | wxCursor::~wxCursor(void) | |
114 | { | |
115 | } | |
116 | ||
117 | wxCursor& wxCursor::operator = ( const wxCursor& cursor ) | |
118 | { | |
119 | if (*this == cursor) return (*this); | |
120 | Ref( cursor ); | |
121 | return *this; | |
122 | } | |
123 | ||
124 | bool wxCursor::operator == ( const wxCursor& cursor ) | |
125 | { | |
126 | return m_refData == cursor.m_refData; | |
127 | } | |
128 | ||
129 | bool wxCursor::operator != ( const wxCursor& cursor ) | |
130 | { | |
131 | return m_refData != cursor.m_refData; | |
132 | } | |
133 | ||
134 | bool wxCursor::Ok(void) const | |
135 | { | |
136 | return (m_refData != NULL); | |
137 | } | |
138 | ||
139 | GdkCursor *wxCursor::GetCursor(void) const | |
140 | { | |
141 | return M_CURSORDATA->m_cursor; | |
142 | } | |
143 | ||
144 | //----------------------------------------------------------------------------- | |
145 | // busy cursor routines | |
146 | //----------------------------------------------------------------------------- | |
147 | ||
148 | bool g_isBusy = FALSE; | |
149 | ||
150 | void wxEndBusyCursor(void) | |
151 | { | |
152 | g_isBusy = FALSE; | |
153 | } | |
154 | ||
155 | void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) | |
156 | { | |
157 | g_isBusy = TRUE; | |
158 | } | |
159 | ||
160 | bool wxIsBusy(void) | |
161 | { | |
162 | return g_isBusy; | |
163 | } | |
164 | ||
165 | void wxSetCursor( const wxCursor& cursor ) | |
166 | { | |
167 | extern wxCursor *g_globalCursor; | |
168 | if (g_globalCursor) (*g_globalCursor) = cursor; | |
169 | ||
170 | if (cursor.Ok()) {} | |
171 | } | |
172 | ||
173 |