]>
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 | |
febb39df RD |
182 | //--------------------------------------------------------------------------- |
183 | // Get all our defs from the REAL header files. | |
184 | %include framemanager.h | |
185 | %include dockart.h | |
186 | %include floatpane.h | |
1c976bff | 187 | %include auibook.h |
febb39df RD |
188 | |
189 | //--------------------------------------------------------------------------- | |
190 | // Methods to inject into the FrameManager class that will sort out calls to | |
191 | // the overloaded versions of GetPane and AddPane | |
192 | ||
2a783b2d | 193 | %extend wxAuiManager { |
d7a7616b | 194 | %pythoncode { |
febb39df RD |
195 | def GetPane(self, item): |
196 | """ | |
197 | GetPane(self, window_or_info item) -> PaneInfo | |
198 | ||
199 | GetPane is used to search for a `PaneInfo` object either by | |
200 | widget reference or by pane name, which acts as a unique id | |
201 | for a window pane. The returned `PaneInfo` object may then be | |
202 | modified to change a pane's look, state or position. After one | |
203 | or more modifications to the `PaneInfo`, `FrameManager.Update` | |
204 | should be called to realize the changes to the user interface. | |
205 | ||
206 | If the lookup failed (meaning the pane could not be found in | |
207 | the manager) GetPane returns an empty `PaneInfo`, a condition | |
208 | which can be checked by calling `PaneInfo.IsOk`. | |
209 | """ | |
210 | if isinstance(item, wx.Window): | |
211 | return self._GetPaneByWidget(item) | |
212 | else: | |
213 | return self._GetPaneByName(item) | |
214 | ||
215 | def AddPane(self, window, info=None, caption=None): | |
216 | """ | |
217 | AddPane(self, window, info=None, caption=None) -> bool | |
218 | ||
219 | AddPane tells the frame manager to start managing a child | |
220 | window. There are two versions of this function. The first | |
221 | verison accepts a `PaneInfo` object for the ``info`` parameter | |
222 | and allows the full spectrum of pane parameter | |
223 | possibilities. (Say that 3 times fast!) | |
224 | ||
225 | The second version is used for simpler user interfaces which | |
226 | do not require as much configuration. In this case the | |
227 | ``info`` parameter specifies the direction property of the | |
228 | pane info, and defaults to ``wx.LEFT``. The pane caption may | |
229 | also be specified as an extra parameter in this form. | |
230 | """ | |
2a783b2d | 231 | if type(info) == AuiPaneInfo: |
4c16bedf | 232 | return self._AddPane1(window, info) |
febb39df RD |
233 | else: |
234 | # This Is AddPane2 | |
4c16bedf RD |
235 | if info is None: |
236 | info = wx.LEFT | |
237 | if caption is None: | |
238 | caption = "" | |
239 | return self._AddPane2(window, info, caption) | |
d7a7616b RD |
240 | } |
241 | ||
242 | // For backwards compatibility | |
243 | %pythoncode { | |
244 | SetFrame = wx._deprecated(SetManagedWindow, | |
245 | "SetFrame is deprecated, use `SetManagedWindow` instead.") | |
246 | GetFrame = wx._deprecated(GetManagedWindow, | |
247 | "GetFrame is deprecated, use `GetManagedWindow` instead.") | |
248 | } | |
febb39df RD |
249 | } |
250 | ||
2a783b2d RD |
251 | %extend wxAuiDockInfo { |
252 | ~wxAuiDockInfo() {} | |
050441c8 RD |
253 | } |
254 | ||
2a783b2d RD |
255 | %extend wxAuiDockUIPart { |
256 | ~wxAuiDockUIPart() {} | |
050441c8 RD |
257 | } |
258 | ||
2a783b2d RD |
259 | %extend wxAuiPaneButton { |
260 | ~wxAuiPaneButton() {} | |
050441c8 RD |
261 | } |
262 | ||
febb39df RD |
263 | //--------------------------------------------------------------------------- |
264 | ||
265 | %{ | |
2db4b82e | 266 | // A wxDocArt class that knows how to forward virtuals to Python methods |
2a783b2d | 267 | class wxPyAuiDockArt : public wxAuiDefaultDockArt |
febb39df | 268 | { |
2a783b2d | 269 | wxPyAuiDockArt() : wxAuiDefaultDockArt() {} |
febb39df RD |
270 | |
271 | DEC_PYCALLBACK_INT_INT(GetMetric); | |
272 | DEC_PYCALLBACK_VOID_INTINT(SetMetric); | |
273 | DEC_PYCALLBACK__INTFONT(SetFont); | |
274 | DEC_PYCALLBACK_FONT_INT(GetFont); | |
275 | DEC_PYCALLBACK_COLOUR_INT(GetColour); | |
276 | DEC_PYCALLBACK__INTCOLOUR(SetColour); | |
277 | ||
278 | virtual void DrawSash(wxDC& dc, | |
e81b607b | 279 | wxWindow* window, |
febb39df RD |
280 | int orientation, |
281 | const wxRect& rect) | |
282 | { | |
283 | bool found; | |
284 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
285 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawSash"))) { | |
286 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 287 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 288 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
e81b607b RD |
289 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)", |
290 | odc, owin, orientation, orect)); | |
febb39df | 291 | Py_DECREF(odc); |
8f514ab4 | 292 | Py_DECREF(owin); |
febb39df RD |
293 | Py_DECREF(orect); |
294 | } | |
295 | wxPyEndBlockThreads(blocked); | |
296 | if (! found) | |
2a783b2d | 297 | wxAuiDefaultDockArt::DrawSash(dc, window, orientation, rect); |
febb39df RD |
298 | } |
299 | ||
300 | virtual void DrawBackground(wxDC& dc, | |
e81b607b | 301 | wxWindow* window, |
febb39df RD |
302 | int orientation, |
303 | const wxRect& rect) | |
304 | { | |
305 | bool found; | |
306 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
307 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) { | |
308 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 309 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 310 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
e81b607b RD |
311 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)", |
312 | odc, owin, orientation, orect)); | |
febb39df | 313 | Py_DECREF(odc); |
8f514ab4 | 314 | Py_DECREF(owin); |
febb39df RD |
315 | Py_DECREF(orect); |
316 | } | |
317 | wxPyEndBlockThreads(blocked); | |
318 | if (! found) | |
2a783b2d | 319 | wxAuiDefaultDockArt::DrawBackground(dc, window, orientation, rect); |
febb39df RD |
320 | } |
321 | ||
322 | virtual void DrawCaption(wxDC& dc, | |
e81b607b | 323 | wxWindow* window, |
febb39df RD |
324 | const wxString& text, |
325 | const wxRect& rect, | |
2a783b2d | 326 | wxAuiPaneInfo& pane) |
febb39df RD |
327 | { |
328 | bool found; | |
329 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
330 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawCaption"))) { | |
331 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 332 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df RD |
333 | PyObject* otext = wx2PyString(text); |
334 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); | |
2a783b2d | 335 | PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0); |
e81b607b RD |
336 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOO)", |
337 | odc, owin, otext, orect, opane)); | |
febb39df | 338 | Py_DECREF(odc); |
8f514ab4 | 339 | Py_DECREF(owin); |
febb39df RD |
340 | Py_DECREF(otext); |
341 | Py_DECREF(orect); | |
342 | Py_DECREF(opane); | |
343 | } | |
344 | wxPyEndBlockThreads(blocked); | |
345 | if (! found) | |
2a783b2d | 346 | wxAuiDefaultDockArt::DrawCaption(dc, window, text, rect, pane); |
febb39df RD |
347 | } |
348 | ||
349 | virtual void DrawGripper(wxDC& dc, | |
e81b607b | 350 | wxWindow* window, |
febb39df | 351 | const wxRect& rect, |
2a783b2d | 352 | wxAuiPaneInfo& pane) |
febb39df RD |
353 | { |
354 | bool found; | |
355 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
356 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawGripper"))) { | |
357 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 358 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 359 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
2a783b2d | 360 | PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0); |
e81b607b | 361 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOO)", odc, owin, orect, opane)); |
febb39df RD |
362 | Py_DECREF(odc); |
363 | Py_DECREF(orect); | |
364 | Py_DECREF(opane); | |
365 | } | |
366 | wxPyEndBlockThreads(blocked); | |
367 | if (! found) | |
2a783b2d | 368 | wxAuiDefaultDockArt::DrawGripper(dc, window, rect, pane); |
febb39df RD |
369 | } |
370 | ||
371 | virtual void DrawBorder(wxDC& dc, | |
e81b607b | 372 | wxWindow* window, |
febb39df | 373 | const wxRect& rect, |
2a783b2d | 374 | wxAuiPaneInfo& pane) |
febb39df RD |
375 | { |
376 | bool found; | |
377 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
378 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawBorder"))) { | |
379 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 380 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 381 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
2a783b2d | 382 | PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0); |
febb39df RD |
383 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, orect, opane)); |
384 | Py_DECREF(odc); | |
8f514ab4 | 385 | Py_DECREF(owin); |
febb39df RD |
386 | Py_DECREF(orect); |
387 | Py_DECREF(opane); | |
388 | } | |
389 | wxPyEndBlockThreads(blocked); | |
390 | if (! found) | |
2a783b2d | 391 | wxAuiDefaultDockArt::DrawBorder(dc, window, rect, pane); |
febb39df RD |
392 | } |
393 | ||
394 | virtual void DrawPaneButton(wxDC& dc, | |
e81b607b | 395 | wxWindow* window, |
febb39df RD |
396 | int button, |
397 | int button_state, | |
398 | const wxRect& rect, | |
2a783b2d | 399 | wxAuiPaneInfo& pane) |
febb39df RD |
400 | { |
401 | bool found; | |
402 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
403 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawPaneButton"))) { | |
404 | PyObject* odc = wxPyMake_wxObject(&dc, false); | |
e81b607b | 405 | PyObject* owin = wxPyMake_wxObject(window, false); |
febb39df | 406 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); |
2a783b2d | 407 | PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0); |
e81b607b RD |
408 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiIOO)", |
409 | odc, owin, button, button_state, | |
febb39df RD |
410 | orect, opane)); |
411 | Py_DECREF(odc); | |
8f514ab4 | 412 | Py_DECREF(owin); |
febb39df RD |
413 | Py_DECREF(orect); |
414 | Py_DECREF(opane); | |
415 | } | |
416 | wxPyEndBlockThreads(blocked); | |
417 | if (! found) | |
2a783b2d | 418 | wxAuiDefaultDockArt::DrawPaneButton(dc, window, button, button_state, rect, pane); |
febb39df RD |
419 | } |
420 | ||
421 | PYPRIVATE; | |
422 | ||
423 | }; | |
424 | ||
2a783b2d RD |
425 | IMP_PYCALLBACK_INT_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetMetric); |
426 | IMP_PYCALLBACK_VOID_INTINT(wxPyAuiDockArt, wxAuiDefaultDockArt, SetMetric); | |
427 | IMP_PYCALLBACK__INTFONT(wxPyAuiDockArt, wxAuiDefaultDockArt, SetFont); | |
428 | IMP_PYCALLBACK_FONT_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetFont); | |
429 | IMP_PYCALLBACK_COLOUR_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetColour); | |
430 | IMP_PYCALLBACK__INTCOLOUR(wxPyAuiDockArt, wxAuiDefaultDockArt, SetColour); | |
febb39df RD |
431 | |
432 | %} | |
433 | ||
434 | ||
2a783b2d RD |
435 | DocStr(wxPyAuiDockArt, |
436 | "This version of the `AuiDockArt` class has been instrumented to be | |
febb39df RD |
437 | subclassable in Python and to reflect all calls to the C++ base class |
438 | methods to the Python methods implemented in the derived class.", ""); | |
439 | ||
2a783b2d | 440 | class wxPyAuiDockArt : public wxAuiDefaultDockArt |
febb39df | 441 | { |
2a783b2d RD |
442 | %pythonAppend wxPyAuiDockArt "self._setCallbackInfo(self, PyAuiDockArt)" |
443 | wxPyAuiDocArt(); | |
febb39df RD |
444 | |
445 | }; | |
446 | ||
447 | ||
777e547f RD |
448 | //--------------------------------------------------------------------------- |
449 | ||
2a783b2d | 450 | %extend wxAuiNotebook { |
777e547f RD |
451 | %property(PageCount, GetPageCount, doc="See `GetPageCount`"); |
452 | %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`"); | |
453 | } | |
454 | ||
455 | ||
456 | %extend wxAuiNotebookEvent { | |
457 | %property(OldSelection, GetOldSelection, SetOldSelection, doc="See `GetOldSelection` and `SetOldSelection`"); | |
458 | %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`"); | |
459 | } | |
460 | ||
461 | ||
462 | %extend wxAuiTabContainer { | |
463 | %property(ActivePage, GetActivePage, SetActivePage, doc="See `GetActivePage` and `SetActivePage`"); | |
464 | %property(PageCount, GetPageCount, doc="See `GetPageCount`"); | |
465 | %property(Pages, GetPages, doc="See `GetPages`"); | |
466 | } | |
467 | ||
468 | ||
2a783b2d | 469 | %extend wxAuiManager { |
777e547f RD |
470 | %property(AllPanes, GetAllPanes, doc="See `GetAllPanes`"); |
471 | %property(ArtProvider, GetArtProvider, SetArtProvider, doc="See `GetArtProvider` and `SetArtProvider`"); | |
472 | %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`"); | |
473 | %property(ManagedWindow, GetManagedWindow, SetManagedWindow, doc="See `GetManagedWindow` and `SetManagedWindow`"); | |
474 | } | |
475 | ||
476 | ||
2a783b2d | 477 | %extend wxAuiManagerEvent { |
777e547f RD |
478 | %property(Button, GetButton, SetButton, doc="See `GetButton` and `SetButton`"); |
479 | %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`"); | |
480 | %property(Pane, GetPane, SetPane, doc="See `GetPane` and `SetPane`"); | |
481 | } | |
482 | ||
483 | ||
2db4b82e RD |
484 | //--------------------------------------------------------------------------- |
485 | ||
486 | %{ | |
487 | // A wxTabArt class that knows how to forward virtuals to Python methods | |
2a783b2d | 488 | class wxPyAuiTabArt : public wxAuiDefaultTabArt |
2db4b82e | 489 | { |
2a783b2d | 490 | wxPyAuiTabArt() : wxAuiDefaultTabArt() {} |
2db4b82e | 491 | |
8f514ab4 | 492 | |
2db4b82e RD |
493 | virtual void DrawBackground( wxDC* dc, |
494 | const wxRect& rect ) | |
495 | { | |
496 | bool found; | |
497 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
498 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) { | |
499 | PyObject* odc = wxPyMake_wxObject(dc, false); | |
500 | PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0); | |
501 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", odc, orect)); | |
502 | Py_DECREF(odc); | |
503 | Py_DECREF(orect); | |
504 | } | |
505 | wxPyEndBlockThreads(blocked); | |
506 | if (!found) | |
2a783b2d | 507 | wxAuiDefaultTabArt::DrawBackground(dc, rect); |
2db4b82e RD |
508 | } |
509 | ||
510 | virtual void DrawTab( wxDC* dc, | |
511 | const wxRect& in_rect, | |
512 | const wxString& caption, | |
513 | bool active, | |
2a783b2d | 514 | bool with_close_button, |
2db4b82e RD |
515 | wxRect* out_rect, |
516 | int* x_extent) | |
517 | { | |
518 | bool found; | |
519 | const char* errmsg = "DrawTab should return a sequence containing (out_rect, x_extent)"; | |
520 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
521 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawTab"))) { | |
522 | PyObject* odc = wxPyMake_wxObject(dc, false); | |
523 | PyObject* orect = wxPyConstructObject((void*)&in_rect, wxT("wxRect"), 0); | |
524 | PyObject* otext = wx2PyString(caption); | |
525 | PyObject* ro; | |
2a783b2d RD |
526 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue( |
527 | "(OOOii)", | |
528 | odc, orect, otext, | |
529 | (int)active, (int)with_close_button)); | |
2db4b82e RD |
530 | if (ro) { |
531 | if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { | |
532 | PyObject* o1 = PySequence_GetItem(ro, 0); | |
533 | PyObject* o2 = PySequence_GetItem(ro, 1); | |
534 | if (!wxRect_helper(o1, &out_rect)) | |
535 | PyErr_SetString(PyExc_TypeError, errmsg); | |
536 | else if (!PyInt_Check(o2)) | |
537 | PyErr_SetString(PyExc_TypeError, errmsg); | |
538 | else | |
539 | *x_extent = PyInt_AsLong(o2); | |
540 | ||
541 | Py_DECREF(o1); | |
542 | Py_DECREF(o2); | |
543 | } | |
544 | else { | |
545 | PyErr_SetString(PyExc_TypeError, errmsg); | |
546 | } | |
547 | Py_DECREF(ro); | |
548 | } | |
549 | ||
550 | Py_DECREF(odc); | |
551 | Py_DECREF(orect); | |
552 | Py_DECREF(otext); | |
553 | } | |
554 | wxPyEndBlockThreads(blocked); | |
555 | if (!found) | |
2a783b2d | 556 | wxAuiDefaultTabArt::DrawTab(dc, in_rect, caption, active, with_close_button, out_rect, x_extent); |
2db4b82e RD |
557 | } |
558 | ||
559 | ||
8f514ab4 RD |
560 | virtual void DrawButton( wxDC* dc, |
561 | const wxRect& in_rect, | |
562 | int bitmap_id, | |
563 | int button_state, | |
564 | int orientation, | |
565 | const wxBitmap& bitmap_override, | |
566 | wxRect* out_rect) | |
567 | { | |
568 | bool found; | |
569 | const char* errmsg = "DrawButton should return a wxRect"; | |
570 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
571 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawButton"))) { | |
572 | PyObject* odc = wxPyMake_wxObject(dc, false); | |
573 | PyObject* orect = wxPyConstructObject((void*)&in_rect, wxT("wxRect"), 0); | |
574 | PyObject* obmp = wxPyConstructObject((void*)&bitmap_override, wxT("wxBitmap"), 0); | |
575 | PyObject* ro; | |
576 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOiiiO)", odc, orect, | |
577 | bitmap_id, button_state, orientation, | |
578 | obmp)); | |
579 | if (ro) { | |
580 | if (!wxRect_helper(ro, &out_rect)) | |
581 | PyErr_SetString(PyExc_TypeError, errmsg); | |
582 | Py_DECREF(ro); | |
583 | } | |
584 | ||
585 | Py_DECREF(odc); | |
586 | Py_DECREF(orect); | |
587 | Py_DECREF(obmp); | |
588 | } | |
589 | wxPyEndBlockThreads(blocked); | |
590 | if (!found) | |
2a783b2d | 591 | wxAuiDefaultTabArt::DrawButton(dc, in_rect, bitmap_id, button_state, orientation, bitmap_override, out_rect); |
8f514ab4 RD |
592 | } |
593 | ||
594 | ||
595 | virtual wxSize GetTabSize( wxDC* dc, | |
596 | const wxString& caption, | |
597 | bool active, | |
2a783b2d | 598 | bool with_close_button, |
8f514ab4 RD |
599 | int* x_extent) |
600 | { | |
601 | bool found; | |
602 | wxSize rv, *prv = &rv; | |
603 | const char* errmsg = "GetTabSize should return a sequence containing (size, x_extent)"; | |
604 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
605 | if ((found = wxPyCBH_findCallback(m_myInst, "GetTabSize"))) { | |
606 | PyObject* odc = wxPyMake_wxObject(dc, false); | |
607 | PyObject* otext = wx2PyString(caption); | |
608 | PyObject* ro; | |
2a783b2d RD |
609 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue( |
610 | "(OOi)", odc, otext, (int)active, (int)with_close_button)); | |
8f514ab4 RD |
611 | if (ro) { |
612 | if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { | |
613 | PyObject* o1 = PySequence_GetItem(ro, 0); | |
614 | PyObject* o2 = PySequence_GetItem(ro, 1); | |
615 | if (!wxSize_helper(o1, &prv)) | |
616 | PyErr_SetString(PyExc_TypeError, errmsg); | |
617 | else if (!PyInt_Check(o2)) | |
618 | PyErr_SetString(PyExc_TypeError, errmsg); | |
619 | else | |
620 | *x_extent = PyInt_AsLong(o2); | |
621 | ||
622 | Py_DECREF(o1); | |
623 | Py_DECREF(o2); | |
624 | } | |
625 | else { | |
626 | PyErr_SetString(PyExc_TypeError, errmsg); | |
627 | } | |
628 | Py_DECREF(ro); | |
629 | } | |
630 | ||
631 | Py_DECREF(odc); | |
632 | Py_DECREF(otext); | |
633 | } | |
634 | wxPyEndBlockThreads(blocked); | |
635 | if (!found) | |
2a783b2d | 636 | rv = wxAuiDefaultTabArt::GetTabSize(dc, caption, active, with_close_button, x_extent); |
8f514ab4 RD |
637 | return rv; |
638 | } | |
639 | ||
640 | ||
641 | ||
2db4b82e RD |
642 | DEC_PYCALLBACK__FONT(SetNormalFont); |
643 | DEC_PYCALLBACK__FONT(SetSelectedFont); | |
644 | DEC_PYCALLBACK__FONT(SetMeasuringFont); | |
8f514ab4 | 645 | DEC_PYCALLBACK_INT_WIN(GetBestTabCtrlSize); |
2db4b82e RD |
646 | |
647 | PYPRIVATE; | |
648 | }; | |
649 | ||
650 | ||
2a783b2d RD |
651 | IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetNormalFont); |
652 | IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetSelectedFont); | |
653 | IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetMeasuringFont); | |
654 | IMP_PYCALLBACK_INT_WIN(wxPyAuiTabArt, wxAuiDefaultTabArt, GetBestTabCtrlSize); | |
2db4b82e RD |
655 | %} |
656 | ||
657 | ||
2a783b2d | 658 | DocStr(wxPyAuiTabArt, |
2db4b82e RD |
659 | "This version of the `TabArt` class has been instrumented to be |
660 | subclassable in Python and to reflect all calls to the C++ base class | |
661 | methods to the Python methods implemented in the derived class.", ""); | |
662 | ||
2a783b2d | 663 | class wxPyAuiTabArt : public wxAuiDefaultTabArt |
2db4b82e | 664 | { |
2a783b2d RD |
665 | %pythonAppend wxPyAuiTabArt "self._setCallbackInfo(self, PyAuiTabArt)" |
666 | wxPyAuiTabArt(); | |
2db4b82e RD |
667 | |
668 | }; | |
669 | ||
670 | ||
777e547f | 671 | //--------------------------------------------------------------------------- |
febb39df RD |
672 | |
673 | #undef wxUSE_AUI | |
674 | #undef WXDLLIMPEXP_AUI | |
675 | ||
676 | //--------------------------------------------------------------------------- | |
677 |