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
;
84 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
87 M_CURSORDATA
->m_hCursor
= ::GetCursor(iBeamCursor
);
90 M_CURSORDATA
->m_hCursor
= ::GetCursor(crossCursor
);
92 case wxCURSOR_SIZENWSE
:
94 wxStAppResource resload
;
95 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
98 case wxCURSOR_SIZENESW
:
100 wxStAppResource resload
;
101 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
104 case wxCURSOR_SIZEWE
:
106 wxStAppResource resload
;
107 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
110 case wxCURSOR_SIZENS
:
112 wxStAppResource resload
;
113 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeNSId
);
118 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
123 wxStAppResource resload
;
124 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
127 case wxCURSOR_BULLSEYE
:
129 wxStAppResource resload
;
130 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
133 case wxCURSOR_PENCIL
:
135 wxStAppResource resload
;
136 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
139 case wxCURSOR_MAGNIFIER
:
141 wxStAppResource resload
;
142 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
145 case wxCURSOR_NO_ENTRY
:
147 wxStAppResource resload
;
148 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
151 case wxCURSOR_LEFT_BUTTON
:
153 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
156 case wxCURSOR_RIGHT_BUTTON
:
158 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
161 case wxCURSOR_MIDDLE_BUTTON
:
163 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
166 case wxCURSOR_SIZING
:
168 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
173 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
176 case wxCURSOR_SPRAYCAN
:
178 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
181 case wxCURSOR_PAINT_BRUSH
:
183 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
186 case wxCURSOR_POINT_LEFT
:
188 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
191 case wxCURSOR_POINT_RIGHT
:
193 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
196 case wxCURSOR_QUESTION_ARROW
:
198 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
203 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
208 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
213 void wxCursor::MacInstall() const
215 if ( m_refData
&& M_CURSORDATA
->m_hCursor
)
217 ::SetCursor( *((CursHandle
)M_CURSORDATA
->m_hCursor
) ) ;
218 gMacCurrentCursor
= (CursHandle
)M_CURSORDATA
->m_hCursor
;
222 ::SetCursor( *MacArrowCursor
) ;
223 gMacCurrentCursor
= NULL
;
227 wxCursor::~wxCursor()
231 // Global cursor setting
232 void wxSetCursor(const wxCursor
& cursor
)
234 cursor
.MacInstall() ;