]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/clipbrd.h | |
3 | // Purpose: wxClipboad class and clipboard functions | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 19.10.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWindows Team | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_CLIPBRD_H_BASE_ | |
13 | #define _WX_CLIPBRD_H_BASE_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_CLIPBOARD | |
18 | ||
19 | #include "wx/object.h" | |
20 | #include "wx/wxchar.h" | |
21 | ||
22 | class WXDLLEXPORT wxDataFormat; | |
23 | class WXDLLEXPORT wxDataObject; | |
24 | ||
25 | // ---------------------------------------------------------------------------- | |
26 | // wxClipboard represents the system clipboard. Normally, you should use | |
27 | // wxTheClipboard which is a global pointer to the (unique) clipboard. | |
28 | // | |
29 | // Clipboard can be used to copy data to/paste data from. It works together | |
30 | // with wxDataObject. | |
31 | // ---------------------------------------------------------------------------- | |
32 | ||
33 | class WXDLLEXPORT wxClipboardBase : public wxObject | |
34 | { | |
35 | public: | |
36 | // open the clipboard before Add/SetData() and GetData() | |
37 | virtual bool Open(); | |
38 | ||
39 | // close the clipboard after Add/SetData() and GetData() | |
40 | virtual void Close(); | |
41 | ||
42 | // add to the clipboard data | |
43 | // | |
44 | // NB: the clipboard owns the pointer and will delete it, so data must be | |
45 | // allocated on the heap | |
46 | virtual bool AddData( wxDataObject *data ); | |
47 | ||
48 | // set the clipboard data, this is the same as Clear() followed by | |
49 | // AddData() | |
50 | virtual bool SetData( wxDataObject *data ); | |
51 | ||
52 | // ask if data in correct format is available | |
53 | virtual bool IsSupported( const wxDataFormat& format ); | |
54 | ||
55 | // fill data with data on the clipboard (if available) | |
56 | virtual bool GetData( wxDataObject& data ); | |
57 | ||
58 | // clears wxTheClipboard and the system's clipboard if possible | |
59 | virtual void Clear(); | |
60 | ||
61 | // flushes the clipboard: this means that the data which is currently on | |
62 | // clipboard will stay available even after the application exits (possibly | |
63 | // eating memory), otherwise the clipboard will be emptied on exit | |
64 | virtual bool Flush() { return FALSE; } | |
65 | ||
66 | // X11 has two clipboards which get selected by this call. Empty on MSW. | |
67 | virtual void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { } | |
68 | ||
69 | #ifdef WXWIN_COMPATIBILITY_2 | |
70 | // deprecated version | |
71 | bool GetData(wxDataObject *data) | |
72 | { | |
73 | wxCHECK_MSG(data, FALSE, wxT("NULL pointer in wxClipboard")); | |
74 | ||
75 | return GetData(*data); | |
76 | } | |
77 | #endif // WXWIN_COMPATIBILITY_2 | |
78 | }; | |
79 | ||
80 | // ---------------------------------------------------------------------------- | |
81 | // include platform-specific class declaration | |
82 | // ---------------------------------------------------------------------------- | |
83 | ||
84 | #if defined(__WXMSW__) | |
85 | #include "wx/msw/clipbrd.h" | |
86 | #elif defined(__WXMOTIF__) | |
87 | #include "wx/motif/clipbrd.h" | |
88 | #elif defined(__WXGTK__) | |
89 | #include "wx/gtk/clipbrd.h" | |
90 | #elif defined(__WXQT__) | |
91 | #include "wx/gtk/clipbrd.h" | |
92 | #elif defined(__WXMAC__) | |
93 | #include "wx/mac/clipbrd.h" | |
94 | #elif defined(__WXPM__) | |
95 | #include "wx/os2/clipbrd.h" | |
96 | #elif defined(__WXSTUBS__) | |
97 | #include "wx/stubs/clipbrd.h" | |
98 | #endif | |
99 | ||
100 | // ---------------------------------------------------------------------------- | |
101 | // globals | |
102 | // ---------------------------------------------------------------------------- | |
103 | ||
104 | // The global clipboard object | |
105 | WXDLLEXPORT_DATA(extern wxClipboard *) wxTheClipboard; | |
106 | ||
107 | // ---------------------------------------------------------------------------- | |
108 | // wxClipboardModule: module responsible for initializing the global clipboard | |
109 | // object | |
110 | // | |
111 | // NB: IMPLEMENT_DYNAMIC_CLASS() for it is in common/appcmn.cpp | |
112 | // ---------------------------------------------------------------------------- | |
113 | ||
114 | class wxClipboardModule : public wxModule | |
115 | { | |
116 | public: | |
117 | bool OnInit() | |
118 | { wxTheClipboard = new wxClipboard; return TRUE; } | |
119 | void OnExit() | |
120 | { delete wxTheClipboard; wxTheClipboard = (wxClipboard *)NULL; } | |
121 | ||
122 | private: | |
123 | DECLARE_DYNAMIC_CLASS(wxClipboardModule) | |
124 | }; | |
125 | ||
126 | #endif // wxUSE_CLIPBOARD | |
127 | ||
128 | #endif // _WX_CLIPBRD_H_BASE_ |