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 wxCursorRefData::wxCursorRefData()
25 m_width = 32; m_height = 32;
32 wxCursorRefData::~wxCursorRefData()
34 // TODO: destroy cursor
42 wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
43 int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
47 wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
49 m_refData = new wxCursorRefData;
51 // TODO: create cursor from a file
54 // Cursors by stock number
55 wxCursor::wxCursor(int cursor_type)
57 m_refData = new wxCursorRefData;
63 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT);
66 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_IBEAM);
69 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS);
71 case wxCURSOR_SIZENWSE:
72 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENWSE);
74 case wxCURSOR_SIZENESW:
75 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENESW);
78 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZEWE);
81 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENS);
85 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
90 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_HAND");
93 case wxCURSOR_BULLSEYE:
95 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BULLSEYE");
100 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PENCIL");
103 case wxCURSOR_MAGNIFIER:
105 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_MAGNIFIER");
108 case wxCURSOR_NO_ENTRY:
110 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_NO_ENTRY");
113 case wxCURSOR_LEFT_BUTTON:
115 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
118 case wxCURSOR_RIGHT_BUTTON:
120 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
123 case wxCURSOR_MIDDLE_BUTTON:
125 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
128 case wxCURSOR_SIZING:
130 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_SIZING");
135 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_WATCH");
138 case wxCURSOR_SPRAYCAN:
140 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_ROLLER");
143 case wxCURSOR_PAINT_BRUSH:
145 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PBRUSH");
148 case wxCURSOR_POINT_LEFT:
150 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PLEFT");
153 case wxCURSOR_POINT_RIGHT:
155 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PRIGHT");
158 case wxCURSOR_QUESTION_ARROW:
160 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_QARROW");
165 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK");
170 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
177 wxCursor::~wxCursor()
181 // Global cursor setting
182 void wxSetCursor(const wxCursor& cursor)
184 // TODO (optional on platforms with no global cursor)
187 static int wxBusyCursorCount = 0;
189 // Set the cursor to the busy cursor for all windows
190 void wxBeginBusyCursor(wxCursor *cursor)
192 wxBusyCursorCount ++;
193 if (wxBusyCursorCount == 1)
203 // Restore cursor to normal
204 void wxEndBusyCursor()
206 if (wxBusyCursorCount == 0)
209 wxBusyCursorCount --;
210 if (wxBusyCursorCount == 0)
216 // TRUE if we're between the above two calls
219 return (wxBusyCursorCount > 0);