]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/src/_clipbrd.i
wxX11 Unicode compilation fix
[wxWidgets.git] / wxPython / src / _clipbrd.i
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: _clipbrd.i
3// Purpose: SWIG definitions for the Clipboard
4//
5// Author: Robin Dunn
6//
7// Created: 31-October-1999
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17%newgroup
18
19%{
20%}
21
22DocStr(wxClipboard,
23"wx.Clipboard represents the system clipboard and provides methods to
24copy 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
26instance.
27
28Call ``wx.TheClipboard``'s `Open` method to get ownership of the
29clipboard. If this operation returns True, you now own the
30clipboard. Call `SetData` to put data on the clipboard, or `GetData`
31to retrieve data from the clipboard. Call `Close` to close the
32clipboard and relinquish ownership. You should keep the clipboard open
33only momentarily.
34
35:see: `wx.DataObject`
36", "");
37
38
39
40class wxClipboard : public wxObject {
41public:
42 DocCtorStr(
43 wxClipboard(),
44 "", "");
45
46 ~wxClipboard();
47
48
49 DocDeclStr(
50 virtual bool , Open(),
51 "Call this function to open the clipboard before calling SetData and
52GetData. Call Close when you have finished with the clipboard. You
53should keep the clipboard open for only a very short time. Returns
54True on success.", "");
55
56
57 DocDeclStr(
58 virtual void , Close(),
59 "Closes the clipboard.", "");
60
61
62 DocDeclStr(
63 virtual bool , IsOpened() const,
64 "Query whether the clipboard is opened", "");
65
66
67
68 %disownarg( wxDataObject *data );
69
70 DocDeclStr(
71 virtual bool , AddData( wxDataObject *data ),
72 "Call this function to add the data object to the clipboard. You may
73call this function repeatedly after having cleared the clipboard.
74After this function has been called, the clipboard owns the data, so
75do not delete the data explicitly.
76
77:see: `wx.DataObject`", "");
78
79
80 DocDeclStr(
81 virtual bool , SetData( wxDataObject *data ),
82 "Set the clipboard data, this is the same as `Clear` followed by
83`AddData`.
84
85:see: `wx.DataObject`", "");
86
87 %cleardisown( wxDataObject *data );
88
89
90 DocDeclStr(
91 virtual bool , IsSupported( const wxDataFormat& format ),
92 "Returns True if the given format is available in the data object(s) on
93the clipboard.", "");
94
95 DocDeclStr(
96 virtual bool , GetData( wxDataObject& data ),
97 "Call this function to fill data with data on the clipboard, if
98available in the required format. Returns true on success.", "");
99
100
101 DocDeclStr(
102 virtual void , Clear(),
103 "Clears data from the clipboard object and also the system's clipboard
104if possible.", "");
105
106
107 DocDeclStr(
108 virtual bool , Flush(),
109 "Flushes the clipboard: this means that the data which is currently on
110clipboard will stay available even after the application exits,
111possibly eating memory, otherwise the clipboard will be emptied on
112exit. Returns False if the operation is unsuccesful for any reason.", "");
113
114
115 DocDeclStr(
116 virtual void , UsePrimarySelection( bool primary = true ),
117 "On platforms supporting it (the X11 based platforms), selects the
118so called PRIMARY SELECTION as the clipboard as opposed to the
119normal clipboard, if primary is True.", "");
120
121
122 DocDeclStr(
123 static wxClipboard *, Get(),
124 "Returns global instance (wxTheClipboard) of the object.", "");
125
126};
127
128
129// Previously we just declared wxTheClipboard as a global, but in C++
130// is has been changed to be a macro for wxClipboard::Get, but the
131// swig generated code will try to evaluate it when it assigns to the
132// swig wrapper var so this causes Get to be called too early on
133// wxGTK. So instead we'll create a Python class that can delay the
134// Get until it is really needed, which is similar in effect to what
135// is really happening on the C++ side too.
136%pythoncode {
137 class _wxPyDelayedInitWrapper(object):
138 def __init__(self, initfunc, *args, **kwargs):
139 self._initfunc = initfunc
140 self._args = args
141 self._kwargs = kwargs
142 self._instance = None
143 def _checkInstance(self):
144 if self._instance is None:
145 if wx.GetApp():
146 self._instance = self._initfunc(*self._args, **self._kwargs)
147 def __getattr__(self, name):
148 self._checkInstance()
149 return getattr(self._instance, name)
150 def __repr__(self):
151 self._checkInstance()
152 return repr(self._instance)
153 TheClipboard = _wxPyDelayedInitWrapper(Clipboard.Get)
154}
155
156
157//---------------------------------------------------------------------------
158
159
160DocStr(wxClipboardLocker,
161"A helpful class for opening the clipboard and automatically
162closing it when the locker is destroyed.", "");
163
164class wxClipboardLocker
165{
166public:
167 wxClipboardLocker(wxClipboard *clipboard = NULL);
168 ~wxClipboardLocker();
169
170 DocStr(__nonzero__,
171 "A ClipboardLocker instance evaluates to True if the clipboard was
172successfully opened.", "");
173 %extend {
174 bool __nonzero__() { return !!(*self); }
175 }
176};
177
178
179//---------------------------------------------------------------------------