1 /////////////////////////////////////////////////////////////////////////////
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"
21 #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)
57 const char WXUNUSED(bits
)[]
59 , int WXUNUSED(height
)
60 , int WXUNUSED(hotSpotX
)
61 , int WXUNUSED(hotSpotY
)
62 , const char WXUNUSED(maskBits
)[]
71 wxImage vImage32
= rImage
.Scale(32,32);
72 int nWidth
= vImage32
.GetWidth();
73 int nHeight
= vImage32
.GetHeight();
76 // Need a bitmap handle somehow
78 HBITMAP hBitmap
= wxBitmap(vImage32
).GetHBITMAP();
79 int nHotSpotX
= vImage32
.GetOptionInt(wxCUR_HOTSPOT_X
);
80 int nHotSpotY
= vImage32
.GetOptionInt(wxCUR_HOTSPOT_Y
);
82 if (nHotSpotX
< 0 || nHotSpotX
>= nWidth
)
84 if (nHotSpotY
< 0 || nHotSpotY
>= nHeight
)
88 wxCursorRefData
* pRefData
= new wxCursorRefData
;
91 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinCreatePointer( HWND_DESKTOP
98 } // end of wxCursor::wxCursor
100 wxCursor::wxCursor( const wxString
& WXUNUSED(rsCursorFile
),
102 int WXUNUSED(nHotSpotX
),
103 int WXUNUSED(nHotSpotY
) )
105 wxCursorRefData
* pRefData
= new wxCursorRefData
;
107 pRefData
= new wxCursorRefData
;
108 m_refData
= pRefData
;
109 pRefData
->m_bDestroyCursor
= FALSE
;
110 if (lFlags
== wxBITMAP_TYPE_CUR_RESOURCE
)
112 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
114 ,(ULONG
)lFlags
// if OS/2 this should be the resource Id
117 } // end of wxCursor::wxCursor
119 // Cursors by stock number
124 wxCursorRefData
* pRefData
= new wxCursorRefData
;
126 m_refData
= pRefData
;
129 case wxCURSOR_ARROWWAIT
:
130 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
138 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
145 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
152 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
158 case wxCURSOR_SIZENWSE
:
159 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
160 ,(ULONG
)SPTR_SIZENWSE
165 case wxCURSOR_SIZENESW
:
166 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
167 ,(ULONG
)SPTR_SIZENESW
172 case wxCURSOR_SIZEWE
:
173 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
179 case wxCURSOR_SIZENS
:
180 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
187 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
194 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
196 ,(ULONG
)wxCURSOR_HAND
200 case wxCURSOR_BULLSEYE
:
201 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
203 ,(ULONG
)wxCURSOR_BULLSEYE
207 case wxCURSOR_PENCIL
:
208 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
210 ,(ULONG
)wxCURSOR_PENCIL
214 case wxCURSOR_MAGNIFIER
:
215 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
217 ,(ULONG
)wxCURSOR_MAGNIFIER
221 case wxCURSOR_NO_ENTRY
:
222 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
228 case wxCURSOR_LEFT_BUTTON
:
229 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
235 case wxCURSOR_RIGHT_BUTTON
:
236 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
242 case wxCURSOR_MIDDLE_BUTTON
:
243 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
249 case wxCURSOR_SIZING
:
250 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
256 case wxCURSOR_SPRAYCAN
:
257 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
259 ,(ULONG
)WXCURSOR_ROLLER
263 case wxCURSOR_PAINT_BRUSH
:
264 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
266 ,(ULONG
)WXCURSOR_PBRUSH
270 case wxCURSOR_POINT_LEFT
:
271 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
273 ,(ULONG
)WXCURSOR_PLEFT
277 case wxCURSOR_POINT_RIGHT
:
278 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
280 ,(ULONG
)WXCURSOR_PRIGHT
284 case wxCURSOR_QUESTION_ARROW
:
285 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
287 ,(ULONG
)WXCURSOR_QARROW
292 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
294 ,(ULONG
)WXCURSOR_BLANK
300 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
307 // No need to destroy the stock cursors
309 ((wxCursorRefData
*)m_refData
)->m_bDestroyCursor
= FALSE
;
310 } // end of wxCursor::wxCursor
312 // Global cursor setting
313 void wxSetCursor(const wxCursor
& cursor
)
315 extern wxCursor
*g_globalCursor
;
317 if ( cursor
.Ok() && cursor
.GetHCURSOR() )
319 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
321 if ( g_globalCursor
)
322 (*g_globalCursor
) = cursor
;