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