]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/cursor.cpp
Bit fiddling.
[wxWidgets.git] / src / gtk1 / cursor.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: cursor.cpp
3// Purpose:
4// Author: Robert Roebling
dbf858b5 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
c801d85f
KB
7// Licence: wxWindows licence
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
21class wxCursorRefData: public wxObjectRefData
22{
23 public:
24
25 wxCursorRefData(void);
26 ~wxCursorRefData(void);
27
28 GdkCursor *m_cursor;
29};
30
31wxCursorRefData::wxCursorRefData(void)
32{
c67daf87 33 m_cursor = (GdkCursor *) NULL;
ff7b1510 34}
c801d85f
KB
35
36wxCursorRefData::~wxCursorRefData(void)
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
45IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject)
46
47wxCursor::wxCursor(void)
48{
ff7b1510 49}
c801d85f 50
debe6624 51wxCursor::wxCursor( int cursorId )
c801d85f
KB
52{
53 m_refData = new wxCursorRefData();
54
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 }
c801d85f
KB
70
71 M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur );
72
73/*
74 do that yourself
75
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*/
98
ff7b1510 99}
c801d85f
KB
100
101wxCursor::wxCursor( const wxCursor &cursor )
102{
103 Ref( cursor );
ff7b1510 104}
c801d85f
KB
105
106wxCursor::wxCursor( const wxCursor *cursor )
107{
108 UnRef();
109 if (cursor) Ref( *cursor );
ff7b1510 110}
c801d85f
KB
111
112wxCursor::~wxCursor(void)
113{
ff7b1510 114}
c801d85f
KB
115
116wxCursor& wxCursor::operator = ( const wxCursor& cursor )
117{
118 if (*this == cursor) return (*this);
119 Ref( cursor );
120 return *this;
ff7b1510 121}
c801d85f
KB
122
123bool wxCursor::operator == ( const wxCursor& cursor )
124{
125 return m_refData == cursor.m_refData;
ff7b1510 126}
c801d85f
KB
127
128bool wxCursor::operator != ( const wxCursor& cursor )
129{
130 return m_refData != cursor.m_refData;
ff7b1510 131}
c801d85f
KB
132
133bool wxCursor::Ok(void) const
134{
d8c83875 135 return (m_refData != NULL);
ff7b1510 136}
c801d85f
KB
137
138GdkCursor *wxCursor::GetCursor(void) const
139{
140 return M_CURSORDATA->m_cursor;
ff7b1510 141}
c801d85f
KB
142
143//-----------------------------------------------------------------------------
144// busy cursor routines
145//-----------------------------------------------------------------------------
146
147bool g_isBusy = FALSE;
148
149void wxEndBusyCursor(void)
150{
151 g_isBusy = FALSE;
ff7b1510 152}
c801d85f
KB
153
154void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
155{
156 g_isBusy = TRUE;
ff7b1510 157}
c801d85f
KB
158
159bool wxIsBusy(void)
160{
161 return g_isBusy;
ff7b1510 162}
c801d85f
KB
163
164void wxSetCursor( const wxCursor& cursor )
165{
166 extern wxCursor *g_globalCursor;
167 if (g_globalCursor) (*g_globalCursor) = cursor;
168
ff7b1510
RR
169 if (cursor.Ok()) {}
170}
c801d85f
KB
171
172