1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxCursor class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "cursor.h"
19 #include "wx/cursor.h"
21 #include "wx/mac/private.h"
23 #if !USE_SHARED_LIBRARIES
24 IMPLEMENT_DYNAMIC_CLASS(wxCursor
, wxBitmap
)
27 const short kwxCursorHandId
= 9 ;
28 const short kwxCursorSizeWEId
= 10 ;
29 const short kwxCursorSizeNSId
= 11 ;
31 Cursor
* MacArrowCursorPtr
= &qd
.arrow
;
32 CursHandle MacArrowCursor
= &MacArrowCursorPtr
;
34 bool MacArrowInstalled
= false ;
36 Cursor
* MacArrowCursorPtr
= &MacArrow
;
37 CursHandle MacArrowCursor
= &MacArrowCursorPtr
;
39 CursHandle gMacCurrentCursor
= NULL
;
41 wxCursorRefData::wxCursorRefData()
44 if ( !MacArrowInstalled
)
46 MacArrowCursorPtr
= GetQDGlobalsArrow( &MacArrow
) ;
47 MacArrowInstalled
= true ;
55 wxCursorRefData::~wxCursorRefData()
57 // if ( m_hCursor && ( m_hCursor != MacArrowCursor ) )
58 // ::ReleaseResource( (Handle) m_hCursor ) ;
66 wxCursor::wxCursor(const char WXUNUSED(bits
)[], int WXUNUSED(width
), int WXUNUSED(height
),
67 int WXUNUSED(hotSpotX
), int WXUNUSED(hotSpotY
), const char WXUNUSED(maskBits
)[])
71 wxCursor::wxCursor(const wxString
& cursor_file
, long flags
, int hotSpotX
, int hotSpotY
)
73 m_refData
= new wxCursorRefData
;
75 // TODO: create cursor from a file
78 // Cursors by stock number
79 wxCursor::wxCursor(int cursor_type
)
81 m_refData
= new wxCursorRefData
;
87 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
90 M_CURSORDATA
->m_hCursor
= ::GetCursor(iBeamCursor
);
93 M_CURSORDATA
->m_hCursor
= ::GetCursor(crossCursor
);
95 case wxCURSOR_SIZENWSE
:
97 wxStAppResource resload
;
98 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
101 case wxCURSOR_SIZENESW
:
103 wxStAppResource resload
;
104 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
107 case wxCURSOR_SIZEWE
:
109 wxStAppResource resload
;
110 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
113 case wxCURSOR_SIZENS
:
115 wxStAppResource resload
;
116 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeNSId
);
121 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
126 wxStAppResource resload
;
127 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
130 case wxCURSOR_BULLSEYE
:
132 wxStAppResource resload
;
133 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
136 case wxCURSOR_PENCIL
:
138 wxStAppResource resload
;
139 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
142 case wxCURSOR_MAGNIFIER
:
144 wxStAppResource resload
;
145 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
148 case wxCURSOR_NO_ENTRY
:
150 wxStAppResource resload
;
151 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
154 case wxCURSOR_LEFT_BUTTON
:
156 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
159 case wxCURSOR_RIGHT_BUTTON
:
161 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
164 case wxCURSOR_MIDDLE_BUTTON
:
166 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
169 case wxCURSOR_SIZING
:
171 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
176 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
179 case wxCURSOR_SPRAYCAN
:
181 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
184 case wxCURSOR_PAINT_BRUSH
:
186 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
189 case wxCURSOR_POINT_LEFT
:
191 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
194 case wxCURSOR_POINT_RIGHT
:
196 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
199 case wxCURSOR_QUESTION_ARROW
:
201 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
206 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
211 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
216 void wxCursor::MacInstall() const
218 if ( m_refData
&& M_CURSORDATA
->m_hCursor
)
220 CursHandle ch
= ((CursHandle
)M_CURSORDATA
->m_hCursor
) ;
222 gMacCurrentCursor
= ch
;
226 ::SetCursor( *MacArrowCursor
) ;
227 gMacCurrentCursor
= NULL
;
231 wxCursor::~wxCursor()
235 // Global cursor setting
236 void wxSetCursor(const wxCursor
& cursor
)
238 cursor
.MacInstall() ;