]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: cursor.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
dbf858b5 | 5 | // Id: $Id$ |
01111366 | 6 | // Copyright: (c) 1998 Robert Roebling |
8bbe427f | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | ||
11 | #ifdef __GNUG__ | |
12 | #pragma implementation "cursor.h" | |
13 | #endif | |
14 | ||
15 | #include "wx/cursor.h" | |
16 | ||
17 | //----------------------------------------------------------------------------- | |
18 | // wxCursor | |
19 | //----------------------------------------------------------------------------- | |
20 | ||
21 | class wxCursorRefData: public wxObjectRefData | |
22 | { | |
23 | public: | |
8bbe427f VZ |
24 | |
25 | wxCursorRefData(); | |
26 | ~wxCursorRefData(); | |
27 | ||
c801d85f KB |
28 | GdkCursor *m_cursor; |
29 | }; | |
30 | ||
8bbe427f | 31 | wxCursorRefData::wxCursorRefData() |
c801d85f | 32 | { |
c67daf87 | 33 | m_cursor = (GdkCursor *) NULL; |
ff7b1510 | 34 | } |
c801d85f | 35 | |
8bbe427f | 36 | wxCursorRefData::~wxCursorRefData() |
c801d85f KB |
37 | { |
38 | if (m_cursor) gdk_cursor_destroy( m_cursor ); | |
ff7b1510 | 39 | } |
c801d85f KB |
40 | |
41 | //----------------------------------------------------------------------------- | |
42 | ||
43 | #define M_CURSORDATA ((wxCursorRefData *)m_refData) | |
44 | ||
45 | IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject) | |
46 | ||
8bbe427f | 47 | wxCursor::wxCursor() |
c801d85f | 48 | { |
ff7b1510 | 49 | } |
c801d85f | 50 | |
debe6624 | 51 | wxCursor::wxCursor( int cursorId ) |
c801d85f KB |
52 | { |
53 | m_refData = new wxCursorRefData(); | |
8bbe427f | 54 | |
c801d85f KB |
55 | GdkCursorType gdk_cur = GDK_LEFT_PTR; |
56 | switch (cursorId) | |
57 | { | |
58 | case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break; | |
59 | case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break; | |
60 | case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break; | |
61 | case wxCURSOR_SIZENS: gdk_cur = GDK_SB_V_DOUBLE_ARROW; break; | |
62 | case wxCURSOR_WAIT: gdk_cur = GDK_WATCH; break; | |
63 | case wxCURSOR_WATCH: gdk_cur = GDK_WATCH; break; | |
64 | case wxCURSOR_SIZING: gdk_cur = GDK_SIZING; break; | |
65 | case wxCURSOR_SPRAYCAN: gdk_cur = GDK_SPRAYCAN; break; | |
66 | case wxCURSOR_IBEAM: gdk_cur = GDK_XTERM; break; | |
67 | case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; | |
68 | case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; | |
ff7b1510 | 69 | } |
8bbe427f | 70 | |
c801d85f | 71 | M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); |
8bbe427f | 72 | |
c801d85f KB |
73 | /* |
74 | do that yourself | |
8bbe427f | 75 | |
c801d85f KB |
76 | wxCURSOR_BULLSEYE, |
77 | wxCURSOR_CHAR, | |
78 | wxCURSOR_LEFT_BUTTON, | |
79 | wxCURSOR_MAGNIFIER, | |
80 | wxCURSOR_MIDDLE_BUTTON, | |
81 | wxCURSOR_NO_ENTRY, | |
82 | wxCURSOR_PAINT_BRUSH, | |
83 | wxCURSOR_POINT_LEFT, | |
84 | wxCURSOR_POINT_RIGHT, | |
85 | wxCURSOR_QUESTION_ARROW, | |
86 | wxCURSOR_RIGHT_BUTTON, | |
87 | wxCURSOR_SIZENESW, | |
88 | wxCURSOR_SIZENS, | |
89 | wxCURSOR_SIZENWSE, | |
90 | wxCURSOR_SIZEWE, | |
91 | wxCURSOR_BLANK | |
92 | , | |
93 | wxCURSOR_CROSS_REVERSE, | |
94 | wxCURSOR_DOUBLE_ARROW, | |
95 | wxCURSOR_BASED_ARROW_UP, | |
96 | wxCURSOR_BASED_ARROW_DOWN | |
97 | */ | |
8bbe427f | 98 | |
ff7b1510 | 99 | } |
c801d85f KB |
100 | |
101 | wxCursor::wxCursor( const wxCursor &cursor ) | |
102 | { | |
103 | Ref( cursor ); | |
ff7b1510 | 104 | } |
c801d85f | 105 | |
8bbe427f | 106 | wxCursor::~wxCursor() |
c801d85f | 107 | { |
ff7b1510 | 108 | } |
c801d85f KB |
109 | |
110 | wxCursor& wxCursor::operator = ( const wxCursor& cursor ) | |
111 | { | |
8bbe427f VZ |
112 | if (*this == cursor) return (*this); |
113 | Ref( cursor ); | |
114 | return *this; | |
ff7b1510 | 115 | } |
c801d85f | 116 | |
8bbe427f | 117 | bool wxCursor::operator == ( const wxCursor& cursor ) const |
c801d85f | 118 | { |
8bbe427f | 119 | return m_refData == cursor.m_refData; |
ff7b1510 | 120 | } |
c801d85f | 121 | |
8bbe427f | 122 | bool wxCursor::operator != ( const wxCursor& cursor ) const |
c801d85f | 123 | { |
8bbe427f | 124 | return m_refData != cursor.m_refData; |
ff7b1510 | 125 | } |
c801d85f | 126 | |
8bbe427f | 127 | bool wxCursor::Ok() const |
c801d85f | 128 | { |
d8c83875 | 129 | return (m_refData != NULL); |
ff7b1510 | 130 | } |
c801d85f | 131 | |
8bbe427f | 132 | GdkCursor *wxCursor::GetCursor() const |
c801d85f KB |
133 | { |
134 | return M_CURSORDATA->m_cursor; | |
ff7b1510 | 135 | } |
c801d85f KB |
136 | |
137 | //----------------------------------------------------------------------------- | |
138 | // busy cursor routines | |
139 | //----------------------------------------------------------------------------- | |
140 | ||
141 | bool g_isBusy = FALSE; | |
142 | ||
8bbe427f | 143 | void wxEndBusyCursor() |
c801d85f KB |
144 | { |
145 | g_isBusy = FALSE; | |
ff7b1510 | 146 | } |
c801d85f KB |
147 | |
148 | void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) | |
149 | { | |
150 | g_isBusy = TRUE; | |
ff7b1510 | 151 | } |
c801d85f | 152 | |
8bbe427f | 153 | bool wxIsBusy() |
c801d85f KB |
154 | { |
155 | return g_isBusy; | |
ff7b1510 | 156 | } |
c801d85f KB |
157 | |
158 | void wxSetCursor( const wxCursor& cursor ) | |
159 | { | |
160 | extern wxCursor *g_globalCursor; | |
161 | if (g_globalCursor) (*g_globalCursor) = cursor; | |
162 | ||
ff7b1510 RR |
163 | if (cursor.Ok()) {} |
164 | } | |
c801d85f KB |
165 | |
166 |