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"
20 #include "wx/cursor.h"
24 #include "wx/os2/private.h"
25 #include "wx/os2/wxrsc.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxCursor
, wxBitmap
)
32 wxCursorRefData::wxCursorRefData(void)
37 m_bDestroyCursor
= false;
40 void wxCursorRefData::Free()
45 ::WinDestroyPointer((HPOINTER
)m_hCursor
);
48 } // end of wxCursorRefData::Free
51 wxCursor::wxCursor(void)
55 wxCursor::wxCursor(const char WXUNUSED(bits
)[],
58 int WXUNUSED(hotSpotX
),
59 int WXUNUSED(hotSpotY
),
60 const char WXUNUSED(maskBits
)[])
64 wxCursor::wxCursor(const wxImage
& rImage
)
66 wxImage vImage32
= rImage
.Scale(32,32);
67 int nWidth
= vImage32
.GetWidth();
68 int nHeight
= vImage32
.GetHeight();
71 // Need a bitmap handle somehow
73 HBITMAP hBitmap
= wxBitmap(vImage32
).GetHBITMAP();
74 int nHotSpotX
= vImage32
.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X
);
75 int nHotSpotY
= vImage32
.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y
);
77 if (nHotSpotX
< 0 || nHotSpotX
>= nWidth
)
79 if (nHotSpotY
< 0 || nHotSpotY
>= nHeight
)
83 wxCursorRefData
* pRefData
= new wxCursorRefData
;
86 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinCreatePointer( HWND_DESKTOP
93 } // end of wxCursor::wxCursor
95 wxCursor::wxCursor( const wxString
& WXUNUSED(rsCursorFile
),
97 int WXUNUSED(nHotSpotX
),
98 int WXUNUSED(nHotSpotY
) )
100 wxCursorRefData
* pRefData
= new wxCursorRefData
;
102 pRefData
= new wxCursorRefData
;
103 m_refData
= pRefData
;
104 pRefData
->m_bDestroyCursor
= false;
105 if (lFlags
== wxBITMAP_TYPE_CUR_RESOURCE
)
107 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
109 ,(ULONG
)lFlags
// if OS/2 this should be the resource Id
112 } // end of wxCursor::wxCursor
114 // Cursors by stock number
115 wxCursor::wxCursor(int nCursorType
)
117 wxCursorRefData
* pRefData
= new wxCursorRefData
;
119 m_refData
= pRefData
;
122 case wxCURSOR_ARROWWAIT
:
123 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
131 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
138 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
145 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
151 case wxCURSOR_SIZENWSE
:
152 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
153 ,(ULONG
)SPTR_SIZENWSE
158 case wxCURSOR_SIZENESW
:
159 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
160 ,(ULONG
)SPTR_SIZENESW
165 case wxCURSOR_SIZEWE
:
166 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
172 case wxCURSOR_SIZENS
:
173 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
180 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
187 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
189 ,(ULONG
)wxCURSOR_HAND
193 case wxCURSOR_BULLSEYE
:
194 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
196 ,(ULONG
)wxCURSOR_BULLSEYE
200 case wxCURSOR_PENCIL
:
201 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
203 ,(ULONG
)wxCURSOR_PENCIL
207 case wxCURSOR_MAGNIFIER
:
208 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
210 ,(ULONG
)wxCURSOR_MAGNIFIER
214 case wxCURSOR_NO_ENTRY
:
215 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
221 case wxCURSOR_LEFT_BUTTON
:
222 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
228 case wxCURSOR_RIGHT_BUTTON
:
229 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
235 case wxCURSOR_MIDDLE_BUTTON
:
236 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
242 case wxCURSOR_SIZING
:
243 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
249 case wxCURSOR_SPRAYCAN
:
250 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
252 ,(ULONG
)WXCURSOR_ROLLER
256 case wxCURSOR_PAINT_BRUSH
:
257 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
259 ,(ULONG
)WXCURSOR_PBRUSH
263 case wxCURSOR_POINT_LEFT
:
264 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
266 ,(ULONG
)WXCURSOR_PLEFT
270 case wxCURSOR_POINT_RIGHT
:
271 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
273 ,(ULONG
)WXCURSOR_PRIGHT
277 case wxCURSOR_QUESTION_ARROW
:
278 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
280 ,(ULONG
)WXCURSOR_QARROW
285 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
287 ,(ULONG
)WXCURSOR_BLANK
293 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
300 // No need to destroy the stock cursors
302 ((wxCursorRefData
*)m_refData
)->m_bDestroyCursor
= false;
303 } // end of wxCursor::wxCursor
305 // Global cursor setting
306 void wxSetCursor(const wxCursor
& cursor
)
308 extern wxCursor
*g_globalCursor
;
310 if ( cursor
.Ok() && cursor
.GetHCURSOR() )
312 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
314 if ( g_globalCursor
)
315 (*g_globalCursor
) = cursor
;