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
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
140 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
147 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
154 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
160 case wxCURSOR_SIZENWSE
:
161 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
162 ,(ULONG
)SPTR_SIZENWSE
167 case wxCURSOR_SIZENESW
:
168 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
169 ,(ULONG
)SPTR_SIZENESW
174 case wxCURSOR_SIZEWE
:
175 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
181 case wxCURSOR_SIZENS
:
182 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
189 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
196 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
198 ,(ULONG
)wxCURSOR_HAND
202 case wxCURSOR_BULLSEYE
:
203 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
205 ,(ULONG
)wxCURSOR_BULLSEYE
209 case wxCURSOR_PENCIL
:
210 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
212 ,(ULONG
)wxCURSOR_PENCIL
216 case wxCURSOR_MAGNIFIER
:
217 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
219 ,(ULONG
)wxCURSOR_MAGNIFIER
223 case wxCURSOR_NO_ENTRY
:
224 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
230 case wxCURSOR_LEFT_BUTTON
:
231 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
237 case wxCURSOR_RIGHT_BUTTON
:
238 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
244 case wxCURSOR_MIDDLE_BUTTON
:
245 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
251 case wxCURSOR_SIZING
:
252 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
258 case wxCURSOR_SPRAYCAN
:
259 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
261 ,(ULONG
)WXCURSOR_ROLLER
265 case wxCURSOR_PAINT_BRUSH
:
266 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
268 ,(ULONG
)WXCURSOR_PBRUSH
272 case wxCURSOR_POINT_LEFT
:
273 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
275 ,(ULONG
)WXCURSOR_PLEFT
279 case wxCURSOR_POINT_RIGHT
:
280 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
282 ,(ULONG
)WXCURSOR_PRIGHT
286 case wxCURSOR_QUESTION_ARROW
:
287 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
289 ,(ULONG
)WXCURSOR_QARROW
294 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinLoadPointer( HWND_DESKTOP
296 ,(ULONG
)WXCURSOR_BLANK
302 pRefData
->m_hCursor
= (WXHCURSOR
) ::WinQuerySysPointer( HWND_DESKTOP
309 // No need to destroy the stock cursors
311 ((wxCursorRefData
*)m_refData
)->m_bDestroyCursor
= FALSE
;
312 } // end of wxCursor::wxCursor
314 // Global cursor setting
315 void wxSetCursor(const wxCursor
& cursor
)
317 extern wxCursor
*g_globalCursor
;
319 if ( cursor
.Ok() && cursor
.GetHCURSOR() )
321 // ::SetCursor((HCURSOR) cursor.GetHCURSOR());
323 if ( g_globalCursor
)
324 (*g_globalCursor
) = cursor
;