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 //---------------------------------------------------------------------------
34 // TODO: Virtualize this class so other book controls can be derived in Python
36 MustHaveApp(wxBookCtrlBase);
38 // Common base class for wxList/Tree/Notebook
39 class wxBookCtrlBase : public wxControl
42 // This is an ABC, it can't be constructed...
44 // wxBookCtrlBase(wxWindow *parent,
46 // const wxPoint& pos = wxDefaultPosition,
47 // const wxSize& size = wxDefaultSize,
49 // const wxString& name = wxPyEmptyString);
50 // %RenameCtor(PreBookCtrlBase, wxBookCtrlBase());
51 // bool Create(wxWindow *parent,
53 // const wxPoint& pos = wxDefaultPosition,
54 // const wxSize& size = wxDefaultSize,
56 // const wxString& name = wxPyEmptyString);
59 // get number of pages in the dialog
60 virtual size_t GetPageCount() const;
62 // get the panel which represents the given page
63 virtual wxWindow *GetPage(size_t n);
65 // get the current page or NULL if none
66 wxWindow* GetCurrentPage() const;
68 // get the currently selected page or wxNOT_FOUND if none
69 virtual int GetSelection() const/* = 0*/;
71 // set/get the title of a page
72 virtual bool SetPageText(size_t n, const wxString& strText)/* = 0*/;
73 virtual wxString GetPageText(size_t n) const/* = 0*/;
76 // image list stuff: each page may have an image associated with it (all
77 // images belong to the same image list)
79 // sets the image list to use, it is *not* deleted by the control
80 virtual void SetImageList(wxImageList *imageList);
82 // as SetImageList() but we will delete the image list ourselves
83 %disownarg( wxImageList *imageList );
84 void AssignImageList(wxImageList *imageList);
85 %cleardisown( wxImageList *imageList );
87 // get pointer (may be NULL) to the associated image list
88 wxImageList* GetImageList() const;
90 // sets/returns item's image index in the current image list
91 virtual int GetPageImage(size_t n) const/* = 0*/;
92 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
95 // resize the notebook so that all pages will have the specified size
96 virtual void SetPageSize(const wxSize& size);
98 // calculate the size of the control from the size of its page
99 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
102 // get/set size of area between book control area and page area
103 unsigned int GetInternalBorder() const;
104 void SetInternalBorder(unsigned int internalBorder);
106 // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
107 bool IsVertical() const;
109 // set/get option to shrink to fit current page
110 void SetShrinkMode(bool shrink);
111 bool GetShrinkMode() const;
114 // remove one page from the control and delete it
115 virtual bool DeletePage(size_t n);
117 // remove one page from the notebook, without deleting it
118 virtual bool RemovePage(size_t n);
120 // remove all pages and delete them
121 virtual bool DeleteAllPages();
123 // adds a new page to the control
124 virtual bool AddPage(wxWindow *page,
125 const wxString& text,
129 // the same as AddPage(), but adds the page at the specified position
130 virtual bool InsertPage(size_t n,
132 const wxString& text,
134 int imageId = -1)/* = 0*/;
136 // set the currently selected page, return the index of the previously
137 // selected one (or -1 on error)
139 // NB: this function will _not_ generate PAGE_CHANGING/ED events
140 virtual int SetSelection(size_t n)/* = 0*/;
143 // cycle thru the pages
144 void AdvanceSelection(bool forward = true);
146 static wxVisualAttributes
147 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
152 class wxBookCtrlBaseEvent : public wxNotifyEvent
155 wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
156 int nSel = -1, int nOldSel = -1);
158 // the currently selected page (-1 if none)
159 int GetSelection() const;
160 void SetSelection(int nSel);
161 // the page that was selected before the change (-1 if none)
162 int GetOldSelection() const;
163 void SetOldSelection(int nOldSel);
168 //---------------------------------------------------------------------------
182 wxNB_HITTEST_NOWHERE = 1, // not on tab
183 wxNB_HITTEST_ONICON = 2, // on icon
184 wxNB_HITTEST_ONLABEL = 4, // on label
185 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
191 MustHaveApp(wxNotebook);
193 class wxNotebook : public wxBookCtrlBase {
195 %pythonAppend wxNotebook "self._setOORInfo(self)"
196 %pythonAppend wxNotebook() ""
197 %typemap(out) wxNotebook*; // turn off this typemap
199 wxNotebook(wxWindow *parent,
201 const wxPoint& pos = wxDefaultPosition,
202 const wxSize& size = wxDefaultSize,
204 const wxString& name = wxPyNotebookNameStr);
205 %RenameCtor(PreNotebook, wxNotebook());
207 // Turn it back on again
208 %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); }
210 bool Create(wxWindow *parent,
212 const wxPoint& pos = wxDefaultPosition,
213 const wxSize& size = wxDefaultSize,
215 const wxString& name = wxPyNotebookNameStr);
218 // get the number of rows for a control with wxNB_MULTILINE style (not all
219 // versions support it - they will always return 1 then)
220 virtual int GetRowCount() const;
222 // set the padding between tabs (in pixels)
223 virtual void SetPadding(const wxSize& padding);
225 // set the size of the tabs for wxNB_FIXEDWIDTH controls
226 virtual void SetTabSize(const wxSize& sz);
228 // hit test, returns which tab is hit and, optionally, where (icon, label)
229 // (not implemented on all platforms)
231 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
232 "HitTest(Point pt) -> (tab, where)",
233 "Returns the tab which is hit, and flags indicating where using
234 wx.NB_HITTEST flags.", "");
236 // implement some base class functions
237 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
239 // On platforms that support it, get the theme page background colour,
240 // else invalid colour
241 wxColour GetThemeBackgroundColour() const;
243 static wxVisualAttributes
244 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
249 class wxNotebookEvent : public wxBookCtrlBaseEvent
252 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
253 int nSel = -1, int nOldSel = -1);
257 // notebook control event types
258 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
259 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
264 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
265 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
270 %#----------------------------------------------------------------------------
272 class NotebookPage(wx.Panel):
274 There is an old (and apparently unsolvable) bug when placing a
275 window with a nonstandard background colour in a wx.Notebook on
276 wxGTK1, as the notbooks's background colour would always be used
277 when the window is refreshed. The solution is to place a panel in
278 the notbook and the coloured window on the panel, sized to cover
279 the panel. This simple class does that for you, just put an
280 instance of this in the notebook and make your regular window a
281 child of this one and it will handle the resize for you.
283 def __init__(self, parent, id=-1,
284 pos=wx.DefaultPosition, size=wx.DefaultSize,
285 style=wx.TAB_TRAVERSAL, name="panel"):
286 wx.Panel.__init__(self, parent, id, pos, size, style, name)
288 self.Bind(wx.EVT_SIZE, self.OnSize)
290 def OnSize(self, evt):
291 if self.child is None:
292 children = self.GetChildren()
294 self.child = children[0]
296 self.child.SetPosition((0,0))
297 self.child.SetSize(self.GetSize())
301 //---------------------------------------------------------------------------
307 // default alignment: left everywhere except Mac where it is top
310 // put the list control to the left/right/top/bottom of the page area
316 // the mask which can be used to extract the alignment from the style
317 wxLB_ALIGN_MASK = 0xf,
322 MustHaveApp(wxListbook);
324 // wxListCtrl and wxNotebook combination
325 class wxListbook : public wxBookCtrlBase
328 %pythonAppend wxListbook "self._setOORInfo(self)"
329 %pythonAppend wxListbook() ""
331 wxListbook(wxWindow *parent,
333 const wxPoint& pos = wxDefaultPosition,
334 const wxSize& size = wxDefaultSize,
336 const wxString& name = wxPyEmptyString);
337 %RenameCtor(PreListbook, wxListbook());
339 bool Create(wxWindow *parent,
341 const wxPoint& pos = wxDefaultPosition,
342 const wxSize& size = wxDefaultSize,
344 const wxString& name = wxPyEmptyString);
346 wxListView* GetListView();
351 class wxListbookEvent : public wxBookCtrlBaseEvent
354 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
355 int nSel = -1, int nOldSel = -1);
359 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
360 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
363 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
364 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
368 //---------------------------------------------------------------------------
384 MustHaveApp(wxChoicebook);
386 class wxChoicebook : public wxBookCtrlBase
389 %pythonAppend wxChoicebook "self._setOORInfo(self)"
390 %pythonAppend wxChoicebook() ""
392 wxChoicebook(wxWindow *parent,
394 const wxPoint& pos = wxDefaultPosition,
395 const wxSize& size = wxDefaultSize,
397 const wxString& name = wxPyEmptyString);
398 %RenameCtor(PreChoicebook, wxChoicebook());
401 bool Create(wxWindow *parent,
403 const wxPoint& pos = wxDefaultPosition,
404 const wxSize& size = wxDefaultSize,
406 const wxString& name = wxPyEmptyString);
409 // returns the choice control
410 wxChoice* GetChoiceCtrl() const;
412 virtual bool DeleteAllPages();
416 class wxChoicebookEvent : public wxBookCtrlBaseEvent
419 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
420 int nSel = -1, int nOldSel = -1);
423 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
424 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
427 EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 )
428 EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 )
431 //---------------------------------------------------------------------------
434 MustHaveApp(wxTreebook);
436 class wxTreebook : public wxBookCtrlBase
439 %pythonAppend wxTreebook "self._setOORInfo(self)"
440 %pythonAppend wxTreebook() ""
443 // This ctor creates the tree book control
444 wxTreebook(wxWindow *parent,
446 const wxPoint& pos = wxDefaultPosition,
447 const wxSize& size = wxDefaultSize,
448 long style = wxBK_DEFAULT,
449 const wxString& name = wxPyEmptyString);
451 %RenameCtor(PreTreebook, wxTreebook());
454 // Really creates the control
455 bool Create(wxWindow *parent,
457 const wxPoint& pos = wxDefaultPosition,
458 const wxSize& size = wxDefaultSize,
459 long style = wxBK_DEFAULT,
460 const wxString& name = wxPyEmptyString);
463 // Notice that page pointer may be NULL in which case the next non NULL
464 // page (usually the first child page of a node) is shown when this page is
467 // Inserts a new page just before the page indicated by page.
468 // The new page is placed on the same level as page.
469 virtual bool InsertPage(size_t pos,
471 const wxString& text,
473 int imageId = wxNOT_FOUND);
475 // Inserts a new sub-page to the end of children of the page at given pos.
476 %Rename(InsertSubPage,
477 virtual bool, AddSubPage(size_t pos,
479 const wxString& text,
481 int imageId = wxNOT_FOUND));
483 // Adds a new page at top level after all other pages.
484 virtual bool AddPage(wxWindow *page,
485 const wxString& text,
487 int imageId = wxNOT_FOUND);
489 // Adds a new child-page to the last top-level page inserted.
490 // Useful when constructing 1 level tree structure.
491 virtual bool AddSubPage(wxWindow *page,
492 const wxString& text,
494 int imageId = wxNOT_FOUND);
496 // Deletes the page and ALL its children. Could trigger page selection
497 // change in a case when selected page is removed. In that case its parent
498 // is selected (or the next page if no parent).
499 virtual bool DeletePage(size_t pos);
505 // Gets the page node state -- node is expanded or collapsed
506 virtual bool IsNodeExpanded(size_t pos) const;
508 // Expands or collapses the page node. Returns the previous state.
509 // May generate page changing events (if selected page
510 // is under the collapsed branch, then parent is autoselected).
511 virtual bool ExpandNode(size_t pos, bool expand = true);
513 // shortcut for ExpandNode(pos, false)
514 bool CollapseNode(size_t pos);
516 // get the parent page or wxNOT_FOUND if this is a top level page
517 int GetPageParent(size_t pos) const;
519 // the tree control we use for showing the pages index tree
520 wxTreeCtrl* GetTreeCtrl() const;
525 class wxTreebookEvent : public wxBookCtrlBaseEvent
528 wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
529 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND);
532 %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED;
533 %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING;
534 %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED;
535 %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED;
539 EVT_TREEBOOK_PAGE_CHANGED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, 1 )
540 EVT_TREEBOOK_PAGE_CHANGING= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, 1)
541 EVT_TREEBOOK_NODE_COLLAPSED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, 1 )
542 EVT_TREEBOOK_NODE_EXPANDED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, 1 )
545 //---------------------------------------------------------------------------
548 MustHaveApp(wxTreebook);
550 class wxToolbook : public wxBookCtrlBase
553 %pythonAppend wxToolbook "self._setOORInfo(self)"
554 %pythonAppend wxToolbook() ""
557 // This ctor creates the tree book control
558 wxToolbook(wxWindow *parent,
560 const wxPoint& pos = wxDefaultPosition,
561 const wxSize& size = wxDefaultSize,
562 long style = wxBK_DEFAULT,
563 const wxString& name = wxPyEmptyString);
565 %RenameCtor(PreToolbook, wxToolbook());
568 bool Create(wxWindow *parent,
570 const wxPoint& pos = wxDefaultPosition,
571 const wxSize& size = wxDefaultSize,
573 const wxString& name = wxEmptyString);
576 wxToolBarBase* GetToolBar() const;
578 // Not part of the wxBookctrl API, but must be called in OnIdle or
579 // by application to realize the toolbar and select the initial page.
584 class wxToolbookEvent : public wxBookCtrlBaseEvent
587 wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
588 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND);
592 %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
593 %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
597 EVT_TOOLBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, 1)
598 EVT_TOOLBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, 1)
601 //---------------------------------------------------------------------------