1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/clipbrd.h
3 // Purpose: wxClipboard for wxGTK
4 // Author: Robert Roebling, Vadim Zeitlin
6 // Copyright: (c) 1998 Robert Roebling
7 // (c) 2007 Vadim Zeitlin
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GTK_CLIPBOARD_H_
12 #define _WX_GTK_CLIPBOARD_H_
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 #include "wx/weakref.h"
20 class WXDLLIMPEXP_CORE wxClipboard
: public wxClipboardBase
23 // there are several clipboards in X11 (and in GDK)
31 virtual ~wxClipboard();
33 // open the clipboard before SetData() and GetData()
36 // close the clipboard after SetData() and GetData()
39 // query whether the clipboard is opened
40 virtual bool IsOpened() const;
42 // set the clipboard data. all other formats will be deleted.
43 virtual bool SetData( wxDataObject
*data
);
45 // add to the clipboard data.
46 virtual bool AddData( wxDataObject
*data
);
48 // ask if data in correct format is available
49 virtual bool IsSupported( const wxDataFormat
& format
);
51 // ask if data in correct format is available
52 virtual bool IsSupportedAsync( wxEvtHandler
*sink
);
54 // fill data with data on the clipboard (if available)
55 virtual bool GetData( wxDataObject
& data
);
57 // clears wxTheClipboard and the system's clipboard if possible
62 // implementation from now on
63 // --------------------------
65 // get our clipboard item (depending on m_usePrimary value)
66 GdkAtom
GTKGetClipboardAtom() const;
68 // get the data object currently being requested
69 wxDataObject
*GTKGetDataObject( GdkAtom atom
);
71 // clear the data for the given clipboard kind
72 void GTKClearData(Kind kind
);
74 // called when selection data is received
75 void GTKOnSelectionReceived(const GtkSelectionData
& sel
);
77 // called when available target information is received
78 bool GTKOnTargetReceived(const wxDataFormat
& format
);
81 // the data object for the specific selection
82 wxDataObject
*& Data(Kind kind
)
84 return kind
== Primary
? m_dataPrimary
: m_dataClipboard
;
87 // the data object we're currently using
88 wxDataObject
*& Data()
90 return Data(m_usePrimary
? Primary
: Clipboard
);
94 // set or unset selection ownership
95 bool SetSelectionOwner(bool set
= true);
97 // add atom to the list of supported targets
98 void AddSupportedTarget(GdkAtom atom
);
100 // check if the given format is supported
101 bool DoIsSupported(const wxDataFormat
& format
);
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
,
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
;
114 // used to pass information about the format we need from DoIsSupported()
115 // to GTKOnTargetReceived()
116 GdkAtom m_targetRequested
;
118 GtkWidget
*m_clipboardWidget
; // for getting and offering data
119 GtkWidget
*m_targetsWidget
; // for getting list of supported formats
121 // ID of the connection to "selection_get" signal, initially 0.
122 unsigned long m_idSelectionGetHandler
;
125 bool m_formatSupported
;
129 wxEvtHandlerRef m_sink
;
131 GtkWidget
*m_targetsWidgetAsync
; // for getting list of supported formats
133 DECLARE_DYNAMIC_CLASS(wxClipboard
)
136 #endif // _WX_GTK_CLIPBOARD_H_