]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: cursor.h | |
3 | // Purpose: wxCursor class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_CURSOR_H_ | |
13 | #define _WX_CURSOR_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "cursor.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/bitmap.h" | |
4daa4d66 CE |
20 | #if wxUSE_IMAGE |
21 | #include "wx/image.h" | |
22 | #endif | |
23 | ||
24 | ||
9b6dbb09 | 25 | |
f97c9854 | 26 | /* Cursor for one display, so we can choose the correct one for |
83df96d6 JS |
27 | * the current display. |
28 | */ | |
f97c9854 JS |
29 | class wxXCursor : public wxObject |
30 | { | |
83df96d6 JS |
31 | DECLARE_DYNAMIC_CLASS(wxXCursor) |
32 | ||
33 | public: | |
34 | WXDisplay* m_display; | |
35 | WXCursor m_cursor; | |
f97c9854 JS |
36 | }; |
37 | ||
9b6dbb09 JS |
38 | class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData |
39 | { | |
40 | friend class WXDLLEXPORT wxBitmap; | |
41 | friend class WXDLLEXPORT wxCursor; | |
42 | public: | |
43 | wxCursorRefData(); | |
44 | ~wxCursorRefData(); | |
83df96d6 | 45 | |
f97c9854 JS |
46 | wxList m_cursors; // wxXCursor objects, one per display |
47 | wxStockCursor m_cursorId; // wxWindows standard cursor id | |
9b6dbb09 JS |
48 | }; |
49 | ||
50 | #define M_CURSORDATA ((wxCursorRefData *)m_refData) | |
51 | #define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData) | |
52 | ||
53 | // Cursor | |
54 | class WXDLLEXPORT wxCursor: public wxBitmap | |
55 | { | |
83df96d6 JS |
56 | DECLARE_DYNAMIC_CLASS(wxCursor) |
57 | ||
9b6dbb09 | 58 | public: |
83df96d6 JS |
59 | wxCursor(); |
60 | ||
61 | // Copy constructors | |
62 | wxCursor(const wxCursor& cursor) { Ref(cursor); } | |
63 | ||
64 | wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1, | |
65 | const char maskBits[] = NULL); | |
66 | ||
67 | wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_XBM, | |
68 | int hotSpotX = 0, int hotSpotY = 0); | |
4daa4d66 CE |
69 | |
70 | #if wxUSE_IMAGE | |
71 | wxCursor(const wxImage& image); | |
72 | #endif | |
73 | ||
83df96d6 JS |
74 | wxCursor(wxStockCursor id); |
75 | ~wxCursor(); | |
76 | ||
77 | virtual bool Ok() const { return ((m_refData != NULL) && M_CURSORDATA->m_ok); } | |
78 | ||
79 | wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; } | |
80 | bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; } | |
81 | bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; } | |
82 | ||
83 | // Motif-specific. | |
84 | // Create/get a cursor for the current display | |
85 | WXCursor GetXCursor(WXDisplay* display) ; | |
86 | // Make a cursor from standard id | |
87 | WXCursor MakeCursor(WXDisplay* display, wxStockCursor id); | |
9b6dbb09 JS |
88 | }; |
89 | ||
90 | extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor); | |
91 | ||
92 | #endif | |
83df96d6 | 93 | // _WX_CURSOR_H_ |