]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/aui.i
c52977fd1f69d60cbb1b3aebcc846898846d2baf
[wxWidgets.git] / wxPython / src / aui.i
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
47 **wx.aui adheres to the following principles**
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
72 self._mgr = wx.aui.AuiManager(self)
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 // Preprocessor stuff so SWIG doesn't get confused when %include-ing
136 // the aui .h files.
137 #define wxUSE_AUI 1
138 #define wxUSE_MENUS 1
139 #define WXDLLIMPEXP_AUI
140 #define unsigned
141 #define wxDEPRECATED(decl)
142 #define DECLARE_EVENT_TABLE()
143 #define DECLARE_DYNAMIC_CLASS(foo)
144
145
146
147 // We'll skip making wrappers for these, they have overloads that take a
148 // wxSize or wxPoint
149 %ignore wxAuiPaneInfo::MaxSize(int x, int y);
150 %ignore wxAuiPaneInfo::MinSize(int x, int y);
151 %ignore wxAuiPaneInfo::BestSize(int x, int y);
152 %ignore wxAuiPaneInfo::FloatingPosition(int x, int y);
153 %ignore wxAuiPaneInfo::FloatingSize(int x, int y);
154
155 // But for these we will do the overloading (see %pythoncode below) so let's
156 // rename the C++ versions
157 %rename(_GetPaneByWidget) wxAuiManager::GetPane(wxWindow* window);
158 %rename(_GetPaneByName) wxAuiManager::GetPane(const wxString& name);
159
160 %rename(_AddPane1) wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info);
161 %rename(_AddPane2) wxAuiManager::AddPane(wxWindow* window, int direction = wxLEFT,
162 const wxString& caption = wxEmptyString);
163
164 %rename(AddPaneAtPos) wxAuiManager::AddPane(wxWindow* window,
165 const wxPaneInfo& pane_info,
166 const wxPoint& drop_pos);
167
168 // A typemap for the return value of wxFrameManager::GetAllPanes
169 %typemap(out) wxAuiPaneInfoArray& {
170 $result = PyList_New(0);
171 for (size_t i=0; i < $1->GetCount(); i++) {
172 PyObject* pane_obj = SWIG_NewPointerObj((void*)(&$1->Item(i)), SWIGTYPE_p_wxAuiPaneInfo, 0);
173 PyList_Append($result, pane_obj);
174 }
175 }
176
177
178 %nokwargs wxAuiTabContainer::SetActivePage;
179
180 %pythonAppend wxAuiTabCtrl::wxAuiTabCtrl "self._setOORInfo(self)";
181
182 %pythonAppend wxAuiNotebook::wxAuiNotebook "self._setOORInfo(self)";
183 %pythonAppend wxAuiNotebook::wxAuiNotebook() "val._setOORInfo(val)";
184 %ignore wxAuiiNotebook::~wxAuiNotebook;
185 %rename(PreAuiNotebook) wxAuiNotebook::wxAuiNotebook();
186
187 // Link error...
188 %ignore wxAuiDefaultTabArt::SetWindow;
189
190 // ignore this overload
191 %ignore wxAuiTabContainer::GetPage(size_t idx) const;
192
193
194
195 %pythonAppend wxAuiMDIParentFrame::wxAuiMDIParentFrame "self._setOORInfo(self)";
196 %pythonAppend wxAuiMDIParentFrame::wxAuiMDIParentFrame() "val._setOORInfo(val)";
197 %ignore wxAuiMDIParentFrame::~wxAuiMDIParentFrame;
198 %rename(PreAuiMDIParentFrame) wxAuiMDIParentFrame::wxAuiMDIParentFrame();
199
200 %pythonAppend wxAuiMDIChildFrame::wxAuiMDIChildFrame "self._setOORInfo(self)";
201 %pythonAppend wxAuiMDIChildFrame::wxAuiMDIChildFrame() "val._setOORInfo(val)";
202 %ignore wxAuiMDIChildFrame::~wxAuiMDIChildFrame;
203 %rename(PreAuiMDIChildFrame) wxAuiMDIChildFrame::wxAuiMDIChildFrame();
204
205 %pythonAppend wxAuiMDIClientWindow::wxAuiMDIClientWindow "self._setOORInfo(self)";
206 %pythonAppend wxAuiMDIClientWindow::wxAuiMDIClientWindow() "val._setOORInfo(val)";
207 %ignore wxAuiMDIClientWindow::~wxAuiMDIClientWindow;
208 %rename(PreAuiMDIClientWindow) wxAuiMDIClientWindow::wxAuiMDIClientWindow();
209
210
211 //---------------------------------------------------------------------------
212 // Get all our defs from the REAL header files.
213
214 #define wxColor wxColour // fix problem in dockart.h
215
216 %include framemanager.h
217 %include dockart.h
218 %include floatpane.h
219 %include auibook.h
220 %include tabmdi.h
221
222 #undef wxColor
223
224 //---------------------------------------------------------------------------
225 // Methods to inject into the FrameManager class that will sort out calls to
226 // the overloaded versions of GetPane and AddPane
227
228 %extend wxAuiManager {
229 %pythoncode {
230 def GetPane(self, item):
231 """
232 GetPane(self, window_or_info item) -> PaneInfo
233
234 GetPane is used to search for a `PaneInfo` object either by
235 widget reference or by pane name, which acts as a unique id
236 for a window pane. The returned `PaneInfo` object may then be
237 modified to change a pane's look, state or position. After one
238 or more modifications to the `PaneInfo`, `FrameManager.Update`
239 should be called to realize the changes to the user interface.
240
241 If the lookup failed (meaning the pane could not be found in
242 the manager) GetPane returns an empty `PaneInfo`, a condition
243 which can be checked by calling `PaneInfo.IsOk`.
244 """
245 if isinstance(item, wx.Window):
246 return self._GetPaneByWidget(item)
247 else:
248 return self._GetPaneByName(item)
249
250 def AddPane(self, window, info=None, caption=None):
251 """
252 AddPane(self, window, info=None, caption=None) -> bool
253
254 AddPane tells the frame manager to start managing a child
255 window. There are two versions of this function. The first
256 verison accepts a `PaneInfo` object for the ``info`` parameter
257 and allows the full spectrum of pane parameter
258 possibilities. (Say that 3 times fast!)
259
260 The second version is used for simpler user interfaces which
261 do not require as much configuration. In this case the
262 ``info`` parameter specifies the direction property of the
263 pane info, and defaults to ``wx.LEFT``. The pane caption may
264 also be specified as an extra parameter in this form.
265 """
266 if type(info) == AuiPaneInfo:
267 return self._AddPane1(window, info)
268 else:
269 # This Is AddPane2
270 if info is None:
271 info = wx.LEFT
272 if caption is None:
273 caption = ""
274 return self._AddPane2(window, info, caption)
275 }
276
277 // For backwards compatibility
278 %pythoncode {
279 SetFrame = wx._deprecated(SetManagedWindow,
280 "SetFrame is deprecated, use `SetManagedWindow` instead.")
281 GetFrame = wx._deprecated(GetManagedWindow,
282 "GetFrame is deprecated, use `GetManagedWindow` instead.")
283 }
284 }
285
286 %extend wxAuiDockInfo {
287 ~wxAuiDockInfo() {}
288 }
289
290 %extend wxAuiDockUIPart {
291 ~wxAuiDockUIPart() {}
292 }
293
294 %extend wxAuiPaneButton {
295 ~wxAuiPaneButton() {}
296 }
297
298 //---------------------------------------------------------------------------
299
300 %{
301 // A wxDocArt class that knows how to forward virtuals to Python methods
302 class wxPyAuiDockArt : public wxAuiDefaultDockArt
303 {
304 wxPyAuiDockArt() : wxAuiDefaultDockArt() {}
305
306 DEC_PYCALLBACK_INT_INT(GetMetric);
307 DEC_PYCALLBACK_VOID_INTINT(SetMetric);
308 DEC_PYCALLBACK__INTFONT(SetFont);
309 DEC_PYCALLBACK_FONT_INT(GetFont);
310 DEC_PYCALLBACK_COLOUR_INT(GetColour);
311 DEC_PYCALLBACK__INTCOLOUR(SetColour);
312
313 virtual void DrawSash(wxDC& dc,
314 wxWindow* window,
315 int orientation,
316 const wxRect& rect)
317 {
318 bool found;
319 wxPyBlock_t blocked = wxPyBeginBlockThreads();
320 if ((found = wxPyCBH_findCallback(m_myInst, "DrawSash"))) {
321 PyObject* odc = wxPyMake_wxObject(&dc, false);
322 PyObject* owin = wxPyMake_wxObject(window, false);
323 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
324 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)",
325 odc, owin, orientation, orect));
326 Py_DECREF(odc);
327 Py_DECREF(owin);
328 Py_DECREF(orect);
329 }
330 wxPyEndBlockThreads(blocked);
331 if (! found)
332 wxAuiDefaultDockArt::DrawSash(dc, window, orientation, rect);
333 }
334
335 virtual void DrawBackground(wxDC& dc,
336 wxWindow* window,
337 int orientation,
338 const wxRect& rect)
339 {
340 bool found;
341 wxPyBlock_t blocked = wxPyBeginBlockThreads();
342 if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) {
343 PyObject* odc = wxPyMake_wxObject(&dc, false);
344 PyObject* owin = wxPyMake_wxObject(window, false);
345 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
346 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)",
347 odc, owin, orientation, orect));
348 Py_DECREF(odc);
349 Py_DECREF(owin);
350 Py_DECREF(orect);
351 }
352 wxPyEndBlockThreads(blocked);
353 if (! found)
354 wxAuiDefaultDockArt::DrawBackground(dc, window, orientation, rect);
355 }
356
357 virtual void DrawCaption(wxDC& dc,
358 wxWindow* window,
359 const wxString& text,
360 const wxRect& rect,
361 wxAuiPaneInfo& pane)
362 {
363 bool found;
364 wxPyBlock_t blocked = wxPyBeginBlockThreads();
365 if ((found = wxPyCBH_findCallback(m_myInst, "DrawCaption"))) {
366 PyObject* odc = wxPyMake_wxObject(&dc, false);
367 PyObject* owin = wxPyMake_wxObject(window, false);
368 PyObject* otext = wx2PyString(text);
369 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
370 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0);
371 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOO)",
372 odc, owin, otext, orect, opane));
373 Py_DECREF(odc);
374 Py_DECREF(owin);
375 Py_DECREF(otext);
376 Py_DECREF(orect);
377 Py_DECREF(opane);
378 }
379 wxPyEndBlockThreads(blocked);
380 if (! found)
381 wxAuiDefaultDockArt::DrawCaption(dc, window, text, rect, pane);
382 }
383
384 virtual void DrawGripper(wxDC& dc,
385 wxWindow* window,
386 const wxRect& rect,
387 wxAuiPaneInfo& pane)
388 {
389 bool found;
390 wxPyBlock_t blocked = wxPyBeginBlockThreads();
391 if ((found = wxPyCBH_findCallback(m_myInst, "DrawGripper"))) {
392 PyObject* odc = wxPyMake_wxObject(&dc, false);
393 PyObject* owin = wxPyMake_wxObject(window, false);
394 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
395 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0);
396 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOO)", odc, owin, orect, opane));
397 Py_DECREF(odc);
398 Py_DECREF(orect);
399 Py_DECREF(opane);
400 }
401 wxPyEndBlockThreads(blocked);
402 if (! found)
403 wxAuiDefaultDockArt::DrawGripper(dc, window, rect, pane);
404 }
405
406 virtual void DrawBorder(wxDC& dc,
407 wxWindow* window,
408 const wxRect& rect,
409 wxAuiPaneInfo& pane)
410 {
411 bool found;
412 wxPyBlock_t blocked = wxPyBeginBlockThreads();
413 if ((found = wxPyCBH_findCallback(m_myInst, "DrawBorder"))) {
414 PyObject* odc = wxPyMake_wxObject(&dc, false);
415 PyObject* owin = wxPyMake_wxObject(window, false);
416 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
417 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0);
418 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, orect, opane));
419 Py_DECREF(odc);
420 Py_DECREF(owin);
421 Py_DECREF(orect);
422 Py_DECREF(opane);
423 }
424 wxPyEndBlockThreads(blocked);
425 if (! found)
426 wxAuiDefaultDockArt::DrawBorder(dc, window, rect, pane);
427 }
428
429 virtual void DrawPaneButton(wxDC& dc,
430 wxWindow* window,
431 int button,
432 int button_state,
433 const wxRect& rect,
434 wxAuiPaneInfo& pane)
435 {
436 bool found;
437 wxPyBlock_t blocked = wxPyBeginBlockThreads();
438 if ((found = wxPyCBH_findCallback(m_myInst, "DrawPaneButton"))) {
439 PyObject* odc = wxPyMake_wxObject(&dc, false);
440 PyObject* owin = wxPyMake_wxObject(window, false);
441 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
442 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0);
443 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiIOO)",
444 odc, owin, button, button_state,
445 orect, opane));
446 Py_DECREF(odc);
447 Py_DECREF(owin);
448 Py_DECREF(orect);
449 Py_DECREF(opane);
450 }
451 wxPyEndBlockThreads(blocked);
452 if (! found)
453 wxAuiDefaultDockArt::DrawPaneButton(dc, window, button, button_state, rect, pane);
454 }
455
456 PYPRIVATE;
457
458 };
459
460 IMP_PYCALLBACK_INT_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetMetric);
461 IMP_PYCALLBACK_VOID_INTINT(wxPyAuiDockArt, wxAuiDefaultDockArt, SetMetric);
462 IMP_PYCALLBACK__INTFONT(wxPyAuiDockArt, wxAuiDefaultDockArt, SetFont);
463 IMP_PYCALLBACK_FONT_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetFont);
464 IMP_PYCALLBACK_COLOUR_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetColour);
465 IMP_PYCALLBACK__INTCOLOUR(wxPyAuiDockArt, wxAuiDefaultDockArt, SetColour);
466
467 %}
468
469
470 DocStr(wxPyAuiDockArt,
471 "This version of the `AuiDockArt` class has been instrumented to be
472 subclassable in Python and to reflect all calls to the C++ base class
473 methods to the Python methods implemented in the derived class.", "");
474
475 class wxPyAuiDockArt : public wxAuiDefaultDockArt
476 {
477 %pythonAppend wxPyAuiDockArt setCallbackInfo(PyAuiDockArt)
478 wxPyAuiDocArt();
479
480 };
481
482
483 //---------------------------------------------------------------------------
484
485 %extend wxAuiNotebook {
486 %property(PageCount, GetPageCount, doc="See `GetPageCount`");
487 %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
488 }
489
490
491 %extend wxAuiNotebookEvent {
492 %property(OldSelection, GetOldSelection, SetOldSelection, doc="See `GetOldSelection` and `SetOldSelection`");
493 %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
494 }
495
496
497 %extend wxAuiTabContainer {
498 %property(ActivePage, GetActivePage, SetActivePage, doc="See `GetActivePage` and `SetActivePage`");
499 %property(PageCount, GetPageCount, doc="See `GetPageCount`");
500 %property(Pages, GetPages, doc="See `GetPages`");
501 }
502
503
504 %extend wxAuiManager {
505 %property(AllPanes, GetAllPanes, doc="See `GetAllPanes`");
506 %property(ArtProvider, GetArtProvider, SetArtProvider, doc="See `GetArtProvider` and `SetArtProvider`");
507 %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`");
508 %property(ManagedWindow, GetManagedWindow, SetManagedWindow, doc="See `GetManagedWindow` and `SetManagedWindow`");
509 }
510
511
512 %extend wxAuiManagerEvent {
513 %property(Button, GetButton, SetButton, doc="See `GetButton` and `SetButton`");
514 %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
515 %property(Pane, GetPane, SetPane, doc="See `GetPane` and `SetPane`");
516 }
517
518
519 //---------------------------------------------------------------------------
520
521 %{
522 // A wxTabArt class that knows how to forward virtuals to Python methods
523 class wxPyAuiTabArt : public wxAuiDefaultTabArt
524 {
525 wxPyAuiTabArt() : wxAuiDefaultTabArt() {}
526
527
528 virtual void DrawBackground( wxDC& dc,
529 wxWindow* wnd,
530 const wxRect& rect )
531 {
532 bool found;
533 wxPyBlock_t blocked = wxPyBeginBlockThreads();
534 if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) {
535 PyObject* odc = wxPyMake_wxObject(&dc, false);
536 PyObject* ownd = wxPyMake_wxObject(wnd, false);
537 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
538 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, ownd, orect));
539 Py_DECREF(odc);
540 Py_DECREF(ownd);
541 Py_DECREF(orect);
542 }
543 wxPyEndBlockThreads(blocked);
544 if (!found)
545 wxAuiDefaultTabArt::DrawBackground(dc, wnd, rect);
546 }
547
548 virtual void DrawTab( wxDC& dc,
549 wxWindow* wnd,
550 const wxAuiNotebookPage& pane,
551 const wxRect& in_rect,
552 int close_button_state,
553 wxRect* out_tab_rect,
554 wxRect* out_button_rect,
555 int* x_extent)
556 {
557 bool found;
558 const char* errmsg = "DrawTab should return a sequence containing (tab_rect, button_rect, x_extent)";
559 wxPyBlock_t blocked = wxPyBeginBlockThreads();
560 if ((found = wxPyCBH_findCallback(m_myInst, "DrawTab"))) {
561 PyObject* odc = wxPyMake_wxObject(&dc, false);
562 PyObject* ownd = wxPyMake_wxObject(wnd, false);
563 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiNotebookPage"), 0);
564 PyObject* orect = wxPyConstructObject((void*)&in_rect, wxT("wxRect"), 0);
565 PyObject* ro;
566 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue(
567 "(OOOOOii)",
568 odc, ownd, orect, opane,
569 close_button_state));
570 if (ro) {
571 if (PySequence_Check(ro) && PyObject_Length(ro) == 3) {
572 PyObject* o1 = PySequence_GetItem(ro, 0);
573 PyObject* o2 = PySequence_GetItem(ro, 1);
574 PyObject* o3 = PySequence_GetItem(ro, 2);
575 if (!wxRect_helper(o1, &out_tab_rect))
576 PyErr_SetString(PyExc_TypeError, errmsg);
577 else if (!wxRect_helper(o2, &out_button_rect))
578 PyErr_SetString(PyExc_TypeError, errmsg);
579 else if (!PyInt_Check(o3))
580 PyErr_SetString(PyExc_TypeError, errmsg);
581 else
582 *x_extent = PyInt_AsLong(o3);
583
584 Py_DECREF(o1);
585 Py_DECREF(o2);
586 Py_DECREF(o3);
587 }
588 else {
589 PyErr_SetString(PyExc_TypeError, errmsg);
590 }
591 Py_DECREF(ro);
592 }
593
594 Py_DECREF(odc);
595 Py_DECREF(ownd);
596 Py_DECREF(orect);
597 Py_DECREF(opane);
598 }
599 wxPyEndBlockThreads(blocked);
600 if (!found)
601 wxAuiDefaultTabArt::DrawTab(dc, wnd, pane, in_rect, close_button_state, out_tab_rect, out_button_rect, x_extent);
602 }
603
604
605 virtual void DrawButton( wxDC& dc,
606 wxWindow* wnd,
607 const wxRect& in_rect,
608 int bitmap_id,
609 int button_state,
610 int orientation,
611 wxRect* out_rect)
612 {
613 bool found;
614 const char* errmsg = "DrawButton should return a wxRect";
615 wxPyBlock_t blocked = wxPyBeginBlockThreads();
616 if ((found = wxPyCBH_findCallback(m_myInst, "DrawButton"))) {
617 PyObject* odc = wxPyMake_wxObject(&dc, false);
618 PyObject* ownd = wxPyMake_wxObject(wnd, false);
619 PyObject* orect = wxPyConstructObject((void*)&in_rect, wxT("wxRect"), 0);
620 PyObject* ro;
621 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOOiiiO)", odc, ownd, orect,
622 bitmap_id, button_state, orientation));
623 if (ro) {
624 if (!wxRect_helper(ro, &out_rect))
625 PyErr_SetString(PyExc_TypeError, errmsg);
626 Py_DECREF(ro);
627 }
628
629 Py_DECREF(odc);
630 Py_DECREF(ownd);
631 Py_DECREF(orect);
632 }
633 wxPyEndBlockThreads(blocked);
634 if (!found)
635 wxAuiDefaultTabArt::DrawButton(dc, wnd, in_rect, bitmap_id, button_state, orientation, out_rect);
636 }
637
638
639 virtual wxSize GetTabSize( wxDC& dc,
640 wxWindow* wnd,
641 const wxString& caption,
642 const wxBitmap& bitmap,
643 bool active,
644 int close_button_state,
645 int* x_extent)
646 {
647 bool found;
648 wxSize rv, *prv = &rv;
649 const char* errmsg = "GetTabSize should return a sequence containing (size, x_extent)";
650 wxPyBlock_t blocked = wxPyBeginBlockThreads();
651 if ((found = wxPyCBH_findCallback(m_myInst, "GetTabSize"))) {
652 PyObject* odc = wxPyMake_wxObject(&dc, false);
653 PyObject* ownd = wxPyMake_wxObject(wnd, false);
654 PyObject* otext = wx2PyString(caption);
655 PyObject* obmp = wxPyMake_wxObject((wxObject*)&bitmap, false);
656 PyObject* ro;
657 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue(
658 "(OOOOii)", odc, ownd, otext, obmp, (int)active, close_button_state));
659 if (ro) {
660 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) {
661 PyObject* o1 = PySequence_GetItem(ro, 0);
662 PyObject* o2 = PySequence_GetItem(ro, 1);
663 if (!wxSize_helper(o1, &prv))
664 PyErr_SetString(PyExc_TypeError, errmsg);
665 else if (!PyInt_Check(o2))
666 PyErr_SetString(PyExc_TypeError, errmsg);
667 else
668 *x_extent = PyInt_AsLong(o2);
669
670 Py_DECREF(o1);
671 Py_DECREF(o2);
672 }
673 else {
674 PyErr_SetString(PyExc_TypeError, errmsg);
675 }
676 Py_DECREF(ro);
677 }
678
679 Py_DECREF(odc);
680 Py_DECREF(ownd);
681 Py_DECREF(otext);
682 Py_DECREF(obmp);
683 }
684 wxPyEndBlockThreads(blocked);
685 if (!found)
686 rv = wxAuiDefaultTabArt::GetTabSize(dc, wnd, caption, bitmap, active, close_button_state, x_extent);
687 return rv;
688 }
689
690 // TODO
691 // virtual int ShowDropDown(
692 // wxWindow* wnd,
693 // const wxAuiNotebookPageArray& items,
694 // int active_idx);
695
696 // virtual int GetIndentSize();
697
698 // virtual int GetBestTabCtrlSize(wxWindow* wnd,
699 // const wxAuiNotebookPageArray& pages,
700 // const wxSize& required_bmp_size);
701 // virtual wxAuiTabArt* Clone();
702 // virtual void SetFlags(unsigned int flags);
703 // virtual void SetSizingInfo(const wxSize& tab_ctrl_size,
704 // size_t tab_count);
705 // virtual int GetIndentSize();
706
707
708
709 DEC_PYCALLBACK__FONT(SetNormalFont);
710 DEC_PYCALLBACK__FONT(SetSelectedFont);
711 DEC_PYCALLBACK__FONT(SetMeasuringFont);
712 // DEC_PYCALLBACK_INT_WIN(GetBestTabCtrlSize);
713
714 PYPRIVATE;
715 };
716
717
718 IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetNormalFont);
719 IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetSelectedFont);
720 IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetMeasuringFont);
721 //IMP_PYCALLBACK_INT_WIN(wxPyAuiTabArt, wxAuiDefaultTabArt, GetBestTabCtrlSize);
722 %}
723
724
725 DocStr(wxPyAuiTabArt,
726 "This version of the `TabArt` class has been instrumented to be
727 subclassable in Python and to reflect all calls to the C++ base class
728 methods to the Python methods implemented in the derived class.", "");
729
730 class wxPyAuiTabArt : public wxAuiDefaultTabArt
731 {
732 %pythonAppend wxPyAuiTabArt setCallbackInfo(PyAuiTabArt)
733 wxPyAuiTabArt();
734
735 };
736
737
738 //---------------------------------------------------------------------------
739
740 #undef wxUSE_AUI
741 #undef wxUSE_MENUS
742 #undef WXDLLIMPEXP_AUI
743
744 //---------------------------------------------------------------------------
745