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