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() ""
172 wxNotebook(wxWindow *parent,
174 const wxPoint& pos = wxDefaultPosition,
175 const wxSize& size = wxDefaultSize,
177 const wxString& name = wxPyNOTEBOOK_NAME);
178 %name(PreNotebook)wxNotebook();
180 bool Create(wxWindow *parent,
182 const wxPoint& pos = wxDefaultPosition,
183 const wxSize& size = wxDefaultSize,
185 const wxString& name = wxPyNOTEBOOK_NAME);
188 // get the number of rows for a control with wxNB_MULTILINE style (not all
189 // versions support it - they will always return 1 then)
190 virtual int GetRowCount() const;
192 // set the padding between tabs (in pixels)
193 virtual void SetPadding(const wxSize& padding);
195 // set the size of the tabs for wxNB_FIXEDWIDTH controls
196 virtual void SetTabSize(const wxSize& sz);
198 // hit test, returns which tab is hit and, optionally, where (icon, label)
199 // (not implemented on all platforms)
201 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
202 "HitTest(Point pt) -> (tab, where)",
203 "Returns the tab which is hit, and flags indicating where using
204 wx.NB_HITTEST flags.", "");
206 // implement some base class functions
207 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
210 // Windows only: attempts to apply the UX theme page background to this page
211 void ApplyThemeBackground(wxWindow* window, const wxColour& colour);
214 static wxVisualAttributes
215 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
220 class wxNotebookEvent : public wxBookCtrlEvent
223 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
224 int nSel = -1, int nOldSel = -1);
228 // notebook control event types
229 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
230 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
235 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
236 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
241 %#----------------------------------------------------------------------------
243 class NotebookPage(wx.Panel):
245 There is an old (and apparently unsolvable) bug when placing a
246 window with a nonstandard background colour in a wxNotebook on
247 wxGTK, as the notbooks's background colour would always be used
248 when the window is refreshed. The solution is to place a panel in
249 the notbook and the coloured window on the panel, sized to cover
250 the panel. This simple class does that for you, just put an
251 instance of this in the notebook and make your regular window a
252 child of this one and it will handle the resize for you.
254 def __init__(self, parent, id=-1,
255 pos=wx.DefaultPosition, size=wx.DefaultSize,
256 style=wx.TAB_TRAVERSAL, name="panel"):
257 wx.Panel.__init__(self, parent, id, pos, size, style, name)
259 EVT_SIZE(self, self.OnSize)
261 def OnSize(self, evt):
262 if self.child is None:
263 children = self.GetChildren()
265 self.child = children[0]
267 self.child.SetPosition((0,0))
268 self.child.SetSize(self.GetSize())
272 //---------------------------------------------------------------------------
278 // default alignment: left everywhere except Mac where it is top
281 // put the list control to the left/right/top/bottom of the page area
287 // the mask which can be used to extract the alignment from the style
288 wxLB_ALIGN_MASK = 0xf,
293 MustHaveApp(wxListbook);
295 // wxListCtrl and wxNotebook combination
296 class wxListbook : public wxBookCtrl
299 %pythonAppend wxListbook "self._setOORInfo(self)"
300 %pythonAppend wxListbook() ""
302 wxListbook(wxWindow *parent,
304 const wxPoint& pos = wxDefaultPosition,
305 const wxSize& size = wxDefaultSize,
307 const wxString& name = wxPyEmptyString);
308 %name(PreListbook)wxListbook();
310 bool Create(wxWindow *parent,
312 const wxPoint& pos = wxDefaultPosition,
313 const wxSize& size = wxDefaultSize,
315 const wxString& name = wxPyEmptyString);
317 // returns True if we have wxLB_TOP or wxLB_BOTTOM style
318 bool IsVertical() const;
324 class wxListbookEvent : public wxBookCtrlEvent
327 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
328 int nSel = -1, int nOldSel = -1);
332 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
333 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
336 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
337 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
341 //---------------------------------------------------------------------------
345 class wxBookCtrlSizer: public wxSizer
348 %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)"
350 wxBookCtrlSizer( wxBookCtrl *nb );
354 wxBookCtrl *GetControl();
358 class wxNotebookSizer: public wxSizer {
360 %pythonAppend wxNotebookSizer "self._setOORInfo(self)"
362 wxNotebookSizer( wxNotebook *nb );
366 wxNotebook *GetNotebook();
369 //---------------------------------------------------------------------------