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 ;
27 Cursor
* MacArrowCursorPtr
= &qd
.arrow
;
28 CursHandle MacArrowCursor
= &MacArrowCursorPtr
;
30 bool MacArrowInstalled
= false ;
32 Cursor
* MacArrowCursorPtr
= &MacArrow
;
33 CursHandle MacArrowCursor
= &MacArrowCursorPtr
;
35 CursHandle gMacCurrentCursor
= NULL
;
37 wxCursorRefData::wxCursorRefData()
40 if ( !MacArrowInstalled
)
42 MacArrowCursorPtr
= GetQDGlobalsArrow( &MacArrow
) ;
43 MacArrowInstalled
= true ;
51 wxCursorRefData::~wxCursorRefData()
53 // if ( m_hCursor && ( m_hCursor != MacArrowCursor ) )
54 // ::ReleaseResource( (Handle) m_hCursor ) ;
62 wxCursor::wxCursor(const char WXUNUSED(bits
)[], int WXUNUSED(width
), int WXUNUSED(height
),
63 int WXUNUSED(hotSpotX
), int WXUNUSED(hotSpotY
), const char WXUNUSED(maskBits
)[])
67 wxCursor::wxCursor(const wxString
& cursor_file
, long flags
, int hotSpotX
, int hotSpotY
)
69 m_refData
= new wxCursorRefData
;
71 // TODO: create cursor from a file
74 // Cursors by stock number
75 wxCursor::wxCursor(int cursor_type
)
77 m_refData
= new wxCursorRefData
;
82 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
85 M_CURSORDATA
->m_hCursor
= ::GetCursor(iBeamCursor
);
88 M_CURSORDATA
->m_hCursor
= ::GetCursor(crossCursor
);
90 case wxCURSOR_SIZENWSE
:
91 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
93 case wxCURSOR_SIZENESW
:
94 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
97 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeWEId
);
100 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorSizeNSId
);
104 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
109 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
112 case wxCURSOR_BULLSEYE
:
114 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
117 case wxCURSOR_PENCIL
:
119 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
122 case wxCURSOR_MAGNIFIER
:
124 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
127 case wxCURSOR_NO_ENTRY
:
129 M_CURSORDATA
->m_hCursor
= ::GetCursor(kwxCursorHandId
);
132 case wxCURSOR_LEFT_BUTTON
:
134 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
137 case wxCURSOR_RIGHT_BUTTON
:
139 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
142 case wxCURSOR_MIDDLE_BUTTON
:
144 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
147 case wxCURSOR_SIZING
:
149 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
154 M_CURSORDATA
->m_hCursor
= ::GetCursor(watchCursor
);
157 case wxCURSOR_SPRAYCAN
:
159 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
162 case wxCURSOR_PAINT_BRUSH
:
164 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
167 case wxCURSOR_POINT_LEFT
:
169 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
172 case wxCURSOR_POINT_RIGHT
:
174 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
177 case wxCURSOR_QUESTION_ARROW
:
179 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
184 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
189 M_CURSORDATA
->m_hCursor
= MacArrowCursor
;
194 void wxCursor::MacInstall() const
196 if ( m_refData
&& M_CURSORDATA
->m_hCursor
)
198 ::SetCursor( *M_CURSORDATA
->m_hCursor
) ;
199 gMacCurrentCursor
= M_CURSORDATA
->m_hCursor
;
203 ::SetCursor( *MacArrowCursor
) ;
204 gMacCurrentCursor
= NULL
;
208 wxCursor::~wxCursor()
212 // Global cursor setting
213 void wxSetCursor(const wxCursor
& cursor
)
215 cursor
.MacInstall() ;