1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface defs for wxNotebook and such
7 // Created: 2-June-1998
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
18 MAKE_CONST_WXSTRING(NotebookNameStr);
20 //---------------------------------------------------------------------------
35 // TODO: Virtualize this class so other book controls can be derived in Python
37 MustHaveApp(wxBookCtrlBase);
39 // Common base class for wxList/Tree/Notebook
40 class wxBookCtrlBase : public wxControl
43 // This is an ABC, it can't be constructed...
45 // wxBookCtrlBase(wxWindow *parent,
47 // const wxPoint& pos = wxDefaultPosition,
48 // const wxSize& size = wxDefaultSize,
50 // const wxString& name = wxPyEmptyString);
51 // %RenameCtor(PreBookCtrlBase, wxBookCtrlBase());
52 // bool Create(wxWindow *parent,
54 // const wxPoint& pos = wxDefaultPosition,
55 // const wxSize& size = wxDefaultSize,
57 // const wxString& name = wxPyEmptyString);
60 // get number of pages in the dialog
61 virtual size_t GetPageCount() const;
63 // get the panel which represents the given page
64 virtual wxWindow *GetPage(size_t n);
66 // get the current page or NULL if none
67 wxWindow* GetCurrentPage() const;
69 // get the currently selected page or wxNOT_FOUND if none
70 virtual int GetSelection() const/* = 0*/;
72 // set/get the title of a page
73 virtual bool SetPageText(size_t n, const wxString& strText)/* = 0*/;
74 virtual wxString GetPageText(size_t n) const/* = 0*/;
77 // image list stuff: each page may have an image associated with it (all
78 // images belong to the same image list)
80 // sets the image list to use, it is *not* deleted by the control
81 virtual void SetImageList(wxImageList *imageList);
83 // as SetImageList() but we will delete the image list ourselves
84 %disownarg( wxImageList *imageList );
85 void AssignImageList(wxImageList *imageList);
86 %cleardisown( wxImageList *imageList );
88 // get pointer (may be NULL) to the associated image list
89 wxImageList* GetImageList() const;
91 // sets/returns item's image index in the current image list
92 virtual int GetPageImage(size_t n) const/* = 0*/;
93 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
96 // resize the notebook so that all pages will have the specified size
97 virtual void SetPageSize(const wxSize& size);
99 // calculate the size of the control from the size of its page
100 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
103 // get/set size of area between book control area and page area
104 unsigned int GetInternalBorder() const;
105 void SetInternalBorder(unsigned int internalBorder);
107 // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
108 bool IsVertical() const;
110 // Sets/gets the margin around the controller
111 void SetControlMargin(int margin);
112 int GetControlMargin() const;
114 // set/get option to shrink to fit current page
115 void SetFitToCurrentPage(bool fit);
116 bool GetFitToCurrentPage() const;
118 // returns the sizer containing the control, if any
119 wxSizer* GetControlSizer() const;
122 // remove one page from the control and delete it
123 virtual bool DeletePage(size_t n);
125 // remove one page from the notebook, without deleting it
126 virtual bool RemovePage(size_t n);
128 // remove all pages and delete them
129 virtual bool DeleteAllPages();
131 // adds a new page to the control
132 virtual bool AddPage(wxWindow *page,
133 const wxString& text,
137 // the same as AddPage(), but adds the page at the specified position
138 virtual bool InsertPage(size_t n,
140 const wxString& text,
142 int imageId = -1)/* = 0*/;
144 // set the currently selected page, return the index of the previously
145 // selected one (or -1 on error)
147 // NB: this function will _not_ generate PAGE_CHANGING/ED events
148 virtual int SetSelection(size_t n)/* = 0*/;
151 // cycle thru the pages
152 void AdvanceSelection(bool forward = true);
154 static wxVisualAttributes
155 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
160 class wxBookCtrlBaseEvent : public wxNotifyEvent
163 wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
164 int nSel = -1, int nOldSel = -1);
166 // the currently selected page (-1 if none)
167 int GetSelection() const;
168 void SetSelection(int nSel);
169 // the page that was selected before the change (-1 if none)
170 int GetOldSelection() const;
171 void SetOldSelection(int nOldSel);
176 //---------------------------------------------------------------------------
190 wxNB_HITTEST_NOWHERE = 1, // not on tab
191 wxNB_HITTEST_ONICON = 2, // on icon
192 wxNB_HITTEST_ONLABEL = 4, // on label
193 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
199 MustHaveApp(wxNotebook);
201 class wxNotebook : public wxBookCtrlBase {
203 %pythonAppend wxNotebook "self._setOORInfo(self)"
204 %pythonAppend wxNotebook() ""
205 %typemap(out) wxNotebook*; // turn off this typemap
207 wxNotebook(wxWindow *parent,
209 const wxPoint& pos = wxDefaultPosition,
210 const wxSize& size = wxDefaultSize,
212 const wxString& name = wxPyNotebookNameStr);
213 %RenameCtor(PreNotebook, wxNotebook());
215 // Turn it back on again
216 %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); }
218 bool Create(wxWindow *parent,
220 const wxPoint& pos = wxDefaultPosition,
221 const wxSize& size = wxDefaultSize,
223 const wxString& name = wxPyNotebookNameStr);
226 // get the number of rows for a control with wxNB_MULTILINE style (not all
227 // versions support it - they will always return 1 then)
228 virtual int GetRowCount() const;
230 // set the padding between tabs (in pixels)
231 virtual void SetPadding(const wxSize& padding);
233 // set the size of the tabs for wxNB_FIXEDWIDTH controls
234 virtual void SetTabSize(const wxSize& sz);
236 // hit test, returns which tab is hit and, optionally, where (icon, label)
237 // (not implemented on all platforms)
239 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
240 "HitTest(Point pt) -> (tab, where)",
241 "Returns the tab which is hit, and flags indicating where using
242 wx.NB_HITTEST flags.", "");
244 // implement some base class functions
245 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
247 // On platforms that support it, get the theme page background colour,
248 // else invalid colour
249 wxColour GetThemeBackgroundColour() const;
251 static wxVisualAttributes
252 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
257 class wxNotebookEvent : public wxBookCtrlBaseEvent
260 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
261 int nSel = -1, int nOldSel = -1);
265 // notebook control event types
266 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
267 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
272 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
273 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
278 %#----------------------------------------------------------------------------
280 class NotebookPage(wx.Panel):
282 There is an old (and apparently unsolvable) bug when placing a
283 window with a nonstandard background colour in a wx.Notebook on
284 wxGTK1, as the notbooks's background colour would always be used
285 when the window is refreshed. The solution is to place a panel in
286 the notbook and the coloured window on the panel, sized to cover
287 the panel. This simple class does that for you, just put an
288 instance of this in the notebook and make your regular window a
289 child of this one and it will handle the resize for you.
291 def __init__(self, parent, id=-1,
292 pos=wx.DefaultPosition, size=wx.DefaultSize,
293 style=wx.TAB_TRAVERSAL, name="panel"):
294 wx.Panel.__init__(self, parent, id, pos, size, style, name)
296 self.Bind(wx.EVT_SIZE, self.OnSize)
298 def OnSize(self, evt):
299 if self.child is None:
300 children = self.GetChildren()
302 self.child = children[0]
304 self.child.SetPosition((0,0))
305 self.child.SetSize(self.GetSize())
309 //---------------------------------------------------------------------------
315 // default alignment: left everywhere except Mac where it is top
318 // put the list control to the left/right/top/bottom of the page area
324 // the mask which can be used to extract the alignment from the style
325 wxLB_ALIGN_MASK = 0xf,
330 MustHaveApp(wxListbook);
332 // wxListCtrl and wxNotebook combination
333 class wxListbook : public wxBookCtrlBase
336 %pythonAppend wxListbook "self._setOORInfo(self)"
337 %pythonAppend wxListbook() ""
339 wxListbook(wxWindow *parent,
341 const wxPoint& pos = wxDefaultPosition,
342 const wxSize& size = wxDefaultSize,
344 const wxString& name = wxPyEmptyString);
345 %RenameCtor(PreListbook, wxListbook());
347 bool Create(wxWindow *parent,
349 const wxPoint& pos = wxDefaultPosition,
350 const wxSize& size = wxDefaultSize,
352 const wxString& name = wxPyEmptyString);
354 wxListView* GetListView();
359 class wxListbookEvent : public wxBookCtrlBaseEvent
362 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
363 int nSel = -1, int nOldSel = -1);
367 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
368 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
371 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
372 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
376 //---------------------------------------------------------------------------
392 MustHaveApp(wxChoicebook);
394 class wxChoicebook : public wxBookCtrlBase
397 %pythonAppend wxChoicebook "self._setOORInfo(self)"
398 %pythonAppend wxChoicebook() ""
400 wxChoicebook(wxWindow *parent,
402 const wxPoint& pos = wxDefaultPosition,
403 const wxSize& size = wxDefaultSize,
405 const wxString& name = wxPyEmptyString);
406 %RenameCtor(PreChoicebook, wxChoicebook());
409 bool Create(wxWindow *parent,
411 const wxPoint& pos = wxDefaultPosition,
412 const wxSize& size = wxDefaultSize,
414 const wxString& name = wxPyEmptyString);
417 // returns the choice control
418 wxChoice* GetChoiceCtrl() const;
420 virtual bool DeleteAllPages();
424 class wxChoicebookEvent : public wxBookCtrlBaseEvent
427 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
428 int nSel = -1, int nOldSel = -1);
431 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
432 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
435 EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 )
436 EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 )
439 //---------------------------------------------------------------------------
442 MustHaveApp(wxTreebook);
444 class wxTreebook : public wxBookCtrlBase
447 %pythonAppend wxTreebook "self._setOORInfo(self)"
448 %pythonAppend wxTreebook() ""
451 // This ctor creates the tree book control
452 wxTreebook(wxWindow *parent,
454 const wxPoint& pos = wxDefaultPosition,
455 const wxSize& size = wxDefaultSize,
456 long style = wxBK_DEFAULT,
457 const wxString& name = wxPyEmptyString);
459 %RenameCtor(PreTreebook, wxTreebook());
462 // Really creates the control
463 bool Create(wxWindow *parent,
465 const wxPoint& pos = wxDefaultPosition,
466 const wxSize& size = wxDefaultSize,
467 long style = wxBK_DEFAULT,
468 const wxString& name = wxPyEmptyString);
471 // Notice that page pointer may be NULL in which case the next non NULL
472 // page (usually the first child page of a node) is shown when this page is
475 // Inserts a new page just before the page indicated by page.
476 // The new page is placed on the same level as page.
477 virtual bool InsertPage(size_t pos,
479 const wxString& text,
481 int imageId = wxNOT_FOUND);
483 // Inserts a new sub-page to the end of children of the page at given pos.
484 virtual bool InsertSubPage(size_t pos,
486 const wxString& text,
488 int imageId = wxNOT_FOUND);
490 // Adds a new page at top level after all other pages.
491 virtual bool AddPage(wxWindow *page,
492 const wxString& text,
494 int imageId = wxNOT_FOUND);
496 // Adds a new child-page to the last top-level page inserted.
497 // Useful when constructing 1 level tree structure.
498 virtual bool AddSubPage(wxWindow *page,
499 const wxString& text,
501 int imageId = wxNOT_FOUND);
503 // Deletes the page and ALL its children. Could trigger page selection
504 // change in a case when selected page is removed. In that case its parent
505 // is selected (or the next page if no parent).
506 virtual bool DeletePage(size_t pos);
512 // Gets the page node state -- node is expanded or collapsed
513 virtual bool IsNodeExpanded(size_t pos) const;
515 // Expands or collapses the page node. Returns the previous state.
516 // May generate page changing events (if selected page
517 // is under the collapsed branch, then parent is autoselected).
518 virtual bool ExpandNode(size_t pos, bool expand = true);
520 // shortcut for ExpandNode(pos, false)
521 bool CollapseNode(size_t pos);
523 // get the parent page or wxNOT_FOUND if this is a top level page
524 int GetPageParent(size_t pos) const;
526 // the tree control we use for showing the pages index tree
527 wxTreeCtrl* GetTreeCtrl() const;
532 class wxTreebookEvent : public wxBookCtrlBaseEvent
535 wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
536 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND);
539 %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED;
540 %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING;
541 %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED;
542 %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED;
546 EVT_TREEBOOK_PAGE_CHANGED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, 1 )
547 EVT_TREEBOOK_PAGE_CHANGING= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, 1)
548 EVT_TREEBOOK_NODE_COLLAPSED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, 1 )
549 EVT_TREEBOOK_NODE_EXPANDED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, 1 )
552 //---------------------------------------------------------------------------
555 MustHaveApp(wxTreebook);
557 class wxToolbook : public wxBookCtrlBase
560 %pythonAppend wxToolbook "self._setOORInfo(self)"
561 %pythonAppend wxToolbook() ""
564 // This ctor creates the tree book control
565 wxToolbook(wxWindow *parent,
567 const wxPoint& pos = wxDefaultPosition,
568 const wxSize& size = wxDefaultSize,
569 long style = wxBK_DEFAULT,
570 const wxString& name = wxPyEmptyString);
572 %RenameCtor(PreToolbook, wxToolbook());
575 bool Create(wxWindow *parent,
577 const wxPoint& pos = wxDefaultPosition,
578 const wxSize& size = wxDefaultSize,
580 const wxString& name = wxEmptyString);
583 wxToolBarBase* GetToolBar() const;
585 // Not part of the wxBookctrl API, but must be called in OnIdle or
586 // by application to realize the toolbar and select the initial page.
591 class wxToolbookEvent : public wxBookCtrlBaseEvent
594 wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
595 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND);
599 %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
600 %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
604 EVT_TOOLBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, 1)
605 EVT_TOOLBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, 1)
608 //---------------------------------------------------------------------------