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