1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxCursor class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWidgets licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "cursor.h"
16 #include "wx/wxprec.h"
19 #include "wx/cursor.h"
22 #if !USE_SHARED_LIBRARIES
23 IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
26 wxCursorRefData::wxCursorRefData()
28 m_width = 32; m_height = 32;
35 wxCursorRefData::~wxCursorRefData()
37 // TODO: destroy cursor
45 wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
46 int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
50 wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
52 m_refData = new wxCursorRefData;
54 // TODO: create cursor from a file
57 // Cursors by stock number
58 wxCursor::wxCursor(int cursor_type)
60 m_refData = new wxCursorRefData;
66 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT);
69 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_IBEAM);
72 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS);
74 case wxCURSOR_SIZENWSE:
75 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENWSE);
77 case wxCURSOR_SIZENESW:
78 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENESW);
81 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZEWE);
84 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENS);
88 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
93 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_HAND");
96 case wxCURSOR_BULLSEYE:
98 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BULLSEYE");
101 case wxCURSOR_PENCIL:
103 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PENCIL");
106 case wxCURSOR_MAGNIFIER:
108 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_MAGNIFIER");
111 case wxCURSOR_NO_ENTRY:
113 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_NO_ENTRY");
116 case wxCURSOR_LEFT_BUTTON:
118 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
121 case wxCURSOR_RIGHT_BUTTON:
123 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
126 case wxCURSOR_MIDDLE_BUTTON:
128 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
131 case wxCURSOR_SIZING:
133 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_SIZING");
138 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_WATCH");
141 case wxCURSOR_SPRAYCAN:
143 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_ROLLER");
146 case wxCURSOR_PAINT_BRUSH:
148 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PBRUSH");
151 case wxCURSOR_POINT_LEFT:
153 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PLEFT");
156 case wxCURSOR_POINT_RIGHT:
158 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PRIGHT");
161 case wxCURSOR_QUESTION_ARROW:
163 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_QARROW");
168 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK");
173 M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
180 wxCursor::~wxCursor()
184 // Global cursor setting
185 void wxSetCursor(const wxCursor& cursor)
187 // TODO (optional on platforms with no global cursor)
190 static int wxBusyCursorCount = 0;
192 // Set the cursor to the busy cursor for all windows
193 void wxBeginBusyCursor(wxCursor *cursor)
195 wxBusyCursorCount ++;
196 if (wxBusyCursorCount == 1)
206 // Restore cursor to normal
207 void wxEndBusyCursor()
209 if (wxBusyCursorCount == 0)
212 wxBusyCursorCount --;
213 if (wxBusyCursorCount == 0)
219 // TRUE if we're between the above two calls
222 return (wxBusyCursorCount > 0);