]> git.saurik.com Git - wxWidgets.git/blob - src/mac/cursor.cpp
resource loader structure added for loading menu bar, apple menu will not get multipl...
[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/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
81 switch (cursor_type)
82 {
83 case wxCURSOR_WAIT:
84 M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor);
85 break;
86 case wxCURSOR_IBEAM:
87 M_CURSORDATA->m_hCursor = ::GetCursor(iBeamCursor);
88 break;
89 case wxCURSOR_CROSS:
90 M_CURSORDATA->m_hCursor = ::GetCursor(crossCursor);
91 break;
92 case wxCURSOR_SIZENWSE:
93 {
94 wxStAppResource resload ;
95 M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId);
96 }
97 break;
98 case wxCURSOR_SIZENESW:
99 {
100 wxStAppResource resload ;
101 M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId);
102 }
103 break;
104 case wxCURSOR_SIZEWE:
105 {
106 wxStAppResource resload ;
107 M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId);
108 }
109 break;
110 case wxCURSOR_SIZENS:
111 {
112 wxStAppResource resload ;
113 M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNSId);
114 }
115 break;
116 case wxCURSOR_CHAR:
117 {
118 M_CURSORDATA->m_hCursor = MacArrowCursor;
119 break;
120 }
121 case wxCURSOR_HAND:
122 {
123 wxStAppResource resload ;
124 M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId);
125 }
126 break;
127 case wxCURSOR_BULLSEYE:
128 {
129 wxStAppResource resload ;
130 M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId);
131 }
132 break;
133 case wxCURSOR_PENCIL:
134 {
135 wxStAppResource resload ;
136 M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId);
137 }
138 break;
139 case wxCURSOR_MAGNIFIER:
140 {
141 wxStAppResource resload ;
142 M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId);
143 }
144 break;
145 case wxCURSOR_NO_ENTRY:
146 {
147 wxStAppResource resload ;
148 M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId);
149 }
150 break;
151 case wxCURSOR_LEFT_BUTTON:
152 {
153 M_CURSORDATA->m_hCursor = MacArrowCursor;
154 break;
155 }
156 case wxCURSOR_RIGHT_BUTTON:
157 {
158 M_CURSORDATA->m_hCursor = MacArrowCursor;
159 break;
160 }
161 case wxCURSOR_MIDDLE_BUTTON:
162 {
163 M_CURSORDATA->m_hCursor = MacArrowCursor;
164 break;
165 }
166 case wxCURSOR_SIZING:
167 {
168 M_CURSORDATA->m_hCursor = MacArrowCursor;
169 break;
170 }
171 case wxCURSOR_WATCH:
172 {
173 M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor);
174 break;
175 }
176 case wxCURSOR_SPRAYCAN:
177 {
178 M_CURSORDATA->m_hCursor = MacArrowCursor;
179 break;
180 }
181 case wxCURSOR_PAINT_BRUSH:
182 {
183 M_CURSORDATA->m_hCursor = MacArrowCursor;
184 break;
185 }
186 case wxCURSOR_POINT_LEFT:
187 {
188 M_CURSORDATA->m_hCursor = MacArrowCursor;
189 break;
190 }
191 case wxCURSOR_POINT_RIGHT:
192 {
193 M_CURSORDATA->m_hCursor = MacArrowCursor;
194 break;
195 }
196 case wxCURSOR_QUESTION_ARROW:
197 {
198 M_CURSORDATA->m_hCursor = MacArrowCursor;
199 break;
200 }
201 case wxCURSOR_BLANK:
202 {
203 M_CURSORDATA->m_hCursor = MacArrowCursor;
204 break;
205 }
206 default:
207 case wxCURSOR_ARROW:
208 M_CURSORDATA->m_hCursor = MacArrowCursor;
209 break;
210 }
211 }
212
213 void wxCursor::MacInstall() const
214 {
215 if ( m_refData && M_CURSORDATA->m_hCursor )
216 {
217 ::SetCursor( *((CursHandle)M_CURSORDATA->m_hCursor) ) ;
218 gMacCurrentCursor = (CursHandle)M_CURSORDATA->m_hCursor ;
219 }
220 else
221 {
222 ::SetCursor( *MacArrowCursor ) ;
223 gMacCurrentCursor = NULL ;
224 }
225 }
226
227 wxCursor::~wxCursor()
228 {
229 }
230
231 // Global cursor setting
232 void wxSetCursor(const wxCursor& cursor)
233 {
234 cursor.MacInstall() ;
235 }
236
237