]> git.saurik.com Git - wxWidgets.git/blame - include/wx/clipbrd.h
wxPalette unified. Source cleaning.
[wxWidgets.git] / include / wx / clipbrd.h
CommitLineData
e1ee679c
VZ
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$
77ffb593 8// Copyright: (c) wxWidgets Team
65571936 9// Licence: wxWindows licence
e1ee679c
VZ
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_CLIPBRD_H_BASE_
13#define _WX_CLIPBRD_H_BASE_
c801d85f 14
e1ee679c
VZ
15#include "wx/defs.h"
16
17#if wxUSE_CLIPBOARD
18
b068c4e8 19
e1ee679c
VZ
20#include "wx/object.h"
21#include "wx/wxchar.h"
22
23class WXDLLEXPORT wxDataFormat;
24class WXDLLEXPORT wxDataObject;
5dc43d1f 25class WXDLLEXPORT wxClipboard;
e1ee679c
VZ
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
35class WXDLLEXPORT wxClipboardBase : public wxObject
36{
37public:
5dc43d1f 38 wxClipboardBase() {}
b068c4e8 39
e1ee679c 40 // open the clipboard before Add/SetData() and GetData()
b068c4e8 41 virtual bool Open() = 0;
e1ee679c
VZ
42
43 // close the clipboard after Add/SetData() and GetData()
b068c4e8 44 virtual void Close() = 0;
e1ee679c 45
f536e0f2
VZ
46 // query whether the clipboard is opened
47 virtual bool IsOpened() const = 0;
48
e1ee679c
VZ
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
b068c4e8 53 virtual bool AddData( wxDataObject *data ) = 0;
e1ee679c
VZ
54
55 // set the clipboard data, this is the same as Clear() followed by
56 // AddData()
b068c4e8 57 virtual bool SetData( wxDataObject *data ) = 0;
e1ee679c
VZ
58
59 // ask if data in correct format is available
b068c4e8 60 virtual bool IsSupported( const wxDataFormat& format ) = 0;
e1ee679c
VZ
61
62 // fill data with data on the clipboard (if available)
b068c4e8 63 virtual bool GetData( wxDataObject& data ) = 0;
68379eaf 64
e1ee679c 65 // clears wxTheClipboard and the system's clipboard if possible
b068c4e8 66 virtual void Clear() = 0;
e1ee679c
VZ
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
68379eaf 71 virtual bool Flush() { return false; }
e1ee679c
VZ
72
73 // X11 has two clipboards which get selected by this call. Empty on MSW.
68379eaf 74 virtual void UsePrimarySelection( bool WXUNUSED(primary) = false ) { }
e1ee679c 75
5dc43d1f
VS
76 // Returns global instance (wxTheClipboard) of the object:
77 static wxClipboard *Get();
e1ee679c
VZ
78};
79
5dc43d1f
VS
80// ----------------------------------------------------------------------------
81// globals
82// ----------------------------------------------------------------------------
83
84// The global clipboard object - backward compatible access macro:
85#define wxTheClipboard (wxClipboard::Get())
86
e1ee679c
VZ
87// ----------------------------------------------------------------------------
88// include platform-specific class declaration
89// ----------------------------------------------------------------------------
90
2049ba38 91#if defined(__WXMSW__)
e1ee679c 92 #include "wx/msw/clipbrd.h"
2049ba38 93#elif defined(__WXMOTIF__)
e1ee679c 94 #include "wx/motif/clipbrd.h"
2049ba38 95#elif defined(__WXGTK__)
e1ee679c 96 #include "wx/gtk/clipbrd.h"
83df96d6
JS
97#elif defined(__WXX11__)
98 #include "wx/x11/clipbrd.h"
1e6feb95
VZ
99#elif defined(__WXMGL__)
100 #include "wx/mgl/clipbrd.h"
34138703 101#elif defined(__WXMAC__)
e1ee679c 102 #include "wx/mac/clipbrd.h"
aa3d0277
DE
103#elif defined(__WXCOCOA__)
104 #include "wx/cocoa/clipbrd.h"
1777b9bb 105#elif defined(__WXPM__)
e1ee679c 106 #include "wx/os2/clipbrd.h"
c801d85f
KB
107#endif
108
f536e0f2
VZ
109// ----------------------------------------------------------------------------
110// helpful class for opening the clipboard and automatically closing it
111// ----------------------------------------------------------------------------
112
113class WXDLLEXPORT wxClipboardLocker
114{
115public:
116 wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL)
117 {
118 m_clipboard = clipboard ? clipboard : wxTheClipboard;
119 if ( m_clipboard )
120 {
121 m_clipboard->Open();
122 }
123 }
124
ffd56fbc 125 bool operator!() const { return !m_clipboard->IsOpened(); }
f536e0f2
VZ
126
127 ~wxClipboardLocker()
128 {
129 if ( m_clipboard )
130 {
131 m_clipboard->Close();
132 }
133 }
134
135private:
136 wxClipboard *m_clipboard;
22f3361e
VZ
137
138 DECLARE_NO_COPY_CLASS(wxClipboardLocker)
f536e0f2
VZ
139};
140
e1ee679c
VZ
141#endif // wxUSE_CLIPBOARD
142
143#endif // _WX_CLIPBRD_H_BASE_