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