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