]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/cursor.cpp
Added (untested) support for sub-locales.
[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
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
83624f79
RR
17#include "gdk/gdk.h"
18
c801d85f
KB
19//-----------------------------------------------------------------------------
20// wxCursor
21//-----------------------------------------------------------------------------
22
23class wxCursorRefData: public wxObjectRefData
24{
25 public:
8bbe427f
VZ
26
27 wxCursorRefData();
28 ~wxCursorRefData();
29
c801d85f
KB
30 GdkCursor *m_cursor;
31};
32
8bbe427f 33wxCursorRefData::wxCursorRefData()
c801d85f 34{
2d17d68f 35 m_cursor = (GdkCursor *) NULL;
ff7b1510 36}
c801d85f 37
8bbe427f 38wxCursorRefData::~wxCursorRefData()
c801d85f 39{
2d17d68f 40 if (m_cursor) gdk_cursor_destroy( m_cursor );
ff7b1510 41}
c801d85f
KB
42
43//-----------------------------------------------------------------------------
44
45#define M_CURSORDATA ((wxCursorRefData *)m_refData)
46
47IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject)
48
8bbe427f 49wxCursor::wxCursor()
c801d85f 50{
ff7b1510 51}
c801d85f 52
debe6624 53wxCursor::wxCursor( int cursorId )
c801d85f 54{
2d17d68f
RR
55 m_refData = new wxCursorRefData();
56
57 GdkCursorType gdk_cur = GDK_LEFT_PTR;
58 switch (cursorId)
59 {
60 case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break;
61 case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break;
62 case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break;
63 case wxCURSOR_SIZENS: gdk_cur = GDK_SB_V_DOUBLE_ARROW; break;
64 case wxCURSOR_WAIT:
65 case wxCURSOR_WATCH: gdk_cur = GDK_WATCH; break;
66 case wxCURSOR_SIZING: gdk_cur = GDK_SIZING; break;
67 case wxCURSOR_SPRAYCAN: gdk_cur = GDK_SPRAYCAN; break;
68 case wxCURSOR_IBEAM: gdk_cur = GDK_XTERM; break;
69 case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break;
70 case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break;
71 case wxCURSOR_SIZENWSE:
72 case wxCURSOR_SIZENESW: gdk_cur = GDK_FLEUR; break;
73 case wxCURSOR_QUESTION_ARROW: gdk_cur = GDK_QUESTION_ARROW; break;
74 case wxCURSOR_PAINT_BRUSH: gdk_cur = GDK_SPRAYCAN; break;
75 case wxCURSOR_MAGNIFIER: gdk_cur = GDK_PLUS; break;
76 case wxCURSOR_CHAR: gdk_cur = GDK_XTERM; break;
77 case wxCURSOR_LEFT_BUTTON: gdk_cur = GDK_LEFTBUTTON; break;
78 case wxCURSOR_MIDDLE_BUTTON: gdk_cur = GDK_MIDDLEBUTTON; break;
79 case wxCURSOR_RIGHT_BUTTON: gdk_cur = GDK_RIGHTBUTTON; break;
c801d85f 80/*
2d17d68f
RR
81 case wxCURSOR_DOUBLE_ARROW: gdk_cur = GDK_DOUBLE_ARROW; break;
82 case wxCURSOR_CROSS_REVERSE: gdk_cur = GDK_CROSS_REVERSE; break;
83 case wxCURSOR_BASED_ARROW_UP: gdk_cur = GDK_BASED_ARROW_UP; break;
84 case wxCURSOR_BASED_ARROW_DOWN: gdk_cur = GDK_BASED_ARROW_DOWN; break;
c801d85f 85*/
2d17d68f 86 }
8bbe427f 87
2d17d68f 88 M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur );
ff7b1510 89}
c801d85f
KB
90
91wxCursor::wxCursor( const wxCursor &cursor )
92{
2d17d68f 93 Ref( cursor );
ff7b1510 94}
c801d85f 95
8bbe427f 96wxCursor::~wxCursor()
c801d85f 97{
ff7b1510 98}
c801d85f
KB
99
100wxCursor& wxCursor::operator = ( const wxCursor& cursor )
101{
2d17d68f
RR
102 if (*this == cursor) return (*this);
103 Ref( cursor );
104
105 return *this;
ff7b1510 106}
c801d85f 107
8bbe427f 108bool wxCursor::operator == ( const wxCursor& cursor ) const
c801d85f 109{
2d17d68f 110 return m_refData == cursor.m_refData;
ff7b1510 111}
c801d85f 112
8bbe427f 113bool wxCursor::operator != ( const wxCursor& cursor ) const
c801d85f 114{
2d17d68f 115 return m_refData != cursor.m_refData;
ff7b1510 116}
c801d85f 117
8bbe427f 118bool wxCursor::Ok() const
c801d85f 119{
2d17d68f 120 return (m_refData != NULL);
ff7b1510 121}
c801d85f 122
8bbe427f 123GdkCursor *wxCursor::GetCursor() const
c801d85f 124{
2d17d68f 125 return M_CURSORDATA->m_cursor;
ff7b1510 126}
c801d85f
KB
127
128//-----------------------------------------------------------------------------
129// busy cursor routines
130//-----------------------------------------------------------------------------
131
132bool g_isBusy = FALSE;
133
8bbe427f 134void wxEndBusyCursor()
c801d85f 135{
2d17d68f 136 g_isBusy = FALSE;
ff7b1510 137}
c801d85f
KB
138
139void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
140{
2d17d68f 141 g_isBusy = TRUE;
ff7b1510 142}
c801d85f 143
8bbe427f 144bool wxIsBusy()
c801d85f 145{
2d17d68f 146 return g_isBusy;
ff7b1510 147}
c801d85f
KB
148
149void wxSetCursor( const wxCursor& cursor )
150{
2d17d68f
RR
151 extern wxCursor *g_globalCursor;
152 if (g_globalCursor) (*g_globalCursor) = cursor;
c801d85f 153
2d17d68f 154 if (cursor.Ok()) {}
ff7b1510 155}
c801d85f
KB
156
157