]> git.saurik.com Git - wxWidgets.git/blob - include/wx/clipbrd.h
remove unused file
[wxWidgets.git] / include / wx / clipbrd.h
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) wxWidgets 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
20 #include "wx/object.h"
21 #include "wx/chartype.h"
22
23 class WXDLLIMPEXP_FWD_CORE wxDataFormat;
24 class WXDLLIMPEXP_FWD_CORE wxDataObject;
25 class WXDLLIMPEXP_FWD_CORE wxClipboard;
26
27 // ----------------------------------------------------------------------------
28 // wxClipboard represents the system clipboard. Normally, you should use
29 // wxTheClipboard which is a global pointer to the (unique) clipboard.
30 //
31 // Clipboard can be used to copy data to/paste data from. It works together
32 // with wxDataObject.
33 // ----------------------------------------------------------------------------
34
35 class WXDLLEXPORT wxClipboardBase : public wxObject
36 {
37 public:
38 wxClipboardBase() { m_usePrimary = false; }
39
40 // open the clipboard before Add/SetData() and GetData()
41 virtual bool Open() = 0;
42
43 // close the clipboard after Add/SetData() and GetData()
44 virtual void Close() = 0;
45
46 // query whether the clipboard is opened
47 virtual bool IsOpened() const = 0;
48
49 // add to the clipboard data
50 //
51 // NB: the clipboard owns the pointer and will delete it, so data must be
52 // allocated on the heap
53 virtual bool AddData( wxDataObject *data ) = 0;
54
55 // set the clipboard data, this is the same as Clear() followed by
56 // AddData()
57 virtual bool SetData( wxDataObject *data ) = 0;
58
59 // ask if data in correct format is available
60 virtual bool IsSupported( const wxDataFormat& format ) = 0;
61
62 // fill data with data on the clipboard (if available)
63 virtual bool GetData( wxDataObject& data ) = 0;
64
65 // clears wxTheClipboard and the system's clipboard if possible
66 virtual void Clear() = 0;
67
68 // flushes the clipboard: this means that the data which is currently on
69 // clipboard will stay available even after the application exits (possibly
70 // eating memory), otherwise the clipboard will be emptied on exit
71 virtual bool Flush() { return false; }
72
73 // this allows to choose whether we work with CLIPBOARD (default) or
74 // PRIMARY selection on X11-based systems
75 //
76 // on the other ones, working with primary selection does nothing: this
77 // allows to write code which sets the primary selection when something is
78 // selected without any ill effects (i.e. without overwriting the
79 // clipboard which would be wrong on the platforms without X11 PRIMARY)
80 virtual void UsePrimarySelection(bool usePrimary = false)
81 {
82 m_usePrimary = usePrimary;
83 }
84
85 // return true if we're using primary selection
86 bool IsUsingPrimarySelection() const { return m_usePrimary; }
87
88 // Returns global instance (wxTheClipboard) of the object:
89 static wxClipboard *Get();
90
91
92 // don't use this directly, it is public for compatibility with some ports
93 // (wxX11, wxMotif, ...) only
94 bool m_usePrimary;
95 };
96
97 // ----------------------------------------------------------------------------
98 // globals
99 // ----------------------------------------------------------------------------
100
101 // The global clipboard object - backward compatible access macro:
102 #define wxTheClipboard (wxClipboard::Get())
103
104 // ----------------------------------------------------------------------------
105 // include platform-specific class declaration
106 // ----------------------------------------------------------------------------
107
108 #if defined(__WXMSW__)
109 #include "wx/msw/clipbrd.h"
110 #elif defined(__WXMOTIF__)
111 #include "wx/motif/clipbrd.h"
112 #elif defined(__WXGTK20__)
113 #include "wx/gtk/clipbrd.h"
114 #elif defined(__WXGTK__)
115 #include "wx/gtk1/clipbrd.h"
116 #elif defined(__WXX11__)
117 #include "wx/x11/clipbrd.h"
118 #elif defined(__WXMGL__)
119 #include "wx/mgl/clipbrd.h"
120 #elif defined(__WXMAC__)
121 #include "wx/mac/clipbrd.h"
122 #elif defined(__WXCOCOA__)
123 #include "wx/cocoa/clipbrd.h"
124 #elif defined(__WXPM__)
125 #include "wx/os2/clipbrd.h"
126 #endif
127
128 // ----------------------------------------------------------------------------
129 // helpful class for opening the clipboard and automatically closing it
130 // ----------------------------------------------------------------------------
131
132 class WXDLLEXPORT wxClipboardLocker
133 {
134 public:
135 wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL)
136 {
137 m_clipboard = clipboard ? clipboard : wxTheClipboard;
138 if ( m_clipboard )
139 {
140 m_clipboard->Open();
141 }
142 }
143
144 bool operator!() const { return !m_clipboard->IsOpened(); }
145
146 ~wxClipboardLocker()
147 {
148 if ( m_clipboard )
149 {
150 m_clipboard->Close();
151 }
152 }
153
154 private:
155 wxClipboard *m_clipboard;
156
157 DECLARE_NO_COPY_CLASS(wxClipboardLocker)
158 };
159
160 #endif // wxUSE_CLIPBOARD
161
162 #endif // _WX_CLIPBRD_H_BASE_