1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxClipboad class and clipboard functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows Team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CLIPBRD_H_BASE_
13 #define _WX_CLIPBRD_H_BASE_
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "clipboardbase.h"
24 #include "wx/object.h"
25 #include "wx/wxchar.h"
27 class WXDLLEXPORT wxDataFormat
;
28 class WXDLLEXPORT wxDataObject
;
30 // ----------------------------------------------------------------------------
31 // wxClipboard represents the system clipboard. Normally, you should use
32 // wxTheClipboard which is a global pointer to the (unique) clipboard.
34 // Clipboard can be used to copy data to/paste data from. It works together
36 // ----------------------------------------------------------------------------
38 class WXDLLEXPORT wxClipboardBase
: public wxObject
43 // open the clipboard before Add/SetData() and GetData()
44 virtual bool Open() = 0;
46 // close the clipboard after Add/SetData() and GetData()
47 virtual void Close() = 0;
49 // query whether the clipboard is opened
50 virtual bool IsOpened() const = 0;
52 // add to the clipboard data
54 // NB: the clipboard owns the pointer and will delete it, so data must be
55 // allocated on the heap
56 virtual bool AddData( wxDataObject
*data
) = 0;
58 // set the clipboard data, this is the same as Clear() followed by
60 virtual bool SetData( wxDataObject
*data
) = 0;
62 // ask if data in correct format is available
63 virtual bool IsSupported( const wxDataFormat
& format
) = 0;
65 // fill data with data on the clipboard (if available)
66 virtual bool GetData( wxDataObject
& data
) = 0;
68 // clears wxTheClipboard and the system's clipboard if possible
69 virtual void Clear() = 0;
71 // flushes the clipboard: this means that the data which is currently on
72 // clipboard will stay available even after the application exits (possibly
73 // eating memory), otherwise the clipboard will be emptied on exit
74 virtual bool Flush() { return FALSE
; }
76 // X11 has two clipboards which get selected by this call. Empty on MSW.
77 virtual void UsePrimarySelection( bool WXUNUSED(primary
) = FALSE
) { }
81 // ----------------------------------------------------------------------------
82 // include platform-specific class declaration
83 // ----------------------------------------------------------------------------
85 #if defined(__WXMSW__)
86 #include "wx/msw/clipbrd.h"
87 #elif defined(__WXMOTIF__)
88 #include "wx/motif/clipbrd.h"
89 #elif defined(__WXGTK__)
90 #include "wx/gtk/clipbrd.h"
91 #elif defined(__WXX11__)
92 #include "wx/x11/clipbrd.h"
93 #elif defined(__WXMGL__)
94 #include "wx/mgl/clipbrd.h"
95 #elif defined(__WXMAC__)
96 #include "wx/mac/clipbrd.h"
97 #elif defined(__WXPM__)
98 #include "wx/os2/clipbrd.h"
99 #elif defined(__WXSTUBS__)
100 #include "wx/stubs/clipbrd.h"
103 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
107 // The global clipboard object
108 WXDLLEXPORT_DATA(extern wxClipboard
*) wxTheClipboard
;
110 // ----------------------------------------------------------------------------
111 // helpful class for opening the clipboard and automatically closing it
112 // ----------------------------------------------------------------------------
114 class WXDLLEXPORT wxClipboardLocker
117 wxClipboardLocker(wxClipboard
*clipboard
= (wxClipboard
*)NULL
)
119 m_clipboard
= clipboard
? clipboard
: wxTheClipboard
;
126 bool operator!() const { return !m_clipboard
->IsOpened(); }
132 m_clipboard
->Close();
137 wxClipboard
*m_clipboard
;
140 #endif // wxUSE_CLIPBOARD
142 #endif // _WX_CLIPBRD_H_BASE_