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(NOTEBOOK_NAME);
20 //---------------------------------------------------------------------------
23 // TODO: Virtualize this class so other book controls can be derived in Python
25 MustHaveApp(wxBookCtrl);
27 // Common base class for wxList/Tree/Notebook
28 class wxBookCtrl : public wxControl
31 // This is an ABC, it can't be constructed...
33 // wxBookCtrl(wxWindow *parent,
35 // const wxPoint& pos = wxDefaultPosition,
36 // const wxSize& size = wxDefaultSize,
38 // const wxString& name = wxPyEmptyString);
39 // %name(PreBookCtrl)wxBookCtrl();
40 // bool Create(wxWindow *parent,
42 // const wxPoint& pos = wxDefaultPosition,
43 // const wxSize& size = wxDefaultSize,
45 // const wxString& name = wxPyEmptyString);
48 // get number of pages in the dialog
49 virtual size_t GetPageCount() const;
51 // get the panel which represents the given page
52 virtual wxWindow *GetPage(size_t n);
54 // get the currently selected page or wxNOT_FOUND if none
55 virtual int GetSelection() const/* = 0*/;
57 // set/get the title of a page
58 virtual bool SetPageText(size_t n, const wxString& strText)/* = 0*/;
59 virtual wxString GetPageText(size_t n) const/* = 0*/;
62 // image list stuff: each page may have an image associated with it (all
63 // images belong to the same image list)
65 // sets the image list to use, it is *not* deleted by the control
66 virtual void SetImageList(wxImageList *imageList);
68 // as SetImageList() but we will delete the image list ourselves
69 %apply SWIGTYPE *DISOWN { wxImageList *imageList };
70 void AssignImageList(wxImageList *imageList);
71 %clear wxImageList *imageList;
73 // get pointer (may be NULL) to the associated image list
74 wxImageList* GetImageList() const;
76 // sets/returns item's image index in the current image list
77 virtual int GetPageImage(size_t n) const/* = 0*/;
78 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
81 // resize the notebook so that all pages will have the specified size
82 virtual void SetPageSize(const wxSize& size);
84 // calculate the size of the control from the size of its page
85 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
89 // remove one page from the control and delete it
90 virtual bool DeletePage(size_t n);
92 // remove one page from the notebook, without deleting it
93 virtual bool RemovePage(size_t n);
95 // remove all pages and delete them
96 virtual bool DeleteAllPages();
98 // adds a new page to the control
99 virtual bool AddPage(wxWindow *page,
100 const wxString& text,
104 // the same as AddPage(), but adds the page at the specified position
105 virtual bool InsertPage(size_t n,
107 const wxString& text,
109 int imageId = -1)/* = 0*/;
111 // set the currently selected page, return the index of the previously
112 // selected one (or -1 on error)
114 // NB: this function will _not_ generate PAGE_CHANGING/ED events
115 virtual int SetSelection(size_t n)/* = 0*/;
118 // cycle thru the pages
119 void AdvanceSelection(bool forward = true);
121 static wxVisualAttributes
122 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
127 class wxBookCtrlEvent : public wxNotifyEvent
130 wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
131 int nSel = -1, int nOldSel = -1);
133 // the currently selected page (-1 if none)
134 int GetSelection() const;
135 void SetSelection(int nSel);
136 // the page that was selected before the change (-1 if none)
137 int GetOldSelection() const;
138 void SetOldSelection(int nOldSel);
143 //---------------------------------------------------------------------------
156 wxNB_HITTEST_NOWHERE = 1, // not on tab
157 wxNB_HITTEST_ONICON = 2, // on icon
158 wxNB_HITTEST_ONLABEL = 4, // on label
159 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
165 MustHaveApp(wxNotebook);
167 class wxNotebook : public wxBookCtrl {
169 %pythonAppend wxNotebook "self._setOORInfo(self)"
170 %pythonAppend wxNotebook() ""
171 %typemap(out) wxNotebook*; // turn off this typemap
173 wxNotebook(wxWindow *parent,
175 const wxPoint& pos = wxDefaultPosition,
176 const wxSize& size = wxDefaultSize,
178 const wxString& name = wxPyNOTEBOOK_NAME);
179 %name(PreNotebook)wxNotebook();
181 // Turn it back on again
182 %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); }
184 bool Create(wxWindow *parent,
186 const wxPoint& pos = wxDefaultPosition,
187 const wxSize& size = wxDefaultSize,
189 const wxString& name = wxPyNOTEBOOK_NAME);
192 // get the number of rows for a control with wxNB_MULTILINE style (not all
193 // versions support it - they will always return 1 then)
194 virtual int GetRowCount() const;
196 // set the padding between tabs (in pixels)
197 virtual void SetPadding(const wxSize& padding);
199 // set the size of the tabs for wxNB_FIXEDWIDTH controls
200 virtual void SetTabSize(const wxSize& sz);
202 // hit test, returns which tab is hit and, optionally, where (icon, label)
203 // (not implemented on all platforms)
205 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
206 "HitTest(Point pt) -> (tab, where)",
207 "Returns the tab which is hit, and flags indicating where using
208 wx.NB_HITTEST flags.", "");
210 // implement some base class functions
211 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
214 // Windows only: attempts to apply the UX theme page background to this page
215 void ApplyThemeBackground(wxWindow* window, const wxColour& colour);
218 static wxVisualAttributes
219 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
224 class wxNotebookEvent : public wxBookCtrlEvent
227 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
228 int nSel = -1, int nOldSel = -1);
232 // notebook control event types
233 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
234 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
239 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
240 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
245 %#----------------------------------------------------------------------------
247 class NotebookPage(wx.Panel):
249 There is an old (and apparently unsolvable) bug when placing a
250 window with a nonstandard background colour in a wxNotebook on
251 wxGTK, as the notbooks's background colour would always be used
252 when the window is refreshed. The solution is to place a panel in
253 the notbook and the coloured window on the panel, sized to cover
254 the panel. This simple class does that for you, just put an
255 instance of this in the notebook and make your regular window a
256 child of this one and it will handle the resize for you.
258 def __init__(self, parent, id=-1,
259 pos=wx.DefaultPosition, size=wx.DefaultSize,
260 style=wx.TAB_TRAVERSAL, name="panel"):
261 wx.Panel.__init__(self, parent, id, pos, size, style, name)
263 EVT_SIZE(self, self.OnSize)
265 def OnSize(self, evt):
266 if self.child is None:
267 children = self.GetChildren()
269 self.child = children[0]
271 self.child.SetPosition((0,0))
272 self.child.SetSize(self.GetSize())
276 //---------------------------------------------------------------------------
282 // default alignment: left everywhere except Mac where it is top
285 // put the list control to the left/right/top/bottom of the page area
291 // the mask which can be used to extract the alignment from the style
292 wxLB_ALIGN_MASK = 0xf,
297 MustHaveApp(wxListbook);
299 // wxListCtrl and wxNotebook combination
300 class wxListbook : public wxBookCtrl
303 %pythonAppend wxListbook "self._setOORInfo(self)"
304 %pythonAppend wxListbook() ""
306 wxListbook(wxWindow *parent,
308 const wxPoint& pos = wxDefaultPosition,
309 const wxSize& size = wxDefaultSize,
311 const wxString& name = wxPyEmptyString);
312 %name(PreListbook)wxListbook();
314 bool Create(wxWindow *parent,
316 const wxPoint& pos = wxDefaultPosition,
317 const wxSize& size = wxDefaultSize,
319 const wxString& name = wxPyEmptyString);
321 // returns True if we have wxLB_TOP or wxLB_BOTTOM style
322 bool IsVertical() const;
324 wxListView* GetListView();
329 class wxListbookEvent : public wxBookCtrlEvent
332 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
333 int nSel = -1, int nOldSel = -1);
337 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
338 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
341 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
342 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
346 //---------------------------------------------------------------------------
362 MustHaveApp(wxChoicebook);
364 class wxChoicebook : public wxBookCtrl
367 %pythonAppend wxChoicebook "self._setOORInfo(self)"
368 %pythonAppend wxChoicebook() ""
370 wxChoicebook(wxWindow *parent,
372 const wxPoint& pos = wxDefaultPosition,
373 const wxSize& size = wxDefaultSize,
375 const wxString& name = wxPyEmptyString);
376 %name(PreChoicebook)wxChoicebook();
379 bool Create(wxWindow *parent,
381 const wxPoint& pos = wxDefaultPosition,
382 const wxSize& size = wxDefaultSize,
384 const wxString& name = wxPyEmptyString);
387 // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
388 bool IsVertical() const { return HasFlag(wxCHB_BOTTOM | wxCHB_TOP); }
390 virtual bool DeleteAllPages();
394 class wxChoicebookEvent : public wxBookCtrlEvent
397 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
398 int nSel = -1, int nOldSel = -1);
401 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
402 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
405 EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 )
406 EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 )
409 //---------------------------------------------------------------------------
413 class wxBookCtrlSizer: public wxSizer
416 %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)"
418 wxBookCtrlSizer( wxBookCtrl *nb );
422 wxBookCtrl *GetControl();
426 class wxNotebookSizer: public wxSizer {
428 %pythonAppend wxNotebookSizer "self._setOORInfo(self)"
430 wxNotebookSizer( wxNotebook *nb );
434 wxNotebook *GetNotebook();
437 //---------------------------------------------------------------------------