]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/cursor.cpp
17646128c6ae14e3abdbcc5070896bea8689847a
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "cursor.h"
15 #include "wx/cursor.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 extern void wxapp_install_idle_handler();
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
31 class wxCursorRefData
: public wxObjectRefData
41 wxCursorRefData::wxCursorRefData()
43 m_cursor
= (GdkCursor
*) NULL
;
46 wxCursorRefData::~wxCursorRefData()
48 if (m_cursor
) gdk_cursor_destroy( m_cursor
);
51 //-----------------------------------------------------------------------------
53 #define M_CURSORDATA ((wxCursorRefData *)m_refData)
55 IMPLEMENT_DYNAMIC_CLASS(wxCursor
,wxObject
)
61 wxCursor::wxCursor( int cursorId
)
63 m_refData
= new wxCursorRefData();
65 GdkCursorType gdk_cur
= GDK_LEFT_PTR
;
68 case wxCURSOR_DEFAULT
: gdk_cur
= GDK_LEFT_PTR
; break;
69 case wxCURSOR_HAND
: gdk_cur
= GDK_HAND1
; break;
70 case wxCURSOR_CROSS
: gdk_cur
= GDK_CROSSHAIR
; break;
71 case wxCURSOR_SIZEWE
: gdk_cur
= GDK_SB_H_DOUBLE_ARROW
; break;
72 case wxCURSOR_SIZENS
: gdk_cur
= GDK_SB_V_DOUBLE_ARROW
; break;
74 case wxCURSOR_WATCH
: gdk_cur
= GDK_WATCH
; break;
75 case wxCURSOR_SIZING
: gdk_cur
= GDK_SIZING
; break;
76 case wxCURSOR_SPRAYCAN
: gdk_cur
= GDK_SPRAYCAN
; break;
77 case wxCURSOR_IBEAM
: gdk_cur
= GDK_XTERM
; break;
78 case wxCURSOR_PENCIL
: gdk_cur
= GDK_PENCIL
; break;
79 case wxCURSOR_NO_ENTRY
: gdk_cur
= GDK_PIRATE
; break;
80 case wxCURSOR_SIZENWSE
:
81 case wxCURSOR_SIZENESW
: gdk_cur
= GDK_FLEUR
; break;
82 case wxCURSOR_QUESTION_ARROW
: gdk_cur
= GDK_QUESTION_ARROW
; break;
83 case wxCURSOR_PAINT_BRUSH
: gdk_cur
= GDK_SPRAYCAN
; break;
84 case wxCURSOR_MAGNIFIER
: gdk_cur
= GDK_PLUS
; break;
85 case wxCURSOR_CHAR
: gdk_cur
= GDK_XTERM
; break;
86 case wxCURSOR_LEFT_BUTTON
: gdk_cur
= GDK_LEFTBUTTON
; break;
87 case wxCURSOR_MIDDLE_BUTTON
: gdk_cur
= GDK_MIDDLEBUTTON
; break;
88 case wxCURSOR_RIGHT_BUTTON
: gdk_cur
= GDK_RIGHTBUTTON
; break;
89 case wxCURSOR_BULLSEYE
: gdk_cur
= GDK_TARGET
; break;
92 case wxCURSOR_DOUBLE_ARROW: gdk_cur = GDK_DOUBLE_ARROW; break;
93 case wxCURSOR_CROSS_REVERSE: gdk_cur = GDK_CROSS_REVERSE; break;
94 case wxCURSOR_BASED_ARROW_UP: gdk_cur = GDK_BASED_ARROW_UP; break;
95 case wxCURSOR_BASED_ARROW_DOWN: gdk_cur = GDK_BASED_ARROW_DOWN; break;
98 wxFAIL_MSG(T("unsupported cursor type"));
99 // will use the standard one
105 M_CURSORDATA
->m_cursor
= gdk_cursor_new( gdk_cur
);
108 wxCursor::wxCursor( const wxCursor
&cursor
)
113 wxCursor::~wxCursor()
117 wxCursor
& wxCursor::operator = ( const wxCursor
& cursor
)
127 bool wxCursor::operator == ( const wxCursor
& cursor
) const
129 return m_refData
== cursor
.m_refData
;
132 bool wxCursor::operator != ( const wxCursor
& cursor
) const
134 return m_refData
!= cursor
.m_refData
;
137 bool wxCursor::Ok() const
139 return (m_refData
!= NULL
);
142 GdkCursor
*wxCursor::GetCursor() const
144 return M_CURSORDATA
->m_cursor
;
147 //-----------------------------------------------------------------------------
148 // busy cursor routines
149 //-----------------------------------------------------------------------------
151 extern wxCursor g_globalCursor
;
153 static wxCursor gs_savedCursor
;
154 static int gs_busyCount
= 0;
156 void wxEndBusyCursor()
158 if (--gs_busyCount
> 0)
161 wxSetCursor( gs_savedCursor
);
162 gs_savedCursor
= wxNullCursor
;
167 void wxBeginBusyCursor( wxCursor
*WXUNUSED(cursor
) )
169 if (gs_busyCount
++ > 0)
172 wxASSERT_MSG( !gs_savedCursor
.Ok(),
173 T("forgot to call wxEndBusyCursor, will leak memory") );
175 gs_savedCursor
= g_globalCursor
;
177 wxSetCursor( wxCursor(wxCURSOR_WATCH
) );
184 return gs_busyCount
> 0;
187 void wxSetCursor( const wxCursor
& cursor
)
190 wxapp_install_idle_handler();
192 g_globalCursor
= cursor
;