]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _notebook.i | |
3 | // Purpose: SWIG interface defs for wxNotebook and such | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 2-June-1998 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | ||
b2dc1044 | 18 | MAKE_CONST_WXSTRING(NOTEBOOK_NAME); |
d14a1e28 RD |
19 | |
20 | //--------------------------------------------------------------------------- | |
21 | %newgroup | |
22 | ||
23 | // TODO: Virtualize this class so other book controls can be derived in Python | |
24 | ||
25 | // Common base class for wxList/Tree/Notebook | |
26 | class wxBookCtrl : public wxControl | |
27 | { | |
28 | public: | |
29 | // This is an ABC, it can't be constructed... | |
30 | ||
31 | // wxBookCtrl(wxWindow *parent, | |
32 | // wxWindowID id, | |
33 | // const wxPoint& pos = wxDefaultPosition, | |
34 | // const wxSize& size = wxDefaultSize, | |
35 | // long style = 0, | |
36 | // const wxString& name = wxPyEmptyString); | |
37 | // %name(PreBookCtrl)wxBookCtrl(); | |
38 | // bool Create(wxWindow *parent, | |
39 | // wxWindowID id, | |
40 | // const wxPoint& pos = wxDefaultPosition, | |
41 | // const wxSize& size = wxDefaultSize, | |
42 | // long style = 0, | |
43 | // const wxString& name = wxPyEmptyString); | |
44 | ||
45 | ||
46 | // get number of pages in the dialog | |
47 | virtual size_t GetPageCount() const; | |
48 | ||
49 | // get the panel which represents the given page | |
50 | virtual wxWindow *GetPage(size_t n); | |
51 | ||
52 | // get the currently selected page or wxNOT_FOUND if none | |
53 | virtual int GetSelection() const/* = 0*/; | |
54 | ||
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*/; | |
58 | ||
59 | ||
60 | // image list stuff: each page may have an image associated with it (all | |
61 | // images belong to the same image list) | |
62 | ||
63 | // sets the image list to use, it is *not* deleted by the control | |
64 | virtual void SetImageList(wxImageList *imageList); | |
65 | ||
66 | // as SetImageList() but we will delete the image list ourselves | |
8668c242 | 67 | %apply SWIGTYPE *DISOWN { wxImageList *imageList }; |
d14a1e28 | 68 | void AssignImageList(wxImageList *imageList); |
8668c242 | 69 | %clear wxImageList *imageList; |
d14a1e28 RD |
70 | |
71 | // get pointer (may be NULL) to the associated image list | |
72 | wxImageList* GetImageList() const; | |
73 | ||
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*/; | |
77 | ||
78 | ||
79 | // resize the notebook so that all pages will have the specified size | |
80 | virtual void SetPageSize(const wxSize& size); | |
81 | ||
82 | // calculate the size of the control from the size of its page | |
83 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/; | |
84 | ||
85 | ||
86 | ||
87 | // remove one page from the control and delete it | |
88 | virtual bool DeletePage(size_t n); | |
89 | ||
90 | // remove one page from the notebook, without deleting it | |
91 | virtual bool RemovePage(size_t n); | |
92 | ||
93 | // remove all pages and delete them | |
94 | virtual bool DeleteAllPages(); | |
95 | ||
96 | // adds a new page to the control | |
97 | virtual bool AddPage(wxWindow *page, | |
98 | const wxString& text, | |
dd9f7fea | 99 | bool select = False, |
d14a1e28 RD |
100 | int imageId = -1); |
101 | ||
102 | // the same as AddPage(), but adds the page at the specified position | |
103 | virtual bool InsertPage(size_t n, | |
104 | wxWindow *page, | |
105 | const wxString& text, | |
dd9f7fea | 106 | bool select = False, |
d14a1e28 RD |
107 | int imageId = -1)/* = 0*/; |
108 | ||
109 | // set the currently selected page, return the index of the previously | |
110 | // selected one (or -1 on error) | |
111 | // | |
112 | // NB: this function will _not_ generate PAGE_CHANGING/ED events | |
113 | virtual int SetSelection(size_t n)/* = 0*/; | |
114 | ||
115 | ||
116 | // cycle thru the pages | |
dd9f7fea | 117 | void AdvanceSelection(bool forward = True); |
d14a1e28 RD |
118 | }; |
119 | ||
120 | ||
121 | ||
122 | class wxBookCtrlEvent : public wxNotifyEvent | |
123 | { | |
124 | public: | |
125 | wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
126 | int nSel = -1, int nOldSel = -1); | |
127 | ||
128 | // the currently selected page (-1 if none) | |
129 | int GetSelection() const; | |
130 | void SetSelection(int nSel); | |
131 | // the page that was selected before the change (-1 if none) | |
132 | int GetOldSelection() const; | |
133 | void SetOldSelection(int nOldSel); | |
134 | }; | |
135 | ||
136 | ||
137 | ||
138 | //--------------------------------------------------------------------------- | |
139 | %newgroup | |
140 | ||
141 | enum { | |
142 | // styles | |
143 | wxNB_FIXEDWIDTH, | |
144 | wxNB_TOP, | |
145 | wxNB_LEFT, | |
146 | wxNB_RIGHT, | |
147 | wxNB_BOTTOM, | |
148 | wxNB_MULTILINE, | |
149 | ||
150 | // hittest flags | |
151 | wxNB_HITTEST_NOWHERE = 1, // not on tab | |
152 | wxNB_HITTEST_ONICON = 2, // on icon | |
153 | wxNB_HITTEST_ONLABEL = 4, // on label | |
154 | wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL, | |
155 | ||
156 | }; | |
157 | ||
158 | ||
159 | ||
160 | class wxNotebook : public wxBookCtrl { | |
161 | public: | |
2b9048c5 RD |
162 | %pythonAppend wxNotebook "self._setOORInfo(self)" |
163 | %pythonAppend wxNotebook() "" | |
d14a1e28 RD |
164 | |
165 | wxNotebook(wxWindow *parent, | |
166 | wxWindowID id, | |
167 | const wxPoint& pos = wxDefaultPosition, | |
168 | const wxSize& size = wxDefaultSize, | |
169 | long style = 0, | |
170 | const wxString& name = wxPyNOTEBOOK_NAME); | |
171 | %name(PreNotebook)wxNotebook(); | |
172 | ||
173 | bool Create(wxWindow *parent, | |
174 | wxWindowID id, | |
175 | const wxPoint& pos = wxDefaultPosition, | |
176 | const wxSize& size = wxDefaultSize, | |
177 | long style = 0, | |
178 | const wxString& name = wxPyNOTEBOOK_NAME); | |
179 | ||
180 | ||
181 | // get the number of rows for a control with wxNB_MULTILINE style (not all | |
182 | // versions support it - they will always return 1 then) | |
183 | virtual int GetRowCount() const; | |
184 | ||
185 | // set the padding between tabs (in pixels) | |
186 | virtual void SetPadding(const wxSize& padding); | |
187 | ||
188 | // set the size of the tabs for wxNB_FIXEDWIDTH controls | |
189 | virtual void SetTabSize(const wxSize& sz); | |
190 | ||
191 | // hit test, returns which tab is hit and, optionally, where (icon, label) | |
192 | // (not implemented on all platforms) | |
322913ce RD |
193 | DocDeclAStr( |
194 | virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const, | |
195 | "HitTest(Point pt) -> (tab, where)", | |
b60e45d1 | 196 | "Returns the tab which is hit, and flags indicating where using wx.NB_HITTEST_ flags."); |
d14a1e28 RD |
197 | |
198 | // implement some base class functions | |
199 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; | |
200 | ||
201 | #ifdef __WXMSW__ | |
202 | // Windows only: attempts to apply the UX theme page background to this page | |
203 | void ApplyThemeBackground(wxWindow* window, const wxColour& colour); | |
204 | #endif | |
205 | }; | |
206 | ||
207 | ||
208 | ||
209 | class wxNotebookEvent : public wxBookCtrlEvent | |
210 | { | |
211 | public: | |
212 | wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
213 | int nSel = -1, int nOldSel = -1); | |
214 | ||
215 | }; | |
216 | ||
217 | // notebook control event types | |
218 | %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED; | |
219 | %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING; | |
220 | ||
221 | ||
222 | %pythoncode { | |
223 | %# wxNotebook events | |
224 | EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 ) | |
225 | EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 ) | |
226 | } | |
227 | ||
228 | ||
229 | %pythoncode { | |
230 | %#---------------------------------------------------------------------------- | |
231 | ||
232 | class NotebookPage(wx.Panel): | |
233 | """ | |
234 | There is an old (and apparently unsolvable) bug when placing a | |
235 | window with a nonstandard background colour in a wxNotebook on | |
236 | wxGTK, as the notbooks's background colour would always be used | |
237 | when the window is refreshed. The solution is to place a panel in | |
238 | the notbook and the coloured window on the panel, sized to cover | |
239 | the panel. This simple class does that for you, just put an | |
240 | instance of this in the notebook and make your regular window a | |
241 | child of this one and it will handle the resize for you. | |
242 | """ | |
243 | def __init__(self, parent, id=-1, | |
244 | pos=wx.DefaultPosition, size=wx.DefaultSize, | |
245 | style=wx.TAB_TRAVERSAL, name="panel"): | |
246 | wx.Panel.__init__(self, parent, id, pos, size, style, name) | |
247 | self.child = None | |
248 | EVT_SIZE(self, self.OnSize) | |
249 | ||
250 | def OnSize(self, evt): | |
251 | if self.child is None: | |
252 | children = self.GetChildren() | |
253 | if len(children): | |
254 | self.child = children[0] | |
255 | if self.child: | |
256 | self.child.SetPosition((0,0)) | |
257 | self.child.SetSize(self.GetSize()) | |
258 | ||
259 | } | |
260 | ||
261 | //--------------------------------------------------------------------------- | |
262 | %newgroup | |
263 | ||
264 | ||
265 | enum | |
266 | { | |
267 | // default alignment: left everywhere except Mac where it is top | |
268 | wxLB_DEFAULT = 0, | |
269 | ||
270 | // put the list control to the left/right/top/bottom of the page area | |
271 | wxLB_TOP = 0x1, | |
272 | wxLB_BOTTOM = 0x2, | |
273 | wxLB_LEFT = 0x4, | |
274 | wxLB_RIGHT = 0x8, | |
275 | ||
276 | // the mask which can be used to extract the alignment from the style | |
277 | wxLB_ALIGN_MASK = 0xf, | |
278 | }; | |
279 | ||
280 | ||
281 | ||
282 | // wxListCtrl and wxNotebook combination | |
283 | class wxListbook : public wxBookCtrl | |
284 | { | |
285 | public: | |
2b9048c5 RD |
286 | %pythonAppend wxListbook "self._setOORInfo(self)" |
287 | %pythonAppend wxListbook() "" | |
d14a1e28 RD |
288 | |
289 | wxListbook(wxWindow *parent, | |
290 | wxWindowID id, | |
291 | const wxPoint& pos = wxDefaultPosition, | |
292 | const wxSize& size = wxDefaultSize, | |
293 | long style = 0, | |
294 | const wxString& name = wxPyEmptyString); | |
295 | %name(PreListbook)wxListbook(); | |
296 | ||
297 | bool Create(wxWindow *parent, | |
298 | wxWindowID id, | |
299 | const wxPoint& pos = wxDefaultPosition, | |
300 | const wxSize& size = wxDefaultSize, | |
301 | long style = 0, | |
302 | const wxString& name = wxPyEmptyString); | |
303 | ||
dd9f7fea | 304 | // returns True if we have wxLB_TOP or wxLB_BOTTOM style |
d14a1e28 RD |
305 | bool IsVertical() const; |
306 | ||
307 | }; | |
308 | ||
309 | ||
310 | ||
311 | class wxListbookEvent : public wxBookCtrlEvent | |
312 | { | |
313 | public: | |
314 | wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
315 | int nSel = -1, int nOldSel = -1); | |
316 | }; | |
317 | ||
318 | ||
319 | %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED; | |
320 | %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING; | |
321 | ||
322 | %pythoncode { | |
323 | EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 ) | |
324 | EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 ) | |
325 | } | |
326 | ||
327 | ||
328 | //--------------------------------------------------------------------------- | |
329 | %newgroup; | |
330 | ||
331 | ||
332 | class wxBookCtrlSizer: public wxSizer | |
333 | { | |
334 | public: | |
2b9048c5 | 335 | %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)" |
d14a1e28 RD |
336 | |
337 | wxBookCtrlSizer( wxBookCtrl *nb ); | |
338 | ||
339 | void RecalcSizes(); | |
340 | wxSize CalcMin(); | |
341 | wxBookCtrl *GetControl(); | |
342 | }; | |
343 | ||
344 | ||
345 | class wxNotebookSizer: public wxSizer { | |
346 | public: | |
2b9048c5 | 347 | %pythonAppend wxNotebookSizer "self._setOORInfo(self)" |
d14a1e28 RD |
348 | |
349 | wxNotebookSizer( wxNotebook *nb ); | |
350 | ||
351 | void RecalcSizes(); | |
352 | wxSize CalcMin(); | |
353 | wxNotebook *GetNotebook(); | |
354 | }; | |
355 | ||
356 | //--------------------------------------------------------------------------- |