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