1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxCursor class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "cursor.h"
16 #include "wx/cursor.h"
19 IMPLEMENT_DYNAMIC_CLASS(wxCursor
, wxBitmap
)
21 const short kwxCursorHandId
= 9 ;
22 const short kwxCursorSizeWEId
= 10 ;
23 const short kwxCursorSizeNSId
= 11 ;
24 Cursor
* MacArrowCursorPtr
= &qd
.arrow
;
25 CursHandle MacArrowCursor
= &MacArrowCursorPtr
;
26 CursHandle gMacCurrentCursor
= NULL
;
28 wxCursorRefData::wxCursorRefData()
35 wxCursorRefData::~wxCursorRefData()
37 if ( m_hCursor
&& ( m_hCursor
!= MacArrowCursor
) )
38 ::DisposeHandle( (Handle
) m_hCursor
) ;
46 wxCursor::wxCursor(const char WXUNUSED(bits
)[], int WXUNUSED(width
), int WXUNUSED(height
),
47 int WXUNUSED(hotSpotX
), int WXUNUSED(hotSpotY
), const char WXUNUSED(maskBits
)[])
51 wxCursor::wxCursor(const wxString
& cursor_file
, long flags
, int hotSpotX
, int hotSpotY
)
53 m_refData
= new wxCursorRefData
;
55 // TODO: create cursor from a file
58 // Cursors by stock number
59 wxCursor::wxCursor(int cursor_type
)
61 m_refData
= new wxCursorRefData
;
66 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
69 M_CURSORDATA
->m_hCursor
= ::GetCursor(iBeamCursor
);
72 M_CURSORDATA
->m_hCursor
= ::GetCursor(crossCursor
);
74 case wxCURSOR_SIZENWSE
:
75 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
77 case wxCURSOR_SIZENESW
:
78 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
81 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
84 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeNSId
);
88 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
93 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
96 case wxCURSOR_BULLSEYE
:
98 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
101 case wxCURSOR_PENCIL
:
103 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
106 case wxCURSOR_MAGNIFIER
:
108 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
111 case wxCURSOR_NO_ENTRY
:
113 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
116 case wxCURSOR_LEFT_BUTTON
:
118 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
121 case wxCURSOR_RIGHT_BUTTON
:
123 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
126 case wxCURSOR_MIDDLE_BUTTON
:
128 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
131 case wxCURSOR_SIZING
:
133 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
138 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
141 case wxCURSOR_SPRAYCAN
:
143 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
146 case wxCURSOR_PAINT_BRUSH
:
148 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
151 case wxCURSOR_POINT_LEFT
:
153 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
156 case wxCURSOR_POINT_RIGHT
:
158 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
161 case wxCURSOR_QUESTION_ARROW
:
163 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
168 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
173 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
178 void wxCursor::MacInstall() const
180 if ( m_refData
&& M_CURSORDATA
->m_hCursor
)
182 ::SetCursor( *M_CURSORDATA
->m_hCursor
) ;
183 gMacCurrentCursor
= M_CURSORDATA
->m_hCursor
;
187 ::SetCursor( *MacArrowCursor
) ;
188 gMacCurrentCursor
= NULL
;
192 wxCursor::~wxCursor()
196 // Global cursor setting
197 void wxSetCursor(const wxCursor
& cursor
)
199 cursor
.MacInstall() ;