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