]>
Commit | Line | Data |
---|---|---|
febb39df RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: aui.i | |
3 | // Purpose: Wrappers for the wxAUI classes. | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 5-July-2006 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2006 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | %define DOCSTRING | |
14 | "The wx.aui moduleis an Advanced User Interface library that aims to | |
15 | implement \"cutting-edge\" interface usability and design features so | |
16 | developers can quickly and easily create beautiful and usable | |
17 | application interfaces. | |
18 | ||
19 | **Vision and Design Principles** | |
20 | ||
21 | wx.aui attempts to encapsulate the following aspects of the user | |
22 | interface: | |
23 | ||
24 | * Frame Management: Frame management provides the means to open, | |
25 | move and hide common controls that are needed to interact with the | |
26 | document, and allow these configurations to be saved into | |
27 | different perspectives and loaded at a later time. | |
28 | ||
29 | * Toolbars: Toolbars are a specialized subset of the frame | |
30 | management system and should behave similarly to other docked | |
31 | components. However, they also require additional functionality, | |
32 | such as \"spring-loaded\" rebar support, \"chevron\" buttons and | |
33 | end-user customizability. | |
34 | ||
35 | * Modeless Controls: Modeless controls expose a tool palette or set | |
36 | of options that float above the application content while allowing | |
37 | it to be accessed. Usually accessed by the toolbar, these controls | |
38 | disappear when an option is selected, but may also be \"torn off\" | |
39 | the toolbar into a floating frame of their own. | |
40 | ||
41 | * Look and Feel: Look and feel encompasses the way controls are | |
42 | drawn, both when shown statically as well as when they are being | |
43 | moved. This aspect of user interface design incorporates \"special | |
44 | effects\" such as transparent window dragging as well as frame | |
45 | animation. | |
46 | ||
2a783b2d | 47 | **wx.aui adheres to the following principles** |
febb39df RD |
48 | |
49 | - Use native floating frames to obtain a native look and feel for | |
50 | all platforms; | |
51 | ||
52 | - Use existing wxPython code where possible, such as sizer | |
53 | implementation for frame management; | |
54 | ||
55 | - Use standard wxPython coding conventions. | |
56 | ||
57 | ||
58 | **Usage** | |
59 | ||
60 | The following example shows a simple implementation that utilizes | |
61 | `wx.aui.FrameManager` to manage three text controls in a frame window:: | |
62 | ||
63 | import wx | |
64 | import wx.aui | |
65 | ||
66 | class MyFrame(wx.Frame): | |
67 | ||
68 | def __init__(self, parent, id=-1, title='wx.aui Test', | |
69 | size=(800, 600), style=wx.DEFAULT_FRAME_STYLE): | |
70 | wx.Frame.__init__(self, parent, id, title, pos, size, style) | |
71 | ||
2a783b2d | 72 | self._mgr = wx.aui.AuiManager(self) |
febb39df RD |
73 | |
74 | # create several text controls | |
75 | text1 = wx.TextCtrl(self, -1, 'Pane 1 - sample text', | |
76 | wx.DefaultPosition, wx.Size(200,150), | |
77 | wx.NO_BORDER | wx.TE_MULTILINE) | |
78 | ||
79 | text2 = wx.TextCtrl(self, -1, 'Pane 2 - sample text', | |
80 | wx.DefaultPosition, wx.Size(200,150), | |
81 | wx.NO_BORDER | wx.TE_MULTILINE) | |
82 | ||
83 | text3 = wx.TextCtrl(self, -1, 'Main content window', | |
84 | wx.DefaultPosition, wx.Size(200,150), | |
85 | wx.NO_BORDER | wx.TE_MULTILINE) | |
86 | ||
87 | # add the panes to the manager | |
88 | self._mgr.AddPane(text1, wx.LEFT, 'Pane Number One') | |
89 | self._mgr.AddPane(text2, wx.BOTTOM, 'Pane Number Two') | |
90 | self._mgr.AddPane(text3, wx.CENTER) | |
91 | ||
92 | # tell the manager to 'commit' all the changes just made | |
93 | self._mgr.Update() | |
94 | ||
95 | self.Bind(wx.EVT_CLOSE, self.OnClose) | |
96 | ||
97 | ||
98 | def OnClose(self, event): | |
99 | # deinitialize the frame manager | |
100 | self._mgr.UnInit() | |
101 | # delete the frame | |
102 | self.Destroy() | |
103 | ||
104 | ||
105 | app = wx.App() | |
106 | frame = MyFrame(None) | |
107 | frame.Show() | |
108 | app.MainLoop() | |
109 | " | |
110 | %enddef | |
111 | ||
112 | ||
113 | ||
114 | %module(package="wx", docstring=DOCSTRING) aui | |
115 | ||
116 | %{ | |
117 | #include "wx/wxPython/wxPython.h" | |
118 | #include "wx/wxPython/pyclasses.h" | |
119 | #include <wx/aui/aui.h> | |
120 | %} | |
121 | ||
122 | //--------------------------------------------------------------------------- | |
123 | ||
124 | %import core.i | |
125 | %import windows.i | |
126 | ||
127 | %pythoncode { wx = _core } | |
128 | %pythoncode { __docfilter__ = wx.__DocFilter(globals()) } | |
129 | ||
130 | ||
131 | %include _aui_docstrings.i | |
132 | ||
133 | //--------------------------------------------------------------------------- | |
134 | ||
135 | ||
136 | #define wxUSE_AUI 1 | |
137 | #define WXDLLIMPEXP_AUI | |
138 | #define unsigned | |
d7a7616b RD |
139 | #define wxDEPRECATED(decl) |
140 | ||
febb39df | 141 | |
1c976bff RD |
142 | // We'll skip making wrappers for these, they have overloads that take a |
143 | // wxSize or wxPoint | |
2a783b2d RD |
144 | %ignore wxAuiPaneInfo::MaxSize(int x, int y); |
145 | %ignore wxAuiPaneInfo::MinSize(int x, int y); | |
146 | %ignore wxAuiPaneInfo::BestSize(int x, int y); | |
147 | %ignore wxAuiPaneInfo::FloatingPosition(int x, int y); | |
148 | %ignore wxAuiPaneInfo::FloatingSize(int x, int y); | |
febb39df RD |
149 | |
150 | // But for these we will do the overloading (see %pythoncode below) so let's | |
151 | // rename the C++ versions | |
2a783b2d RD |
152 | %rename(_GetPaneByWidget) wxAuiManager::GetPane(wxWindow* window); |
153 | %rename(_GetPaneByName) wxAuiManager::GetPane(const wxString& name); | |
febb39df | 154 | |
2a783b2d RD |
155 | %rename(_AddPane1) wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info); |
156 | %rename(_AddPane2) wxAuiManager::AddPane(wxWindow* window, int direction = wxLEFT, | |
157 | const wxString& caption = wxEmptyString); | |
febb39df | 158 | |
2a783b2d RD |
159 | %rename(AddPaneAtPos) wxAuiManager::AddPane(wxWindow* window, |
160 | const wxPaneInfo& pane_info, | |
161 | const wxPoint& drop_pos); | |
febb39df RD |
162 | |
163 | // A typemap for the return value of wxFrameManager::GetAllPanes | |
2a783b2d | 164 | %typemap(out) wxAuiPaneInfoArray& { |
febb39df RD |
165 | $result = PyList_New(0); |
166 | for (size_t i=0; i < $1->GetCount(); i++) { | |
2a783b2d | 167 | PyObject* pane_obj = SWIG_NewPointerObj((void*)(&$1->Item(i)), SWIGTYPE_p_wxAuiPaneInfo, 0); |
febb39df RD |
168 | PyList_Append($result, pane_obj); |
169 | } | |
170 | } | |
171 | ||
172 | ||
1c976bff RD |
173 | %nokwargs wxAuiTabContainer::SetActivePage; |
174 | ||
175 | %pythonAppend wxAuiTabCtrl::wxAuiTabCtrl "self._setOORInfo(self)"; | |
176 | ||
2a783b2d RD |
177 | %pythonAppend wxAuiNotebook::wxAuiNotebook "self._setOORInfo(self)"; |
178 | %pythonAppend wxAuiNotebook::wxAuiNotebook() "self._setOORInfo(self)"; | |
179 | %ignore wxAuiiNotebook::~wxAuiNotebook; | |
180 | %rename(PreAuiNotebook) wxAuiNotebook::wxAuiNotebook(); | |
1c976bff | 181 | |
54af9b8b RD |
182 | |
183 | ||
184 | %ignore wxAuiDefaultTabArt::SetWindow; // Link error... | |
185 | ||
febb39df RD |
186 | //--------------------------------------------------------------------------- |
187 | // Get all our defs from the REAL header files. | |
188 | %include framemanager.h | |
189 | %include dockart.h | |
190 | %include floatpane.h | |
1c976bff | 191 | %include auibook.h |
febb39df RD |
192 | |
193 | //--------------------------------------------------------------------------- | |
194 | // Methods to inject into the FrameManager class that will sort out calls to | |
195 | // the overloaded versions of GetPane and AddPane | |
196 | ||
2a783b2d | 197 | %extend wxAuiManager { |
d7a7616b | 198 | %pythoncode { |
febb39df RD |
199 | def GetPane(self, item): |
200 | """ | |
201 | GetPane(self, window_or_info item) -> PaneInfo | |
202 | ||
203 | GetPane is used to search for a `PaneInfo` object either by | |
204 | widget reference or by pane name, which acts as a unique id | |
205 | for a window pane. The returned `PaneInfo` object may then be | |
206 | modified to change a pane's look, state or position. After one | |
207 | or more modifications to the `PaneInfo`, `FrameManager.Update` | |
208 | should be called to realize the changes to the user interface. | |
209 | ||
210 | If the lookup failed (meaning the pane could not be found in | |
211 | the manager) GetPane returns an empty `PaneInfo`, a condition | |
212 | which can be checked by calling `PaneInfo.IsOk`. | |
213 | """ | |
214 | if isinstance(item, wx.Window): | |
215 | return self._GetPaneByWidget(item) | |
216 | else: | |
217 | return self._GetPaneByName(item) | |
218 | ||
219 | def AddPane(self, window, info=None, caption=None): | |
220 | """ | |
221 | AddPane(self, window, info=None, caption=None) -> bool | |
222 | ||
223 | AddPane tells the frame manager to start managing a child | |
224 | window. There are two versions of this function. The first | |
225 | verison accepts a `PaneInfo` object for the ``info`` parameter | |
226 | and allows the full spectrum of pane parameter | |
227 | possibilities. (Say that 3 times fast!) | |
228 | ||
229 | The second version is used for simpler user interfaces which | |
230 | do not require as much configuration. In this case the | |
231 | ``info`` parameter specifies the direction property of the | |
232 | pane info, and defaults to ``wx.LEFT``. The pane caption may | |
233 | also be specified as an extra parameter in this form. | |
234 | """ | |
2a783b2d | 235 | if type(info) == AuiPaneInfo: |
4c16bedf | 236 | return self._AddPane1(window, info) |
febb39df RD |
237 | else: |
238 | # This Is AddPane2 | |
4c16bedf RD |
239 | if info is None: |
240 | info = wx.LEFT | |
241 | if caption is None: | |
242 | caption = "" | |
243 | return self._AddPane2(window, info, caption) | |
d7a7616b RD |
244 | } |
245 | ||
246 | // For backwards compatibility | |
247 | %pythoncode { | |
248 | SetFrame = wx._deprecated(SetManagedWindow, | |
249 | "SetFrame is deprecated, use `SetManagedWindow` instead.") | |
250 | GetFrame = wx._deprecated(GetManagedWindow, | |
251 | "GetFrame is deprecated, use `GetManagedWindow` instead.") | |
252 | } | |
febb39df RD |
253 | } |
254 | ||
2a783b2d RD |
255 | %extend wxAuiDockInfo { |
256 | ~wxAuiDockInfo() {} | |
050441c8 RD |
257 | } |
258 | ||
2a783b2d RD |
259 | %extend wxAuiDockUIPart { |
260 | ~wxAuiDockUIPart() {} | |
050441c8 RD |
261 | } |
262 | ||
2a783b2d RD |
263 | %extend wxAuiPaneButton { |
264 | ~wxAuiPaneButton() {} | |
050441c8 RD |
265 | } |
266 | ||
febb39df RD |
267 | //--------------------------------------------------------------------------- |
268 | ||
269 | %{ | |
2db4b82e | 270 | // A wxDocArt class that knows how to forward virtuals to Python methods |
2a783b2d | 271 | class wxPyAuiDockArt : public wxAuiDefaultDockArt |
febb39df | 272 | { |
2a783b2d | 273 | wxPyAuiDockArt() : wxAuiDefaultDockArt() {} |
febb39df RD |
274 | |
275 | DEC_PYCALLBACK_INT_INT(GetMetric); | |
276 | DEC_PYCALLBACK_VOID_INTINT(SetMetric); | |
277 | DEC_PYCALLBACK__INTFONT(SetFont); | |
278 | DEC_PYCALLBACK_FONT_INT(GetFont); | |
279 | DEC_PYCALLBACK_COLOUR_INT(GetColour); | |
280 | DEC_PYCALLBACK__INTCOLOUR(SetColour); | |
281 | ||
282 | virtual void DrawSash(wxDC& dc, | |
e81b607b | 283 | wxWindow* window, |
febb39df RD |
284 | int orientation, |
285 | const wxRect& rect) | |
286 | { | |
287 | bool found; | |
288 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
289 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawSash"))) { | |
290 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 291 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 292 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
e81b607b RD |
293 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)", |
294 | odc, owin, orientation, orect)); | |
febb39df | 295 | Py_DECREF(odc); |
8f514ab4 | 296 | Py_DECREF(owin); |
febb39df RD |
297 | Py_DECREF(orect); |
298 | } | |
299 | wxPyEndBlockThreads(blocked); | |
300 | if (! found) | |
2a783b2d | 301 | wxAuiDefaultDockArt::DrawSash(dc, window, orientation, rect); |
febb39df RD |
302 | } |
303 | ||
304 | virtual void DrawBackground(wxDC& dc, | |
e81b607b | 305 | wxWindow* window, |
febb39df RD |
306 | int orientation, |
307 | const wxRect& rect) | |
308 | { | |
309 | bool found; | |
310 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
311 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) { | |
312 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 313 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 314 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
e81b607b RD |
315 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)", |
316 | odc, owin, orientation, orect)); | |
febb39df | 317 | Py_DECREF(odc); |
8f514ab4 | 318 | Py_DECREF(owin); |
febb39df RD |
319 | Py_DECREF(orect); |
320 | } | |
321 | wxPyEndBlockThreads(blocked); | |
322 | if (! found) | |
2a783b2d | 323 | wxAuiDefaultDockArt::DrawBackground(dc, window, orientation, rect); |
febb39df RD |
324 | } |
325 | ||
326 | virtual void DrawCaption(wxDC& dc, | |
e81b607b | 327 | wxWindow* window, |
febb39df RD |
328 | const wxString& text, |
329 | const wxRect& rect, | |
2a783b2d | 330 | wxAuiPaneInfo& pane) |
febb39df RD |
331 | { |
332 | bool found; | |
333 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
334 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawCaption"))) { | |
335 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 336 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df RD |
337 | PyObject* otext = wx2PyString(text); |
338 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); | |
2a783b2d | 339 | PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0); |
e81b607b RD |
340 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOO)", |
341 | odc, owin, otext, orect, opane)); | |
febb39df | 342 | Py_DECREF(odc); |
8f514ab4 | 343 | Py_DECREF(owin); |
febb39df RD |
344 | Py_DECREF(otext); |
345 | Py_DECREF(orect); | |
346 | Py_DECREF(opane); | |
347 | } | |
348 | wxPyEndBlockThreads(blocked); | |
349 | if (! found) | |
2a783b2d | 350 | wxAuiDefaultDockArt::DrawCaption(dc, window, text, rect, pane); |
febb39df RD |
351 | } |
352 | ||
353 | virtual void DrawGripper(wxDC& dc, | |
e81b607b | 354 | wxWindow* window, |
febb39df | 355 | const wxRect& rect, |
2a783b2d | 356 | wxAuiPaneInfo& pane) |
febb39df RD |
357 | { |
358 | bool found; | |
359 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
360 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawGripper"))) { | |
361 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 362 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 363 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
2a783b2d | 364 | PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0); |
e81b607b | 365 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOO)", odc, owin, orect, opane)); |
febb39df RD |
366 | Py_DECREF(odc); |
367 | Py_DECREF(orect); | |
368 | Py_DECREF(opane); | |
369 | } | |
370 | wxPyEndBlockThreads(blocked); | |
371 | if (! found) | |
2a783b2d | 372 | wxAuiDefaultDockArt::DrawGripper(dc, window, rect, pane); |
febb39df RD |
373 | } |
374 | ||
375 | virtual void DrawBorder(wxDC& dc, | |
e81b607b | 376 | wxWindow* window, |
febb39df | 377 | const wxRect& rect, |
2a783b2d | 378 | wxAuiPaneInfo& pane) |
febb39df RD |
379 | { |
380 | bool found; | |
381 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
382 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawBorder"))) { | |
383 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 384 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 385 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
2a783b2d | 386 | PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0); |
febb39df RD |
387 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, orect, opane)); |
388 | Py_DECREF(odc); | |
8f514ab4 | 389 | Py_DECREF(owin); |
febb39df RD |
390 | Py_DECREF(orect); |
391 | Py_DECREF(opane); | |
392 | } | |
393 | wxPyEndBlockThreads(blocked); | |
394 | if (! found) | |
2a783b2d | 395 | wxAuiDefaultDockArt::DrawBorder(dc, window, rect, pane); |
febb39df RD |
396 | } |
397 | ||
398 | virtual void DrawPaneButton(wxDC& dc, | |
e81b607b | 399 | wxWindow* window, |
febb39df RD |
400 | int button, |
401 | int button_state, | |
402 | const wxRect& rect, | |
2a783b2d | 403 | wxAuiPaneInfo& pane) |
febb39df RD |
404 | { |
405 | bool found; | |
406 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
407 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawPaneButton"))) { | |
408 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 409 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 410 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
2a783b2d | 411 | PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0); |
e81b607b RD |
412 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiIOO)", |
413 | odc, owin, button, button_state, | |
febb39df RD |
414 | orect, opane)); |
415 | Py_DECREF(odc); | |
8f514ab4 | 416 | Py_DECREF(owin); |
febb39df RD |
417 | Py_DECREF(orect); |
418 | Py_DECREF(opane); | |
419 | } | |
420 | wxPyEndBlockThreads(blocked); | |
421 | if (! found) | |
2a783b2d | 422 | wxAuiDefaultDockArt::DrawPaneButton(dc, window, button, button_state, rect, pane); |
febb39df RD |
423 | } |
424 | ||
425 | PYPRIVATE; | |
426 | ||
427 | }; | |
428 | ||
2a783b2d RD |
429 | IMP_PYCALLBACK_INT_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetMetric); |
430 | IMP_PYCALLBACK_VOID_INTINT(wxPyAuiDockArt, wxAuiDefaultDockArt, SetMetric); | |
431 | IMP_PYCALLBACK__INTFONT(wxPyAuiDockArt, wxAuiDefaultDockArt, SetFont); | |
432 | IMP_PYCALLBACK_FONT_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetFont); | |
433 | IMP_PYCALLBACK_COLOUR_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetColour); | |
434 | IMP_PYCALLBACK__INTCOLOUR(wxPyAuiDockArt, wxAuiDefaultDockArt, SetColour); | |
febb39df RD |
435 | |
436 | %} | |
437 | ||
438 | ||
2a783b2d RD |
439 | DocStr(wxPyAuiDockArt, |
440 | "This version of the `AuiDockArt` class has been instrumented to be | |
febb39df RD |
441 | subclassable in Python and to reflect all calls to the C++ base class |
442 | methods to the Python methods implemented in the derived class.", ""); | |
443 | ||
2a783b2d | 444 | class wxPyAuiDockArt : public wxAuiDefaultDockArt |
febb39df | 445 | { |
2a783b2d RD |
446 | %pythonAppend wxPyAuiDockArt "self._setCallbackInfo(self, PyAuiDockArt)" |
447 | wxPyAuiDocArt(); | |
febb39df RD |
448 | |
449 | }; | |
450 | ||
451 | ||
777e547f RD |
452 | //--------------------------------------------------------------------------- |
453 | ||
2a783b2d | 454 | %extend wxAuiNotebook { |
777e547f RD |
455 | %property(PageCount, GetPageCount, doc="See `GetPageCount`"); |
456 | %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`"); | |
457 | } | |
458 | ||
459 | ||
460 | %extend wxAuiNotebookEvent { | |
461 | %property(OldSelection, GetOldSelection, SetOldSelection, doc="See `GetOldSelection` and `SetOldSelection`"); | |
462 | %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`"); | |
463 | } | |
464 | ||
465 | ||
466 | %extend wxAuiTabContainer { | |
467 | %property(ActivePage, GetActivePage, SetActivePage, doc="See `GetActivePage` and `SetActivePage`"); | |
468 | %property(PageCount, GetPageCount, doc="See `GetPageCount`"); | |
469 | %property(Pages, GetPages, doc="See `GetPages`"); | |
470 | } | |
471 | ||
472 | ||
2a783b2d | 473 | %extend wxAuiManager { |
777e547f RD |
474 | %property(AllPanes, GetAllPanes, doc="See `GetAllPanes`"); |
475 | %property(ArtProvider, GetArtProvider, SetArtProvider, doc="See `GetArtProvider` and `SetArtProvider`"); | |
476 | %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`"); | |
477 | %property(ManagedWindow, GetManagedWindow, SetManagedWindow, doc="See `GetManagedWindow` and `SetManagedWindow`"); | |
478 | } | |
479 | ||
480 | ||
2a783b2d | 481 | %extend wxAuiManagerEvent { |
777e547f RD |
482 | %property(Button, GetButton, SetButton, doc="See `GetButton` and `SetButton`"); |
483 | %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`"); | |
484 | %property(Pane, GetPane, SetPane, doc="See `GetPane` and `SetPane`"); | |
485 | } | |
486 | ||
487 | ||
2db4b82e RD |
488 | //--------------------------------------------------------------------------- |
489 | ||
490 | %{ | |
491 | // A wxTabArt class that knows how to forward virtuals to Python methods | |
2a783b2d | 492 | class wxPyAuiTabArt : public wxAuiDefaultTabArt |
2db4b82e | 493 | { |
2a783b2d | 494 | wxPyAuiTabArt() : wxAuiDefaultTabArt() {} |
2db4b82e | 495 | |
8f514ab4 | 496 | |
2db4b82e | 497 | virtual void DrawBackground( wxDC* dc, |
54af9b8b | 498 | wxWindow* wnd, |
2db4b82e RD |
499 | const wxRect& rect ) |
500 | { | |
501 | bool found; | |
502 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
503 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) { | |
504 | PyObject* odc = wxPyMake_wxObject(dc, false); | |
54af9b8b | 505 | PyObject* ownd = wxPyMake_wxObject(wnd, false); |
2db4b82e | 506 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
54af9b8b | 507 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, ownd, orect)); |
2db4b82e | 508 | Py_DECREF(odc); |
54af9b8b | 509 | Py_DECREF(ownd); |
2db4b82e RD |
510 | Py_DECREF(orect); |
511 | } | |
512 | wxPyEndBlockThreads(blocked); | |
513 | if (!found) | |
54af9b8b | 514 | wxAuiDefaultTabArt::DrawBackground(dc, wnd, rect); |
2db4b82e RD |
515 | } |
516 | ||
517 | virtual void DrawTab( wxDC* dc, | |
54af9b8b | 518 | wxWindow* wnd, |
2db4b82e RD |
519 | const wxRect& in_rect, |
520 | const wxString& caption, | |
521 | bool active, | |
36cb9ebe RD |
522 | int close_button_state, |
523 | wxRect* out_tab_rect, | |
524 | wxRect* out_button_rect, | |
2db4b82e RD |
525 | int* x_extent) |
526 | { | |
527 | bool found; | |
36cb9ebe | 528 | const char* errmsg = "DrawTab should return a sequence containing (tab_rect, button_rect, x_extent)"; |
2db4b82e RD |
529 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
530 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawTab"))) { | |
531 | PyObject* odc = wxPyMake_wxObject(dc, false); | |
54af9b8b | 532 | PyObject* ownd = wxPyMake_wxObject(wnd, false); |
2db4b82e RD |
533 | PyObject* orect = wxPyConstructObject((void*)&in_rect, wxT("wxRect"), 0); |
534 | PyObject* otext = wx2PyString(caption); | |
535 | PyObject* ro; | |
2a783b2d | 536 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue( |
54af9b8b RD |
537 | "(OOOOii)", |
538 | odc, ownd, orect, otext, | |
36cb9ebe | 539 | (int)active, close_button_state)); |
2db4b82e | 540 | if (ro) { |
36cb9ebe | 541 | if (PySequence_Check(ro) && PyObject_Length(ro) == 3) { |
2db4b82e RD |
542 | PyObject* o1 = PySequence_GetItem(ro, 0); |
543 | PyObject* o2 = PySequence_GetItem(ro, 1); | |
36cb9ebe RD |
544 | PyObject* o3 = PySequence_GetItem(ro, 2); |
545 | if (!wxRect_helper(o1, &out_tab_rect)) | |
2db4b82e | 546 | PyErr_SetString(PyExc_TypeError, errmsg); |
36cb9ebe RD |
547 | else if (!wxRect_helper(o2, &out_button_rect)) |
548 | PyErr_SetString(PyExc_TypeError, errmsg); | |
549 | else if (!PyInt_Check(o3)) | |
2db4b82e RD |
550 | PyErr_SetString(PyExc_TypeError, errmsg); |
551 | else | |
36cb9ebe | 552 | *x_extent = PyInt_AsLong(o3); |
2db4b82e RD |
553 | |
554 | Py_DECREF(o1); | |
555 | Py_DECREF(o2); | |
36cb9ebe | 556 | Py_DECREF(o3); |
2db4b82e RD |
557 | } |
558 | else { | |
559 | PyErr_SetString(PyExc_TypeError, errmsg); | |
560 | } | |
561 | Py_DECREF(ro); | |
562 | } | |
563 | ||
564 | Py_DECREF(odc); | |
54af9b8b | 565 | Py_DECREF(ownd); |
2db4b82e RD |
566 | Py_DECREF(orect); |
567 | Py_DECREF(otext); | |
568 | } | |
569 | wxPyEndBlockThreads(blocked); | |
570 | if (!found) | |
54af9b8b | 571 | wxAuiDefaultTabArt::DrawTab(dc, wnd, in_rect, caption, active, close_button_state, out_tab_rect, out_button_rect, x_extent); |
2db4b82e RD |
572 | } |
573 | ||
574 | ||
8f514ab4 | 575 | virtual void DrawButton( wxDC* dc, |
54af9b8b | 576 | wxWindow* wnd, |
8f514ab4 RD |
577 | const wxRect& in_rect, |
578 | int bitmap_id, | |
579 | int button_state, | |
580 | int orientation, | |
581 | const wxBitmap& bitmap_override, | |
582 | wxRect* out_rect) | |
583 | { | |
584 | bool found; | |
585 | const char* errmsg = "DrawButton should return a wxRect"; | |
586 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
587 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawButton"))) { | |
588 | PyObject* odc = wxPyMake_wxObject(dc, false); | |
54af9b8b | 589 | PyObject* ownd = wxPyMake_wxObject(wnd, false); |
8f514ab4 RD |
590 | PyObject* orect = wxPyConstructObject((void*)&in_rect, wxT("wxRect"), 0); |
591 | PyObject* obmp = wxPyConstructObject((void*)&bitmap_override, wxT("wxBitmap"), 0); | |
592 | PyObject* ro; | |
54af9b8b | 593 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOOiiiO)", odc, ownd, orect, |
8f514ab4 RD |
594 | bitmap_id, button_state, orientation, |
595 | obmp)); | |
596 | if (ro) { | |
597 | if (!wxRect_helper(ro, &out_rect)) | |
598 | PyErr_SetString(PyExc_TypeError, errmsg); | |
599 | Py_DECREF(ro); | |
600 | } | |
601 | ||
602 | Py_DECREF(odc); | |
54af9b8b | 603 | Py_DECREF(ownd); |
8f514ab4 RD |
604 | Py_DECREF(orect); |
605 | Py_DECREF(obmp); | |
606 | } | |
607 | wxPyEndBlockThreads(blocked); | |
608 | if (!found) | |
54af9b8b | 609 | wxAuiDefaultTabArt::DrawButton(dc, wnd, in_rect, bitmap_id, button_state, orientation, bitmap_override, out_rect); |
8f514ab4 RD |
610 | } |
611 | ||
54af9b8b RD |
612 | |
613 | // TODO | |
614 | // virtual int ShowWindowList( | |
615 | // wxWindow* wnd, | |
616 | // const wxArrayString& items, | |
617 | // int active_idx); | |
8f514ab4 RD |
618 | |
619 | virtual wxSize GetTabSize( wxDC* dc, | |
54af9b8b | 620 | wxWindow* wnd, |
8f514ab4 RD |
621 | const wxString& caption, |
622 | bool active, | |
36cb9ebe | 623 | int close_button_state, |
8f514ab4 RD |
624 | int* x_extent) |
625 | { | |
626 | bool found; | |
627 | wxSize rv, *prv = &rv; | |
628 | const char* errmsg = "GetTabSize should return a sequence containing (size, x_extent)"; | |
629 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
630 | if ((found = wxPyCBH_findCallback(m_myInst, "GetTabSize"))) { | |
631 | PyObject* odc = wxPyMake_wxObject(dc, false); | |
54af9b8b | 632 | PyObject* ownd = wxPyMake_wxObject(wnd, false); |
8f514ab4 RD |
633 | PyObject* otext = wx2PyString(caption); |
634 | PyObject* ro; | |
2a783b2d | 635 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue( |
54af9b8b | 636 | "(OOOi)", odc, ownd, otext, (int)active, close_button_state)); |
8f514ab4 RD |
637 | if (ro) { |
638 | if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { | |
639 | PyObject* o1 = PySequence_GetItem(ro, 0); | |
640 | PyObject* o2 = PySequence_GetItem(ro, 1); | |
641 | if (!wxSize_helper(o1, &prv)) | |
642 | PyErr_SetString(PyExc_TypeError, errmsg); | |
643 | else if (!PyInt_Check(o2)) | |
644 | PyErr_SetString(PyExc_TypeError, errmsg); | |
645 | else | |
646 | *x_extent = PyInt_AsLong(o2); | |
647 | ||
648 | Py_DECREF(o1); | |
649 | Py_DECREF(o2); | |
650 | } | |
651 | else { | |
652 | PyErr_SetString(PyExc_TypeError, errmsg); | |
653 | } | |
654 | Py_DECREF(ro); | |
655 | } | |
656 | ||
657 | Py_DECREF(odc); | |
54af9b8b | 658 | Py_DECREF(ownd); |
8f514ab4 RD |
659 | Py_DECREF(otext); |
660 | } | |
661 | wxPyEndBlockThreads(blocked); | |
662 | if (!found) | |
54af9b8b | 663 | rv = wxAuiDefaultTabArt::GetTabSize(dc, wnd, caption, active, close_button_state, x_extent); |
8f514ab4 RD |
664 | return rv; |
665 | } | |
54af9b8b RD |
666 | |
667 | // TODO | |
668 | // virtual int GetBestTabCtrlSize(wxWindow* wnd); | |
669 | ||
8f514ab4 | 670 | |
2db4b82e RD |
671 | DEC_PYCALLBACK__FONT(SetNormalFont); |
672 | DEC_PYCALLBACK__FONT(SetSelectedFont); | |
673 | DEC_PYCALLBACK__FONT(SetMeasuringFont); | |
8f514ab4 | 674 | DEC_PYCALLBACK_INT_WIN(GetBestTabCtrlSize); |
2db4b82e RD |
675 | |
676 | PYPRIVATE; | |
677 | }; | |
678 | ||
679 | ||
2a783b2d RD |
680 | IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetNormalFont); |
681 | IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetSelectedFont); | |
682 | IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetMeasuringFont); | |
683 | IMP_PYCALLBACK_INT_WIN(wxPyAuiTabArt, wxAuiDefaultTabArt, GetBestTabCtrlSize); | |
2db4b82e RD |
684 | %} |
685 | ||
686 | ||
2a783b2d | 687 | DocStr(wxPyAuiTabArt, |
2db4b82e RD |
688 | "This version of the `TabArt` class has been instrumented to be |
689 | subclassable in Python and to reflect all calls to the C++ base class | |
690 | methods to the Python methods implemented in the derived class.", ""); | |
691 | ||
2a783b2d | 692 | class wxPyAuiTabArt : public wxAuiDefaultTabArt |
2db4b82e | 693 | { |
2a783b2d RD |
694 | %pythonAppend wxPyAuiTabArt "self._setCallbackInfo(self, PyAuiTabArt)" |
695 | wxPyAuiTabArt(); | |
2db4b82e RD |
696 | |
697 | }; | |
698 | ||
699 | ||
777e547f | 700 | //--------------------------------------------------------------------------- |
febb39df RD |
701 | |
702 | #undef wxUSE_AUI | |
703 | #undef WXDLLIMPEXP_AUI | |
704 | ||
705 | //--------------------------------------------------------------------------- | |
706 |