]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/clipbrd.h
abstract VC6 workaround inside a WX_CPPUNIT_ALLOW_EQUALS_TO_INT() macro
[wxWidgets.git] / include / wx / gtk / clipbrd.h
CommitLineData
dc86cb34 1/////////////////////////////////////////////////////////////////////////////
eddb9644
VZ
2// Name: wx/gtk/clipboard.h
3// Purpose: wxClipboard for wxGTK
4// Author: Robert Roebling, Vadim Zeitlin
dc86cb34
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
eddb9644 7// (c) 2007 Vadim Zeitlin
65571936 8// Licence: wxWindows licence
dc86cb34
RR
9/////////////////////////////////////////////////////////////////////////////
10
0416c418
PC
11#ifndef _WX_GTK_CLIPBOARD_H_
12#define _WX_GTK_CLIPBOARD_H_
dc86cb34 13
e1ee679c 14// ----------------------------------------------------------------------------
dc86cb34 15// wxClipboard
e1ee679c 16// ----------------------------------------------------------------------------
dc86cb34 17
c220de0b
RR
18#include "wx/weakref.h"
19
20123d49 20class WXDLLIMPEXP_CORE wxClipboard : public wxClipboardBase
dc86cb34 21{
dc86cb34 22public:
eddb9644
VZ
23 // there are several clipboards in X11 (and in GDK)
24 enum Kind
25 {
26 Primary,
27 Clipboard
28 };
29
26f86486 30 wxClipboard();
d3c7fc99 31 virtual ~wxClipboard();
26f86486
VZ
32
33 // open the clipboard before SetData() and GetData()
34 virtual bool Open();
35
36 // close the clipboard after SetData() and GetData()
37 virtual void Close();
38
f536e0f2
VZ
39 // query whether the clipboard is opened
40 virtual bool IsOpened() const;
41
26f86486
VZ
42 // set the clipboard data. all other formats will be deleted.
43 virtual bool SetData( wxDataObject *data );
44
45 // add to the clipboard data.
46 virtual bool AddData( wxDataObject *data );
47
48 // ask if data in correct format is available
e1ee679c 49 virtual bool IsSupported( const wxDataFormat& format );
26f86486 50
c220de0b
RR
51 // ask if data in correct format is available
52 virtual bool IsSupportedAsync( wxEvtHandler *sink );
53
26f86486 54 // fill data with data on the clipboard (if available)
e1ee679c 55 virtual bool GetData( wxDataObject& data );
26f86486
VZ
56
57 // clears wxTheClipboard and the system's clipboard if possible
58 virtual void Clear();
59
9005f2ed 60
06f5d975 61
e1ee679c 62 // implementation from now on
06f5d975
VZ
63 // --------------------------
64
eddb9644
VZ
65 // get our clipboard item (depending on m_usePrimary value)
66 GdkAtom GTKGetClipboardAtom() const;
67
68 // get the data object currently being used
69 wxDataObject *GTKGetDataObject() { return Data(); }
26f86486 70
eddb9644
VZ
71 // clear the data for the given clipboard kind
72 void GTKClearData(Kind kind);
26f86486 73
eddb9644
VZ
74 // called when selection data is received
75 void GTKOnSelectionReceived(const GtkSelectionData& sel);
76
77 // called when available target information is received
78 bool GTKOnTargetReceived(const wxDataFormat& format);
b527aac5 79
738f9e5a 80private:
511383f9
VZ
81 // the data object for the specific selection
82 wxDataObject *& Data(Kind kind)
83 {
84 return kind == Primary ? m_dataPrimary : m_dataClipboard;
85 }
86
eddb9644
VZ
87 // the data object we're currently using
88 wxDataObject *& Data()
89 {
511383f9 90 return Data(m_usePrimary ? Primary : Clipboard);
eddb9644
VZ
91 }
92
511383f9 93
eddb9644
VZ
94 // set or unset selection ownership
95 bool SetSelectionOwner(bool set = true);
96
97 // add atom to the list of supported targets
98 void AddSupportedTarget(GdkAtom atom);
99
100 // check if the given format is supported
101 bool DoIsSupported(const wxDataFormat& format);
102
103
104 // both of these pointers can be non-NULL simultaneously but we only use
105 // one of them at any moment depending on m_usePrimary value, use Data()
106 // (from inside) or GTKGetDataObject() (from outside) accessors
107 wxDataObject *m_dataPrimary,
108 *m_dataClipboard;
109
110 // this is used to temporarily hold the object passed to our GetData() so
111 // that GTK callbacks could access it
112 wxDataObject *m_receivedData;
113
114 // used to pass information about the format we need from DoIsSupported()
115 // to GTKOnTargetReceived()
116 GdkAtom m_targetRequested;
117
118 GtkWidget *m_clipboardWidget; // for getting and offering data
119 GtkWidget *m_targetsWidget; // for getting list of supported formats
120
121 bool m_open;
eddb9644
VZ
122 bool m_formatSupported;
123
c220de0b
RR
124public:
125 // async stuff
126 wxEvtHandlerRef m_sink;
127private:
128 GtkWidget *m_targetsWidgetAsync; // for getting list of supported formats
eddb9644 129
e1ee679c 130 DECLARE_DYNAMIC_CLASS(wxClipboard)
dc86cb34
RR
131};
132
0416c418 133#endif // _WX_GTK_CLIPBOARD_H_