]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/clipbrd.h
Add lambda-friendly wxDialog::ShowWindowModalThenDo().
[wxWidgets.git] / include / wx / gtk / clipbrd.h
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 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_GTK_CLIPBOARD_H_
11 #define _WX_GTK_CLIPBOARD_H_
12
13 // ----------------------------------------------------------------------------
14 // wxClipboard
15 // ----------------------------------------------------------------------------
16
17 #include "wx/weakref.h"
18
19 class WXDLLIMPEXP_CORE wxClipboard : public wxClipboardBase
20 {
21 public:
22 // there are several clipboards in X11 (and in GDK)
23 enum Kind
24 {
25 Primary,
26 Clipboard
27 };
28
29 wxClipboard();
30 virtual ~wxClipboard();
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
38 // query whether the clipboard is opened
39 virtual bool IsOpened() const;
40
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
48 virtual bool IsSupported( const wxDataFormat& format );
49
50 // ask if data in correct format is available
51 virtual bool IsSupportedAsync( wxEvtHandler *sink );
52
53 // fill data with data on the clipboard (if available)
54 virtual bool GetData( wxDataObject& data );
55
56 // clears wxTheClipboard and the system's clipboard if possible
57 virtual void Clear();
58
59
60
61 // implementation from now on
62 // --------------------------
63
64 // get our clipboard item (depending on m_usePrimary value)
65 GdkAtom GTKGetClipboardAtom() const;
66
67 // get the data object currently being requested
68 wxDataObject *GTKGetDataObject( GdkAtom atom );
69
70 // clear the data for the given clipboard kind
71 void GTKClearData(Kind kind);
72
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);
78
79 private:
80 // the data object for the specific selection
81 wxDataObject *& Data(Kind kind)
82 {
83 return kind == Primary ? m_dataPrimary : m_dataClipboard;
84 }
85
86 // the data object we're currently using
87 wxDataObject *& Data()
88 {
89 return Data(m_usePrimary ? Primary : Clipboard);
90 }
91
92
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
120 // ID of the connection to "selection_get" signal, initially 0.
121 unsigned long m_idSelectionGetHandler;
122
123 bool m_open;
124 bool m_formatSupported;
125
126 public:
127 // async stuff
128 wxEvtHandlerRef m_sink;
129 private:
130 GtkWidget *m_targetsWidgetAsync; // for getting list of supported formats
131
132 DECLARE_DYNAMIC_CLASS(wxClipboard)
133 };
134
135 #endif // _WX_GTK_CLIPBOARD_H_