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