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