]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: cursor.cpp | |
3 | // Purpose: wxCursor class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "cursor.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/cursor.h" | |
17 | #include "wx/icon.h" | |
18 | #include "wx/mac/private.h" | |
19 | ||
20 | #if !USE_SHARED_LIBRARIES | |
21 | IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) | |
22 | #endif | |
23 | ||
24 | const short kwxCursorHandId = 9 ; | |
25 | const short kwxCursorSizeWEId = 10 ; | |
26 | const short kwxCursorSizeNSId = 11 ; | |
27 | #if !TARGET_CARBON | |
28 | Cursor* MacArrowCursorPtr = &qd.arrow ; | |
29 | CursHandle MacArrowCursor = &MacArrowCursorPtr ; | |
30 | #else | |
31 | bool MacArrowInstalled = false ; | |
32 | Cursor MacArrow ; | |
33 | Cursor* MacArrowCursorPtr = &MacArrow ; | |
34 | CursHandle MacArrowCursor = &MacArrowCursorPtr ; | |
35 | #endif | |
36 | CursHandle gMacCurrentCursor = NULL ; | |
37 | ||
38 | wxCursorRefData::wxCursorRefData() | |
39 | { | |
40 | #if TARGET_CARBON | |
41 | if ( !MacArrowInstalled ) | |
42 | { | |
43 | MacArrowCursorPtr = GetQDGlobalsArrow( &MacArrow ) ; | |
44 | MacArrowInstalled = true ; | |
45 | } | |
46 | #endif | |
47 | m_width = 32; | |
48 | m_height = 32; | |
49 | m_hCursor = NULL ; | |
50 | } | |
51 | ||
52 | wxCursorRefData::~wxCursorRefData() | |
53 | { | |
54 | // if ( m_hCursor && ( m_hCursor != MacArrowCursor ) ) | |
55 | // ::ReleaseResource( (Handle) m_hCursor ) ; | |
56 | } | |
57 | ||
58 | // Cursors | |
59 | wxCursor::wxCursor() | |
60 | { | |
61 | } | |
62 | ||
63 | wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height), | |
64 | int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[]) | |
65 | { | |
66 | } | |
67 | ||
68 | wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY) | |
69 | { | |
70 | m_refData = new wxCursorRefData; | |
71 | ||
72 | // TODO: create cursor from a file | |
73 | } | |
74 | ||
75 | // Cursors by stock number | |
76 | wxCursor::wxCursor(int cursor_type) | |
77 | { | |
78 | m_refData = new wxCursorRefData; | |
79 | ||
80 | switch (cursor_type) | |
81 | { | |
82 | case wxCURSOR_WAIT: | |
83 | M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); | |
84 | break; | |
85 | case wxCURSOR_IBEAM: | |
86 | M_CURSORDATA->m_hCursor = ::GetCursor(iBeamCursor); | |
87 | break; | |
88 | case wxCURSOR_CROSS: | |
89 | M_CURSORDATA->m_hCursor = ::GetCursor(crossCursor); | |
90 | break; | |
91 | case wxCURSOR_SIZENWSE: | |
92 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); | |
93 | break; | |
94 | case wxCURSOR_SIZENESW: | |
95 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); | |
96 | break; | |
97 | case wxCURSOR_SIZEWE: | |
98 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); | |
99 | break; | |
100 | case wxCURSOR_SIZENS: | |
101 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNSId); | |
102 | break; | |
103 | case wxCURSOR_CHAR: | |
104 | { | |
105 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
106 | break; | |
107 | } | |
108 | case wxCURSOR_HAND: | |
109 | { | |
110 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
111 | break; | |
112 | } | |
113 | case wxCURSOR_BULLSEYE: | |
114 | { | |
115 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
116 | break; | |
117 | } | |
118 | case wxCURSOR_PENCIL: | |
119 | { | |
120 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
121 | break; | |
122 | } | |
123 | case wxCURSOR_MAGNIFIER: | |
124 | { | |
125 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
126 | break; | |
127 | } | |
128 | case wxCURSOR_NO_ENTRY: | |
129 | { | |
130 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
131 | break; | |
132 | } | |
133 | case wxCURSOR_LEFT_BUTTON: | |
134 | { | |
135 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
136 | break; | |
137 | } | |
138 | case wxCURSOR_RIGHT_BUTTON: | |
139 | { | |
140 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
141 | break; | |
142 | } | |
143 | case wxCURSOR_MIDDLE_BUTTON: | |
144 | { | |
145 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
146 | break; | |
147 | } | |
148 | case wxCURSOR_SIZING: | |
149 | { | |
150 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
151 | break; | |
152 | } | |
153 | case wxCURSOR_WATCH: | |
154 | { | |
155 | M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); | |
156 | break; | |
157 | } | |
158 | case wxCURSOR_SPRAYCAN: | |
159 | { | |
160 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
161 | break; | |
162 | } | |
163 | case wxCURSOR_PAINT_BRUSH: | |
164 | { | |
165 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
166 | break; | |
167 | } | |
168 | case wxCURSOR_POINT_LEFT: | |
169 | { | |
170 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
171 | break; | |
172 | } | |
173 | case wxCURSOR_POINT_RIGHT: | |
174 | { | |
175 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
176 | break; | |
177 | } | |
178 | case wxCURSOR_QUESTION_ARROW: | |
179 | { | |
180 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
181 | break; | |
182 | } | |
183 | case wxCURSOR_BLANK: | |
184 | { | |
185 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
186 | break; | |
187 | } | |
188 | default: | |
189 | case wxCURSOR_ARROW: | |
190 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
191 | break; | |
192 | } | |
193 | } | |
194 | ||
195 | void wxCursor::MacInstall() const | |
196 | { | |
197 | if ( m_refData && M_CURSORDATA->m_hCursor ) | |
198 | { | |
199 | ::SetCursor( *((CursHandle)M_CURSORDATA->m_hCursor) ) ; | |
200 | gMacCurrentCursor = (CursHandle)M_CURSORDATA->m_hCursor ; | |
201 | } | |
202 | else | |
203 | { | |
204 | ::SetCursor( *MacArrowCursor ) ; | |
205 | gMacCurrentCursor = NULL ; | |
206 | } | |
207 | } | |
208 | ||
209 | wxCursor::~wxCursor() | |
210 | { | |
211 | } | |
212 | ||
213 | // Global cursor setting | |
214 | void wxSetCursor(const wxCursor& cursor) | |
215 | { | |
216 | cursor.MacInstall() ; | |
217 | } | |
218 | ||
219 |