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"
23 #include "wx/resource.h"
26 #include "wx/os2/private.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
101 const wxString
& rsCursorFile
107 wxCursorRefData
* pRefData
= new wxCursorRefData
;
109 pRefData
= new wxCursorRefData
;
110 m_refData
= pRefData
;
111 pRefData
->m_bDestroyCursor
= FALSE
;
112 if (lFlags
== wxBITMAP_TYPE_CUR_RESOURCE
)
114 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
116 ,(ULONG
)lFlags
// if OS/2 this should be the resource Id
119 } // end of wxCursor::wxCursor
121 // Cursors by stock number
126 wxCursorRefData
* pRefData
= new wxCursorRefData
;
128 m_refData
= pRefData
;
131 case wxCURSOR_ARROWWAIT
:
132 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
139 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
146 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
153 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
159 case wxCURSOR_SIZENWSE
:
160 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
161 ,(ULONG
)SPTR_SIZENWSE
166 case wxCURSOR_SIZENESW
:
167 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
168 ,(ULONG
)SPTR_SIZENESW
173 case wxCURSOR_SIZEWE
:
174 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
180 case wxCURSOR_SIZENS
:
181 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
188 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
195 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
197 ,(ULONG
)wxCURSOR_HAND
201 case wxCURSOR_BULLSEYE
:
202 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
204 ,(ULONG
)wxCURSOR_BULLSEYE
208 case wxCURSOR_PENCIL
:
209 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
211 ,(ULONG
)wxCURSOR_PENCIL
215 case wxCURSOR_MAGNIFIER
:
216 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
218 ,(ULONG
)wxCURSOR_MAGNIFIER
222 case wxCURSOR_NO_ENTRY
:
223 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
225 ,(ULONG
)wxCURSOR_NO_ENTRY
229 case wxCURSOR_LEFT_BUTTON
:
230 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
236 case wxCURSOR_RIGHT_BUTTON
:
237 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
243 case wxCURSOR_MIDDLE_BUTTON
:
244 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
250 case wxCURSOR_SIZING
:
251 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
258 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
260 ,(ULONG
)wxCURSOR_WATCH
264 case wxCURSOR_SPRAYCAN
:
265 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
267 ,(ULONG
)WXCURSOR_ROLLER
271 case wxCURSOR_PAINT_BRUSH
:
272 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
274 ,(ULONG
)WXCURSOR_PBRUSH
278 case wxCURSOR_POINT_LEFT
:
279 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
281 ,(ULONG
)WXCURSOR_PLEFT
285 case wxCURSOR_POINT_RIGHT
:
286 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
288 ,(ULONG
)WXCURSOR_PRIGHT
292 case wxCURSOR_QUESTION_ARROW
:
293 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
295 ,(ULONG
)WXCURSOR_QARROW
300 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
302 ,(ULONG
)WXCURSOR_BLANK
308 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
314 } // end of wxCursor::wxCursor
316 // Global cursor setting
317 void wxSetCursor(const wxCursor
& cursor
)
319 extern wxCursor
*g_globalCursor
;
321 if ( cursor
.Ok() && cursor
.GetHCURSOR() )
323 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
325 if ( g_globalCursor
)
326 (*g_globalCursor
) = cursor
;