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"
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)
56 const char WXUNUSED(bits
)[]
58 , int WXUNUSED(height
)
59 , int WXUNUSED(hotSpotX
)
60 , int WXUNUSED(hotSpotY
)
61 , const char WXUNUSED(maskBits
)[]
70 wxImage vImage32
= rImage
.Scale(32,32);
71 int nWidth
= vImage32
.GetWidth();
72 int nHeight
= vImage32
.GetHeight();
75 // Need a bitmap handle somehow
77 HBITMAP hBitmap
= wxBitmap(vImage32
).GetHBITMAP();
78 int nHotSpotX
= vImage32
.GetOptionInt(wxCUR_HOTSPOT_X
);
79 int nHotSpotY
= vImage32
.GetOptionInt(wxCUR_HOTSPOT_Y
);
81 if (nHotSpotX
< 0 || nHotSpotX
>= nWidth
)
83 if (nHotSpotY
< 0 || nHotSpotY
>= nHeight
)
87 wxCursorRefData
* pRefData
= new wxCursorRefData
;
90 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinCreatePointer( HWND_DESKTOP
97 } // end of wxCursor::wxCursor
100 const wxString
& rsCursorFile
106 wxCursorRefData
* pRefData
= new wxCursorRefData
;
108 pRefData
= new wxCursorRefData
;
109 m_refData
= pRefData
;
110 pRefData
->m_bDestroyCursor
= FALSE
;
111 if (lFlags
== wxBITMAP_TYPE_CUR_RESOURCE
)
113 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
115 ,(ULONG
)lFlags
// if OS/2 this should be the resource Id
118 } // end of wxCursor::wxCursor
120 // Cursors by stock number
125 wxCursorRefData
* pRefData
= new wxCursorRefData
;
127 m_refData
= pRefData
;
130 case wxCURSOR_ARROWWAIT
:
131 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
) ::WinLoadPointer( HWND_DESKTOP
224 ,(ULONG
)wxCURSOR_NO_ENTRY
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
257 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
259 ,(ULONG
)wxCURSOR_WATCH
263 case wxCURSOR_SPRAYCAN
:
264 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
266 ,(ULONG
)WXCURSOR_ROLLER
270 case wxCURSOR_PAINT_BRUSH
:
271 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
273 ,(ULONG
)WXCURSOR_PBRUSH
277 case wxCURSOR_POINT_LEFT
:
278 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
280 ,(ULONG
)WXCURSOR_PLEFT
284 case wxCURSOR_POINT_RIGHT
:
285 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
287 ,(ULONG
)WXCURSOR_PRIGHT
291 case wxCURSOR_QUESTION_ARROW
:
292 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
294 ,(ULONG
)WXCURSOR_QARROW
299 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
301 ,(ULONG
)WXCURSOR_BLANK
307 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
313 } // end of wxCursor::wxCursor
315 // Global cursor setting
316 void wxSetCursor(const wxCursor
& cursor
)
318 extern wxCursor
*g_globalCursor
;
320 if ( cursor
.Ok() && cursor
.GetHCURSOR() )
322 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
324 if ( g_globalCursor
)
325 (*g_globalCursor
) = cursor
;