]> git.saurik.com Git - wxWidgets.git/blame - include/wx/clipbrd.h
don't draw borders for bitmap buttons with wxBORDER_NONE style
[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
01fc4932 20#include "wx/event.h"
e3f6cbd9 21#include "wx/chartype.h"
c220de0b 22#include "wx/vector.h"
e1ee679c 23
b5dbe15d
VS
24class WXDLLIMPEXP_FWD_CORE wxDataFormat;
25class WXDLLIMPEXP_FWD_CORE wxDataObject;
26class WXDLLIMPEXP_FWD_CORE wxClipboard;
e1ee679c
VZ
27
28// ----------------------------------------------------------------------------
29// wxClipboard represents the system clipboard. Normally, you should use
30// wxTheClipboard which is a global pointer to the (unique) clipboard.
31//
32// Clipboard can be used to copy data to/paste data from. It works together
33// with wxDataObject.
34// ----------------------------------------------------------------------------
35
53a2db12 36class WXDLLIMPEXP_CORE wxClipboardBase : public wxObject
e1ee679c
VZ
37{
38public:
9005f2ed 39 wxClipboardBase() { m_usePrimary = false; }
b068c4e8 40
e1ee679c 41 // open the clipboard before Add/SetData() and GetData()
b068c4e8 42 virtual bool Open() = 0;
e1ee679c
VZ
43
44 // close the clipboard after Add/SetData() and GetData()
b068c4e8 45 virtual void Close() = 0;
e1ee679c 46
f536e0f2
VZ
47 // query whether the clipboard is opened
48 virtual bool IsOpened() const = 0;
49
e1ee679c
VZ
50 // add to the clipboard data
51 //
52 // NB: the clipboard owns the pointer and will delete it, so data must be
53 // allocated on the heap
b068c4e8 54 virtual bool AddData( wxDataObject *data ) = 0;
e1ee679c
VZ
55
56 // set the clipboard data, this is the same as Clear() followed by
57 // AddData()
b068c4e8 58 virtual bool SetData( wxDataObject *data ) = 0;
e1ee679c
VZ
59
60 // ask if data in correct format is available
b068c4e8 61 virtual bool IsSupported( const wxDataFormat& format ) = 0;
e1ee679c 62
311c1be9
RR
63 // ask if data in correct format is available
64 virtual bool IsSupportedAsync( wxEvtHandler *sink );
8946ede1 65
e1ee679c 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 76
9005f2ed
VZ
77 // this allows to choose whether we work with CLIPBOARD (default) or
78 // PRIMARY selection on X11-based systems
79 //
80 // on the other ones, working with primary selection does nothing: this
81 // allows to write code which sets the primary selection when something is
82 // selected without any ill effects (i.e. without overwriting the
83 // clipboard which would be wrong on the platforms without X11 PRIMARY)
84 virtual void UsePrimarySelection(bool usePrimary = false)
85 {
86 m_usePrimary = usePrimary;
87 }
88
89 // return true if we're using primary selection
90 bool IsUsingPrimarySelection() const { return m_usePrimary; }
e1ee679c 91
5dc43d1f
VS
92 // Returns global instance (wxTheClipboard) of the object:
93 static wxClipboard *Get();
9005f2ed
VZ
94
95
96 // don't use this directly, it is public for compatibility with some ports
97 // (wxX11, wxMotif, ...) only
98 bool m_usePrimary;
e1ee679c
VZ
99};
100
c220de0b
RR
101// ----------------------------------------------------------------------------
102// asynchronous clipboard event
103// ----------------------------------------------------------------------------
104
105class WXDLLIMPEXP_CORE wxClipboardEvent : public wxEvent
106{
107public:
8946ede1
VZ
108 wxClipboardEvent(wxEventType evtType = wxEVT_NULL);
109 wxClipboardEvent(const wxClipboardEvent& event);
c220de0b 110
8946ede1
VZ
111 bool SupportsFormat(const wxDataFormat& format) const;
112 void AddFormat(const wxDataFormat& format);
c220de0b 113
8d3166e8 114 virtual wxEvent *Clone() const;
c220de0b
RR
115
116protected:
117 wxVector<wxDataFormat> m_formats;
118
c220de0b
RR
119 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardEvent)
120};
121
9b11752c 122wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CLIPBOARD_CHANGED, wxClipboardEvent );
c220de0b
RR
123
124typedef void (wxEvtHandler::*wxClipboardEventFunction)(wxClipboardEvent&);
125
126#define wxClipboardEventHandler(func) \
3c778901 127 wxEVENT_HANDLER_CAST(wxClipboardEventFunction, func)
c220de0b
RR
128
129#define EVT_CLIPBOARD_CHANGED(func) wx__DECLARE_EVT0(wxEVT_CLIPBOARD_CHANGED, wxClipboardEventHandler(func))
130
5dc43d1f
VS
131// ----------------------------------------------------------------------------
132// globals
133// ----------------------------------------------------------------------------
134
135// The global clipboard object - backward compatible access macro:
136#define wxTheClipboard (wxClipboard::Get())
137
e1ee679c
VZ
138// ----------------------------------------------------------------------------
139// include platform-specific class declaration
140// ----------------------------------------------------------------------------
141
2049ba38 142#if defined(__WXMSW__)
e1ee679c 143 #include "wx/msw/clipbrd.h"
2049ba38 144#elif defined(__WXMOTIF__)
e1ee679c 145 #include "wx/motif/clipbrd.h"
1be7a35c 146#elif defined(__WXGTK20__)
e1ee679c 147 #include "wx/gtk/clipbrd.h"
1be7a35c
MR
148#elif defined(__WXGTK__)
149 #include "wx/gtk1/clipbrd.h"
83df96d6
JS
150#elif defined(__WXX11__)
151 #include "wx/x11/clipbrd.h"
1e6feb95
VZ
152#elif defined(__WXMGL__)
153 #include "wx/mgl/clipbrd.h"
34138703 154#elif defined(__WXMAC__)
ef0e9220 155 #include "wx/osx/clipbrd.h"
aa3d0277
DE
156#elif defined(__WXCOCOA__)
157 #include "wx/cocoa/clipbrd.h"
1777b9bb 158#elif defined(__WXPM__)
e1ee679c 159 #include "wx/os2/clipbrd.h"
c801d85f
KB
160#endif
161
f536e0f2
VZ
162// ----------------------------------------------------------------------------
163// helpful class for opening the clipboard and automatically closing it
164// ----------------------------------------------------------------------------
165
53a2db12 166class WXDLLIMPEXP_CORE wxClipboardLocker
f536e0f2
VZ
167{
168public:
d3b9f782 169 wxClipboardLocker(wxClipboard *clipboard = NULL)
f536e0f2
VZ
170 {
171 m_clipboard = clipboard ? clipboard : wxTheClipboard;
172 if ( m_clipboard )
173 {
174 m_clipboard->Open();
175 }
176 }
177
ffd56fbc 178 bool operator!() const { return !m_clipboard->IsOpened(); }
f536e0f2
VZ
179
180 ~wxClipboardLocker()
181 {
182 if ( m_clipboard )
183 {
184 m_clipboard->Close();
185 }
186 }
187
188private:
189 wxClipboard *m_clipboard;
22f3361e 190
c0c133e1 191 wxDECLARE_NO_COPY_CLASS(wxClipboardLocker);
f536e0f2
VZ
192};
193
e1ee679c
VZ
194#endif // wxUSE_CLIPBOARD
195
196#endif // _WX_CLIPBRD_H_BASE_