]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/aui.i
use the right number in the tarball filename
[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
47**PyAUI 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
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
72 self._mgr = wx.aui.FrameManager(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
136#define wxUSE_AUI 1
137#define WXDLLIMPEXP_AUI
138#define unsigned
d7a7616b
RD
139#define wxDEPRECATED(decl)
140
febb39df 141
1c976bff
RD
142// We'll skip making wrappers for these, they have overloads that take a
143// wxSize or wxPoint
febb39df
RD
144%ignore wxPaneInfo::MaxSize(int x, int y);
145%ignore wxPaneInfo::MinSize(int x, int y);
146%ignore wxPaneInfo::BestSize(int x, int y);
147%ignore wxPaneInfo::FloatingPosition(int x, int y);
148%ignore wxPaneInfo::FloatingSize(int x, int y);
149
150// But for these we will do the overloading (see %pythoncode below) so let's
151// rename the C++ versions
152%rename(_GetPaneByWidget) wxFrameManager::GetPane(wxWindow* window);
153%rename(_GetPaneByName) wxFrameManager::GetPane(const wxString& name);
154
155%rename(_AddPane1) wxFrameManager::AddPane(wxWindow* window, const wxPaneInfo& pane_info);
156%rename(_AddPane2) wxFrameManager::AddPane(wxWindow* window, int direction = wxLEFT,
6ec59a2b 157 const wxString& caption = wxEmptyString);
febb39df 158
6ec59a2b
RD
159%rename(AddPaneAtPos) wxFrameManager::AddPane(wxWindow* window,
160 const wxPaneInfo& pane_info,
161 const wxPoint& drop_pos);
febb39df
RD
162
163// A typemap for the return value of wxFrameManager::GetAllPanes
164%typemap(out) wxPaneInfoArray& {
165 $result = PyList_New(0);
166 for (size_t i=0; i < $1->GetCount(); i++) {
167 PyObject* pane_obj = SWIG_NewPointerObj((void*)(&$1->Item(i)), SWIGTYPE_p_wxPaneInfo, 0);
168 PyList_Append($result, pane_obj);
169 }
170}
171
172
1c976bff
RD
173%nokwargs wxAuiTabContainer::SetActivePage;
174
175%pythonAppend wxAuiTabCtrl::wxAuiTabCtrl "self._setOORInfo(self)";
176
177%pythonAppend wxAuiMultiNotebook::wxAuiMultiNotebook "self._setOORInfo(self)";
178%pythonAppend wxAuiMultiNotebook::wxAuiMultiNotebook() "self._setOORInfo(self)";
179%ignore wxAuiMultiNotebook::~wxAuiMultiNotebook;
180%rename(PreAuiMultiNotebook) wxAuiMultiNotebook::wxAuiMultiNotebook();
181
febb39df
RD
182//---------------------------------------------------------------------------
183// Get all our defs from the REAL header files.
184%include framemanager.h
185%include dockart.h
186%include floatpane.h
1c976bff 187%include auibook.h
febb39df
RD
188
189//---------------------------------------------------------------------------
190// Methods to inject into the FrameManager class that will sort out calls to
191// the overloaded versions of GetPane and AddPane
192
193%extend wxFrameManager {
d7a7616b 194 %pythoncode {
febb39df
RD
195 def GetPane(self, item):
196 """
197 GetPane(self, window_or_info item) -> PaneInfo
198
199 GetPane is used to search for a `PaneInfo` object either by
200 widget reference or by pane name, which acts as a unique id
201 for a window pane. The returned `PaneInfo` object may then be
202 modified to change a pane's look, state or position. After one
203 or more modifications to the `PaneInfo`, `FrameManager.Update`
204 should be called to realize the changes to the user interface.
205
206 If the lookup failed (meaning the pane could not be found in
207 the manager) GetPane returns an empty `PaneInfo`, a condition
208 which can be checked by calling `PaneInfo.IsOk`.
209 """
210 if isinstance(item, wx.Window):
211 return self._GetPaneByWidget(item)
212 else:
213 return self._GetPaneByName(item)
214
215 def AddPane(self, window, info=None, caption=None):
216 """
217 AddPane(self, window, info=None, caption=None) -> bool
218
219 AddPane tells the frame manager to start managing a child
220 window. There are two versions of this function. The first
221 verison accepts a `PaneInfo` object for the ``info`` parameter
222 and allows the full spectrum of pane parameter
223 possibilities. (Say that 3 times fast!)
224
225 The second version is used for simpler user interfaces which
226 do not require as much configuration. In this case the
227 ``info`` parameter specifies the direction property of the
228 pane info, and defaults to ``wx.LEFT``. The pane caption may
229 also be specified as an extra parameter in this form.
230 """
4c16bedf
RD
231 if type(info) == PaneInfo:
232 return self._AddPane1(window, info)
febb39df
RD
233 else:
234 # This Is AddPane2
4c16bedf
RD
235 if info is None:
236 info = wx.LEFT
237 if caption is None:
238 caption = ""
239 return self._AddPane2(window, info, caption)
d7a7616b
RD
240 }
241
242 // For backwards compatibility
243 %pythoncode {
244 SetFrame = wx._deprecated(SetManagedWindow,
245 "SetFrame is deprecated, use `SetManagedWindow` instead.")
246 GetFrame = wx._deprecated(GetManagedWindow,
247 "GetFrame is deprecated, use `GetManagedWindow` instead.")
248 }
febb39df
RD
249}
250
050441c8
RD
251%extend wxDockInfo {
252 ~wxDockInfo() {}
253}
254
255%extend wxDockUIPart {
050441c8
RD
256 ~wxDockUIPart() {}
257}
258
259%extend wxPaneButton {
050441c8
RD
260 ~wxPaneButton() {}
261}
262
febb39df
RD
263//---------------------------------------------------------------------------
264
265%{
777e547f 266// A wxDocArt class that knows how to forward virtuals to Python methods
febb39df
RD
267class wxPyDockArt : public wxDefaultDockArt
268{
269 wxPyDockArt() : wxDefaultDockArt() {}
270
271 DEC_PYCALLBACK_INT_INT(GetMetric);
272 DEC_PYCALLBACK_VOID_INTINT(SetMetric);
273 DEC_PYCALLBACK__INTFONT(SetFont);
274 DEC_PYCALLBACK_FONT_INT(GetFont);
275 DEC_PYCALLBACK_COLOUR_INT(GetColour);
276 DEC_PYCALLBACK__INTCOLOUR(SetColour);
277
278 virtual void DrawSash(wxDC& dc,
e81b607b 279 wxWindow* window,
febb39df
RD
280 int orientation,
281 const wxRect& rect)
282 {
283 bool found;
284 wxPyBlock_t blocked = wxPyBeginBlockThreads();
285 if ((found = wxPyCBH_findCallback(m_myInst, "DrawSash"))) {
286 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 287 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df 288 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
e81b607b
RD
289 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)",
290 odc, owin, orientation, orect));
febb39df
RD
291 Py_DECREF(odc);
292 Py_DECREF(orect);
293 }
294 wxPyEndBlockThreads(blocked);
295 if (! found)
e81b607b 296 wxDefaultDockArt::DrawSash(dc, window, orientation, rect);
febb39df
RD
297 }
298
299 virtual void DrawBackground(wxDC& dc,
e81b607b 300 wxWindow* window,
febb39df
RD
301 int orientation,
302 const wxRect& rect)
303 {
304 bool found;
305 wxPyBlock_t blocked = wxPyBeginBlockThreads();
306 if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) {
307 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 308 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df 309 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
e81b607b
RD
310 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiO)",
311 odc, owin, orientation, orect));
febb39df
RD
312 Py_DECREF(odc);
313 Py_DECREF(orect);
314 }
315 wxPyEndBlockThreads(blocked);
316 if (! found)
e81b607b 317 wxDefaultDockArt::DrawBackground(dc, window, orientation, rect);
febb39df
RD
318 }
319
320 virtual void DrawCaption(wxDC& dc,
e81b607b 321 wxWindow* window,
febb39df
RD
322 const wxString& text,
323 const wxRect& rect,
324 wxPaneInfo& pane)
325 {
326 bool found;
327 wxPyBlock_t blocked = wxPyBeginBlockThreads();
328 if ((found = wxPyCBH_findCallback(m_myInst, "DrawCaption"))) {
329 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 330 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df
RD
331 PyObject* otext = wx2PyString(text);
332 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
333 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
e81b607b
RD
334 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOO)",
335 odc, owin, otext, orect, opane));
febb39df
RD
336 Py_DECREF(odc);
337 Py_DECREF(otext);
338 Py_DECREF(orect);
339 Py_DECREF(opane);
340 }
341 wxPyEndBlockThreads(blocked);
342 if (! found)
e81b607b 343 wxDefaultDockArt::DrawCaption(dc, window, text, rect, pane);
febb39df
RD
344 }
345
346 virtual void DrawGripper(wxDC& dc,
e81b607b 347 wxWindow* window,
febb39df
RD
348 const wxRect& rect,
349 wxPaneInfo& pane)
350 {
351 bool found;
352 wxPyBlock_t blocked = wxPyBeginBlockThreads();
353 if ((found = wxPyCBH_findCallback(m_myInst, "DrawGripper"))) {
354 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 355 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df
RD
356 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
357 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
e81b607b 358 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOO)", odc, owin, orect, opane));
febb39df
RD
359 Py_DECREF(odc);
360 Py_DECREF(orect);
361 Py_DECREF(opane);
362 }
363 wxPyEndBlockThreads(blocked);
364 if (! found)
e81b607b 365 wxDefaultDockArt::DrawGripper(dc, window, rect, pane);
febb39df
RD
366 }
367
368 virtual void DrawBorder(wxDC& dc,
e81b607b 369 wxWindow* window,
febb39df
RD
370 const wxRect& rect,
371 wxPaneInfo& pane)
372 {
373 bool found;
374 wxPyBlock_t blocked = wxPyBeginBlockThreads();
375 if ((found = wxPyCBH_findCallback(m_myInst, "DrawBorder"))) {
376 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 377 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df
RD
378 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
379 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
380 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, orect, opane));
381 Py_DECREF(odc);
382 Py_DECREF(orect);
383 Py_DECREF(opane);
384 }
385 wxPyEndBlockThreads(blocked);
386 if (! found)
e81b607b 387 wxDefaultDockArt::DrawBorder(dc, window, rect, pane);
febb39df
RD
388 }
389
390 virtual void DrawPaneButton(wxDC& dc,
e81b607b 391 wxWindow* window,
febb39df
RD
392 int button,
393 int button_state,
394 const wxRect& rect,
395 wxPaneInfo& pane)
396 {
397 bool found;
398 wxPyBlock_t blocked = wxPyBeginBlockThreads();
399 if ((found = wxPyCBH_findCallback(m_myInst, "DrawPaneButton"))) {
400 PyObject* odc = wxPyMake_wxObject(&dc, false);
e81b607b 401 PyObject* owin = wxPyMake_wxObject(window, false);
febb39df
RD
402 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
403 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
e81b607b
RD
404 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOiIOO)",
405 odc, owin, button, button_state,
febb39df
RD
406 orect, opane));
407 Py_DECREF(odc);
408 Py_DECREF(orect);
409 Py_DECREF(opane);
410 }
411 wxPyEndBlockThreads(blocked);
412 if (! found)
e81b607b 413 wxDefaultDockArt::DrawPaneButton(dc, window, button, button_state, rect, pane);
febb39df
RD
414 }
415
416 PYPRIVATE;
417
418};
419
420IMP_PYCALLBACK_INT_INT(wxPyDockArt, wxDefaultDockArt, GetMetric);
421IMP_PYCALLBACK_VOID_INTINT(wxPyDockArt, wxDefaultDockArt, SetMetric);
422IMP_PYCALLBACK__INTFONT(wxPyDockArt, wxDefaultDockArt, SetFont);
423IMP_PYCALLBACK_FONT_INT(wxPyDockArt, wxDefaultDockArt, GetFont);
424IMP_PYCALLBACK_COLOUR_INT(wxPyDockArt, wxDefaultDockArt, GetColour);
425IMP_PYCALLBACK__INTCOLOUR(wxPyDockArt, wxDefaultDockArt, SetColour);
426
427%}
428
429
430DocStr(wxPyDockArt,
431"This version of the `DockArt` class has been instrumented to be
432subclassable in Python and to reflect all calls to the C++ base class
433methods to the Python methods implemented in the derived class.", "");
434
435class wxPyDockArt : public wxDefaultDockArt
436{
437 %pythonAppend wxPyDockArt "self._setCallbackInfo(self, PyDockArt)"
438 PyDocArt();
439
440};
441
442
777e547f
RD
443//---------------------------------------------------------------------------
444
445%extend wxAuiMultiNotebook {
446 %property(PageCount, GetPageCount, doc="See `GetPageCount`");
447 %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
448}
449
450
451%extend wxAuiNotebookEvent {
452 %property(OldSelection, GetOldSelection, SetOldSelection, doc="See `GetOldSelection` and `SetOldSelection`");
453 %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
454}
455
456
457%extend wxAuiTabContainer {
458 %property(ActivePage, GetActivePage, SetActivePage, doc="See `GetActivePage` and `SetActivePage`");
459 %property(PageCount, GetPageCount, doc="See `GetPageCount`");
460 %property(Pages, GetPages, doc="See `GetPages`");
461}
462
463
464%extend wxFrameManager {
465 %property(AllPanes, GetAllPanes, doc="See `GetAllPanes`");
466 %property(ArtProvider, GetArtProvider, SetArtProvider, doc="See `GetArtProvider` and `SetArtProvider`");
467 %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`");
468 %property(ManagedWindow, GetManagedWindow, SetManagedWindow, doc="See `GetManagedWindow` and `SetManagedWindow`");
469}
470
471
472%extend wxFrameManagerEvent {
473 %property(Button, GetButton, SetButton, doc="See `GetButton` and `SetButton`");
474 %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
475 %property(Pane, GetPane, SetPane, doc="See `GetPane` and `SetPane`");
476}
477
478
479//---------------------------------------------------------------------------
febb39df
RD
480
481#undef wxUSE_AUI
482#undef WXDLLIMPEXP_AUI
483
484//---------------------------------------------------------------------------
485