]> git.saurik.com Git - wxWidgets.git/blame - include/wx/clipbrd.h
minor clean up
[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$
8// Copyright: (c) wxWindows Team
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_CLIPBRD_H_BASE_
13#define _WX_CLIPBRD_H_BASE_
c801d85f 14
b068c4e8
RR
15#ifdef __GNUG__
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;
29
30// ----------------------------------------------------------------------------
31// wxClipboard represents the system clipboard. Normally, you should use
32// wxTheClipboard which is a global pointer to the (unique) clipboard.
33//
34// Clipboard can be used to copy data to/paste data from. It works together
35// with wxDataObject.
36// ----------------------------------------------------------------------------
37
38class WXDLLEXPORT wxClipboardBase : public wxObject
39{
40public:
b068c4e8
RR
41 wxClipboardBase();
42
e1ee679c 43 // open the clipboard before Add/SetData() and GetData()
b068c4e8 44 virtual bool Open() = 0;
e1ee679c
VZ
45
46 // close the clipboard after Add/SetData() and GetData()
b068c4e8 47 virtual void Close() = 0;
e1ee679c 48
f536e0f2
VZ
49 // query whether the clipboard is opened
50 virtual bool IsOpened() const = 0;
51
e1ee679c
VZ
52 // add to the clipboard data
53 //
54 // NB: the clipboard owns the pointer and will delete it, so data must be
55 // allocated on the heap
b068c4e8 56 virtual bool AddData( wxDataObject *data ) = 0;
e1ee679c
VZ
57
58 // set the clipboard data, this is the same as Clear() followed by
59 // AddData()
b068c4e8 60 virtual bool SetData( wxDataObject *data ) = 0;
e1ee679c
VZ
61
62 // ask if data in correct format is available
b068c4e8 63 virtual bool IsSupported( const wxDataFormat& format ) = 0;
e1ee679c
VZ
64
65 // fill data with data on the clipboard (if available)
b068c4e8
RR
66 virtual bool GetData( wxDataObject& data ) = 0;
67
e1ee679c 68 // clears wxTheClipboard and the system's clipboard if possible
b068c4e8 69 virtual void Clear() = 0;
e1ee679c
VZ
70
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; }
75
76 // X11 has two clipboards which get selected by this call. Empty on MSW.
77 virtual void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { }
78
e1ee679c
VZ
79};
80
81// ----------------------------------------------------------------------------
82// include platform-specific class declaration
83// ----------------------------------------------------------------------------
84
2049ba38 85#if defined(__WXMSW__)
e1ee679c 86 #include "wx/msw/clipbrd.h"
2049ba38 87#elif defined(__WXMOTIF__)
e1ee679c 88 #include "wx/motif/clipbrd.h"
2049ba38 89#elif defined(__WXGTK__)
e1ee679c 90 #include "wx/gtk/clipbrd.h"
1e6feb95
VZ
91#elif defined(__WXMGL__)
92 #include "wx/mgl/clipbrd.h"
b4e76e0d 93#elif defined(__WXQT__)
e1ee679c 94 #include "wx/gtk/clipbrd.h"
34138703 95#elif defined(__WXMAC__)
e1ee679c 96 #include "wx/mac/clipbrd.h"
1777b9bb 97#elif defined(__WXPM__)
e1ee679c 98 #include "wx/os2/clipbrd.h"
34138703 99#elif defined(__WXSTUBS__)
e1ee679c 100 #include "wx/stubs/clipbrd.h"
c801d85f
KB
101#endif
102
e1ee679c
VZ
103// ----------------------------------------------------------------------------
104// globals
105// ----------------------------------------------------------------------------
106
107// The global clipboard object
108WXDLLEXPORT_DATA(extern wxClipboard *) wxTheClipboard;
109
f536e0f2
VZ
110// ----------------------------------------------------------------------------
111// helpful class for opening the clipboard and automatically closing it
112// ----------------------------------------------------------------------------
113
114class WXDLLEXPORT wxClipboardLocker
115{
116public:
117 wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL)
118 {
119 m_clipboard = clipboard ? clipboard : wxTheClipboard;
120 if ( m_clipboard )
121 {
122 m_clipboard->Open();
123 }
124 }
125
ffd56fbc 126 bool operator!() const { return !m_clipboard->IsOpened(); }
f536e0f2
VZ
127
128 ~wxClipboardLocker()
129 {
130 if ( m_clipboard )
131 {
132 m_clipboard->Close();
133 }
134 }
135
136private:
137 wxClipboard *m_clipboard;
138};
139
e1ee679c
VZ
140#endif // wxUSE_CLIPBOARD
141
142#endif // _WX_CLIPBRD_H_BASE_