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