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