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