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)
194 virtual int HitTest(const wxPoint& pt, long* OUTPUT) const;
196 // implement some base class functions
197 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
200 // Windows only: attempts to apply the UX theme page background to this page
201 void ApplyThemeBackground(wxWindow* window, const wxColour& colour);
207 class wxNotebookEvent : public wxBookCtrlEvent
210 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
211 int nSel = -1, int nOldSel = -1);
215 // notebook control event types
216 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
217 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
222 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
223 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
228 %#----------------------------------------------------------------------------
230 class NotebookPage(wx.Panel):
232 There is an old (and apparently unsolvable) bug when placing a
233 window with a nonstandard background colour in a wxNotebook on
234 wxGTK, as the notbooks's background colour would always be used
235 when the window is refreshed. The solution is to place a panel in
236 the notbook and the coloured window on the panel, sized to cover
237 the panel. This simple class does that for you, just put an
238 instance of this in the notebook and make your regular window a
239 child of this one and it will handle the resize for you.
241 def __init__(self, parent, id=-1,
242 pos=wx.DefaultPosition, size=wx.DefaultSize,
243 style=wx.TAB_TRAVERSAL, name="panel"):
244 wx.Panel.__init__(self, parent, id, pos, size, style, name)
246 EVT_SIZE(self, self.OnSize)
248 def OnSize(self, evt):
249 if self.child is None:
250 children = self.GetChildren()
252 self.child = children[0]
254 self.child.SetPosition((0,0))
255 self.child.SetSize(self.GetSize())
259 //---------------------------------------------------------------------------
265 // default alignment: left everywhere except Mac where it is top
268 // put the list control to the left/right/top/bottom of the page area
274 // the mask which can be used to extract the alignment from the style
275 wxLB_ALIGN_MASK = 0xf,
280 // wxListCtrl and wxNotebook combination
281 class wxListbook : public wxBookCtrl
284 %addtofunc wxListbook "self._setOORInfo(self)"
285 %addtofunc wxListbook() ""
287 wxListbook(wxWindow *parent,
289 const wxPoint& pos = wxDefaultPosition,
290 const wxSize& size = wxDefaultSize,
292 const wxString& name = wxPyEmptyString);
293 %name(PreListbook)wxListbook();
295 bool Create(wxWindow *parent,
297 const wxPoint& pos = wxDefaultPosition,
298 const wxSize& size = wxDefaultSize,
300 const wxString& name = wxPyEmptyString);
302 // returns True if we have wxLB_TOP or wxLB_BOTTOM style
303 bool IsVertical() const;
309 class wxListbookEvent : public wxBookCtrlEvent
312 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
313 int nSel = -1, int nOldSel = -1);
317 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
318 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
321 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
322 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
326 //---------------------------------------------------------------------------
330 class wxBookCtrlSizer: public wxSizer
333 %addtofunc wxBookCtrlSizer "self._setOORInfo(self)"
335 wxBookCtrlSizer( wxBookCtrl *nb );
339 wxBookCtrl *GetControl();
343 class wxNotebookSizer: public wxSizer {
345 %addtofunc wxNotebookSizer "self._setOORInfo(self)"
347 wxNotebookSizer( wxNotebook *nb );
351 wxNotebook *GetNotebook();
354 //---------------------------------------------------------------------------