]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/clipbrd.h
adding 10.4 build compatibility for osx cocoa, see #10361
[wxWidgets.git] / include / wx / gtk / clipbrd.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/clipboard.h
3 // Purpose: wxClipboard for wxGTK
4 // Author: Robert Roebling, Vadim Zeitlin
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // (c) 2007 Vadim Zeitlin
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_GTK_CLIPBOARD_H_
12 #define _WX_GTK_CLIPBOARD_H_
13
14 // ----------------------------------------------------------------------------
15 // wxClipboard
16 // ----------------------------------------------------------------------------
17
18 #include "wx/weakref.h"
19
20 class WXDLLIMPEXP_CORE wxClipboard : public wxClipboardBase
21 {
22 public:
23 // there are several clipboards in X11 (and in GDK)
24 enum Kind
25 {
26 Primary,
27 Clipboard
28 };
29
30 wxClipboard();
31 virtual ~wxClipboard();
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
39 // query whether the clipboard is opened
40 virtual bool IsOpened() const;
41
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
49 virtual bool IsSupported( const wxDataFormat& format );
50
51 // ask if data in correct format is available
52 virtual bool IsSupportedAsync( wxEvtHandler *sink );
53
54 // fill data with data on the clipboard (if available)
55 virtual bool GetData( wxDataObject& data );
56
57 // clears wxTheClipboard and the system's clipboard if possible
58 virtual void Clear();
59
60
61
62 // implementation from now on
63 // --------------------------
64
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(); }
70
71 // clear the data for the given clipboard kind
72 void GTKClearData(Kind kind);
73
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);
79
80 private:
81 // the data object for the specific selection
82 wxDataObject *& Data(Kind kind)
83 {
84 return kind == Primary ? m_dataPrimary : m_dataClipboard;
85 }
86
87 // the data object we're currently using
88 wxDataObject *& Data()
89 {
90 return Data(m_usePrimary ? Primary : Clipboard);
91 }
92
93
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;
122 bool m_formatSupported;
123
124 public:
125 // async stuff
126 wxEvtHandlerRef m_sink;
127 private:
128 GtkWidget *m_targetsWidgetAsync; // for getting list of supported formats
129
130 DECLARE_DYNAMIC_CLASS(wxClipboard)
131 };
132
133 #endif // _WX_GTK_CLIPBOARD_H_