]>
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 | ||
6c2dd16f RD |
157 | |
158 | // acts as SetSelection but does not generate events | |
159 | virtual int ChangeSelection(size_t n)/* = 0*/; | |
d14a1e28 RD |
160 | |
161 | // cycle thru the pages | |
a72f4631 | 162 | void AdvanceSelection(bool forward = true); |
880715c9 | 163 | |
45dc66f8 RD |
164 | DocDeclAStr( |
165 | virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const, | |
166 | "HitTest(Point pt) -> (tab, where)", | |
167 | "Returns the page/tab which is hit, and flags indicating where using | |
168 | wx.NB_HITTEST flags.", ""); | |
169 | ||
880715c9 RD |
170 | static wxVisualAttributes |
171 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
0eae5d09 RD |
172 | |
173 | %property(ControlMargin, GetControlMargin, SetControlMargin, doc="See `GetControlMargin` and `SetControlMargin`"); | |
174 | %property(ControlSizer, GetControlSizer, doc="See `GetControlSizer`"); | |
175 | %property(CurrentPage, GetCurrentPage, doc="See `GetCurrentPage`"); | |
176 | %property(FitToCurrentPage, GetFitToCurrentPage, SetFitToCurrentPage, doc="See `GetFitToCurrentPage` and `SetFitToCurrentPage`"); | |
177 | %property(ImageList, GetImageList, SetImageList, doc="See `GetImageList` and `SetImageList`"); | |
178 | %property(InternalBorder, GetInternalBorder, SetInternalBorder, doc="See `GetInternalBorder` and `SetInternalBorder`"); | |
179 | %property(Page, GetPage, doc="See `GetPage`"); | |
180 | %property(PageCount, GetPageCount, doc="See `GetPageCount`"); | |
181 | %property(PageImage, GetPageImage, SetPageImage, doc="See `GetPageImage` and `SetPageImage`"); | |
182 | %property(PageText, GetPageText, SetPageText, doc="See `GetPageText` and `SetPageText`"); | |
183 | %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`"); | |
184 | ||
d14a1e28 RD |
185 | }; |
186 | ||
187 | ||
188 | ||
1c272b5d | 189 | class wxBookCtrlBaseEvent : public wxNotifyEvent |
d14a1e28 RD |
190 | { |
191 | public: | |
1c272b5d | 192 | wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int id = 0, |
d14a1e28 RD |
193 | int nSel = -1, int nOldSel = -1); |
194 | ||
195 | // the currently selected page (-1 if none) | |
196 | int GetSelection() const; | |
197 | void SetSelection(int nSel); | |
198 | // the page that was selected before the change (-1 if none) | |
199 | int GetOldSelection() const; | |
200 | void SetOldSelection(int nOldSel); | |
0eae5d09 RD |
201 | |
202 | %property(OldSelection, GetOldSelection, SetOldSelection, doc="See `GetOldSelection` and `SetOldSelection`"); | |
203 | %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`"); | |
204 | ||
d14a1e28 RD |
205 | }; |
206 | ||
207 | ||
208 | ||
209 | //--------------------------------------------------------------------------- | |
210 | %newgroup | |
211 | ||
212 | enum { | |
213 | // styles | |
214 | wxNB_FIXEDWIDTH, | |
215 | wxNB_TOP, | |
216 | wxNB_LEFT, | |
217 | wxNB_RIGHT, | |
218 | wxNB_BOTTOM, | |
219 | wxNB_MULTILINE, | |
9c7d6396 | 220 | wxNB_NOPAGETHEME, |
d14a1e28 | 221 | |
d58c3ba2 RD |
222 | // for backwards compatibility only |
223 | wxNB_HITTEST_NOWHERE, | |
224 | wxNB_HITTEST_ONICON, | |
225 | wxNB_HITTEST_ONLABEL, | |
226 | wxNB_HITTEST_ONITEM, | |
227 | wxNB_HITTEST_ONPAGE, | |
d14a1e28 RD |
228 | }; |
229 | ||
230 | ||
231 | ||
ab1f7d2a RD |
232 | MustHaveApp(wxNotebook); |
233 | ||
1c272b5d | 234 | class wxNotebook : public wxBookCtrlBase { |
d14a1e28 | 235 | public: |
2b9048c5 RD |
236 | %pythonAppend wxNotebook "self._setOORInfo(self)" |
237 | %pythonAppend wxNotebook() "" | |
b39c3fa0 | 238 | %typemap(out) wxNotebook*; // turn off this typemap |
d14a1e28 RD |
239 | |
240 | wxNotebook(wxWindow *parent, | |
13baae2c | 241 | wxWindowID id=-1, |
d14a1e28 RD |
242 | const wxPoint& pos = wxDefaultPosition, |
243 | const wxSize& size = wxDefaultSize, | |
244 | long style = 0, | |
a356336e | 245 | const wxString& name = wxPyNotebookNameStr); |
1b8c7ba6 | 246 | %RenameCtor(PreNotebook, wxNotebook()); |
d14a1e28 | 247 | |
b39c3fa0 RD |
248 | // Turn it back on again |
249 | %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); } | |
250 | ||
d14a1e28 | 251 | bool Create(wxWindow *parent, |
d5573410 | 252 | wxWindowID id=-1, |
d14a1e28 RD |
253 | const wxPoint& pos = wxDefaultPosition, |
254 | const wxSize& size = wxDefaultSize, | |
255 | long style = 0, | |
a356336e | 256 | const wxString& name = wxPyNotebookNameStr); |
d14a1e28 RD |
257 | |
258 | ||
259 | // get the number of rows for a control with wxNB_MULTILINE style (not all | |
260 | // versions support it - they will always return 1 then) | |
261 | virtual int GetRowCount() const; | |
262 | ||
263 | // set the padding between tabs (in pixels) | |
264 | virtual void SetPadding(const wxSize& padding); | |
265 | ||
266 | // set the size of the tabs for wxNB_FIXEDWIDTH controls | |
267 | virtual void SetTabSize(const wxSize& sz); | |
268 | ||
d14a1e28 RD |
269 | // implement some base class functions |
270 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; | |
271 | ||
9c7d6396 RD |
272 | // On platforms that support it, get the theme page background colour, |
273 | // else invalid colour | |
274 | wxColour GetThemeBackgroundColour() const; | |
6aabc8da | 275 | |
880715c9 RD |
276 | static wxVisualAttributes |
277 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
203bfdca | 278 | |
6c2dd16f RD |
279 | // returns false if the change to nPage is vetoed by the program |
280 | bool SendPageChangingEvent(int nPage); | |
281 | ||
282 | // sends the event about page change from old to new (or GetSelection() if | |
283 | // new is -1) | |
284 | void SendPageChangedEvent(int nPageOld, int nPageNew = -1); | |
285 | ||
203bfdca RD |
286 | %property(RowCount, GetRowCount, doc="See `GetRowCount`"); |
287 | %property(ThemeBackgroundColour, GetThemeBackgroundColour, doc="See `GetThemeBackgroundColour`"); | |
d14a1e28 RD |
288 | }; |
289 | ||
290 | ||
291 | ||
1c272b5d | 292 | class wxNotebookEvent : public wxBookCtrlBaseEvent |
d14a1e28 RD |
293 | { |
294 | public: | |
295 | wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
296 | int nSel = -1, int nOldSel = -1); | |
297 | ||
298 | }; | |
299 | ||
300 | // notebook control event types | |
301 | %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED; | |
302 | %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING; | |
303 | ||
304 | ||
305 | %pythoncode { | |
306 | %# wxNotebook events | |
307 | EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 ) | |
308 | EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 ) | |
309 | } | |
310 | ||
311 | ||
312 | %pythoncode { | |
313 | %#---------------------------------------------------------------------------- | |
314 | ||
315 | class NotebookPage(wx.Panel): | |
316 | """ | |
317 | There is an old (and apparently unsolvable) bug when placing a | |
9718d66a | 318 | window with a nonstandard background colour in a wx.Notebook on |
ac3b7152 | 319 | wxGTK1, as the notbooks's background colour would always be used |
d14a1e28 RD |
320 | when the window is refreshed. The solution is to place a panel in |
321 | the notbook and the coloured window on the panel, sized to cover | |
322 | the panel. This simple class does that for you, just put an | |
323 | instance of this in the notebook and make your regular window a | |
324 | child of this one and it will handle the resize for you. | |
325 | """ | |
326 | def __init__(self, parent, id=-1, | |
327 | pos=wx.DefaultPosition, size=wx.DefaultSize, | |
328 | style=wx.TAB_TRAVERSAL, name="panel"): | |
329 | wx.Panel.__init__(self, parent, id, pos, size, style, name) | |
330 | self.child = None | |
9718d66a | 331 | self.Bind(wx.EVT_SIZE, self.OnSize) |
9694b21a | 332 | |
d14a1e28 RD |
333 | def OnSize(self, evt): |
334 | if self.child is None: | |
335 | children = self.GetChildren() | |
336 | if len(children): | |
337 | self.child = children[0] | |
338 | if self.child: | |
339 | self.child.SetPosition((0,0)) | |
340 | self.child.SetSize(self.GetSize()) | |
341 | ||
342 | } | |
343 | ||
344 | //--------------------------------------------------------------------------- | |
345 | %newgroup | |
346 | ||
347 | ||
348 | enum | |
349 | { | |
350 | // default alignment: left everywhere except Mac where it is top | |
351 | wxLB_DEFAULT = 0, | |
352 | ||
353 | // put the list control to the left/right/top/bottom of the page area | |
354 | wxLB_TOP = 0x1, | |
355 | wxLB_BOTTOM = 0x2, | |
356 | wxLB_LEFT = 0x4, | |
357 | wxLB_RIGHT = 0x8, | |
358 | ||
359 | // the mask which can be used to extract the alignment from the style | |
360 | wxLB_ALIGN_MASK = 0xf, | |
361 | }; | |
362 | ||
363 | ||
364 | ||
ab1f7d2a RD |
365 | MustHaveApp(wxListbook); |
366 | ||
d14a1e28 | 367 | // wxListCtrl and wxNotebook combination |
1c272b5d | 368 | class wxListbook : public wxBookCtrlBase |
d14a1e28 RD |
369 | { |
370 | public: | |
2b9048c5 RD |
371 | %pythonAppend wxListbook "self._setOORInfo(self)" |
372 | %pythonAppend wxListbook() "" | |
d14a1e28 RD |
373 | |
374 | wxListbook(wxWindow *parent, | |
13baae2c | 375 | wxWindowID id=-1, |
d14a1e28 RD |
376 | const wxPoint& pos = wxDefaultPosition, |
377 | const wxSize& size = wxDefaultSize, | |
378 | long style = 0, | |
379 | const wxString& name = wxPyEmptyString); | |
1b8c7ba6 | 380 | %RenameCtor(PreListbook, wxListbook()); |
d14a1e28 RD |
381 | |
382 | bool Create(wxWindow *parent, | |
d5573410 | 383 | wxWindowID id=-1, |
d14a1e28 RD |
384 | const wxPoint& pos = wxDefaultPosition, |
385 | const wxSize& size = wxDefaultSize, | |
386 | long style = 0, | |
387 | const wxString& name = wxPyEmptyString); | |
388 | ||
9694b21a | 389 | wxListView* GetListView(); |
76b8fa1d | 390 | %property(ListView, GetListView, doc="See `GetListView`"); |
d14a1e28 RD |
391 | }; |
392 | ||
393 | ||
394 | ||
1c272b5d | 395 | class wxListbookEvent : public wxBookCtrlBaseEvent |
d14a1e28 RD |
396 | { |
397 | public: | |
398 | wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
399 | int nSel = -1, int nOldSel = -1); | |
400 | }; | |
401 | ||
402 | ||
403 | %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED; | |
404 | %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING; | |
405 | ||
406 | %pythoncode { | |
407 | EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 ) | |
408 | EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 ) | |
409 | } | |
410 | ||
411 | ||
9694b21a RD |
412 | //--------------------------------------------------------------------------- |
413 | ||
9694b21a RD |
414 | |
415 | /* | |
416 | * wxChoicebook flags | |
417 | */ | |
418 | enum { | |
419 | wxCHB_DEFAULT, | |
420 | wxCHB_TOP, | |
421 | wxCHB_BOTTOM, | |
422 | wxCHB_LEFT, | |
423 | wxCHB_RIGHT, | |
424 | wxCHB_ALIGN_MASK | |
425 | }; | |
426 | ||
427 | ||
428 | MustHaveApp(wxChoicebook); | |
429 | ||
1c272b5d | 430 | class wxChoicebook : public wxBookCtrlBase |
9694b21a RD |
431 | { |
432 | public: | |
433 | %pythonAppend wxChoicebook "self._setOORInfo(self)" | |
434 | %pythonAppend wxChoicebook() "" | |
435 | ||
436 | wxChoicebook(wxWindow *parent, | |
437 | wxWindowID id, | |
438 | const wxPoint& pos = wxDefaultPosition, | |
439 | const wxSize& size = wxDefaultSize, | |
440 | long style = 0, | |
441 | const wxString& name = wxPyEmptyString); | |
1b8c7ba6 | 442 | %RenameCtor(PreChoicebook, wxChoicebook()); |
9694b21a RD |
443 | |
444 | // quasi ctor | |
445 | bool Create(wxWindow *parent, | |
446 | wxWindowID id, | |
447 | const wxPoint& pos = wxDefaultPosition, | |
448 | const wxSize& size = wxDefaultSize, | |
449 | long style = 0, | |
450 | const wxString& name = wxPyEmptyString); | |
451 | ||
452 | ||
88609ec9 RD |
453 | // returns the choice control |
454 | wxChoice* GetChoiceCtrl() const; | |
9694b21a RD |
455 | |
456 | virtual bool DeleteAllPages(); | |
0eae5d09 RD |
457 | |
458 | %property(ChoiceCtrl, GetChoiceCtrl, doc="See `GetChoiceCtrl`"); | |
459 | ||
9694b21a RD |
460 | }; |
461 | ||
462 | ||
1c272b5d | 463 | class wxChoicebookEvent : public wxBookCtrlBaseEvent |
9694b21a RD |
464 | { |
465 | public: | |
466 | wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
467 | int nSel = -1, int nOldSel = -1); | |
468 | }; | |
469 | ||
470 | %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED; | |
471 | %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING; | |
472 | ||
473 | %pythoncode { | |
474 | EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 ) | |
475 | EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 ) | |
476 | } | |
477 | ||
d14a1e28 RD |
478 | //--------------------------------------------------------------------------- |
479 | %newgroup; | |
480 | ||
6aabc8da RD |
481 | MustHaveApp(wxTreebook); |
482 | ||
483 | class wxTreebook : public wxBookCtrlBase | |
d14a1e28 RD |
484 | { |
485 | public: | |
6aabc8da RD |
486 | %pythonAppend wxTreebook "self._setOORInfo(self)" |
487 | %pythonAppend wxTreebook() "" | |
488 | ||
489 | ||
490 | // This ctor creates the tree book control | |
491 | wxTreebook(wxWindow *parent, | |
492 | wxWindowID id, | |
493 | const wxPoint& pos = wxDefaultPosition, | |
494 | const wxSize& size = wxDefaultSize, | |
495 | long style = wxBK_DEFAULT, | |
496 | const wxString& name = wxPyEmptyString); | |
497 | ||
498 | %RenameCtor(PreTreebook, wxTreebook()); | |
499 | ||
500 | ||
501 | // Really creates the control | |
502 | bool Create(wxWindow *parent, | |
503 | wxWindowID id, | |
504 | const wxPoint& pos = wxDefaultPosition, | |
505 | const wxSize& size = wxDefaultSize, | |
506 | long style = wxBK_DEFAULT, | |
507 | const wxString& name = wxPyEmptyString); | |
508 | ||
509 | ||
510 | // Notice that page pointer may be NULL in which case the next non NULL | |
511 | // page (usually the first child page of a node) is shown when this page is | |
512 | // selected | |
513 | ||
514 | // Inserts a new page just before the page indicated by page. | |
515 | // The new page is placed on the same level as page. | |
516 | virtual bool InsertPage(size_t pos, | |
517 | wxWindow *page, | |
518 | const wxString& text, | |
519 | bool select = false, | |
520 | int imageId = wxNOT_FOUND); | |
521 | ||
522 | // Inserts a new sub-page to the end of children of the page at given pos. | |
1d9bb35f RD |
523 | virtual bool InsertSubPage(size_t pos, |
524 | wxWindow *page, | |
525 | const wxString& text, | |
526 | bool select = false, | |
527 | int imageId = wxNOT_FOUND); | |
6aabc8da RD |
528 | |
529 | // Adds a new page at top level after all other pages. | |
530 | virtual bool AddPage(wxWindow *page, | |
531 | const wxString& text, | |
532 | bool select = false, | |
533 | int imageId = wxNOT_FOUND); | |
534 | ||
535 | // Adds a new child-page to the last top-level page inserted. | |
536 | // Useful when constructing 1 level tree structure. | |
537 | virtual bool AddSubPage(wxWindow *page, | |
538 | const wxString& text, | |
539 | bool select = false, | |
540 | int imageId = wxNOT_FOUND); | |
541 | ||
542 | // Deletes the page and ALL its children. Could trigger page selection | |
543 | // change in a case when selected page is removed. In that case its parent | |
544 | // is selected (or the next page if no parent). | |
545 | virtual bool DeletePage(size_t pos); | |
d14a1e28 | 546 | |
9694b21a | 547 | |
6aabc8da RD |
548 | // Tree operations |
549 | // --------------- | |
550 | ||
551 | // Gets the page node state -- node is expanded or collapsed | |
552 | virtual bool IsNodeExpanded(size_t pos) const; | |
553 | ||
554 | // Expands or collapses the page node. Returns the previous state. | |
555 | // May generate page changing events (if selected page | |
556 | // is under the collapsed branch, then parent is autoselected). | |
557 | virtual bool ExpandNode(size_t pos, bool expand = true); | |
558 | ||
559 | // shortcut for ExpandNode(pos, false) | |
560 | bool CollapseNode(size_t pos); | |
561 | ||
562 | // get the parent page or wxNOT_FOUND if this is a top level page | |
563 | int GetPageParent(size_t pos) const; | |
564 | ||
565 | // the tree control we use for showing the pages index tree | |
20eebe1a | 566 | wxPyTreeCtrl* GetTreeCtrl() const; |
6aabc8da | 567 | |
994453b8 | 568 | %property(TreeCtrl, GetTreeCtrl, doc="See `GetTreeCtrl`"); |
6aabc8da RD |
569 | }; |
570 | ||
571 | ||
572 | class wxTreebookEvent : public wxBookCtrlBaseEvent | |
573 | { | |
574 | public: | |
575 | wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
576 | int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND); | |
d14a1e28 RD |
577 | }; |
578 | ||
6aabc8da RD |
579 | %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED; |
580 | %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING; | |
581 | %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED; | |
582 | %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED; | |
d14a1e28 | 583 | |
6aabc8da RD |
584 | |
585 | %pythoncode { | |
586 | EVT_TREEBOOK_PAGE_CHANGED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, 1 ) | |
587 | EVT_TREEBOOK_PAGE_CHANGING= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, 1) | |
588 | EVT_TREEBOOK_NODE_COLLAPSED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, 1 ) | |
589 | EVT_TREEBOOK_NODE_EXPANDED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, 1 ) | |
590 | } | |
591 | ||
592 | //--------------------------------------------------------------------------- | |
593 | %newgroup; | |
594 | ||
595 | MustHaveApp(wxTreebook); | |
596 | ||
597 | class wxToolbook : public wxBookCtrlBase | |
598 | { | |
d14a1e28 | 599 | public: |
6aabc8da RD |
600 | %pythonAppend wxToolbook "self._setOORInfo(self)" |
601 | %pythonAppend wxToolbook() "" | |
602 | ||
603 | ||
604 | // This ctor creates the tree book control | |
605 | wxToolbook(wxWindow *parent, | |
606 | wxWindowID id, | |
607 | const wxPoint& pos = wxDefaultPosition, | |
608 | const wxSize& size = wxDefaultSize, | |
609 | long style = wxBK_DEFAULT, | |
610 | const wxString& name = wxPyEmptyString); | |
611 | ||
612 | %RenameCtor(PreToolbook, wxToolbook()); | |
613 | ||
614 | // quasi ctor | |
615 | bool Create(wxWindow *parent, | |
616 | wxWindowID id, | |
617 | const wxPoint& pos = wxDefaultPosition, | |
618 | const wxSize& size = wxDefaultSize, | |
619 | long style = 0, | |
620 | const wxString& name = wxEmptyString); | |
d14a1e28 | 621 | |
9694b21a | 622 | |
6aabc8da RD |
623 | wxToolBarBase* GetToolBar() const; |
624 | ||
625 | // Not part of the wxBookctrl API, but must be called in OnIdle or | |
626 | // by application to realize the toolbar and select the initial page. | |
627 | void Realize(); | |
994453b8 RD |
628 | |
629 | %property(ToolBar, GetToolBar, doc="See `GetToolBar`"); | |
6aabc8da RD |
630 | }; |
631 | ||
632 | ||
633 | class wxToolbookEvent : public wxBookCtrlBaseEvent | |
634 | { | |
635 | public: | |
636 | wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
637 | int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND); | |
d14a1e28 RD |
638 | }; |
639 | ||
6aabc8da RD |
640 | |
641 | %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED; | |
642 | %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING; | |
643 | ||
644 | ||
645 | %pythoncode { | |
646 | EVT_TOOLBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, 1) | |
647 | EVT_TOOLBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, 1) | |
648 | } | |
496d695b | 649 | |
d14a1e28 | 650 | //--------------------------------------------------------------------------- |