1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxClipboad class and clipboard functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets Team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CLIPBRD_H_BASE_
13 #define _WX_CLIPBRD_H_BASE_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "clipboardbase.h"
24 #include "wx/object.h"
25 #include "wx/wxchar.h"
27 class WXDLLEXPORT wxDataFormat
;
28 class WXDLLEXPORT wxDataObject
;
29 class WXDLLEXPORT wxClipboard
;
31 // ----------------------------------------------------------------------------
32 // wxClipboard represents the system clipboard. Normally, you should use
33 // wxTheClipboard which is a global pointer to the (unique) clipboard.
35 // Clipboard can be used to copy data to/paste data from. It works together
37 // ----------------------------------------------------------------------------
39 class WXDLLEXPORT wxClipboardBase
: public wxObject
44 // open the clipboard before Add/SetData() and GetData()
45 virtual bool Open() = 0;
47 // close the clipboard after Add/SetData() and GetData()
48 virtual void Close() = 0;
50 // query whether the clipboard is opened
51 virtual bool IsOpened() const = 0;
53 // add to the clipboard data
55 // NB: the clipboard owns the pointer and will delete it, so data must be
56 // allocated on the heap
57 virtual bool AddData( wxDataObject
*data
) = 0;
59 // set the clipboard data, this is the same as Clear() followed by
61 virtual bool SetData( wxDataObject
*data
) = 0;
63 // ask if data in correct format is available
64 virtual bool IsSupported( const wxDataFormat
& format
) = 0;
66 // fill data with data on the clipboard (if available)
67 virtual bool GetData( wxDataObject
& data
) = 0;
69 // clears wxTheClipboard and the system's clipboard if possible
70 virtual void Clear() = 0;
72 // flushes the clipboard: this means that the data which is currently on
73 // clipboard will stay available even after the application exits (possibly
74 // eating memory), otherwise the clipboard will be emptied on exit
75 virtual bool Flush() { return FALSE
; }
77 // X11 has two clipboards which get selected by this call. Empty on MSW.
78 virtual void UsePrimarySelection( bool WXUNUSED(primary
) = FALSE
) { }
80 // Returns global instance (wxTheClipboard) of the object:
81 static wxClipboard
*Get();
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
88 // The global clipboard object - backward compatible access macro:
89 #define wxTheClipboard (wxClipboard::Get())
91 // ----------------------------------------------------------------------------
92 // include platform-specific class declaration
93 // ----------------------------------------------------------------------------
95 #if defined(__WXMSW__)
96 #include "wx/msw/clipbrd.h"
97 #elif defined(__WXMOTIF__)
98 #include "wx/motif/clipbrd.h"
99 #elif defined(__WXGTK__)
100 #include "wx/gtk/clipbrd.h"
101 #elif defined(__WXX11__)
102 #include "wx/x11/clipbrd.h"
103 #elif defined(__WXMGL__)
104 #include "wx/mgl/clipbrd.h"
105 #elif defined(__WXMAC__)
106 #include "wx/mac/clipbrd.h"
107 #elif defined(__WXCOCOA__)
108 #include "wx/cocoa/clipbrd.h"
109 #elif defined(__WXPM__)
110 #include "wx/os2/clipbrd.h"
113 // ----------------------------------------------------------------------------
114 // helpful class for opening the clipboard and automatically closing it
115 // ----------------------------------------------------------------------------
117 class WXDLLEXPORT wxClipboardLocker
120 wxClipboardLocker(wxClipboard
*clipboard
= (wxClipboard
*)NULL
)
122 m_clipboard
= clipboard
? clipboard
: wxTheClipboard
;
129 bool operator!() const { return !m_clipboard
->IsOpened(); }
135 m_clipboard
->Close();
140 wxClipboard
*m_clipboard
;
142 DECLARE_NO_COPY_CLASS(wxClipboardLocker
)
145 #endif // wxUSE_CLIPBOARD
147 #endif // _WX_CLIPBRD_H_BASE_