1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions for the Clipboard
7 // Created: 31-October-1999
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
23 "wx.Clipboard represents the system clipboard and provides methods to
24 copy data to it or paste data from it. Normally, you should only use
25 ``wx.TheClipboard`` which is a reference to a global wx.Clipboard
28 Call ``wx.TheClipboard``'s `Open` method to get ownership of the
29 clipboard. If this operation returns True, you now own the
30 clipboard. Call `SetData` to put data on the clipboard, or `GetData`
31 to retrieve data from the clipboard. Call `Close` to close the
32 clipboard and relinquish ownership. You should keep the clipboard open
40 class wxClipboard : public wxObject {
50 virtual bool , Open(),
51 "Call this function to open the clipboard before calling SetData and
52 GetData. Call Close when you have finished with the clipboard. You
53 should keep the clipboard open for only a very short time. Returns
54 True on success.", "");
58 virtual void , Close(),
59 "Closes the clipboard.", "");
63 virtual bool , IsOpened() const,
64 "Query whether the clipboard is opened", "");
68 %disownarg( wxDataObject *data );
71 virtual bool , AddData( wxDataObject *data ),
72 "Call this function to add the data object to the clipboard. You may
73 call this function repeatedly after having cleared the clipboard.
74 After this function has been called, the clipboard owns the data, so
75 do not delete the data explicitly.
77 :see: `wx.DataObject`", "");
81 virtual bool , SetData( wxDataObject *data ),
82 "Set the clipboard data, this is the same as `Clear` followed by
85 :see: `wx.DataObject`", "");
87 %cleardisown( wxDataObject *data );
91 virtual bool , IsSupported( const wxDataFormat& format ),
92 "Returns True if the given format is available in the data object(s) on
96 virtual bool , GetData( wxDataObject& data ),
97 "Call this function to fill data with data on the clipboard, if
98 available in the required format. Returns true on success.", "");
102 virtual void , Clear(),
103 "Clears data from the clipboard object and also the system's clipboard
108 virtual bool , Flush(),
109 "Flushes the clipboard: this means that the data which is currently on
110 clipboard will stay available even after the application exits,
111 possibly eating memory, otherwise the clipboard will be emptied on
112 exit. Returns False if the operation is unsuccesful for any reason.", "");
116 virtual void , UsePrimarySelection( bool primary = true ),
117 "On platforms supporting it (the X11 based platforms), selects the
118 so called PRIMARY SELECTION as the clipboard as opposed to the
119 normal clipboard, if primary is True.", "");
123 static wxClipboard *, Get(),
124 "Returns global instance (wxTheClipboard) of the object.", "");
126 %property(Data, GetData, SetData, doc="See `GetData` and `SetData`");
131 // Previously we just declared wxTheClipboard as a global, but in C++
132 // is has been changed to be a macro for wxClipboard::Get, but the
133 // swig generated code will try to evaluate it when it assigns to the
134 // swig wrapper var so this causes Get to be called too early on
135 // wxGTK. So instead we'll create a Python class that can delay the
136 // Get until it is really needed, which is similar in effect to what
137 // is really happening on the C++ side too.
139 class _wxPyDelayedInitWrapper(object):
140 def __init__(self, initfunc, *args, **kwargs):
141 self._initfunc = initfunc
143 self._kwargs = kwargs
144 self._instance = None
145 def _checkInstance(self):
146 if self._instance is None:
148 self._instance = self._initfunc(*self._args, **self._kwargs)
149 def __getattr__(self, name):
150 self._checkInstance()
151 return getattr(self._instance, name)
153 self._checkInstance()
154 return repr(self._instance)
155 TheClipboard = _wxPyDelayedInitWrapper(Clipboard.Get)
159 //---------------------------------------------------------------------------
162 DocStr(wxClipboardLocker,
163 "A helpful class for opening the clipboard and automatically
164 closing it when the locker is destroyed.", "");
166 class wxClipboardLocker
169 wxClipboardLocker(wxClipboard *clipboard = NULL);
170 ~wxClipboardLocker();
173 "A ClipboardLocker instance evaluates to True if the clipboard was
174 successfully opened.", "");
176 bool __nonzero__() { return !!(*self); }
181 //---------------------------------------------------------------------------