1//---------------------------------------------------------------------------
2// This file is generated by wxPython's SIP generator.  Do not edit by hand.
3//
4// Copyright: (c) 2018 by Total Control Software
5// License:   wxWindows License
6//
7// This file will be included by _core.sip
8//
9//---------------------------------------------------------------------------
10
11//---------------------------------------------------------------------------
12
13class wxClipboard : wxObject
14{
15    %Docstring
16        Clipboard()
17
18        A class for manipulating the clipboard.
19    %End
20    %TypeHeaderCode
21        #include <wx/clipbrd.h>
22    %End
23
24public:
25    wxClipboard();
26    %PreMethodCode
27        if (!wxPyCheckForApp()) return NULL;
28    %End
29
30    virtual
31    ~wxClipboard();
32
33    virtual
34    bool AddData(
35        wxDataObject * data   /Transfer/
36    );
37    %Docstring
38        AddData(data) -> bool
39
40        Call this function to add the data object to the clipboard.
41    %End
42
43    virtual
44    void Clear();
45    %Docstring
46        Clear()
47
48        Clears the global clipboard object and the system's clipboard if
49        possible.
50    %End
51
52    virtual
53    void Close();
54    %Docstring
55        Close()
56
57        Call this function to close the clipboard, having opened it with
58        Open().
59    %End
60
61    virtual
62    bool Flush();
63    %Docstring
64        Flush() -> bool
65
66        Flushes the clipboard: this means that the data which is currently on
67        clipboard will stay available even after the application exits
68        (possibly eating memory), otherwise the clipboard will be emptied on
69        exit.
70    %End
71
72    virtual
73    bool GetData(
74        wxDataObject & data
75    );
76    %Docstring
77        GetData(data) -> bool
78
79        Call this function to fill data with data on the clipboard, if
80        available in the required format.
81    %End
82
83    virtual
84    bool IsOpened() const;
85    %Docstring
86        IsOpened() -> bool
87
88        Returns true if the clipboard has been opened.
89    %End
90
91    virtual
92    bool IsSupported(
93        const wxDataFormat & format
94    );
95    %Docstring
96        IsSupported(format) -> bool
97
98        Returns true if there is data which matches the data format of the
99        given data object currently available on the clipboard.
100    %End
101
102    bool IsUsingPrimarySelection() const;
103    %Docstring
104        IsUsingPrimarySelection() -> bool
105
106        Returns true if we are using the primary selection, false if clipboard
107        one.
108    %End
109
110    virtual
111    bool Open();
112    %Docstring
113        Open() -> bool
114
115        Call this function to open the clipboard before calling SetData() and
116        GetData().
117    %End
118
119    virtual
120    bool SetData(
121        wxDataObject * data   /Transfer/
122    );
123    %Docstring
124        SetData(data) -> bool
125
126        Call this function to set the data object to the clipboard.
127    %End
128
129    virtual
130    void UsePrimarySelection(
131        bool primary = false
132    );
133    %Docstring
134        UsePrimarySelection(primary=False)
135
136        On platforms supporting it (all X11-based ports), wxClipboard uses the
137        CLIPBOARD X11 selection by default.
138    %End
139
140    static
141    wxClipboard * Get();
142    %Docstring
143        Get() -> Clipboard
144
145        Returns the global instance (wxTheClipboard) of the clipboard object.
146    %End
147    %PreMethodCode
148        if (!wxPyCheckForApp()) return NULL;
149    %End
150
151    public:
152
153
154};  // end of class wxClipboard
155
156
157%Extract(id=pycode_core)
158# Since wxTheClipboard is not really a global variable (it is a macro
159# that calls the Get static method) we can't declare it as a global
160# variable for the wrapper generator, otherwise it will try to run the
161# function at module import and the wxApp object won't exist yet.  So
162# we'll use a class that will allow us to delay calling the Get until
163# wx.TheClipboard is actually being used for the first time.
164class _wxPyDelayedInitWrapper(object):
165    def __init__(self, initfunc, *args, **kwargs):
166        self._initfunc = initfunc
167        self._args = args
168        self._kwargs = kwargs
169        self._instance = None
170    def _checkInstance(self):
171        if self._instance is None:
172            if wx.GetApp():
173                self._instance = self._initfunc(*self._args, **self._kwargs)
174    def __getattr__(self, name):
175        self._checkInstance()
176        return getattr(self._instance, name)
177    def __repr__(self):
178        self._checkInstance()
179        return repr(self._instance)
180
181    # context manager methods
182    def __enter__(self):
183        self._checkInstance()
184        if not self.Open():
185            raise RuntimeError('Unable to open clipboard.')
186        return self
187    def __exit__(self, exc_type, exc_val, exc_tb):
188        self.Close()
189
190TheClipboard = _wxPyDelayedInitWrapper(Clipboard.Get)
191
192%End
193
194
195//---------------------------------------------------------------------------
196
197