1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/clipbrd.h
3 // Purpose: wxClipboard for wxGTK
4 // Author: Robert Roebling, Vadim Zeitlin
5 // Copyright: (c) 1998 Robert Roebling
6 // (c) 2007 Vadim Zeitlin
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_CLIPBOARD_H_
11 #define _WX_GTK_CLIPBOARD_H_
13 // ----------------------------------------------------------------------------
15 // ----------------------------------------------------------------------------
17 #include "wx/weakref.h"
19 class WXDLLIMPEXP_CORE wxClipboard
: public wxClipboardBase
22 // there are several clipboards in X11 (and in GDK)
30 virtual ~wxClipboard();
32 // open the clipboard before SetData() and GetData()
35 // close the clipboard after SetData() and GetData()
38 // query whether the clipboard is opened
39 virtual bool IsOpened() const;
41 // set the clipboard data. all other formats will be deleted.
42 virtual bool SetData( wxDataObject
*data
);
44 // add to the clipboard data.
45 virtual bool AddData( wxDataObject
*data
);
47 // ask if data in correct format is available
48 virtual bool IsSupported( const wxDataFormat
& format
);
50 // ask if data in correct format is available
51 virtual bool IsSupportedAsync( wxEvtHandler
*sink
);
53 // fill data with data on the clipboard (if available)
54 virtual bool GetData( wxDataObject
& data
);
56 // clears wxTheClipboard and the system's clipboard if possible
61 // implementation from now on
62 // --------------------------
64 // get our clipboard item (depending on m_usePrimary value)
65 GdkAtom
GTKGetClipboardAtom() const;
67 // get the data object currently being requested
68 wxDataObject
*GTKGetDataObject( GdkAtom atom
);
70 // clear the data for the given clipboard kind
71 void GTKClearData(Kind kind
);
73 // called when selection data is received
74 void GTKOnSelectionReceived(const GtkSelectionData
& sel
);
76 // called when available target information is received
77 bool GTKOnTargetReceived(const wxDataFormat
& format
);
80 // the data object for the specific selection
81 wxDataObject
*& Data(Kind kind
)
83 return kind
== Primary
? m_dataPrimary
: m_dataClipboard
;
86 // the data object we're currently using
87 wxDataObject
*& Data()
89 return Data(m_usePrimary
? Primary
: Clipboard
);
93 // set or unset selection ownership
94 bool SetSelectionOwner(bool set
= true);
96 // add atom to the list of supported targets
97 void AddSupportedTarget(GdkAtom atom
);
99 // check if the given format is supported
100 bool DoIsSupported(const wxDataFormat
& format
);
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
,
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
;
113 // used to pass information about the format we need from DoIsSupported()
114 // to GTKOnTargetReceived()
115 GdkAtom m_targetRequested
;
117 GtkWidget
*m_clipboardWidget
; // for getting and offering data
118 GtkWidget
*m_targetsWidget
; // for getting list of supported formats
120 // ID of the connection to "selection_get" signal, initially 0.
121 unsigned long m_idSelectionGetHandler
;
124 bool m_formatSupported
;
128 wxEvtHandlerRef m_sink
;
130 GtkWidget
*m_targetsWidgetAsync
; // for getting list of supported formats
132 DECLARE_DYNAMIC_CLASS(wxClipboard
)
135 #endif // _WX_GTK_CLIPBOARD_H_