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