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_
19 #include "wx/object.h"
20 #include "wx/wxchar.h"
22 class WXDLLEXPORT wxDataFormat
;
23 class WXDLLEXPORT wxDataObject
;
25 // ----------------------------------------------------------------------------
26 // wxClipboard represents the system clipboard. Normally, you should use
27 // wxTheClipboard which is a global pointer to the (unique) clipboard.
29 // Clipboard can be used to copy data to/paste data from. It works together
31 // ----------------------------------------------------------------------------
33 class WXDLLEXPORT wxClipboardBase
: public wxObject
36 // open the clipboard before Add/SetData() and GetData()
39 // close the clipboard after Add/SetData() and GetData()
42 // add to the clipboard data
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
);
48 // set the clipboard data, this is the same as Clear() followed by
50 virtual bool SetData( wxDataObject
*data
);
52 // ask if data in correct format is available
53 virtual bool IsSupported( const wxDataFormat
& format
);
55 // fill data with data on the clipboard (if available)
56 virtual bool GetData( wxDataObject
& data
);
58 // clears wxTheClipboard and the system's clipboard if possible
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
; }
66 // X11 has two clipboards which get selected by this call. Empty on MSW.
67 virtual void UsePrimarySelection( bool WXUNUSED(primary
) = FALSE
) { }
69 #ifdef WXWIN_COMPATIBILITY_2
71 bool GetData(wxDataObject
*data
)
73 wxCHECK_MSG(data
, FALSE
, wxT("NULL pointer in wxClipboard"));
75 return GetData(*data
);
77 #endif // WXWIN_COMPATIBILITY_2
80 // ----------------------------------------------------------------------------
81 // include platform-specific class declaration
82 // ----------------------------------------------------------------------------
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"
100 // ----------------------------------------------------------------------------
102 // ----------------------------------------------------------------------------
104 // The global clipboard object
105 WXDLLEXPORT_DATA(extern wxClipboard
*) wxTheClipboard
;
107 // ----------------------------------------------------------------------------
108 // wxClipboardModule: module responsible for initializing the global clipboard
111 // NB: IMPLEMENT_DYNAMIC_CLASS() for it is in common/appcmn.cpp
112 // ----------------------------------------------------------------------------
114 class wxClipboardModule
: public wxModule
118 { wxTheClipboard
= new wxClipboard
; return TRUE
; }
120 { delete wxTheClipboard
; wxTheClipboard
= (wxClipboard
*)NULL
; }
123 DECLARE_DYNAMIC_CLASS(wxClipboardModule
)
126 #endif // wxUSE_CLIPBOARD
128 #endif // _WX_CLIPBRD_H_BASE_