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