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(wxBookCtrlBase);
27 // Common base class for wxList/Tree/Notebook
28 class wxBookCtrlBase : public wxControl
31 // This is an ABC, it can't be constructed...
33 // wxBookCtrlBase(wxWindow *parent,
35 // const wxPoint& pos = wxDefaultPosition,
36 // const wxSize& size = wxDefaultSize,
38 // const wxString& name = wxPyEmptyString);
39 // %name(PreBookCtrlBase)wxBookCtrlBase();
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 current page or NULL if none
55 wxWindow* GetCurrentPage() const;
57 // get the currently selected page or wxNOT_FOUND if none
58 virtual int GetSelection() const/* = 0*/;
60 // set/get the title of a page
61 virtual bool SetPageText(size_t n, const wxString& strText)/* = 0*/;
62 virtual wxString GetPageText(size_t n) const/* = 0*/;
65 // image list stuff: each page may have an image associated with it (all
66 // images belong to the same image list)
68 // sets the image list to use, it is *not* deleted by the control
69 virtual void SetImageList(wxImageList *imageList);
71 // as SetImageList() but we will delete the image list ourselves
72 %apply SWIGTYPE *DISOWN { wxImageList *imageList };
73 void AssignImageList(wxImageList *imageList);
74 %clear wxImageList *imageList;
76 // get pointer (may be NULL) to the associated image list
77 wxImageList* GetImageList() const;
79 // sets/returns item's image index in the current image list
80 virtual int GetPageImage(size_t n) const/* = 0*/;
81 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
84 // resize the notebook so that all pages will have the specified size
85 virtual void SetPageSize(const wxSize& size);
87 // calculate the size of the control from the size of its page
88 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
92 // remove one page from the control and delete it
93 virtual bool DeletePage(size_t n);
95 // remove one page from the notebook, without deleting it
96 virtual bool RemovePage(size_t n);
98 // remove all pages and delete them
99 virtual bool DeleteAllPages();
101 // adds a new page to the control
102 virtual bool AddPage(wxWindow *page,
103 const wxString& text,
107 // the same as AddPage(), but adds the page at the specified position
108 virtual bool InsertPage(size_t n,
110 const wxString& text,
112 int imageId = -1)/* = 0*/;
114 // set the currently selected page, return the index of the previously
115 // selected one (or -1 on error)
117 // NB: this function will _not_ generate PAGE_CHANGING/ED events
118 virtual int SetSelection(size_t n)/* = 0*/;
121 // cycle thru the pages
122 void AdvanceSelection(bool forward = true);
124 static wxVisualAttributes
125 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
130 class wxBookCtrlBaseEvent : public wxNotifyEvent
133 wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
134 int nSel = -1, int nOldSel = -1);
136 // the currently selected page (-1 if none)
137 int GetSelection() const;
138 void SetSelection(int nSel);
139 // the page that was selected before the change (-1 if none)
140 int GetOldSelection() const;
141 void SetOldSelection(int nOldSel);
146 //---------------------------------------------------------------------------
159 wxNB_HITTEST_NOWHERE = 1, // not on tab
160 wxNB_HITTEST_ONICON = 2, // on icon
161 wxNB_HITTEST_ONLABEL = 4, // on label
162 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
168 MustHaveApp(wxNotebook);
170 class wxNotebook : public wxBookCtrlBase {
172 %pythonAppend wxNotebook "self._setOORInfo(self)"
173 %pythonAppend wxNotebook() ""
174 %typemap(out) wxNotebook*; // turn off this typemap
176 wxNotebook(wxWindow *parent,
178 const wxPoint& pos = wxDefaultPosition,
179 const wxSize& size = wxDefaultSize,
181 const wxString& name = wxPyNOTEBOOK_NAME);
182 %name(PreNotebook)wxNotebook();
184 // Turn it back on again
185 %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); }
187 bool Create(wxWindow *parent,
189 const wxPoint& pos = wxDefaultPosition,
190 const wxSize& size = wxDefaultSize,
192 const wxString& name = wxPyNOTEBOOK_NAME);
195 // get the number of rows for a control with wxNB_MULTILINE style (not all
196 // versions support it - they will always return 1 then)
197 virtual int GetRowCount() const;
199 // set the padding between tabs (in pixels)
200 virtual void SetPadding(const wxSize& padding);
202 // set the size of the tabs for wxNB_FIXEDWIDTH controls
203 virtual void SetTabSize(const wxSize& sz);
205 // hit test, returns which tab is hit and, optionally, where (icon, label)
206 // (not implemented on all platforms)
208 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
209 "HitTest(Point pt) -> (tab, where)",
210 "Returns the tab which is hit, and flags indicating where using
211 wx.NB_HITTEST flags.", "");
213 // implement some base class functions
214 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
216 static wxVisualAttributes
217 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
222 class wxNotebookEvent : public wxBookCtrlBaseEvent
225 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
226 int nSel = -1, int nOldSel = -1);
230 // notebook control event types
231 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
232 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
237 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
238 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
243 %#----------------------------------------------------------------------------
245 class NotebookPage(wx.Panel):
247 There is an old (and apparently unsolvable) bug when placing a
248 window with a nonstandard background colour in a wxNotebook on
249 wxGTK, as the notbooks's background colour would always be used
250 when the window is refreshed. The solution is to place a panel in
251 the notbook and the coloured window on the panel, sized to cover
252 the panel. This simple class does that for you, just put an
253 instance of this in the notebook and make your regular window a
254 child of this one and it will handle the resize for you.
256 def __init__(self, parent, id=-1,
257 pos=wx.DefaultPosition, size=wx.DefaultSize,
258 style=wx.TAB_TRAVERSAL, name="panel"):
259 wx.Panel.__init__(self, parent, id, pos, size, style, name)
261 EVT_SIZE(self, self.OnSize)
263 def OnSize(self, evt):
264 if self.child is None:
265 children = self.GetChildren()
267 self.child = children[0]
269 self.child.SetPosition((0,0))
270 self.child.SetSize(self.GetSize())
274 //---------------------------------------------------------------------------
280 // default alignment: left everywhere except Mac where it is top
283 // put the list control to the left/right/top/bottom of the page area
289 // the mask which can be used to extract the alignment from the style
290 wxLB_ALIGN_MASK = 0xf,
295 MustHaveApp(wxListbook);
297 // wxListCtrl and wxNotebook combination
298 class wxListbook : public wxBookCtrlBase
301 %pythonAppend wxListbook "self._setOORInfo(self)"
302 %pythonAppend wxListbook() ""
304 wxListbook(wxWindow *parent,
306 const wxPoint& pos = wxDefaultPosition,
307 const wxSize& size = wxDefaultSize,
309 const wxString& name = wxPyEmptyString);
310 %name(PreListbook)wxListbook();
312 bool Create(wxWindow *parent,
314 const wxPoint& pos = wxDefaultPosition,
315 const wxSize& size = wxDefaultSize,
317 const wxString& name = wxPyEmptyString);
319 // returns True if we have wxLB_TOP or wxLB_BOTTOM style
320 bool IsVertical() const;
322 wxListView* GetListView();
327 class wxListbookEvent : public wxBookCtrlBaseEvent
330 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
331 int nSel = -1, int nOldSel = -1);
335 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
336 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
339 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
340 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
344 //---------------------------------------------------------------------------
360 MustHaveApp(wxChoicebook);
362 class wxChoicebook : public wxBookCtrlBase
365 %pythonAppend wxChoicebook "self._setOORInfo(self)"
366 %pythonAppend wxChoicebook() ""
368 wxChoicebook(wxWindow *parent,
370 const wxPoint& pos = wxDefaultPosition,
371 const wxSize& size = wxDefaultSize,
373 const wxString& name = wxPyEmptyString);
374 %name(PreChoicebook)wxChoicebook();
377 bool Create(wxWindow *parent,
379 const wxPoint& pos = wxDefaultPosition,
380 const wxSize& size = wxDefaultSize,
382 const wxString& name = wxPyEmptyString);
385 // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
386 bool IsVertical() const { return HasFlag(wxCHB_BOTTOM | wxCHB_TOP); }
388 virtual bool DeleteAllPages();
392 class wxChoicebookEvent : public wxBookCtrlBaseEvent
395 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
396 int nSel = -1, int nOldSel = -1);
399 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
400 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
403 EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 )
404 EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 )
407 //---------------------------------------------------------------------------
411 class wxBookCtrlSizer: public wxSizer
414 %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)"
416 wxBookCtrlSizer( wxBookCtrlBase *nb );
420 wxBookCtrlBase *GetControl();
424 class wxNotebookSizer: public wxSizer {
426 %pythonAppend wxNotebookSizer "self._setOORInfo(self)"
428 wxNotebookSizer( wxNotebook *nb );
432 wxNotebook *GetNotebook();
435 //---------------------------------------------------------------------------