]> git.saurik.com Git - wxWidgets.git/blame - include/wx/clipbrd.h
Unicode compilation fix after last commit
[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"
1be7a35c 95#elif defined(__WXGTK20__)
e1ee679c 96 #include "wx/gtk/clipbrd.h"
1be7a35c
MR
97#elif defined(__WXGTK__)
98 #include "wx/gtk1/clipbrd.h"
83df96d6
JS
99#elif defined(__WXX11__)
100 #include "wx/x11/clipbrd.h"
1e6feb95
VZ
101#elif defined(__WXMGL__)
102 #include "wx/mgl/clipbrd.h"
34138703 103#elif defined(__WXMAC__)
e1ee679c 104 #include "wx/mac/clipbrd.h"
aa3d0277
DE
105#elif defined(__WXCOCOA__)
106 #include "wx/cocoa/clipbrd.h"
1777b9bb 107#elif defined(__WXPM__)
e1ee679c 108 #include "wx/os2/clipbrd.h"
c801d85f
KB
109#endif
110
f536e0f2
VZ
111// ----------------------------------------------------------------------------
112// helpful class for opening the clipboard and automatically closing it
113// ----------------------------------------------------------------------------
114
115class WXDLLEXPORT wxClipboardLocker
116{
117public:
118 wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL)
119 {
120 m_clipboard = clipboard ? clipboard : wxTheClipboard;
121 if ( m_clipboard )
122 {
123 m_clipboard->Open();
124 }
125 }
126
ffd56fbc 127 bool operator!() const { return !m_clipboard->IsOpened(); }
f536e0f2
VZ
128
129 ~wxClipboardLocker()
130 {
131 if ( m_clipboard )
132 {
133 m_clipboard->Close();
134 }
135 }
136
137private:
138 wxClipboard *m_clipboard;
22f3361e
VZ
139
140 DECLARE_NO_COPY_CLASS(wxClipboardLocker)
f536e0f2
VZ
141};
142
e1ee679c
VZ
143#endif // wxUSE_CLIPBOARD
144
145#endif // _WX_CLIPBRD_H_BASE_