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 %addtofunc AssignImageList "args[1].thisown = 0"
68 void AssignImageList(wxImageList *imageList);
70 // get pointer (may be NULL) to the associated image list
71 wxImageList* GetImageList() const;
73 // sets/returns item's image index in the current image list
74 virtual int GetPageImage(size_t n) const/* = 0*/;
75 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
78 // resize the notebook so that all pages will have the specified size
79 virtual void SetPageSize(const wxSize& size);
81 // calculate the size of the control from the size of its page
82 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
86 // remove one page from the control and delete it
87 virtual bool DeletePage(size_t n);
89 // remove one page from the notebook, without deleting it
90 virtual bool RemovePage(size_t n);
92 // remove all pages and delete them
93 virtual bool DeleteAllPages();
95 // adds a new page to the control
96 virtual bool AddPage(wxWindow *page,
101 // the same as AddPage(), but adds the page at the specified position
102 virtual bool InsertPage(size_t n,
104 const wxString& text,
106 int imageId = -1)/* = 0*/;
108 // set the currently selected page, return the index of the previously
109 // selected one (or -1 on error)
111 // NB: this function will _not_ generate PAGE_CHANGING/ED events
112 virtual int SetSelection(size_t n)/* = 0*/;
115 // cycle thru the pages
116 void AdvanceSelection(bool forward = True);
121 class wxBookCtrlEvent : public wxNotifyEvent
124 wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
125 int nSel = -1, int nOldSel = -1);
127 // the currently selected page (-1 if none)
128 int GetSelection() const;
129 void SetSelection(int nSel);
130 // the page that was selected before the change (-1 if none)
131 int GetOldSelection() const;
132 void SetOldSelection(int nOldSel);
137 //---------------------------------------------------------------------------
150 wxNB_HITTEST_NOWHERE = 1, // not on tab
151 wxNB_HITTEST_ONICON = 2, // on icon
152 wxNB_HITTEST_ONLABEL = 4, // on label
153 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
159 class wxNotebook : public wxBookCtrl {
161 %addtofunc wxNotebook "self._setOORInfo(self)"
162 %addtofunc wxNotebook() ""
164 wxNotebook(wxWindow *parent,
166 const wxPoint& pos = wxDefaultPosition,
167 const wxSize& size = wxDefaultSize,
169 const wxString& name = wxPyNOTEBOOK_NAME);
170 %name(PreNotebook)wxNotebook();
172 bool Create(wxWindow *parent,
174 const wxPoint& pos = wxDefaultPosition,
175 const wxSize& size = wxDefaultSize,
177 const wxString& name = wxPyNOTEBOOK_NAME);
180 // get the number of rows for a control with wxNB_MULTILINE style (not all
181 // versions support it - they will always return 1 then)
182 virtual int GetRowCount() const;
184 // set the padding between tabs (in pixels)
185 virtual void SetPadding(const wxSize& padding);
187 // set the size of the tabs for wxNB_FIXEDWIDTH controls
188 virtual void SetTabSize(const wxSize& sz);
190 // hit test, returns which tab is hit and, optionally, where (icon, label)
191 // (not implemented on all platforms)
193 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
194 "HitTest(Point pt) -> (tab, where)",
195 "Returns the tab which is hit, and flags indicating where using wxNB_HITTEST_ flags.");
197 // implement some base class functions
198 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
201 // Windows only: attempts to apply the UX theme page background to this page
202 void ApplyThemeBackground(wxWindow* window, const wxColour& colour);
208 class wxNotebookEvent : public wxBookCtrlEvent
211 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
212 int nSel = -1, int nOldSel = -1);
216 // notebook control event types
217 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
218 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
223 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
224 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
229 %#----------------------------------------------------------------------------
231 class NotebookPage(wx.Panel):
233 There is an old (and apparently unsolvable) bug when placing a
234 window with a nonstandard background colour in a wxNotebook on
235 wxGTK, as the notbooks's background colour would always be used
236 when the window is refreshed. The solution is to place a panel in
237 the notbook and the coloured window on the panel, sized to cover
238 the panel. This simple class does that for you, just put an
239 instance of this in the notebook and make your regular window a
240 child of this one and it will handle the resize for you.
242 def __init__(self, parent, id=-1,
243 pos=wx.DefaultPosition, size=wx.DefaultSize,
244 style=wx.TAB_TRAVERSAL, name="panel"):
245 wx.Panel.__init__(self, parent, id, pos, size, style, name)
247 EVT_SIZE(self, self.OnSize)
249 def OnSize(self, evt):
250 if self.child is None:
251 children = self.GetChildren()
253 self.child = children[0]
255 self.child.SetPosition((0,0))
256 self.child.SetSize(self.GetSize())
260 //---------------------------------------------------------------------------
266 // default alignment: left everywhere except Mac where it is top
269 // put the list control to the left/right/top/bottom of the page area
275 // the mask which can be used to extract the alignment from the style
276 wxLB_ALIGN_MASK = 0xf,
281 // wxListCtrl and wxNotebook combination
282 class wxListbook : public wxBookCtrl
285 %addtofunc wxListbook "self._setOORInfo(self)"
286 %addtofunc wxListbook() ""
288 wxListbook(wxWindow *parent,
290 const wxPoint& pos = wxDefaultPosition,
291 const wxSize& size = wxDefaultSize,
293 const wxString& name = wxPyEmptyString);
294 %name(PreListbook)wxListbook();
296 bool Create(wxWindow *parent,
298 const wxPoint& pos = wxDefaultPosition,
299 const wxSize& size = wxDefaultSize,
301 const wxString& name = wxPyEmptyString);
303 // returns True if we have wxLB_TOP or wxLB_BOTTOM style
304 bool IsVertical() const;
310 class wxListbookEvent : public wxBookCtrlEvent
313 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
314 int nSel = -1, int nOldSel = -1);
318 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
319 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
322 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
323 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
327 //---------------------------------------------------------------------------
331 class wxBookCtrlSizer: public wxSizer
334 %addtofunc wxBookCtrlSizer "self._setOORInfo(self)"
336 wxBookCtrlSizer( wxBookCtrl *nb );
340 wxBookCtrl *GetControl();
344 class wxNotebookSizer: public wxSizer {
346 %addtofunc wxNotebookSizer "self._setOORInfo(self)"
348 wxNotebookSizer( wxNotebook *nb );
352 wxNotebook *GetNotebook();
355 //---------------------------------------------------------------------------