]> git.saurik.com Git - wxWidgets.git/blob - src/os2/cursor.cpp
Rotated text patch from Hans-Joachim Baader (with some corrections)
[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 #if !USE_SHARED_LIBRARIES
30 IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
31 #endif
32
33 wxCursorRefData::wxCursorRefData(void)
34 {
35 m_nWidth = 32;
36 m_nHeight = 32;
37 m_hCursor = 0 ;
38 m_destroyCursor = FALSE;
39 }
40
41 wxCursorRefData::~wxCursorRefData(void)
42 {
43 // if ( m_hCursor && m_destroyCursor)
44 // ::DestroyCursor((HICON) m_hCursor);
45 }
46
47 // Cursors
48 wxCursor::wxCursor(void)
49 {
50 }
51
52 wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
53 int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
54 {
55 }
56
57 wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
58 {
59 m_refData = new wxCursorRefData;
60
61 M_CURSORDATA->m_destroyCursor = FALSE;
62 M_CURSORDATA->m_hCursor = 0;
63 // TODO:
64 /*
65 M_CURSORDATA->m_bOK = FALSE;
66 if (flags & wxBITMAP_TYPE_CUR_RESOURCE)
67 {
68 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);
69 if (M_CURSORDATA->m_hCursor)
70 M_CURSORDATA->m_ok = TRUE;
71 else
72 M_CURSORDATA->m_ok = FALSE;
73 }
74 else if (flags & wxBITMAP_TYPE_CUR)
75 {
76 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
77 }
78 else if (flags & wxBITMAP_TYPE_ICO)
79 {
80 }
81 else if (flags & wxBITMAP_TYPE_BMP)
82 {
83 }
84 */
85 }
86
87 // Cursors by stock number
88 wxCursor::wxCursor(int cursor_type)
89 {
90 m_refData = new wxCursorRefData;
91 // TODO:
92 /*
93 switch (cursor_type)
94 {
95 case wxCURSOR_WAIT:
96 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_WAIT);
97 break;
98 case wxCURSOR_IBEAM:
99 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_IBEAM);
100 break;
101 case wxCURSOR_CROSS:
102 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_CROSS);
103 break;
104 case wxCURSOR_SIZENWSE:
105 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENWSE);
106 break;
107 case wxCURSOR_SIZENESW:
108 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENESW);
109 break;
110 case wxCURSOR_SIZEWE:
111 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZEWE);
112 break;
113 case wxCURSOR_SIZENS:
114 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENS);
115 break;
116 case wxCURSOR_CHAR:
117 {
118 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
119 break;
120 }
121 case wxCURSOR_HAND:
122 {
123 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_HAND"));
124 break;
125 }
126 case wxCURSOR_BULLSEYE:
127 {
128 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BULLSEYE"));
129 break;
130 }
131 case wxCURSOR_PENCIL:
132 {
133 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PENCIL"));
134 break;
135 }
136 case wxCURSOR_MAGNIFIER:
137 {
138 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_MAGNIFIER"));
139 break;
140 }
141 case wxCURSOR_NO_ENTRY:
142 {
143 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_NO_ENTRY"));
144 break;
145 }
146 case wxCURSOR_LEFT_BUTTON:
147 {
148 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
149 break;
150 }
151 case wxCURSOR_RIGHT_BUTTON:
152 {
153 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
154 break;
155 }
156 case wxCURSOR_MIDDLE_BUTTON:
157 {
158 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
159 break;
160 }
161 case wxCURSOR_SIZING:
162 {
163 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_SIZING"));
164 break;
165 }
166 case wxCURSOR_WATCH:
167 {
168 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_WATCH"));
169 break;
170 }
171 case wxCURSOR_SPRAYCAN:
172 {
173 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_ROLLER"));
174 break;
175 }
176 case wxCURSOR_PAINT_BRUSH:
177 {
178 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PBRUSH"));
179 break;
180 }
181 case wxCURSOR_POINT_LEFT:
182 {
183 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PLEFT"));
184 break;
185 }
186 case wxCURSOR_POINT_RIGHT:
187 {
188 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PRIGHT"));
189 break;
190 }
191 case wxCURSOR_QUESTION_ARROW:
192 {
193 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_QARROW"));
194 break;
195 }
196 case wxCURSOR_BLANK:
197 {
198 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BLANK"));
199 break;
200 }
201 default:
202 case wxCURSOR_ARROW:
203 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
204 break;
205 }
206 */
207 }
208
209 wxCursor::~wxCursor(void)
210 {
211 // FreeResource(TRUE);
212 }
213
214 bool wxCursor::FreeResource(bool WXUNUSED(force))
215 {
216 // if (M_CURSORDATA && M_CURSORDATA->m_hCursor && M_CURSORDATA->m_destroyCursor)
217 // {
218 // DestroyCursor((HCURSOR) M_CURSORDATA->m_hCursor);
219 // M_CURSORDATA->m_hCursor = 0;
220 // }
221 return TRUE;
222 }
223
224 void wxCursor::SetHCURSOR(WXHCURSOR cursor)
225 {
226 if ( !M_CURSORDATA )
227 m_refData = new wxCursorRefData;
228
229 M_CURSORDATA->m_hCursor = cursor;
230 }
231
232 // Global cursor setting
233 void wxSetCursor(const wxCursor& cursor)
234 {
235 extern wxCursor *g_globalCursor;
236
237 if ( cursor.Ok() && cursor.GetHCURSOR() )
238 {
239 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
240
241 if ( g_globalCursor )
242 (*g_globalCursor) = cursor;
243 }
244 }
245