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