]> git.saurik.com Git - wxWidgets.git/blame - include/wx/clipbrd.h
fix for CW compilation
[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
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
b068c4e8
RR
16 #pragma interface "clipboardbase.h"
17#endif
18
e1ee679c
VZ
19#include "wx/defs.h"
20
21#if wxUSE_CLIPBOARD
22
b068c4e8 23
e1ee679c
VZ
24#include "wx/object.h"
25#include "wx/wxchar.h"
26
27class WXDLLEXPORT wxDataFormat;
28class WXDLLEXPORT wxDataObject;
5dc43d1f 29class WXDLLEXPORT wxClipboard;
e1ee679c
VZ
30
31// ----------------------------------------------------------------------------
32// wxClipboard represents the system clipboard. Normally, you should use
33// wxTheClipboard which is a global pointer to the (unique) clipboard.
34//
35// Clipboard can be used to copy data to/paste data from. It works together
36// with wxDataObject.
37// ----------------------------------------------------------------------------
38
39class WXDLLEXPORT wxClipboardBase : public wxObject
40{
41public:
5dc43d1f 42 wxClipboardBase() {}
b068c4e8 43
e1ee679c 44 // open the clipboard before Add/SetData() and GetData()
b068c4e8 45 virtual bool Open() = 0;
e1ee679c
VZ
46
47 // close the clipboard after Add/SetData() and GetData()
b068c4e8 48 virtual void Close() = 0;
e1ee679c 49
f536e0f2
VZ
50 // query whether the clipboard is opened
51 virtual bool IsOpened() const = 0;
52
e1ee679c
VZ
53 // add to the clipboard data
54 //
55 // NB: the clipboard owns the pointer and will delete it, so data must be
56 // allocated on the heap
b068c4e8 57 virtual bool AddData( wxDataObject *data ) = 0;
e1ee679c
VZ
58
59 // set the clipboard data, this is the same as Clear() followed by
60 // AddData()
b068c4e8 61 virtual bool SetData( wxDataObject *data ) = 0;
e1ee679c
VZ
62
63 // ask if data in correct format is available
b068c4e8 64 virtual bool IsSupported( const wxDataFormat& format ) = 0;
e1ee679c
VZ
65
66 // fill data with data on the clipboard (if available)
b068c4e8 67 virtual bool GetData( wxDataObject& data ) = 0;
68379eaf 68
e1ee679c 69 // clears wxTheClipboard and the system's clipboard if possible
b068c4e8 70 virtual void Clear() = 0;
e1ee679c
VZ
71
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
68379eaf 75 virtual bool Flush() { return false; }
e1ee679c
VZ
76
77 // X11 has two clipboards which get selected by this call. Empty on MSW.
68379eaf 78 virtual void UsePrimarySelection( bool WXUNUSED(primary) = false ) { }
e1ee679c 79
5dc43d1f
VS
80 // Returns global instance (wxTheClipboard) of the object:
81 static wxClipboard *Get();
e1ee679c
VZ
82};
83
5dc43d1f
VS
84// ----------------------------------------------------------------------------
85// globals
86// ----------------------------------------------------------------------------
87
88// The global clipboard object - backward compatible access macro:
89#define wxTheClipboard (wxClipboard::Get())
90
e1ee679c
VZ
91// ----------------------------------------------------------------------------
92// include platform-specific class declaration
93// ----------------------------------------------------------------------------
94
2049ba38 95#if defined(__WXMSW__)
e1ee679c 96 #include "wx/msw/clipbrd.h"
2049ba38 97#elif defined(__WXMOTIF__)
e1ee679c 98 #include "wx/motif/clipbrd.h"
2049ba38 99#elif defined(__WXGTK__)
e1ee679c 100 #include "wx/gtk/clipbrd.h"
83df96d6
JS
101#elif defined(__WXX11__)
102 #include "wx/x11/clipbrd.h"
1e6feb95
VZ
103#elif defined(__WXMGL__)
104 #include "wx/mgl/clipbrd.h"
34138703 105#elif defined(__WXMAC__)
e1ee679c 106 #include "wx/mac/clipbrd.h"
aa3d0277
DE
107#elif defined(__WXCOCOA__)
108 #include "wx/cocoa/clipbrd.h"
1777b9bb 109#elif defined(__WXPM__)
e1ee679c 110 #include "wx/os2/clipbrd.h"
c801d85f
KB
111#endif
112
f536e0f2
VZ
113// ----------------------------------------------------------------------------
114// helpful class for opening the clipboard and automatically closing it
115// ----------------------------------------------------------------------------
116
117class WXDLLEXPORT wxClipboardLocker
118{
119public:
120 wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL)
121 {
122 m_clipboard = clipboard ? clipboard : wxTheClipboard;
123 if ( m_clipboard )
124 {
125 m_clipboard->Open();
126 }
127 }
128
ffd56fbc 129 bool operator!() const { return !m_clipboard->IsOpened(); }
f536e0f2
VZ
130
131 ~wxClipboardLocker()
132 {
133 if ( m_clipboard )
134 {
135 m_clipboard->Close();
136 }
137 }
138
139private:
140 wxClipboard *m_clipboard;
22f3361e
VZ
141
142 DECLARE_NO_COPY_CLASS(wxClipboardLocker)
f536e0f2
VZ
143};
144
e1ee679c
VZ
145#endif // wxUSE_CLIPBOARD
146
147#endif // _WX_CLIPBRD_H_BASE_