]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
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 | { | |
c67daf87 | 34 | m_cursor = (GdkCursor *) NULL; |
ff7b1510 | 35 | } |
c801d85f KB |
36 | |
37 | wxCursorRefData::~wxCursorRefData(void) | |
38 | { | |
39 | if (m_cursor) gdk_cursor_destroy( m_cursor ); | |
ff7b1510 | 40 | } |
c801d85f KB |
41 | |
42 | //----------------------------------------------------------------------------- | |
43 | ||
44 | #define M_CURSORDATA ((wxCursorRefData *)m_refData) | |
45 | ||
46 | IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject) | |
47 | ||
48 | wxCursor::wxCursor(void) | |
49 | { | |
ff7b1510 | 50 | } |
c801d85f | 51 | |
debe6624 | 52 | wxCursor::wxCursor( int cursorId ) |
c801d85f KB |
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; | |
ff7b1510 | 70 | } |
c801d85f KB |
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 | ||
ff7b1510 | 100 | } |
c801d85f KB |
101 | |
102 | wxCursor::wxCursor( const wxCursor &cursor ) | |
103 | { | |
104 | Ref( cursor ); | |
ff7b1510 | 105 | } |
c801d85f KB |
106 | |
107 | wxCursor::wxCursor( const wxCursor *cursor ) | |
108 | { | |
109 | UnRef(); | |
110 | if (cursor) Ref( *cursor ); | |
ff7b1510 | 111 | } |
c801d85f KB |
112 | |
113 | wxCursor::~wxCursor(void) | |
114 | { | |
ff7b1510 | 115 | } |
c801d85f KB |
116 | |
117 | wxCursor& wxCursor::operator = ( const wxCursor& cursor ) | |
118 | { | |
119 | if (*this == cursor) return (*this); | |
120 | Ref( cursor ); | |
121 | return *this; | |
ff7b1510 | 122 | } |
c801d85f KB |
123 | |
124 | bool wxCursor::operator == ( const wxCursor& cursor ) | |
125 | { | |
126 | return m_refData == cursor.m_refData; | |
ff7b1510 | 127 | } |
c801d85f KB |
128 | |
129 | bool wxCursor::operator != ( const wxCursor& cursor ) | |
130 | { | |
131 | return m_refData != cursor.m_refData; | |
ff7b1510 | 132 | } |
c801d85f KB |
133 | |
134 | bool wxCursor::Ok(void) const | |
135 | { | |
136 | return TRUE; | |
ff7b1510 | 137 | } |
c801d85f KB |
138 | |
139 | GdkCursor *wxCursor::GetCursor(void) const | |
140 | { | |
141 | return M_CURSORDATA->m_cursor; | |
ff7b1510 | 142 | } |
c801d85f KB |
143 | |
144 | //----------------------------------------------------------------------------- | |
145 | // busy cursor routines | |
146 | //----------------------------------------------------------------------------- | |
147 | ||
148 | bool g_isBusy = FALSE; | |
149 | ||
150 | void wxEndBusyCursor(void) | |
151 | { | |
152 | g_isBusy = FALSE; | |
ff7b1510 | 153 | } |
c801d85f KB |
154 | |
155 | void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) | |
156 | { | |
157 | g_isBusy = TRUE; | |
ff7b1510 | 158 | } |
c801d85f KB |
159 | |
160 | bool wxIsBusy(void) | |
161 | { | |
162 | return g_isBusy; | |
ff7b1510 | 163 | } |
c801d85f KB |
164 | |
165 | void wxSetCursor( const wxCursor& cursor ) | |
166 | { | |
167 | extern wxCursor *g_globalCursor; | |
168 | if (g_globalCursor) (*g_globalCursor) = cursor; | |
169 | ||
ff7b1510 RR |
170 | if (cursor.Ok()) {} |
171 | } | |
c801d85f KB |
172 | |
173 |