]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _notebook.i | |
3 | // Purpose: SWIG interface defs for wxNotebook and such | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 2-June-1998 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | ||
a356336e | 18 | MAKE_CONST_WXSTRING(NotebookNameStr); |
d14a1e28 RD |
19 | |
20 | //--------------------------------------------------------------------------- | |
21 | %newgroup | |
22 | ||
6aabc8da RD |
23 | |
24 | enum { | |
25 | wxBK_DEFAULT, | |
26 | wxBK_TOP, | |
27 | wxBK_BOTTOM, | |
28 | wxBK_LEFT, | |
29 | wxBK_RIGHT, | |
15648073 | 30 | wxBK_ALIGN_MASK, |
5ebc78ec RD |
31 | wxBK_BUTTONBAR, |
32 | ||
33 | // hittest flags | |
34 | wxBK_HITTEST_NOWHERE = 1, // not on tab | |
35 | wxBK_HITTEST_ONICON = 2, // on icon | |
36 | wxBK_HITTEST_ONLABEL = 4, // on label | |
37 | wxBK_HITTEST_ONITEM = wxBK_HITTEST_ONICON | wxBK_HITTEST_ONLABEL, | |
38 | wxBK_HITTEST_ONPAGE = 8, // not on tab control, but over the selected page | |
6aabc8da RD |
39 | }; |
40 | ||
41 | ||
d14a1e28 RD |
42 | // TODO: Virtualize this class so other book controls can be derived in Python |
43 | ||
1c272b5d | 44 | MustHaveApp(wxBookCtrlBase); |
ab1f7d2a | 45 | |
d14a1e28 | 46 | // Common base class for wxList/Tree/Notebook |
1c272b5d | 47 | class wxBookCtrlBase : public wxControl |
d14a1e28 RD |
48 | { |
49 | public: | |
50 | // This is an ABC, it can't be constructed... | |
51 | ||
1c272b5d | 52 | // wxBookCtrlBase(wxWindow *parent, |
d14a1e28 RD |
53 | // wxWindowID id, |
54 | // const wxPoint& pos = wxDefaultPosition, | |
55 | // const wxSize& size = wxDefaultSize, | |
56 | // long style = 0, | |
57 | // const wxString& name = wxPyEmptyString); | |
1b8c7ba6 | 58 | // %RenameCtor(PreBookCtrlBase, wxBookCtrlBase()); |
d14a1e28 RD |
59 | // bool Create(wxWindow *parent, |
60 | // wxWindowID id, | |
61 | // const wxPoint& pos = wxDefaultPosition, | |
62 | // const wxSize& size = wxDefaultSize, | |
63 | // long style = 0, | |
64 | // const wxString& name = wxPyEmptyString); | |
65 | ||
66 | ||
67 | // get number of pages in the dialog | |
68 | virtual size_t GetPageCount() const; | |
69 | ||
70 | // get the panel which represents the given page | |
71 | virtual wxWindow *GetPage(size_t n); | |
72 | ||
fbb9eac0 RD |
73 | // get the current page or NULL if none |
74 | wxWindow* GetCurrentPage() const; | |
75 | ||
d14a1e28 RD |
76 | // get the currently selected page or wxNOT_FOUND if none |
77 | virtual int GetSelection() const/* = 0*/; | |
78 | ||
79 | // set/get the title of a page | |
80 | virtual bool SetPageText(size_t n, const wxString& strText)/* = 0*/; | |
81 | virtual wxString GetPageText(size_t n) const/* = 0*/; | |
82 | ||
83 | ||
84 | // image list stuff: each page may have an image associated with it (all | |
85 | // images belong to the same image list) | |
86 | ||
87 | // sets the image list to use, it is *not* deleted by the control | |
88 | virtual void SetImageList(wxImageList *imageList); | |
89 | ||
90 | // as SetImageList() but we will delete the image list ourselves | |
214c4fbe | 91 | %disownarg( wxImageList *imageList ); |
d14a1e28 | 92 | void AssignImageList(wxImageList *imageList); |
214c4fbe | 93 | %cleardisown( wxImageList *imageList ); |
d14a1e28 RD |
94 | |
95 | // get pointer (may be NULL) to the associated image list | |
96 | wxImageList* GetImageList() const; | |
97 | ||
98 | // sets/returns item's image index in the current image list | |
99 | virtual int GetPageImage(size_t n) const/* = 0*/; | |
100 | virtual bool SetPageImage(size_t n, int imageId)/* = 0*/; | |
101 | ||
102 | ||
103 | // resize the notebook so that all pages will have the specified size | |
104 | virtual void SetPageSize(const wxSize& size); | |
105 | ||
106 | // calculate the size of the control from the size of its page | |
107 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/; | |
108 | ||
109 | ||
6aabc8da | 110 | // get/set size of area between book control area and page area |
68025747 RD |
111 | unsigned int GetInternalBorder() const; |
112 | void SetInternalBorder(unsigned int internalBorder); | |
6aabc8da RD |
113 | |
114 | // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style | |
115 | bool IsVertical() const; | |
116 | ||
15648073 RD |
117 | // Sets/gets the margin around the controller |
118 | void SetControlMargin(int margin); | |
119 | int GetControlMargin() const; | |
120 | ||
6aabc8da | 121 | // set/get option to shrink to fit current page |
c3f93e04 RD |
122 | void SetFitToCurrentPage(bool fit); |
123 | bool GetFitToCurrentPage() const; | |
6aabc8da | 124 | |
15648073 RD |
125 | // returns the sizer containing the control, if any |
126 | wxSizer* GetControlSizer() const; | |
127 | ||
d14a1e28 RD |
128 | |
129 | // remove one page from the control and delete it | |
130 | virtual bool DeletePage(size_t n); | |
131 | ||
132 | // remove one page from the notebook, without deleting it | |
133 | virtual bool RemovePage(size_t n); | |
134 | ||
135 | // remove all pages and delete them | |
136 | virtual bool DeleteAllPages(); | |
137 | ||
138 | // adds a new page to the control | |
139 | virtual bool AddPage(wxWindow *page, | |
140 | const wxString& text, | |
a72f4631 | 141 | bool select = false, |
d14a1e28 RD |
142 | int imageId = -1); |
143 | ||
144 | // the same as AddPage(), but adds the page at the specified position | |
145 | virtual bool InsertPage(size_t n, | |
146 | wxWindow *page, | |
147 | const wxString& text, | |
a72f4631 | 148 | bool select = false, |
d14a1e28 RD |
149 | int imageId = -1)/* = 0*/; |
150 | ||
151 | // set the currently selected page, return the index of the previously | |
152 | // selected one (or -1 on error) | |
153 | // | |
154 | // NB: this function will _not_ generate PAGE_CHANGING/ED events | |
155 | virtual int SetSelection(size_t n)/* = 0*/; | |
156 | ||
157 | ||
158 | // cycle thru the pages | |
a72f4631 | 159 | void AdvanceSelection(bool forward = true); |
880715c9 | 160 | |
45dc66f8 RD |
161 | DocDeclAStr( |
162 | virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const, | |
163 | "HitTest(Point pt) -> (tab, where)", | |
164 | "Returns the page/tab which is hit, and flags indicating where using | |
165 | wx.NB_HITTEST flags.", ""); | |
166 | ||
880715c9 RD |
167 | static wxVisualAttributes |
168 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
0eae5d09 RD |
169 | |
170 | %property(ControlMargin, GetControlMargin, SetControlMargin, doc="See `GetControlMargin` and `SetControlMargin`"); | |
171 | %property(ControlSizer, GetControlSizer, doc="See `GetControlSizer`"); | |
172 | %property(CurrentPage, GetCurrentPage, doc="See `GetCurrentPage`"); | |
173 | %property(FitToCurrentPage, GetFitToCurrentPage, SetFitToCurrentPage, doc="See `GetFitToCurrentPage` and `SetFitToCurrentPage`"); | |
174 | %property(ImageList, GetImageList, SetImageList, doc="See `GetImageList` and `SetImageList`"); | |
175 | %property(InternalBorder, GetInternalBorder, SetInternalBorder, doc="See `GetInternalBorder` and `SetInternalBorder`"); | |
176 | %property(Page, GetPage, doc="See `GetPage`"); | |
177 | %property(PageCount, GetPageCount, doc="See `GetPageCount`"); | |
178 | %property(PageImage, GetPageImage, SetPageImage, doc="See `GetPageImage` and `SetPageImage`"); | |
179 | %property(PageText, GetPageText, SetPageText, doc="See `GetPageText` and `SetPageText`"); | |
180 | %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`"); | |
181 | ||
d14a1e28 RD |
182 | }; |
183 | ||
184 | ||
185 | ||
1c272b5d | 186 | class wxBookCtrlBaseEvent : public wxNotifyEvent |
d14a1e28 RD |
187 | { |
188 | public: | |
1c272b5d | 189 | wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int id = 0, |
d14a1e28 RD |
190 | int nSel = -1, int nOldSel = -1); |
191 | ||
192 | // the currently selected page (-1 if none) | |
193 | int GetSelection() const; | |
194 | void SetSelection(int nSel); | |
195 | // the page that was selected before the change (-1 if none) | |
196 | int GetOldSelection() const; | |
197 | void SetOldSelection(int nOldSel); | |
0eae5d09 RD |
198 | |
199 | %property(OldSelection, GetOldSelection, SetOldSelection, doc="See `GetOldSelection` and `SetOldSelection`"); | |
200 | %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`"); | |
201 | ||
d14a1e28 RD |
202 | }; |
203 | ||
204 | ||
205 | ||
206 | //--------------------------------------------------------------------------- | |
207 | %newgroup | |
208 | ||
209 | enum { | |
210 | // styles | |
211 | wxNB_FIXEDWIDTH, | |
212 | wxNB_TOP, | |
213 | wxNB_LEFT, | |
214 | wxNB_RIGHT, | |
215 | wxNB_BOTTOM, | |
216 | wxNB_MULTILINE, | |
9c7d6396 | 217 | wxNB_NOPAGETHEME, |
d14a1e28 | 218 | |
d58c3ba2 RD |
219 | // for backwards compatibility only |
220 | wxNB_HITTEST_NOWHERE, | |
221 | wxNB_HITTEST_ONICON, | |
222 | wxNB_HITTEST_ONLABEL, | |
223 | wxNB_HITTEST_ONITEM, | |
224 | wxNB_HITTEST_ONPAGE, | |
d14a1e28 RD |
225 | }; |
226 | ||
227 | ||
228 | ||
ab1f7d2a RD |
229 | MustHaveApp(wxNotebook); |
230 | ||
1c272b5d | 231 | class wxNotebook : public wxBookCtrlBase { |
d14a1e28 | 232 | public: |
2b9048c5 RD |
233 | %pythonAppend wxNotebook "self._setOORInfo(self)" |
234 | %pythonAppend wxNotebook() "" | |
b39c3fa0 | 235 | %typemap(out) wxNotebook*; // turn off this typemap |
d14a1e28 RD |
236 | |
237 | wxNotebook(wxWindow *parent, | |
13baae2c | 238 | wxWindowID id=-1, |
d14a1e28 RD |
239 | const wxPoint& pos = wxDefaultPosition, |
240 | const wxSize& size = wxDefaultSize, | |
241 | long style = 0, | |
a356336e | 242 | const wxString& name = wxPyNotebookNameStr); |
1b8c7ba6 | 243 | %RenameCtor(PreNotebook, wxNotebook()); |
d14a1e28 | 244 | |
b39c3fa0 RD |
245 | // Turn it back on again |
246 | %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); } | |
247 | ||
d14a1e28 | 248 | bool Create(wxWindow *parent, |
d5573410 | 249 | wxWindowID id=-1, |
d14a1e28 RD |
250 | const wxPoint& pos = wxDefaultPosition, |
251 | const wxSize& size = wxDefaultSize, | |
252 | long style = 0, | |
a356336e | 253 | const wxString& name = wxPyNotebookNameStr); |
d14a1e28 RD |
254 | |
255 | ||
256 | // get the number of rows for a control with wxNB_MULTILINE style (not all | |
257 | // versions support it - they will always return 1 then) | |
258 | virtual int GetRowCount() const; | |
259 | ||
260 | // set the padding between tabs (in pixels) | |
261 | virtual void SetPadding(const wxSize& padding); | |
262 | ||
263 | // set the size of the tabs for wxNB_FIXEDWIDTH controls | |
264 | virtual void SetTabSize(const wxSize& sz); | |
265 | ||
d14a1e28 RD |
266 | // implement some base class functions |
267 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; | |
268 | ||
9c7d6396 RD |
269 | // On platforms that support it, get the theme page background colour, |
270 | // else invalid colour | |
271 | wxColour GetThemeBackgroundColour() const; | |
6aabc8da | 272 | |
880715c9 RD |
273 | static wxVisualAttributes |
274 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
203bfdca RD |
275 | |
276 | %property(RowCount, GetRowCount, doc="See `GetRowCount`"); | |
277 | %property(ThemeBackgroundColour, GetThemeBackgroundColour, doc="See `GetThemeBackgroundColour`"); | |
d14a1e28 RD |
278 | }; |
279 | ||
280 | ||
281 | ||
1c272b5d | 282 | class wxNotebookEvent : public wxBookCtrlBaseEvent |
d14a1e28 RD |
283 | { |
284 | public: | |
285 | wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
286 | int nSel = -1, int nOldSel = -1); | |
287 | ||
288 | }; | |
289 | ||
290 | // notebook control event types | |
291 | %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED; | |
292 | %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING; | |
293 | ||
294 | ||
295 | %pythoncode { | |
296 | %# wxNotebook events | |
297 | EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 ) | |
298 | EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 ) | |
299 | } | |
300 | ||
301 | ||
302 | %pythoncode { | |
303 | %#---------------------------------------------------------------------------- | |
304 | ||
305 | class NotebookPage(wx.Panel): | |
306 | """ | |
307 | There is an old (and apparently unsolvable) bug when placing a | |
9718d66a | 308 | window with a nonstandard background colour in a wx.Notebook on |
ac3b7152 | 309 | wxGTK1, as the notbooks's background colour would always be used |
d14a1e28 RD |
310 | when the window is refreshed. The solution is to place a panel in |
311 | the notbook and the coloured window on the panel, sized to cover | |
312 | the panel. This simple class does that for you, just put an | |
313 | instance of this in the notebook and make your regular window a | |
314 | child of this one and it will handle the resize for you. | |
315 | """ | |
316 | def __init__(self, parent, id=-1, | |
317 | pos=wx.DefaultPosition, size=wx.DefaultSize, | |
318 | style=wx.TAB_TRAVERSAL, name="panel"): | |
319 | wx.Panel.__init__(self, parent, id, pos, size, style, name) | |
320 | self.child = None | |
9718d66a | 321 | self.Bind(wx.EVT_SIZE, self.OnSize) |
9694b21a | 322 | |
d14a1e28 RD |
323 | def OnSize(self, evt): |
324 | if self.child is None: | |
325 | children = self.GetChildren() | |
326 | if len(children): | |
327 | self.child = children[0] | |
328 | if self.child: | |
329 | self.child.SetPosition((0,0)) | |
330 | self.child.SetSize(self.GetSize()) | |
331 | ||
332 | } | |
333 | ||
334 | //--------------------------------------------------------------------------- | |
335 | %newgroup | |
336 | ||
337 | ||
338 | enum | |
339 | { | |
340 | // default alignment: left everywhere except Mac where it is top | |
341 | wxLB_DEFAULT = 0, | |
342 | ||
343 | // put the list control to the left/right/top/bottom of the page area | |
344 | wxLB_TOP = 0x1, | |
345 | wxLB_BOTTOM = 0x2, | |
346 | wxLB_LEFT = 0x4, | |
347 | wxLB_RIGHT = 0x8, | |
348 | ||
349 | // the mask which can be used to extract the alignment from the style | |
350 | wxLB_ALIGN_MASK = 0xf, | |
351 | }; | |
352 | ||
353 | ||
354 | ||
ab1f7d2a RD |
355 | MustHaveApp(wxListbook); |
356 | ||
d14a1e28 | 357 | // wxListCtrl and wxNotebook combination |
1c272b5d | 358 | class wxListbook : public wxBookCtrlBase |
d14a1e28 RD |
359 | { |
360 | public: | |
2b9048c5 RD |
361 | %pythonAppend wxListbook "self._setOORInfo(self)" |
362 | %pythonAppend wxListbook() "" | |
d14a1e28 RD |
363 | |
364 | wxListbook(wxWindow *parent, | |
13baae2c | 365 | wxWindowID id=-1, |
d14a1e28 RD |
366 | const wxPoint& pos = wxDefaultPosition, |
367 | const wxSize& size = wxDefaultSize, | |
368 | long style = 0, | |
369 | const wxString& name = wxPyEmptyString); | |
1b8c7ba6 | 370 | %RenameCtor(PreListbook, wxListbook()); |
d14a1e28 RD |
371 | |
372 | bool Create(wxWindow *parent, | |
d5573410 | 373 | wxWindowID id=-1, |
d14a1e28 RD |
374 | const wxPoint& pos = wxDefaultPosition, |
375 | const wxSize& size = wxDefaultSize, | |
376 | long style = 0, | |
377 | const wxString& name = wxPyEmptyString); | |
378 | ||
9694b21a | 379 | wxListView* GetListView(); |
76b8fa1d | 380 | %property(ListView, GetListView, doc="See `GetListView`"); |
d14a1e28 RD |
381 | }; |
382 | ||
383 | ||
384 | ||
1c272b5d | 385 | class wxListbookEvent : public wxBookCtrlBaseEvent |
d14a1e28 RD |
386 | { |
387 | public: | |
388 | wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
389 | int nSel = -1, int nOldSel = -1); | |
390 | }; | |
391 | ||
392 | ||
393 | %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED; | |
394 | %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING; | |
395 | ||
396 | %pythoncode { | |
397 | EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 ) | |
398 | EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 ) | |
399 | } | |
400 | ||
401 | ||
9694b21a RD |
402 | //--------------------------------------------------------------------------- |
403 | ||
9694b21a RD |
404 | |
405 | /* | |
406 | * wxChoicebook flags | |
407 | */ | |
408 | enum { | |
409 | wxCHB_DEFAULT, | |
410 | wxCHB_TOP, | |
411 | wxCHB_BOTTOM, | |
412 | wxCHB_LEFT, | |
413 | wxCHB_RIGHT, | |
414 | wxCHB_ALIGN_MASK | |
415 | }; | |
416 | ||
417 | ||
418 | MustHaveApp(wxChoicebook); | |
419 | ||
1c272b5d | 420 | class wxChoicebook : public wxBookCtrlBase |
9694b21a RD |
421 | { |
422 | public: | |
423 | %pythonAppend wxChoicebook "self._setOORInfo(self)" | |
424 | %pythonAppend wxChoicebook() "" | |
425 | ||
426 | wxChoicebook(wxWindow *parent, | |
427 | wxWindowID id, | |
428 | const wxPoint& pos = wxDefaultPosition, | |
429 | const wxSize& size = wxDefaultSize, | |
430 | long style = 0, | |
431 | const wxString& name = wxPyEmptyString); | |
1b8c7ba6 | 432 | %RenameCtor(PreChoicebook, wxChoicebook()); |
9694b21a RD |
433 | |
434 | // quasi ctor | |
435 | bool Create(wxWindow *parent, | |
436 | wxWindowID id, | |
437 | const wxPoint& pos = wxDefaultPosition, | |
438 | const wxSize& size = wxDefaultSize, | |
439 | long style = 0, | |
440 | const wxString& name = wxPyEmptyString); | |
441 | ||
442 | ||
88609ec9 RD |
443 | // returns the choice control |
444 | wxChoice* GetChoiceCtrl() const; | |
9694b21a RD |
445 | |
446 | virtual bool DeleteAllPages(); | |
0eae5d09 RD |
447 | |
448 | %property(ChoiceCtrl, GetChoiceCtrl, doc="See `GetChoiceCtrl`"); | |
449 | ||
9694b21a RD |
450 | }; |
451 | ||
452 | ||
1c272b5d | 453 | class wxChoicebookEvent : public wxBookCtrlBaseEvent |
9694b21a RD |
454 | { |
455 | public: | |
456 | wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
457 | int nSel = -1, int nOldSel = -1); | |
458 | }; | |
459 | ||
460 | %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED; | |
461 | %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING; | |
462 | ||
463 | %pythoncode { | |
464 | EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 ) | |
465 | EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 ) | |
466 | } | |
467 | ||
d14a1e28 RD |
468 | //--------------------------------------------------------------------------- |
469 | %newgroup; | |
470 | ||
6aabc8da RD |
471 | MustHaveApp(wxTreebook); |
472 | ||
473 | class wxTreebook : public wxBookCtrlBase | |
d14a1e28 RD |
474 | { |
475 | public: | |
6aabc8da RD |
476 | %pythonAppend wxTreebook "self._setOORInfo(self)" |
477 | %pythonAppend wxTreebook() "" | |
478 | ||
479 | ||
480 | // This ctor creates the tree book control | |
481 | wxTreebook(wxWindow *parent, | |
482 | wxWindowID id, | |
483 | const wxPoint& pos = wxDefaultPosition, | |
484 | const wxSize& size = wxDefaultSize, | |
485 | long style = wxBK_DEFAULT, | |
486 | const wxString& name = wxPyEmptyString); | |
487 | ||
488 | %RenameCtor(PreTreebook, wxTreebook()); | |
489 | ||
490 | ||
491 | // Really creates the control | |
492 | bool Create(wxWindow *parent, | |
493 | wxWindowID id, | |
494 | const wxPoint& pos = wxDefaultPosition, | |
495 | const wxSize& size = wxDefaultSize, | |
496 | long style = wxBK_DEFAULT, | |
497 | const wxString& name = wxPyEmptyString); | |
498 | ||
499 | ||
500 | // Notice that page pointer may be NULL in which case the next non NULL | |
501 | // page (usually the first child page of a node) is shown when this page is | |
502 | // selected | |
503 | ||
504 | // Inserts a new page just before the page indicated by page. | |
505 | // The new page is placed on the same level as page. | |
506 | virtual bool InsertPage(size_t pos, | |
507 | wxWindow *page, | |
508 | const wxString& text, | |
509 | bool select = false, | |
510 | int imageId = wxNOT_FOUND); | |
511 | ||
512 | // Inserts a new sub-page to the end of children of the page at given pos. | |
1d9bb35f RD |
513 | virtual bool InsertSubPage(size_t pos, |
514 | wxWindow *page, | |
515 | const wxString& text, | |
516 | bool select = false, | |
517 | int imageId = wxNOT_FOUND); | |
6aabc8da RD |
518 | |
519 | // Adds a new page at top level after all other pages. | |
520 | virtual bool AddPage(wxWindow *page, | |
521 | const wxString& text, | |
522 | bool select = false, | |
523 | int imageId = wxNOT_FOUND); | |
524 | ||
525 | // Adds a new child-page to the last top-level page inserted. | |
526 | // Useful when constructing 1 level tree structure. | |
527 | virtual bool AddSubPage(wxWindow *page, | |
528 | const wxString& text, | |
529 | bool select = false, | |
530 | int imageId = wxNOT_FOUND); | |
531 | ||
532 | // Deletes the page and ALL its children. Could trigger page selection | |
533 | // change in a case when selected page is removed. In that case its parent | |
534 | // is selected (or the next page if no parent). | |
535 | virtual bool DeletePage(size_t pos); | |
d14a1e28 | 536 | |
9694b21a | 537 | |
6aabc8da RD |
538 | // Tree operations |
539 | // --------------- | |
540 | ||
541 | // Gets the page node state -- node is expanded or collapsed | |
542 | virtual bool IsNodeExpanded(size_t pos) const; | |
543 | ||
544 | // Expands or collapses the page node. Returns the previous state. | |
545 | // May generate page changing events (if selected page | |
546 | // is under the collapsed branch, then parent is autoselected). | |
547 | virtual bool ExpandNode(size_t pos, bool expand = true); | |
548 | ||
549 | // shortcut for ExpandNode(pos, false) | |
550 | bool CollapseNode(size_t pos); | |
551 | ||
552 | // get the parent page or wxNOT_FOUND if this is a top level page | |
553 | int GetPageParent(size_t pos) const; | |
554 | ||
555 | // the tree control we use for showing the pages index tree | |
20eebe1a | 556 | wxPyTreeCtrl* GetTreeCtrl() const; |
6aabc8da | 557 | |
994453b8 | 558 | %property(TreeCtrl, GetTreeCtrl, doc="See `GetTreeCtrl`"); |
6aabc8da RD |
559 | }; |
560 | ||
561 | ||
562 | class wxTreebookEvent : public wxBookCtrlBaseEvent | |
563 | { | |
564 | public: | |
565 | wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
566 | int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND); | |
d14a1e28 RD |
567 | }; |
568 | ||
6aabc8da RD |
569 | %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED; |
570 | %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING; | |
571 | %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED; | |
572 | %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED; | |
d14a1e28 | 573 | |
6aabc8da RD |
574 | |
575 | %pythoncode { | |
576 | EVT_TREEBOOK_PAGE_CHANGED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, 1 ) | |
577 | EVT_TREEBOOK_PAGE_CHANGING= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, 1) | |
578 | EVT_TREEBOOK_NODE_COLLAPSED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, 1 ) | |
579 | EVT_TREEBOOK_NODE_EXPANDED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, 1 ) | |
580 | } | |
581 | ||
582 | //--------------------------------------------------------------------------- | |
583 | %newgroup; | |
584 | ||
585 | MustHaveApp(wxTreebook); | |
586 | ||
587 | class wxToolbook : public wxBookCtrlBase | |
588 | { | |
d14a1e28 | 589 | public: |
6aabc8da RD |
590 | %pythonAppend wxToolbook "self._setOORInfo(self)" |
591 | %pythonAppend wxToolbook() "" | |
592 | ||
593 | ||
594 | // This ctor creates the tree book control | |
595 | wxToolbook(wxWindow *parent, | |
596 | wxWindowID id, | |
597 | const wxPoint& pos = wxDefaultPosition, | |
598 | const wxSize& size = wxDefaultSize, | |
599 | long style = wxBK_DEFAULT, | |
600 | const wxString& name = wxPyEmptyString); | |
601 | ||
602 | %RenameCtor(PreToolbook, wxToolbook()); | |
603 | ||
604 | // quasi ctor | |
605 | bool Create(wxWindow *parent, | |
606 | wxWindowID id, | |
607 | const wxPoint& pos = wxDefaultPosition, | |
608 | const wxSize& size = wxDefaultSize, | |
609 | long style = 0, | |
610 | const wxString& name = wxEmptyString); | |
d14a1e28 | 611 | |
9694b21a | 612 | |
6aabc8da RD |
613 | wxToolBarBase* GetToolBar() const; |
614 | ||
615 | // Not part of the wxBookctrl API, but must be called in OnIdle or | |
616 | // by application to realize the toolbar and select the initial page. | |
617 | void Realize(); | |
994453b8 RD |
618 | |
619 | %property(ToolBar, GetToolBar, doc="See `GetToolBar`"); | |
6aabc8da RD |
620 | }; |
621 | ||
622 | ||
623 | class wxToolbookEvent : public wxBookCtrlBaseEvent | |
624 | { | |
625 | public: | |
626 | wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
627 | int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND); | |
d14a1e28 RD |
628 | }; |
629 | ||
6aabc8da RD |
630 | |
631 | %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED; | |
632 | %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING; | |
633 | ||
634 | ||
635 | %pythoncode { | |
636 | EVT_TOOLBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, 1) | |
637 | EVT_TOOLBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, 1) | |
638 | } | |
496d695b | 639 | |
d14a1e28 | 640 | //--------------------------------------------------------------------------- |