1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxCursor class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "cursor.h"
16 #include "wx/cursor.h"
18 #include "wx/mac/private.h"
20 #if !USE_SHARED_LIBRARIES
21 IMPLEMENT_DYNAMIC_CLASS(wxCursor
, wxBitmap
)
24 const short kwxCursorHandId
= 9 ;
25 const short kwxCursorSizeWEId
= 10 ;
26 const short kwxCursorSizeNSId
= 11 ;
28 Cursor
* MacArrowCursorPtr
= &qd
.arrow
;
29 CursHandle MacArrowCursor
= &MacArrowCursorPtr
;
31 bool MacArrowInstalled
= false ;
33 Cursor
* MacArrowCursorPtr
= &MacArrow
;
34 CursHandle MacArrowCursor
= &MacArrowCursorPtr
;
36 CursHandle gMacCurrentCursor
= NULL
;
38 wxCursorRefData::wxCursorRefData()
41 if ( !MacArrowInstalled
)
43 MacArrowCursorPtr
= GetQDGlobalsArrow( &MacArrow
) ;
44 MacArrowInstalled
= true ;
52 wxCursorRefData::~wxCursorRefData()
54 // if ( m_hCursor && ( m_hCursor != MacArrowCursor ) )
55 // ::ReleaseResource( (Handle) m_hCursor ) ;
63 wxCursor::wxCursor(const char WXUNUSED(bits
)[], int WXUNUSED(width
), int WXUNUSED(height
),
64 int WXUNUSED(hotSpotX
), int WXUNUSED(hotSpotY
), const char WXUNUSED(maskBits
)[])
68 wxCursor::wxCursor(const wxString
& cursor_file
, long flags
, int hotSpotX
, int hotSpotY
)
70 m_refData
= new wxCursorRefData
;
72 // TODO: create cursor from a file
75 // Cursors by stock number
76 wxCursor::wxCursor(int cursor_type
)
78 m_refData
= new wxCursorRefData
;
83 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
86 M_CURSORDATA
->m_hCursor
= ::GetCursor(iBeamCursor
);
89 M_CURSORDATA
->m_hCursor
= ::GetCursor(crossCursor
);
91 case wxCURSOR_SIZENWSE
:
92 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
94 case wxCURSOR_SIZENESW
:
95 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
98 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
100 case wxCURSOR_SIZENS
:
101 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeNSId
);
105 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
110 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
113 case wxCURSOR_BULLSEYE
:
115 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
118 case wxCURSOR_PENCIL
:
120 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
123 case wxCURSOR_MAGNIFIER
:
125 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
128 case wxCURSOR_NO_ENTRY
:
130 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
133 case wxCURSOR_LEFT_BUTTON
:
135 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
138 case wxCURSOR_RIGHT_BUTTON
:
140 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
143 case wxCURSOR_MIDDLE_BUTTON
:
145 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
148 case wxCURSOR_SIZING
:
150 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
155 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
158 case wxCURSOR_SPRAYCAN
:
160 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
163 case wxCURSOR_PAINT_BRUSH
:
165 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
168 case wxCURSOR_POINT_LEFT
:
170 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
173 case wxCURSOR_POINT_RIGHT
:
175 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
178 case wxCURSOR_QUESTION_ARROW
:
180 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
185 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
190 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
195 void wxCursor::MacInstall() const
197 if ( m_refData
&& M_CURSORDATA
->m_hCursor
)
199 ::SetCursor( *((CursHandle
)M_CURSORDATA
->m_hCursor
) ) ;
200 gMacCurrentCursor
= (CursHandle
)M_CURSORDATA
->m_hCursor
;
204 ::SetCursor( *MacArrowCursor
) ;
205 gMacCurrentCursor
= NULL
;
209 wxCursor::~wxCursor()
213 // Global cursor setting
214 void wxSetCursor(const wxCursor
& cursor
)
216 cursor
.MacInstall() ;