]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/aui.i
GetTmpDefaultItem
[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
RD
141
142// We'll let SWIG handle the function overloading for these
143%ignore wxPaneInfo::MaxSize(int x, int y);
144%ignore wxPaneInfo::MinSize(int x, int y);
145%ignore wxPaneInfo::BestSize(int x, int y);
146%ignore wxPaneInfo::FloatingPosition(int x, int y);
147%ignore wxPaneInfo::FloatingSize(int x, int y);
148
149// But for these we will do the overloading (see %pythoncode below) so let's
150// rename the C++ versions
151%rename(_GetPaneByWidget) wxFrameManager::GetPane(wxWindow* window);
152%rename(_GetPaneByName) wxFrameManager::GetPane(const wxString& name);
153
154%rename(_AddPane1) wxFrameManager::AddPane(wxWindow* window, const wxPaneInfo& pane_info);
155%rename(_AddPane2) wxFrameManager::AddPane(wxWindow* window, int direction = wxLEFT,
156 const wxString& caption = wxEmptyString);
157
158
159// A typemap for the return value of wxFrameManager::GetAllPanes
160%typemap(out) wxPaneInfoArray& {
161 $result = PyList_New(0);
162 for (size_t i=0; i < $1->GetCount(); i++) {
163 PyObject* pane_obj = SWIG_NewPointerObj((void*)(&$1->Item(i)), SWIGTYPE_p_wxPaneInfo, 0);
164 PyList_Append($result, pane_obj);
165 }
166}
167
168
169//---------------------------------------------------------------------------
170// Get all our defs from the REAL header files.
171%include framemanager.h
172%include dockart.h
173%include floatpane.h
174
175
176//---------------------------------------------------------------------------
177// Methods to inject into the FrameManager class that will sort out calls to
178// the overloaded versions of GetPane and AddPane
179
180%extend wxFrameManager {
d7a7616b 181 %pythoncode {
febb39df
RD
182 def GetPane(self, item):
183 """
184 GetPane(self, window_or_info item) -> PaneInfo
185
186 GetPane is used to search for a `PaneInfo` object either by
187 widget reference or by pane name, which acts as a unique id
188 for a window pane. The returned `PaneInfo` object may then be
189 modified to change a pane's look, state or position. After one
190 or more modifications to the `PaneInfo`, `FrameManager.Update`
191 should be called to realize the changes to the user interface.
192
193 If the lookup failed (meaning the pane could not be found in
194 the manager) GetPane returns an empty `PaneInfo`, a condition
195 which can be checked by calling `PaneInfo.IsOk`.
196 """
197 if isinstance(item, wx.Window):
198 return self._GetPaneByWidget(item)
199 else:
200 return self._GetPaneByName(item)
201
202 def AddPane(self, window, info=None, caption=None):
203 """
204 AddPane(self, window, info=None, caption=None) -> bool
205
206 AddPane tells the frame manager to start managing a child
207 window. There are two versions of this function. The first
208 verison accepts a `PaneInfo` object for the ``info`` parameter
209 and allows the full spectrum of pane parameter
210 possibilities. (Say that 3 times fast!)
211
212 The second version is used for simpler user interfaces which
213 do not require as much configuration. In this case the
214 ``info`` parameter specifies the direction property of the
215 pane info, and defaults to ``wx.LEFT``. The pane caption may
216 also be specified as an extra parameter in this form.
217 """
4c16bedf
RD
218 if type(info) == PaneInfo:
219 return self._AddPane1(window, info)
febb39df
RD
220 else:
221 # This Is AddPane2
4c16bedf
RD
222 if info is None:
223 info = wx.LEFT
224 if caption is None:
225 caption = ""
226 return self._AddPane2(window, info, caption)
d7a7616b
RD
227 }
228
229 // For backwards compatibility
230 %pythoncode {
231 SetFrame = wx._deprecated(SetManagedWindow,
232 "SetFrame is deprecated, use `SetManagedWindow` instead.")
233 GetFrame = wx._deprecated(GetManagedWindow,
234 "GetFrame is deprecated, use `GetManagedWindow` instead.")
235 }
febb39df
RD
236}
237
238//---------------------------------------------------------------------------
239
240%{
241class wxPyDockArt : public wxDefaultDockArt
242{
243 wxPyDockArt() : wxDefaultDockArt() {}
244
245 DEC_PYCALLBACK_INT_INT(GetMetric);
246 DEC_PYCALLBACK_VOID_INTINT(SetMetric);
247 DEC_PYCALLBACK__INTFONT(SetFont);
248 DEC_PYCALLBACK_FONT_INT(GetFont);
249 DEC_PYCALLBACK_COLOUR_INT(GetColour);
250 DEC_PYCALLBACK__INTCOLOUR(SetColour);
251
252 virtual void DrawSash(wxDC& dc,
253 int orientation,
254 const wxRect& rect)
255 {
256 bool found;
257 wxPyBlock_t blocked = wxPyBeginBlockThreads();
258 if ((found = wxPyCBH_findCallback(m_myInst, "DrawSash"))) {
259 PyObject* odc = wxPyMake_wxObject(&dc, false);
260 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
261 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)",
262 odc, orientation, orect));
263 Py_DECREF(odc);
264 Py_DECREF(orect);
265 }
266 wxPyEndBlockThreads(blocked);
267 if (! found)
268 wxDefaultDockArt::DrawSash(dc, orientation, rect);
269 }
270
271 virtual void DrawBackground(wxDC& dc,
272 int orientation,
273 const wxRect& rect)
274 {
275 bool found;
276 wxPyBlock_t blocked = wxPyBeginBlockThreads();
277 if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) {
278 PyObject* odc = wxPyMake_wxObject(&dc, false);
279 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
280 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)",
281 odc, orientation, orect));
282 Py_DECREF(odc);
283 Py_DECREF(orect);
284 }
285 wxPyEndBlockThreads(blocked);
286 if (! found)
287 wxDefaultDockArt::DrawBackground(dc, orientation, rect);
288 }
289
290 virtual void DrawCaption(wxDC& dc,
291 const wxString& text,
292 const wxRect& rect,
293 wxPaneInfo& pane)
294 {
295 bool found;
296 wxPyBlock_t blocked = wxPyBeginBlockThreads();
297 if ((found = wxPyCBH_findCallback(m_myInst, "DrawCaption"))) {
298 PyObject* odc = wxPyMake_wxObject(&dc, false);
299 PyObject* otext = wx2PyString(text);
300 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
301 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
302 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOO)",
303 odc, otext, orect, opane));
304 Py_DECREF(odc);
305 Py_DECREF(otext);
306 Py_DECREF(orect);
307 Py_DECREF(opane);
308 }
309 wxPyEndBlockThreads(blocked);
310 if (! found)
311 wxDefaultDockArt::DrawCaption(dc, text, rect, pane);
312 }
313
314 virtual void DrawGripper(wxDC& dc,
315 const wxRect& rect,
316 wxPaneInfo& pane)
317 {
318 bool found;
319 wxPyBlock_t blocked = wxPyBeginBlockThreads();
320 if ((found = wxPyCBH_findCallback(m_myInst, "DrawGripper"))) {
321 PyObject* odc = wxPyMake_wxObject(&dc, false);
322 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
323 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
324 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, orect, opane));
325 Py_DECREF(odc);
326 Py_DECREF(orect);
327 Py_DECREF(opane);
328 }
329 wxPyEndBlockThreads(blocked);
330 if (! found)
331 wxDefaultDockArt::DrawGripper(dc, rect, pane);
332 }
333
334 virtual void DrawBorder(wxDC& dc,
335 const wxRect& rect,
336 wxPaneInfo& pane)
337 {
338 bool found;
339 wxPyBlock_t blocked = wxPyBeginBlockThreads();
340 if ((found = wxPyCBH_findCallback(m_myInst, "DrawBorder"))) {
341 PyObject* odc = wxPyMake_wxObject(&dc, false);
342 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
343 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
344 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, orect, opane));
345 Py_DECREF(odc);
346 Py_DECREF(orect);
347 Py_DECREF(opane);
348 }
349 wxPyEndBlockThreads(blocked);
350 if (! found)
351 wxDefaultDockArt::DrawBorder(dc, rect, pane);
352 }
353
354 virtual void DrawPaneButton(wxDC& dc,
355 int button,
356 int button_state,
357 const wxRect& rect,
358 wxPaneInfo& pane)
359 {
360 bool found;
361 wxPyBlock_t blocked = wxPyBeginBlockThreads();
362 if ((found = wxPyCBH_findCallback(m_myInst, "DrawPaneButton"))) {
363 PyObject* odc = wxPyMake_wxObject(&dc, false);
364 PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
365 PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
366 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiIOO)",
367 odc, button, button_state,
368 orect, opane));
369 Py_DECREF(odc);
370 Py_DECREF(orect);
371 Py_DECREF(opane);
372 }
373 wxPyEndBlockThreads(blocked);
374 if (! found)
375 wxDefaultDockArt::DrawPaneButton(dc, button, button_state, rect, pane);
376 }
377
378 PYPRIVATE;
379
380};
381
382IMP_PYCALLBACK_INT_INT(wxPyDockArt, wxDefaultDockArt, GetMetric);
383IMP_PYCALLBACK_VOID_INTINT(wxPyDockArt, wxDefaultDockArt, SetMetric);
384IMP_PYCALLBACK__INTFONT(wxPyDockArt, wxDefaultDockArt, SetFont);
385IMP_PYCALLBACK_FONT_INT(wxPyDockArt, wxDefaultDockArt, GetFont);
386IMP_PYCALLBACK_COLOUR_INT(wxPyDockArt, wxDefaultDockArt, GetColour);
387IMP_PYCALLBACK__INTCOLOUR(wxPyDockArt, wxDefaultDockArt, SetColour);
388
389%}
390
391
392DocStr(wxPyDockArt,
393"This version of the `DockArt` class has been instrumented to be
394subclassable in Python and to reflect all calls to the C++ base class
395methods to the Python methods implemented in the derived class.", "");
396
397class wxPyDockArt : public wxDefaultDockArt
398{
399 %pythonAppend wxPyDockArt "self._setCallbackInfo(self, PyDockArt)"
400 PyDocArt();
401
402};
403
404
405
406#undef wxUSE_AUI
407#undef WXDLLIMPEXP_AUI
408
409//---------------------------------------------------------------------------
410