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 #if !USE_SHARED_LIBRARIES
20 IMPLEMENT_DYNAMIC_CLASS(wxCursor
, wxBitmap
)
23 const short kwxCursorHandId
= 9 ;
24 const short kwxCursorSizeWEId
= 10 ;
25 const short kwxCursorSizeNSId
= 11 ;
26 Cursor
* MacArrowCursorPtr
= &qd
.arrow
;
27 CursHandle MacArrowCursor
= &MacArrowCursorPtr
;
28 CursHandle gMacCurrentCursor
= NULL
;
30 wxCursorRefData::wxCursorRefData()
37 wxCursorRefData::~wxCursorRefData()
39 if ( m_hCursor
&& ( m_hCursor
!= MacArrowCursor
) )
40 ::DisposeHandle( (Handle
) m_hCursor
) ;
48 wxCursor::wxCursor(const char WXUNUSED(bits
)[], int WXUNUSED(width
), int WXUNUSED(height
),
49 int WXUNUSED(hotSpotX
), int WXUNUSED(hotSpotY
), const char WXUNUSED(maskBits
)[])
53 wxCursor::wxCursor(const wxString
& cursor_file
, long flags
, int hotSpotX
, int hotSpotY
)
55 m_refData
= new wxCursorRefData
;
57 // TODO: create cursor from a file
60 // Cursors by stock number
61 wxCursor::wxCursor(int cursor_type
)
63 m_refData
= new wxCursorRefData
;
68 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
71 M_CURSORDATA
->m_hCursor
= ::GetCursor(iBeamCursor
);
74 M_CURSORDATA
->m_hCursor
= ::GetCursor(crossCursor
);
76 case wxCURSOR_SIZENWSE
:
77 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
79 case wxCURSOR_SIZENESW
:
80 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
83 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
86 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeNSId
);
90 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
95 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
98 case wxCURSOR_BULLSEYE
:
100 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
103 case wxCURSOR_PENCIL
:
105 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
108 case wxCURSOR_MAGNIFIER
:
110 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
113 case wxCURSOR_NO_ENTRY
:
115 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
118 case wxCURSOR_LEFT_BUTTON
:
120 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
123 case wxCURSOR_RIGHT_BUTTON
:
125 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
128 case wxCURSOR_MIDDLE_BUTTON
:
130 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
133 case wxCURSOR_SIZING
:
135 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
140 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
143 case wxCURSOR_SPRAYCAN
:
145 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
148 case wxCURSOR_PAINT_BRUSH
:
150 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
153 case wxCURSOR_POINT_LEFT
:
155 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
158 case wxCURSOR_POINT_RIGHT
:
160 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
163 case wxCURSOR_QUESTION_ARROW
:
165 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
170 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
175 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
180 void wxCursor::MacInstall() const
182 if ( m_refData
&& M_CURSORDATA
->m_hCursor
)
184 ::SetCursor( *M_CURSORDATA
->m_hCursor
) ;
185 gMacCurrentCursor
= M_CURSORDATA
->m_hCursor
;
189 ::SetCursor( *MacArrowCursor
) ;
190 gMacCurrentCursor
= NULL
;
194 wxCursor::~wxCursor()
198 // Global cursor setting
199 void wxSetCursor(const wxCursor
& cursor
)
201 cursor
.MacInstall() ;