]>
Commit | Line | Data |
---|---|---|
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 | IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) | |
20 | ||
21 | const short kwxCursorHandId = 9 ; | |
22 | const short kwxCursorSizeWEId = 10 ; | |
23 | const short kwxCursorSizeNSId = 11 ; | |
24 | Cursor* MacArrowCursorPtr = &qd.arrow ; | |
25 | CursHandle MacArrowCursor = &MacArrowCursorPtr ; | |
26 | CursHandle gMacCurrentCursor = NULL ; | |
27 | ||
28 | wxCursorRefData::wxCursorRefData() | |
29 | { | |
30 | m_width = 32; | |
31 | m_height = 32; | |
32 | m_hCursor = NULL ; | |
33 | } | |
34 | ||
35 | wxCursorRefData::~wxCursorRefData() | |
36 | { | |
37 | if ( m_hCursor && ( m_hCursor != MacArrowCursor ) ) | |
38 | ::DisposeHandle( (Handle) m_hCursor ) ; | |
39 | } | |
40 | ||
41 | // Cursors | |
42 | wxCursor::wxCursor() | |
43 | { | |
44 | } | |
45 | ||
46 | wxCursor::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 | ||
51 | wxCursor::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 | |
59 | wxCursor::wxCursor(int cursor_type) | |
60 | { | |
61 | m_refData = new wxCursorRefData; | |
62 | ||
63 | switch (cursor_type) | |
64 | { | |
65 | case wxCURSOR_WAIT: | |
66 | M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); | |
67 | break; | |
68 | case wxCURSOR_IBEAM: | |
69 | M_CURSORDATA->m_hCursor = ::GetCursor(iBeamCursor); | |
70 | break; | |
71 | case wxCURSOR_CROSS: | |
72 | M_CURSORDATA->m_hCursor = ::GetCursor(crossCursor); | |
73 | break; | |
74 | case wxCURSOR_SIZENWSE: | |
75 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); | |
76 | break; | |
77 | case wxCURSOR_SIZENESW: | |
78 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); | |
79 | break; | |
80 | case wxCURSOR_SIZEWE: | |
81 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); | |
82 | break; | |
83 | case wxCURSOR_SIZENS: | |
84 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNSId); | |
85 | break; | |
86 | case wxCURSOR_CHAR: | |
87 | { | |
88 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
89 | break; | |
90 | } | |
91 | case wxCURSOR_HAND: | |
92 | { | |
93 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
94 | break; | |
95 | } | |
96 | case wxCURSOR_BULLSEYE: | |
97 | { | |
98 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
99 | break; | |
100 | } | |
101 | case wxCURSOR_PENCIL: | |
102 | { | |
103 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
104 | break; | |
105 | } | |
106 | case wxCURSOR_MAGNIFIER: | |
107 | { | |
108 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
109 | break; | |
110 | } | |
111 | case wxCURSOR_NO_ENTRY: | |
112 | { | |
113 | M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); | |
114 | break; | |
115 | } | |
116 | case wxCURSOR_LEFT_BUTTON: | |
117 | { | |
118 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
119 | break; | |
120 | } | |
121 | case wxCURSOR_RIGHT_BUTTON: | |
122 | { | |
123 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
124 | break; | |
125 | } | |
126 | case wxCURSOR_MIDDLE_BUTTON: | |
127 | { | |
128 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
129 | break; | |
130 | } | |
131 | case wxCURSOR_SIZING: | |
132 | { | |
133 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
134 | break; | |
135 | } | |
136 | case wxCURSOR_WATCH: | |
137 | { | |
138 | M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); | |
139 | break; | |
140 | } | |
141 | case wxCURSOR_SPRAYCAN: | |
142 | { | |
143 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
144 | break; | |
145 | } | |
146 | case wxCURSOR_PAINT_BRUSH: | |
147 | { | |
148 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
149 | break; | |
150 | } | |
151 | case wxCURSOR_POINT_LEFT: | |
152 | { | |
153 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
154 | break; | |
155 | } | |
156 | case wxCURSOR_POINT_RIGHT: | |
157 | { | |
158 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
159 | break; | |
160 | } | |
161 | case wxCURSOR_QUESTION_ARROW: | |
162 | { | |
163 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
164 | break; | |
165 | } | |
166 | case wxCURSOR_BLANK: | |
167 | { | |
168 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
169 | break; | |
170 | } | |
171 | default: | |
172 | case wxCURSOR_ARROW: | |
173 | M_CURSORDATA->m_hCursor = MacArrowCursor; | |
174 | break; | |
175 | } | |
176 | } | |
177 | ||
178 | void 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 | } | |
190 | } | |
191 | ||
192 | wxCursor::~wxCursor() | |
193 | { | |
194 | } | |
195 | ||
196 | // Global cursor setting | |
197 | void wxSetCursor(const wxCursor& cursor) | |
198 | { | |
199 | cursor.MacInstall() ; | |
200 | } | |
201 | ||
202 |