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