1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/cursor.cpp
3 // Purpose: wxCursor class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #include "wx/cursor.h"
25 #include "wx/os2/private.h"
26 #include "wx/os2/wxrsc.h"
31 IMPLEMENT_DYNAMIC_CLASS(wxCursor
, wxBitmap
)
33 wxCursorRefData::wxCursorRefData(void)
38 m_bDestroyCursor
= false;
41 void wxCursorRefData::Free()
46 ::WinDestroyPointer((HPOINTER
)m_hCursor
);
49 } // end of wxCursorRefData::Free
52 wxCursor::wxCursor(void)
56 wxCursor::wxCursor(const char WXUNUSED(bits
)[],
59 int WXUNUSED(hotSpotX
),
60 int WXUNUSED(hotSpotY
),
61 const char WXUNUSED(maskBits
)[])
65 wxCursor::wxCursor(const wxImage
& rImage
)
67 wxImage vImage32
= rImage
.Scale(32,32);
68 int nWidth
= vImage32
.GetWidth();
69 int nHeight
= vImage32
.GetHeight();
72 // Need a bitmap handle somehow
74 HBITMAP hBitmap
= wxBitmap(vImage32
).GetHBITMAP();
75 int nHotSpotX
= vImage32
.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X
);
76 int nHotSpotY
= vImage32
.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y
);
78 if (nHotSpotX
< 0 || nHotSpotX
>= nWidth
)
80 if (nHotSpotY
< 0 || nHotSpotY
>= nHeight
)
84 wxCursorRefData
* pRefData
= new wxCursorRefData
;
87 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinCreatePointer( HWND_DESKTOP
94 } // end of wxCursor::wxCursor
96 wxCursor::wxCursor( const wxString
& WXUNUSED(rsCursorFile
),
98 int WXUNUSED(nHotSpotX
),
99 int WXUNUSED(nHotSpotY
) )
101 wxCursorRefData
* pRefData
= new wxCursorRefData
;
103 pRefData
= new wxCursorRefData
;
104 m_refData
= pRefData
;
105 pRefData
->m_bDestroyCursor
= false;
106 if (lFlags
== wxBITMAP_TYPE_CUR_RESOURCE
)
108 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
110 ,(ULONG
)lFlags
// if OS/2 this should be the resource Id
113 } // end of wxCursor::wxCursor
115 // Cursors by stock number
116 wxCursor::wxCursor(int nCursorType
)
118 wxCursorRefData
* pRefData
= new wxCursorRefData
;
120 m_refData
= pRefData
;
123 case wxCURSOR_ARROWWAIT
:
124 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
132 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
139 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
146 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
152 case wxCURSOR_SIZENWSE
:
153 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
154 ,(ULONG
)SPTR_SIZENWSE
159 case wxCURSOR_SIZENESW
:
160 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
161 ,(ULONG
)SPTR_SIZENESW
166 case wxCURSOR_SIZEWE
:
167 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
173 case wxCURSOR_SIZENS
:
174 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
181 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
188 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
190 ,(ULONG
)wxCURSOR_HAND
194 case wxCURSOR_BULLSEYE
:
195 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
197 ,(ULONG
)wxCURSOR_BULLSEYE
201 case wxCURSOR_PENCIL
:
202 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
204 ,(ULONG
)wxCURSOR_PENCIL
208 case wxCURSOR_MAGNIFIER
:
209 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
211 ,(ULONG
)wxCURSOR_MAGNIFIER
215 case wxCURSOR_NO_ENTRY
:
216 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
222 case wxCURSOR_LEFT_BUTTON
:
223 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
229 case wxCURSOR_RIGHT_BUTTON
:
230 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
236 case wxCURSOR_MIDDLE_BUTTON
:
237 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
243 case wxCURSOR_SIZING
:
244 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
250 case wxCURSOR_SPRAYCAN
:
251 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
253 ,(ULONG
)WXCURSOR_ROLLER
257 case wxCURSOR_PAINT_BRUSH
:
258 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
260 ,(ULONG
)WXCURSOR_PBRUSH
264 case wxCURSOR_POINT_LEFT
:
265 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
267 ,(ULONG
)WXCURSOR_PLEFT
271 case wxCURSOR_POINT_RIGHT
:
272 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
274 ,(ULONG
)WXCURSOR_PRIGHT
278 case wxCURSOR_QUESTION_ARROW
:
279 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
281 ,(ULONG
)WXCURSOR_QARROW
286 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
288 ,(ULONG
)WXCURSOR_BLANK
294 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
301 // No need to destroy the stock cursors
303 ((wxCursorRefData
*)m_refData
)->m_bDestroyCursor
= false;
304 } // end of wxCursor::wxCursor
306 // Global cursor setting
307 void wxSetCursor(const wxCursor
& cursor
)
309 extern wxCursor
*g_globalCursor
;
311 if ( cursor
.Ok() && cursor
.GetHCURSOR() )
313 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
315 if ( g_globalCursor
)
316 (*g_globalCursor
) = cursor
;