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