]> git.saurik.com Git - wxWidgets.git/blob - src/os2/cursor.cpp
Fixed Tim's patch so it will compile when using a Python version < 2.0
[wxWidgets.git] / src / os2 / cursor.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cursor.cpp
3 // Purpose: wxCursor class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/13/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifndef WX_PRECOMP
16 #include <stdio.h>
17 #include "wx/setup.h"
18 #include "wx/list.h"
19 #include "wx/utils.h"
20 #include "wx/app.h"
21 #include "wx/cursor.h"
22 #include "wx/icon.h"
23 #endif
24
25 #include "wx/os2/private.h"
26
27 #include "assert.h"
28
29 IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
30
31 wxCursorRefData::wxCursorRefData(void)
32 {
33 m_nWidth = 32;
34 m_nHeight = 32;
35 m_hCursor = 0 ;
36 m_destroyCursor = FALSE;
37 }
38
39 wxCursorRefData::~wxCursorRefData(void)
40 {
41 // if ( m_hCursor && m_destroyCursor)
42 // ::DestroyCursor((HICON) m_hCursor);
43 }
44
45 // Cursors
46 wxCursor::wxCursor(void)
47 {
48 }
49
50 wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
51 int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
52 {
53 }
54
55 wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
56 {
57 m_refData = new wxCursorRefData;
58
59 M_CURSORDATA->m_destroyCursor = FALSE;
60 M_CURSORDATA->m_hCursor = 0;
61 // TODO:
62 /*
63 M_CURSORDATA->m_bOK = FALSE;
64 if (flags & wxBITMAP_TYPE_CUR_RESOURCE)
65 {
66 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);
67 if (M_CURSORDATA->m_hCursor)
68 M_CURSORDATA->m_ok = TRUE;
69 else
70 M_CURSORDATA->m_ok = FALSE;
71 }
72 else if (flags & wxBITMAP_TYPE_CUR)
73 {
74 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
75 }
76 else if (flags & wxBITMAP_TYPE_ICO)
77 {
78 }
79 else if (flags & wxBITMAP_TYPE_BMP)
80 {
81 }
82 */
83 }
84
85 // Cursors by stock number
86 wxCursor::wxCursor(int cursor_type)
87 {
88 m_refData = new wxCursorRefData;
89 // TODO:
90 /*
91 switch (cursor_type)
92 {
93 case wxCURSOR_WAIT:
94 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_WAIT);
95 break;
96 case wxCURSOR_IBEAM:
97 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_IBEAM);
98 break;
99 case wxCURSOR_CROSS:
100 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_CROSS);
101 break;
102 case wxCURSOR_SIZENWSE:
103 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENWSE);
104 break;
105 case wxCURSOR_SIZENESW:
106 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENESW);
107 break;
108 case wxCURSOR_SIZEWE:
109 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZEWE);
110 break;
111 case wxCURSOR_SIZENS:
112 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENS);
113 break;
114 case wxCURSOR_CHAR:
115 {
116 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
117 break;
118 }
119 case wxCURSOR_HAND:
120 {
121 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_HAND"));
122 break;
123 }
124 case wxCURSOR_BULLSEYE:
125 {
126 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BULLSEYE"));
127 break;
128 }
129 case wxCURSOR_PENCIL:
130 {
131 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PENCIL"));
132 break;
133 }
134 case wxCURSOR_MAGNIFIER:
135 {
136 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_MAGNIFIER"));
137 break;
138 }
139 case wxCURSOR_NO_ENTRY:
140 {
141 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_NO_ENTRY"));
142 break;
143 }
144 case wxCURSOR_LEFT_BUTTON:
145 {
146 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
147 break;
148 }
149 case wxCURSOR_RIGHT_BUTTON:
150 {
151 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
152 break;
153 }
154 case wxCURSOR_MIDDLE_BUTTON:
155 {
156 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
157 break;
158 }
159 case wxCURSOR_SIZING:
160 {
161 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_SIZING"));
162 break;
163 }
164 case wxCURSOR_WATCH:
165 {
166 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_WATCH"));
167 break;
168 }
169 case wxCURSOR_SPRAYCAN:
170 {
171 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_ROLLER"));
172 break;
173 }
174 case wxCURSOR_PAINT_BRUSH:
175 {
176 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PBRUSH"));
177 break;
178 }
179 case wxCURSOR_POINT_LEFT:
180 {
181 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PLEFT"));
182 break;
183 }
184 case wxCURSOR_POINT_RIGHT:
185 {
186 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PRIGHT"));
187 break;
188 }
189 case wxCURSOR_QUESTION_ARROW:
190 {
191 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_QARROW"));
192 break;
193 }
194 case wxCURSOR_BLANK:
195 {
196 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BLANK"));
197 break;
198 }
199 default:
200 case wxCURSOR_ARROW:
201 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
202 break;
203 }
204 */
205 }
206
207 wxCursor::~wxCursor(void)
208 {
209 // FreeResource(TRUE);
210 }
211
212 bool wxCursor::FreeResource(bool WXUNUSED(force))
213 {
214 // if (M_CURSORDATA && M_CURSORDATA->m_hCursor && M_CURSORDATA->m_destroyCursor)
215 // {
216 // DestroyCursor((HCURSOR) M_CURSORDATA->m_hCursor);
217 // M_CURSORDATA->m_hCursor = 0;
218 // }
219 return TRUE;
220 }
221
222 void wxCursor::SetHCURSOR(WXHCURSOR cursor)
223 {
224 if ( !M_CURSORDATA )
225 m_refData = new wxCursorRefData;
226
227 M_CURSORDATA->m_hCursor = cursor;
228 }
229
230 // Global cursor setting
231 void wxSetCursor(const wxCursor& cursor)
232 {
233 extern wxCursor *g_globalCursor;
234
235 if ( cursor.Ok() && cursor.GetHCURSOR() )
236 {
237 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
238
239 if ( g_globalCursor )
240 (*g_globalCursor) = cursor;
241 }
242 }
243