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