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 //---------------------------------------------------------------------------
19 DECLARE_DEF_STRING(NOTEBOOK_NAME);
22 //---------------------------------------------------------------------------
25 // TODO: Virtualize this class so other book controls can be derived in Python
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 %addtofunc AssignImageList "args[1].thisown = 0"
70 void AssignImageList(wxImageList *imageList);
72 // get pointer (may be NULL) to the associated image list
73 wxImageList* GetImageList() const;
75 // sets/returns item's image index in the current image list
76 virtual int GetPageImage(size_t n) const/* = 0*/;
77 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
80 // resize the notebook so that all pages will have the specified size
81 virtual void SetPageSize(const wxSize& size);
83 // calculate the size of the control from the size of its page
84 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
88 // remove one page from the control and delete it
89 virtual bool DeletePage(size_t n);
91 // remove one page from the notebook, without deleting it
92 virtual bool RemovePage(size_t n);
94 // remove all pages and delete them
95 virtual bool DeleteAllPages();
97 // adds a new page to the control
98 virtual bool AddPage(wxWindow *page,
103 // the same as AddPage(), but adds the page at the specified position
104 virtual bool InsertPage(size_t n,
106 const wxString& text,
108 int imageId = -1)/* = 0*/;
110 // set the currently selected page, return the index of the previously
111 // selected one (or -1 on error)
113 // NB: this function will _not_ generate PAGE_CHANGING/ED events
114 virtual int SetSelection(size_t n)/* = 0*/;
117 // cycle thru the pages
118 void AdvanceSelection(bool forward = True);
123 class wxBookCtrlEvent : public wxNotifyEvent
126 wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
127 int nSel = -1, int nOldSel = -1);
129 // the currently selected page (-1 if none)
130 int GetSelection() const;
131 void SetSelection(int nSel);
132 // the page that was selected before the change (-1 if none)
133 int GetOldSelection() const;
134 void SetOldSelection(int nOldSel);
139 //---------------------------------------------------------------------------
152 wxNB_HITTEST_NOWHERE = 1, // not on tab
153 wxNB_HITTEST_ONICON = 2, // on icon
154 wxNB_HITTEST_ONLABEL = 4, // on label
155 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
161 class wxNotebook : public wxBookCtrl {
163 %addtofunc wxNotebook "self._setOORInfo(self)"
164 %addtofunc wxNotebook() ""
166 wxNotebook(wxWindow *parent,
168 const wxPoint& pos = wxDefaultPosition,
169 const wxSize& size = wxDefaultSize,
171 const wxString& name = wxPyNOTEBOOK_NAME);
172 %name(PreNotebook)wxNotebook();
174 bool Create(wxWindow *parent,
176 const wxPoint& pos = wxDefaultPosition,
177 const wxSize& size = wxDefaultSize,
179 const wxString& name = wxPyNOTEBOOK_NAME);
182 // get the number of rows for a control with wxNB_MULTILINE style (not all
183 // versions support it - they will always return 1 then)
184 virtual int GetRowCount() const;
186 // set the padding between tabs (in pixels)
187 virtual void SetPadding(const wxSize& padding);
189 // set the size of the tabs for wxNB_FIXEDWIDTH controls
190 virtual void SetTabSize(const wxSize& sz);
192 // hit test, returns which tab is hit and, optionally, where (icon, label)
193 // (not implemented on all platforms)
195 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
196 "HitTest(Point pt) -> (tab, where)",
197 "Returns the tab which is hit, and flags indicating where using wxNB_HITTEST_ flags.");
199 // implement some base class functions
200 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
203 // Windows only: attempts to apply the UX theme page background to this page
204 void ApplyThemeBackground(wxWindow* window, const wxColour& colour);
210 class wxNotebookEvent : public wxBookCtrlEvent
213 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
214 int nSel = -1, int nOldSel = -1);
218 // notebook control event types
219 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
220 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
225 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
226 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
231 %#----------------------------------------------------------------------------
233 class NotebookPage(wx.Panel):
235 There is an old (and apparently unsolvable) bug when placing a
236 window with a nonstandard background colour in a wxNotebook on
237 wxGTK, as the notbooks's background colour would always be used
238 when the window is refreshed. The solution is to place a panel in
239 the notbook and the coloured window on the panel, sized to cover
240 the panel. This simple class does that for you, just put an
241 instance of this in the notebook and make your regular window a
242 child of this one and it will handle the resize for you.
244 def __init__(self, parent, id=-1,
245 pos=wx.DefaultPosition, size=wx.DefaultSize,
246 style=wx.TAB_TRAVERSAL, name="panel"):
247 wx.Panel.__init__(self, parent, id, pos, size, style, name)
249 EVT_SIZE(self, self.OnSize)
251 def OnSize(self, evt):
252 if self.child is None:
253 children = self.GetChildren()
255 self.child = children[0]
257 self.child.SetPosition((0,0))
258 self.child.SetSize(self.GetSize())
262 //---------------------------------------------------------------------------
268 // default alignment: left everywhere except Mac where it is top
271 // put the list control to the left/right/top/bottom of the page area
277 // the mask which can be used to extract the alignment from the style
278 wxLB_ALIGN_MASK = 0xf,
283 // wxListCtrl and wxNotebook combination
284 class wxListbook : public wxBookCtrl
287 %addtofunc wxListbook "self._setOORInfo(self)"
288 %addtofunc wxListbook() ""
290 wxListbook(wxWindow *parent,
292 const wxPoint& pos = wxDefaultPosition,
293 const wxSize& size = wxDefaultSize,
295 const wxString& name = wxPyEmptyString);
296 %name(PreListbook)wxListbook();
298 bool Create(wxWindow *parent,
300 const wxPoint& pos = wxDefaultPosition,
301 const wxSize& size = wxDefaultSize,
303 const wxString& name = wxPyEmptyString);
305 // returns True if we have wxLB_TOP or wxLB_BOTTOM style
306 bool IsVertical() const;
312 class wxListbookEvent : public wxBookCtrlEvent
315 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
316 int nSel = -1, int nOldSel = -1);
320 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
321 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
324 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
325 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
329 //---------------------------------------------------------------------------
333 class wxBookCtrlSizer: public wxSizer
336 %addtofunc wxBookCtrlSizer "self._setOORInfo(self)"
338 wxBookCtrlSizer( wxBookCtrl *nb );
342 wxBookCtrl *GetControl();
346 class wxNotebookSizer: public wxSizer {
348 %addtofunc wxNotebookSizer "self._setOORInfo(self)"
350 wxNotebookSizer( wxNotebook *nb );
354 wxNotebook *GetNotebook();
357 //---------------------------------------------------------------------------