]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/aui.i
added more wxUSE_TREE/LISTCTRL tests to fix compilation when they're set to 0
[wxWidgets.git] / wxPython / src / aui.i
CommitLineData
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
15implement \"cutting-edge\" interface usability and design features so
16developers can quickly and easily create beautiful and usable
17application interfaces.
18
19**Vision and Design Principles**
20
21wx.aui attempts to encapsulate the following aspects of the user
22interface:
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
60The 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
34d71f81
RD
135// Preprocessor stuff so SWIG doesn't get confused when %include-ing
136// the aui .h files.
febb39df 137#define wxUSE_AUI 1
34d71f81 138#define wxUSE_MENUS 1
febb39df
RD
139#define WXDLLIMPEXP_AUI
140#define unsigned
d7a7616b 141#define wxDEPRECATED(decl)
34d71f81
RD
142#define DECLARE_EVENT_TABLE()
143#define DECLARE_DYNAMIC_CLASS(foo)
144
d7a7616b 145
febb39df 146
1c976bff
RD
147// We'll skip making wrappers for these, they have overloads that take a
148// wxSize or wxPoint
2a783b2d
RD
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);
febb39df
RD
154
155// But for these we will do the overloading (see %pythoncode below) so let's
156// rename the C++ versions
2a783b2d
RD
157%rename(_GetPaneByWidget) wxAuiManager::GetPane(wxWindow* window);
158%rename(_GetPaneByName) wxAuiManager::GetPane(const wxString& name);
febb39df 159
2a783b2d
RD
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);
febb39df 163
2a783b2d
RD
164%rename(AddPaneAtPos) wxAuiManager::AddPane(wxWindow* window,
165 const wxPaneInfo& pane_info,
166 const wxPoint& drop_pos);
febb39df
RD
167
168// A typemap for the return value of wxFrameManager::GetAllPanes
2a783b2d 169%typemap(out) wxAuiPaneInfoArray& {
febb39df
RD
170 $result = PyList_New(0);
171 for (size_t i=0; i < $1->GetCount(); i++) {
2a783b2d 172 PyObject* pane_obj = SWIG_NewPointerObj((void*)(&$1->Item(i)), SWIGTYPE_p_wxAuiPaneInfo, 0);
febb39df
RD
173 PyList_Append($result, pane_obj);
174 }
175}
176
177
1c976bff
RD
178%nokwargs wxAuiTabContainer::SetActivePage;
179
180%pythonAppend wxAuiTabCtrl::wxAuiTabCtrl "self._setOORInfo(self)";
181
2a783b2d 182%pythonAppend wxAuiNotebook::wxAuiNotebook "self._setOORInfo(self)";
34d71f81 183%pythonAppend wxAuiNotebook::wxAuiNotebook() "val._setOORInfo(val)";
2a783b2d
RD
184%ignore wxAuiiNotebook::~wxAuiNotebook;
185%rename(PreAuiNotebook) wxAuiNotebook::wxAuiNotebook();
1c976bff 186
34d71f81
RD
187// Link error...
188%ignore wxAuiDefaultTabArt::SetWindow;
54af9b8b 189
d48ae46b
RD
190// ignore this overload
191%ignore wxAuiTabContainer::GetPage(size_t idx) const;
192
193
34d71f81
RD
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
febb39df
RD
211//---------------------------------------------------------------------------
212// Get all our defs from the REAL header files.
55424c8c
RD
213
214#define wxColor wxColour // fix problem in dockart.h
215
febb39df
RD
216%include framemanager.h
217%include dockart.h
218%include floatpane.h
1c976bff 219%include auibook.h
34d71f81 220%include tabmdi.h
febb39df 221
55424c8c
RD
222#undef wxColor
223
febb39df
RD
224//---------------------------------------------------------------------------
225// Methods to inject into the FrameManager class that will sort out calls to
226// the overloaded versions of GetPane and AddPane
227
2a783b2d 228%extend wxAuiManager {
d7a7616b 229 %pythoncode {
febb39df
RD
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 """
2a783b2d 266 if type(info) == AuiPaneInfo:
4c16bedf 267 return self._AddPane1(window, info)
febb39df
RD
268 else:
269 # This Is AddPane2
4c16bedf
RD
270 if info is None:
271 info = wx.LEFT
272 if caption is None:
273 caption = ""
274 return self._AddPane2(window, info, caption)
d7a7616b
RD
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 }
febb39df
RD
284}
285
2a783b2d
RD
286%extend wxAuiDockInfo {
287 ~wxAuiDockInfo() {}
050441c8
RD
288}
289
2a783b2d
RD
290%extend wxAuiDockUIPart {
291 ~wxAuiDockUIPart() {}
050441c8
RD
292}
293
2a783b2d
RD
294%extend wxAuiPaneButton {
295 ~wxAuiPaneButton() {}
050441c8
RD
296}
297
febb39df
RD
298//---------------------------------------------------------------------------
299
300%{
2db4b82e 301// A wxDocArt class that knows how to forward virtuals to Python methods
2a783b2d 302class wxPyAuiDockArt : public wxAuiDefaultDockArt
febb39df 303{
2a783b2d 304 wxPyAuiDockArt() : wxAuiDefaultDockArt() {}
febb39df
RD
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,
e81b607b 314 wxWindow* window,
febb39df
RD
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);
e81b607b 322 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df 323 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
e81b607b
RD
324 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)",
325 odc, owin, orientation, orect));
febb39df 326 Py_DECREF(odc);
8f514ab4 327 Py_DECREF(owin);
febb39df
RD
328 Py_DECREF(orect);
329 }
330 wxPyEndBlockThreads(blocked);
331 if (! found)
2a783b2d 332 wxAuiDefaultDockArt::DrawSash(dc, window, orientation, rect);
febb39df
RD
333 }
334
335 virtual void DrawBackground(wxDC& dc,
e81b607b 336 wxWindow* window,
febb39df
RD
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);
e81b607b 344 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df 345 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
e81b607b
RD
346 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)",
347 odc, owin, orientation, orect));
febb39df 348 Py_DECREF(odc);
8f514ab4 349 Py_DECREF(owin);
febb39df
RD
350 Py_DECREF(orect);
351 }
352 wxPyEndBlockThreads(blocked);
353 if (! found)
2a783b2d 354 wxAuiDefaultDockArt::DrawBackground(dc, window, orientation, rect);
febb39df
RD
355 }
356
357 virtual void DrawCaption(wxDC& dc,
e81b607b 358 wxWindow* window,
febb39df
RD
359 const wxString& text,
360 const wxRect& rect,
2a783b2d 361 wxAuiPaneInfo& pane)
febb39df
RD
362 {
363 bool found;
364 wxPyBlock_t blocked = wxPyBeginBlockThreads();
365 if ((found = wxPyCBH_findCallback(m_myInst, "DrawCaption"))) {
366 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 367 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df
RD
368 PyObject* otext = wx2PyString(text);
369 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
2a783b2d 370 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0);
e81b607b
RD
371 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOO)",
372 odc, owin, otext, orect, opane));
febb39df 373 Py_DECREF(odc);
8f514ab4 374 Py_DECREF(owin);
febb39df
RD
375 Py_DECREF(otext);
376 Py_DECREF(orect);
377 Py_DECREF(opane);
378 }
379 wxPyEndBlockThreads(blocked);
380 if (! found)
2a783b2d 381 wxAuiDefaultDockArt::DrawCaption(dc, window, text, rect, pane);
febb39df
RD
382 }
383
384 virtual void DrawGripper(wxDC& dc,
e81b607b 385 wxWindow* window,
febb39df 386 const wxRect& rect,
2a783b2d 387 wxAuiPaneInfo& pane)
febb39df
RD
388 {
389 bool found;
390 wxPyBlock_t blocked = wxPyBeginBlockThreads();
391 if ((found = wxPyCBH_findCallback(m_myInst, "DrawGripper"))) {
392 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 393 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df 394 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
2a783b2d 395 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0);
e81b607b 396 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOO)", odc, owin, orect, opane));
febb39df
RD
397 Py_DECREF(odc);
398 Py_DECREF(orect);
399 Py_DECREF(opane);
400 }
401 wxPyEndBlockThreads(blocked);
402 if (! found)
2a783b2d 403 wxAuiDefaultDockArt::DrawGripper(dc, window, rect, pane);
febb39df
RD
404 }
405
406 virtual void DrawBorder(wxDC& dc,
e81b607b 407 wxWindow* window,
febb39df 408 const wxRect& rect,
2a783b2d 409 wxAuiPaneInfo& pane)
febb39df
RD
410 {
411 bool found;
412 wxPyBlock_t blocked = wxPyBeginBlockThreads();
413 if ((found = wxPyCBH_findCallback(m_myInst, "DrawBorder"))) {
414 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 415 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df 416 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
2a783b2d 417 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0);
febb39df
RD
418 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, orect, opane));
419 Py_DECREF(odc);
8f514ab4 420 Py_DECREF(owin);
febb39df
RD
421 Py_DECREF(orect);
422 Py_DECREF(opane);
423 }
424 wxPyEndBlockThreads(blocked);
425 if (! found)
2a783b2d 426 wxAuiDefaultDockArt::DrawBorder(dc, window, rect, pane);
febb39df
RD
427 }
428
429 virtual void DrawPaneButton(wxDC& dc,
e81b607b 430 wxWindow* window,
febb39df
RD
431 int button,
432 int button_state,
433 const wxRect& rect,
2a783b2d 434 wxAuiPaneInfo& pane)
febb39df
RD
435 {
436 bool found;
437 wxPyBlock_t blocked = wxPyBeginBlockThreads();
438 if ((found = wxPyCBH_findCallback(m_myInst, "DrawPaneButton"))) {
439 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 440 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df 441 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
2a783b2d 442 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiPaneInfo"), 0);
e81b607b
RD
443 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiIOO)",
444 odc, owin, button, button_state,
febb39df
RD
445 orect, opane));
446 Py_DECREF(odc);
8f514ab4 447 Py_DECREF(owin);
febb39df
RD
448 Py_DECREF(orect);
449 Py_DECREF(opane);
450 }
451 wxPyEndBlockThreads(blocked);
452 if (! found)
2a783b2d 453 wxAuiDefaultDockArt::DrawPaneButton(dc, window, button, button_state, rect, pane);
febb39df
RD
454 }
455
456 PYPRIVATE;
457
458};
459
2a783b2d
RD
460IMP_PYCALLBACK_INT_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetMetric);
461IMP_PYCALLBACK_VOID_INTINT(wxPyAuiDockArt, wxAuiDefaultDockArt, SetMetric);
462IMP_PYCALLBACK__INTFONT(wxPyAuiDockArt, wxAuiDefaultDockArt, SetFont);
463IMP_PYCALLBACK_FONT_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetFont);
464IMP_PYCALLBACK_COLOUR_INT(wxPyAuiDockArt, wxAuiDefaultDockArt, GetColour);
465IMP_PYCALLBACK__INTCOLOUR(wxPyAuiDockArt, wxAuiDefaultDockArt, SetColour);
febb39df
RD
466
467%}
468
469
2a783b2d
RD
470DocStr(wxPyAuiDockArt,
471"This version of the `AuiDockArt` class has been instrumented to be
febb39df
RD
472subclassable in Python and to reflect all calls to the C++ base class
473methods to the Python methods implemented in the derived class.", "");
474
2a783b2d 475class wxPyAuiDockArt : public wxAuiDefaultDockArt
febb39df 476{
c25f90f6 477 %pythonAppend wxPyAuiDockArt setCallbackInfo(PyAuiDockArt)
2a783b2d 478 wxPyAuiDocArt();
febb39df
RD
479
480};
481
482
777e547f
RD
483//---------------------------------------------------------------------------
484
2a783b2d 485%extend wxAuiNotebook {
777e547f
RD
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
2a783b2d 504%extend wxAuiManager {
777e547f
RD
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
2a783b2d 512%extend wxAuiManagerEvent {
777e547f
RD
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
2db4b82e
RD
519//---------------------------------------------------------------------------
520
521%{
522// A wxTabArt class that knows how to forward virtuals to Python methods
2a783b2d 523class wxPyAuiTabArt : public wxAuiDefaultTabArt
2db4b82e 524{
2a783b2d 525 wxPyAuiTabArt() : wxAuiDefaultTabArt() {}
2db4b82e 526
8f514ab4 527
d95b9f2b 528 virtual void DrawBackground( wxDC& dc,
54af9b8b 529 wxWindow* wnd,
2db4b82e
RD
530 const wxRect& rect )
531 {
532 bool found;
533 wxPyBlock_t blocked = wxPyBeginBlockThreads();
534 if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) {
d95b9f2b 535 PyObject* odc = wxPyMake_wxObject(&dc, false);
54af9b8b 536 PyObject* ownd = wxPyMake_wxObject(wnd, false);
2db4b82e 537 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
54af9b8b 538 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, ownd, orect));
2db4b82e 539 Py_DECREF(odc);
54af9b8b 540 Py_DECREF(ownd);
2db4b82e
RD
541 Py_DECREF(orect);
542 }
543 wxPyEndBlockThreads(blocked);
544 if (!found)
54af9b8b 545 wxAuiDefaultTabArt::DrawBackground(dc, wnd, rect);
2db4b82e
RD
546 }
547
d95b9f2b 548 virtual void DrawTab( wxDC& dc,
54af9b8b 549 wxWindow* wnd,
81fd0478 550 const wxAuiNotebookPage& pane,
2db4b82e 551 const wxRect& in_rect,
36cb9ebe
RD
552 int close_button_state,
553 wxRect* out_tab_rect,
554 wxRect* out_button_rect,
2db4b82e
RD
555 int* x_extent)
556 {
557 bool found;
36cb9ebe 558 const char* errmsg = "DrawTab should return a sequence containing (tab_rect, button_rect, x_extent)";
2db4b82e
RD
559 wxPyBlock_t blocked = wxPyBeginBlockThreads();
560 if ((found = wxPyCBH_findCallback(m_myInst, "DrawTab"))) {
d95b9f2b 561 PyObject* odc = wxPyMake_wxObject(&dc, false);
54af9b8b 562 PyObject* ownd = wxPyMake_wxObject(wnd, false);
81fd0478 563 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxAuiNotebookPage"), 0);
2db4b82e 564 PyObject* orect = wxPyConstructObject((void*)&in_rect, wxT("wxRect"), 0);
2db4b82e 565 PyObject* ro;
2a783b2d 566 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue(
bce16979 567 "(OOOOOii)",
81fd0478
KO
568 odc, ownd, orect, opane,
569 close_button_state));
2db4b82e 570 if (ro) {
36cb9ebe 571 if (PySequence_Check(ro) && PyObject_Length(ro) == 3) {
2db4b82e
RD
572 PyObject* o1 = PySequence_GetItem(ro, 0);
573 PyObject* o2 = PySequence_GetItem(ro, 1);
36cb9ebe
RD
574 PyObject* o3 = PySequence_GetItem(ro, 2);
575 if (!wxRect_helper(o1, &out_tab_rect))
2db4b82e 576 PyErr_SetString(PyExc_TypeError, errmsg);
36cb9ebe
RD
577 else if (!wxRect_helper(o2, &out_button_rect))
578 PyErr_SetString(PyExc_TypeError, errmsg);
579 else if (!PyInt_Check(o3))
2db4b82e
RD
580 PyErr_SetString(PyExc_TypeError, errmsg);
581 else
36cb9ebe 582 *x_extent = PyInt_AsLong(o3);
2db4b82e
RD
583
584 Py_DECREF(o1);
585 Py_DECREF(o2);
36cb9ebe 586 Py_DECREF(o3);
2db4b82e
RD
587 }
588 else {
589 PyErr_SetString(PyExc_TypeError, errmsg);
590 }
591 Py_DECREF(ro);
592 }
593
594 Py_DECREF(odc);
54af9b8b 595 Py_DECREF(ownd);
2db4b82e 596 Py_DECREF(orect);
81fd0478 597 Py_DECREF(opane);
2db4b82e
RD
598 }
599 wxPyEndBlockThreads(blocked);
600 if (!found)
81fd0478 601 wxAuiDefaultTabArt::DrawTab(dc, wnd, pane, in_rect, close_button_state, out_tab_rect, out_button_rect, x_extent);
2db4b82e
RD
602 }
603
604
d95b9f2b 605 virtual void DrawButton( wxDC& dc,
54af9b8b 606 wxWindow* wnd,
8f514ab4
RD
607 const wxRect& in_rect,
608 int bitmap_id,
609 int button_state,
610 int orientation,
8f514ab4
RD
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"))) {
d95b9f2b 617 PyObject* odc = wxPyMake_wxObject(&dc, false);
54af9b8b 618 PyObject* ownd = wxPyMake_wxObject(wnd, false);
8f514ab4 619 PyObject* orect = wxPyConstructObject((void*)&in_rect, wxT("wxRect"), 0);
8f514ab4 620 PyObject* ro;
54af9b8b 621 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOOiiiO)", odc, ownd, orect,
81fd0478 622 bitmap_id, button_state, orientation));
8f514ab4
RD
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);
54af9b8b 630 Py_DECREF(ownd);
8f514ab4 631 Py_DECREF(orect);
8f514ab4
RD
632 }
633 wxPyEndBlockThreads(blocked);
634 if (!found)
81fd0478 635 wxAuiDefaultTabArt::DrawButton(dc, wnd, in_rect, bitmap_id, button_state, orientation, out_rect);
8f514ab4
RD
636 }
637
54af9b8b 638
d95b9f2b 639 virtual wxSize GetTabSize( wxDC& dc,
54af9b8b 640 wxWindow* wnd,
8f514ab4 641 const wxString& caption,
bce16979 642 const wxBitmap& bitmap,
8f514ab4 643 bool active,
36cb9ebe 644 int close_button_state,
8f514ab4
RD
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"))) {
d95b9f2b 652 PyObject* odc = wxPyMake_wxObject(&dc, false);
54af9b8b 653 PyObject* ownd = wxPyMake_wxObject(wnd, false);
8f514ab4 654 PyObject* otext = wx2PyString(caption);
bce16979 655 PyObject* obmp = wxPyMake_wxObject((wxObject*)&bitmap, false);
8f514ab4 656 PyObject* ro;
2a783b2d 657 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue(
bce16979 658 "(OOOOii)", odc, ownd, otext, obmp, (int)active, close_button_state));
8f514ab4
RD
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);
54af9b8b 680 Py_DECREF(ownd);
8f514ab4 681 Py_DECREF(otext);
bce16979 682 Py_DECREF(obmp);
8f514ab4
RD
683 }
684 wxPyEndBlockThreads(blocked);
685 if (!found)
bce16979 686 rv = wxAuiDefaultTabArt::GetTabSize(dc, wnd, caption, bitmap, active, close_button_state, x_extent);
8f514ab4
RD
687 return rv;
688 }
54af9b8b 689
d95b9f2b 690// TODO
81fd0478 691// virtual int ShowDropDown(
d95b9f2b 692// wxWindow* wnd,
81fd0478 693// const wxAuiNotebookPageArray& items,
d95b9f2b 694// int active_idx);
81fd0478
KO
695
696// virtual int GetIndentSize();
697
bce16979 698// virtual int GetBestTabCtrlSize(wxWindow* wnd,
81fd0478
KO
699// const wxAuiNotebookPageArray& pages,
700// const wxSize& required_bmp_size);
bce16979
RD
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
d95b9f2b 707
8f514ab4 708
2db4b82e
RD
709 DEC_PYCALLBACK__FONT(SetNormalFont);
710 DEC_PYCALLBACK__FONT(SetSelectedFont);
711 DEC_PYCALLBACK__FONT(SetMeasuringFont);
bce16979 712// DEC_PYCALLBACK_INT_WIN(GetBestTabCtrlSize);
2db4b82e
RD
713
714 PYPRIVATE;
715};
716
717
2a783b2d
RD
718IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetNormalFont);
719IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetSelectedFont);
720IMP_PYCALLBACK__FONT(wxPyAuiTabArt, wxAuiDefaultTabArt, SetMeasuringFont);
bce16979 721//IMP_PYCALLBACK_INT_WIN(wxPyAuiTabArt, wxAuiDefaultTabArt, GetBestTabCtrlSize);
2db4b82e
RD
722%}
723
724
2a783b2d 725DocStr(wxPyAuiTabArt,
2db4b82e
RD
726"This version of the `TabArt` class has been instrumented to be
727subclassable in Python and to reflect all calls to the C++ base class
728methods to the Python methods implemented in the derived class.", "");
729
2a783b2d 730class wxPyAuiTabArt : public wxAuiDefaultTabArt
2db4b82e 731{
c25f90f6 732 %pythonAppend wxPyAuiTabArt setCallbackInfo(PyAuiTabArt)
2a783b2d 733 wxPyAuiTabArt();
2db4b82e
RD
734
735};
736
737
777e547f 738//---------------------------------------------------------------------------
febb39df
RD
739
740#undef wxUSE_AUI
34d71f81 741#undef wxUSE_MENUS
febb39df
RD
742#undef WXDLLIMPEXP_AUI
743
744//---------------------------------------------------------------------------
745