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