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 // Common base class for wxList/Tree/Notebook
26 class wxBookCtrl : public wxControl
29 // This is an ABC, it can't be constructed...
31 // wxBookCtrl(wxWindow *parent,
33 // const wxPoint& pos = wxDefaultPosition,
34 // const wxSize& size = wxDefaultSize,
36 // const wxString& name = wxPyEmptyString);
37 // %name(PreBookCtrl)wxBookCtrl();
38 // bool Create(wxWindow *parent,
40 // const wxPoint& pos = wxDefaultPosition,
41 // const wxSize& size = wxDefaultSize,
43 // const wxString& name = wxPyEmptyString);
46 // get number of pages in the dialog
47 virtual size_t GetPageCount() const;
49 // get the panel which represents the given page
50 virtual wxWindow *GetPage(size_t n);
52 // get the currently selected page or wxNOT_FOUND if none
53 virtual int GetSelection() const/* = 0*/;
55 // set/get the title of a page
56 virtual bool SetPageText(size_t n, const wxString& strText)/* = 0*/;
57 virtual wxString GetPageText(size_t n) const/* = 0*/;
60 // image list stuff: each page may have an image associated with it (all
61 // images belong to the same image list)
63 // sets the image list to use, it is *not* deleted by the control
64 virtual void SetImageList(wxImageList *imageList);
66 // as SetImageList() but we will delete the image list ourselves
67 %apply SWIGTYPE *DISOWN { wxImageList *imageList };
68 void AssignImageList(wxImageList *imageList);
69 %clear wxImageList *imageList;
71 // get pointer (may be NULL) to the associated image list
72 wxImageList* GetImageList() const;
74 // sets/returns item's image index in the current image list
75 virtual int GetPageImage(size_t n) const/* = 0*/;
76 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
79 // resize the notebook so that all pages will have the specified size
80 virtual void SetPageSize(const wxSize& size);
82 // calculate the size of the control from the size of its page
83 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
87 // remove one page from the control and delete it
88 virtual bool DeletePage(size_t n);
90 // remove one page from the notebook, without deleting it
91 virtual bool RemovePage(size_t n);
93 // remove all pages and delete them
94 virtual bool DeleteAllPages();
96 // adds a new page to the control
97 virtual bool AddPage(wxWindow *page,
102 // the same as AddPage(), but adds the page at the specified position
103 virtual bool InsertPage(size_t n,
105 const wxString& text,
107 int imageId = -1)/* = 0*/;
109 // set the currently selected page, return the index of the previously
110 // selected one (or -1 on error)
112 // NB: this function will _not_ generate PAGE_CHANGING/ED events
113 virtual int SetSelection(size_t n)/* = 0*/;
116 // cycle thru the pages
117 void AdvanceSelection(bool forward = True);
119 static wxVisualAttributes
120 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
125 class wxBookCtrlEvent : public wxNotifyEvent
128 wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
129 int nSel = -1, int nOldSel = -1);
131 // the currently selected page (-1 if none)
132 int GetSelection() const;
133 void SetSelection(int nSel);
134 // the page that was selected before the change (-1 if none)
135 int GetOldSelection() const;
136 void SetOldSelection(int nOldSel);
141 //---------------------------------------------------------------------------
154 wxNB_HITTEST_NOWHERE = 1, // not on tab
155 wxNB_HITTEST_ONICON = 2, // on icon
156 wxNB_HITTEST_ONLABEL = 4, // on label
157 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
163 class wxNotebook : public wxBookCtrl {
165 %pythonAppend wxNotebook "self._setOORInfo(self)"
166 %pythonAppend wxNotebook() ""
168 wxNotebook(wxWindow *parent,
170 const wxPoint& pos = wxDefaultPosition,
171 const wxSize& size = wxDefaultSize,
173 const wxString& name = wxPyNOTEBOOK_NAME);
174 %name(PreNotebook)wxNotebook();
176 bool Create(wxWindow *parent,
178 const wxPoint& pos = wxDefaultPosition,
179 const wxSize& size = wxDefaultSize,
181 const wxString& name = wxPyNOTEBOOK_NAME);
184 // get the number of rows for a control with wxNB_MULTILINE style (not all
185 // versions support it - they will always return 1 then)
186 virtual int GetRowCount() const;
188 // set the padding between tabs (in pixels)
189 virtual void SetPadding(const wxSize& padding);
191 // set the size of the tabs for wxNB_FIXEDWIDTH controls
192 virtual void SetTabSize(const wxSize& sz);
194 // hit test, returns which tab is hit and, optionally, where (icon, label)
195 // (not implemented on all platforms)
197 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
198 "HitTest(Point pt) -> (tab, where)",
199 "Returns the tab which is hit, and flags indicating where using
200 wx.NB_HITTEST flags.", "");
202 // implement some base class functions
203 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
206 // Windows only: attempts to apply the UX theme page background to this page
207 void ApplyThemeBackground(wxWindow* window, const wxColour& colour);
210 static wxVisualAttributes
211 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
216 class wxNotebookEvent : public wxBookCtrlEvent
219 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
220 int nSel = -1, int nOldSel = -1);
224 // notebook control event types
225 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
226 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
231 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
232 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
237 %#----------------------------------------------------------------------------
239 class NotebookPage(wx.Panel):
241 There is an old (and apparently unsolvable) bug when placing a
242 window with a nonstandard background colour in a wxNotebook on
243 wxGTK, as the notbooks's background colour would always be used
244 when the window is refreshed. The solution is to place a panel in
245 the notbook and the coloured window on the panel, sized to cover
246 the panel. This simple class does that for you, just put an
247 instance of this in the notebook and make your regular window a
248 child of this one and it will handle the resize for you.
250 def __init__(self, parent, id=-1,
251 pos=wx.DefaultPosition, size=wx.DefaultSize,
252 style=wx.TAB_TRAVERSAL, name="panel"):
253 wx.Panel.__init__(self, parent, id, pos, size, style, name)
255 EVT_SIZE(self, self.OnSize)
257 def OnSize(self, evt):
258 if self.child is None:
259 children = self.GetChildren()
261 self.child = children[0]
263 self.child.SetPosition((0,0))
264 self.child.SetSize(self.GetSize())
268 //---------------------------------------------------------------------------
274 // default alignment: left everywhere except Mac where it is top
277 // put the list control to the left/right/top/bottom of the page area
283 // the mask which can be used to extract the alignment from the style
284 wxLB_ALIGN_MASK = 0xf,
289 // wxListCtrl and wxNotebook combination
290 class wxListbook : public wxBookCtrl
293 %pythonAppend wxListbook "self._setOORInfo(self)"
294 %pythonAppend wxListbook() ""
296 wxListbook(wxWindow *parent,
298 const wxPoint& pos = wxDefaultPosition,
299 const wxSize& size = wxDefaultSize,
301 const wxString& name = wxPyEmptyString);
302 %name(PreListbook)wxListbook();
304 bool Create(wxWindow *parent,
306 const wxPoint& pos = wxDefaultPosition,
307 const wxSize& size = wxDefaultSize,
309 const wxString& name = wxPyEmptyString);
311 // returns True if we have wxLB_TOP or wxLB_BOTTOM style
312 bool IsVertical() const;
318 class wxListbookEvent : public wxBookCtrlEvent
321 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
322 int nSel = -1, int nOldSel = -1);
326 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
327 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
330 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
331 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
335 //---------------------------------------------------------------------------
339 class wxBookCtrlSizer: public wxSizer
342 %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)"
344 wxBookCtrlSizer( wxBookCtrl *nb );
348 wxBookCtrl *GetControl();
352 class wxNotebookSizer: public wxSizer {
354 %pythonAppend wxNotebookSizer "self._setOORInfo(self)"
356 wxNotebookSizer( wxNotebook *nb );
360 wxNotebook *GetNotebook();
363 //---------------------------------------------------------------------------