1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/clipboard.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 class WXDLLIMPEXP_CORE wxClipboard
: public wxClipboardBase
21 // there are several clipboards in X11 (and in GDK)
29 virtual ~wxClipboard();
31 // open the clipboard before SetData() and GetData()
34 // close the clipboard after SetData() and GetData()
37 // query whether the clipboard is opened
38 virtual bool IsOpened() const;
40 // set the clipboard data. all other formats will be deleted.
41 virtual bool SetData( wxDataObject
*data
);
43 // add to the clipboard data.
44 virtual bool AddData( wxDataObject
*data
);
46 // ask if data in correct format is available
47 virtual bool IsSupported( const wxDataFormat
& format
);
49 // fill data with data on the clipboard (if available)
50 virtual bool GetData( wxDataObject
& data
);
52 // clears wxTheClipboard and the system's clipboard if possible
57 // implementation from now on
58 // --------------------------
60 // get our clipboard item (depending on m_usePrimary value)
61 GdkAtom
GTKGetClipboardAtom() const;
63 // get the data object currently being used
64 wxDataObject
*GTKGetDataObject() { return Data(); }
66 // clear the data for the given clipboard kind
67 void GTKClearData(Kind kind
);
69 // called when selection data is received
70 void GTKOnSelectionReceived(const GtkSelectionData
& sel
);
72 // called when available target information is received
73 bool GTKOnTargetReceived(const wxDataFormat
& format
);
76 // the data object we're currently using
77 wxDataObject
*& Data()
79 return m_usePrimary
? m_dataPrimary
: m_dataClipboard
;
82 // set or unset selection ownership
83 bool SetSelectionOwner(bool set
= true);
85 // add atom to the list of supported targets
86 void AddSupportedTarget(GdkAtom atom
);
88 // check if the given format is supported
89 bool DoIsSupported(const wxDataFormat
& format
);
92 // both of these pointers can be non-NULL simultaneously but we only use
93 // one of them at any moment depending on m_usePrimary value, use Data()
94 // (from inside) or GTKGetDataObject() (from outside) accessors
95 wxDataObject
*m_dataPrimary
,
98 // this is used to temporarily hold the object passed to our GetData() so
99 // that GTK callbacks could access it
100 wxDataObject
*m_receivedData
;
102 // used to pass information about the format we need from DoIsSupported()
103 // to GTKOnTargetReceived()
104 GdkAtom m_targetRequested
;
106 GtkWidget
*m_clipboardWidget
; // for getting and offering data
107 GtkWidget
*m_targetsWidget
; // for getting list of supported formats
110 bool m_formatSupported
;
113 DECLARE_DYNAMIC_CLASS(wxClipboard
)
116 #endif // _WX_GTK_CLIPBOARD_H_