]>
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 | ||
a356336e | 18 | MAKE_CONST_WXSTRING(NotebookNameStr); |
d14a1e28 RD |
19 | |
20 | //--------------------------------------------------------------------------- | |
21 | %newgroup | |
22 | ||
23 | // TODO: Virtualize this class so other book controls can be derived in Python | |
24 | ||
1c272b5d | 25 | MustHaveApp(wxBookCtrlBase); |
ab1f7d2a | 26 | |
d14a1e28 | 27 | // Common base class for wxList/Tree/Notebook |
1c272b5d | 28 | class wxBookCtrlBase : public wxControl |
d14a1e28 RD |
29 | { |
30 | public: | |
31 | // This is an ABC, it can't be constructed... | |
32 | ||
1c272b5d | 33 | // wxBookCtrlBase(wxWindow *parent, |
d14a1e28 RD |
34 | // wxWindowID id, |
35 | // const wxPoint& pos = wxDefaultPosition, | |
36 | // const wxSize& size = wxDefaultSize, | |
37 | // long style = 0, | |
38 | // const wxString& name = wxPyEmptyString); | |
1b8c7ba6 | 39 | // %RenameCtor(PreBookCtrlBase, wxBookCtrlBase()); |
d14a1e28 RD |
40 | // bool Create(wxWindow *parent, |
41 | // wxWindowID id, | |
42 | // const wxPoint& pos = wxDefaultPosition, | |
43 | // const wxSize& size = wxDefaultSize, | |
44 | // long style = 0, | |
45 | // const wxString& name = wxPyEmptyString); | |
46 | ||
47 | ||
48 | // get number of pages in the dialog | |
49 | virtual size_t GetPageCount() const; | |
50 | ||
51 | // get the panel which represents the given page | |
52 | virtual wxWindow *GetPage(size_t n); | |
53 | ||
fbb9eac0 RD |
54 | // get the current page or NULL if none |
55 | wxWindow* GetCurrentPage() const; | |
56 | ||
d14a1e28 RD |
57 | // get the currently selected page or wxNOT_FOUND if none |
58 | virtual int GetSelection() const/* = 0*/; | |
59 | ||
60 | // set/get the title of a page | |
61 | virtual bool SetPageText(size_t n, const wxString& strText)/* = 0*/; | |
62 | virtual wxString GetPageText(size_t n) const/* = 0*/; | |
63 | ||
64 | ||
65 | // image list stuff: each page may have an image associated with it (all | |
66 | // images belong to the same image list) | |
67 | ||
68 | // sets the image list to use, it is *not* deleted by the control | |
69 | virtual void SetImageList(wxImageList *imageList); | |
70 | ||
71 | // as SetImageList() but we will delete the image list ourselves | |
8668c242 | 72 | %apply SWIGTYPE *DISOWN { wxImageList *imageList }; |
d14a1e28 | 73 | void AssignImageList(wxImageList *imageList); |
8668c242 | 74 | %clear wxImageList *imageList; |
d14a1e28 RD |
75 | |
76 | // get pointer (may be NULL) to the associated image list | |
77 | wxImageList* GetImageList() const; | |
78 | ||
79 | // sets/returns item's image index in the current image list | |
80 | virtual int GetPageImage(size_t n) const/* = 0*/; | |
81 | virtual bool SetPageImage(size_t n, int imageId)/* = 0*/; | |
82 | ||
83 | ||
84 | // resize the notebook so that all pages will have the specified size | |
85 | virtual void SetPageSize(const wxSize& size); | |
86 | ||
87 | // calculate the size of the control from the size of its page | |
88 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/; | |
89 | ||
90 | ||
91 | ||
92 | // remove one page from the control and delete it | |
93 | virtual bool DeletePage(size_t n); | |
94 | ||
95 | // remove one page from the notebook, without deleting it | |
96 | virtual bool RemovePage(size_t n); | |
97 | ||
98 | // remove all pages and delete them | |
99 | virtual bool DeleteAllPages(); | |
100 | ||
101 | // adds a new page to the control | |
102 | virtual bool AddPage(wxWindow *page, | |
103 | const wxString& text, | |
a72f4631 | 104 | bool select = false, |
d14a1e28 RD |
105 | int imageId = -1); |
106 | ||
107 | // the same as AddPage(), but adds the page at the specified position | |
108 | virtual bool InsertPage(size_t n, | |
109 | wxWindow *page, | |
110 | const wxString& text, | |
a72f4631 | 111 | bool select = false, |
d14a1e28 RD |
112 | int imageId = -1)/* = 0*/; |
113 | ||
114 | // set the currently selected page, return the index of the previously | |
115 | // selected one (or -1 on error) | |
116 | // | |
117 | // NB: this function will _not_ generate PAGE_CHANGING/ED events | |
118 | virtual int SetSelection(size_t n)/* = 0*/; | |
119 | ||
120 | ||
121 | // cycle thru the pages | |
a72f4631 | 122 | void AdvanceSelection(bool forward = true); |
880715c9 RD |
123 | |
124 | static wxVisualAttributes | |
125 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
d14a1e28 RD |
126 | }; |
127 | ||
128 | ||
129 | ||
1c272b5d | 130 | class wxBookCtrlBaseEvent : public wxNotifyEvent |
d14a1e28 RD |
131 | { |
132 | public: | |
1c272b5d | 133 | wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int id = 0, |
d14a1e28 RD |
134 | int nSel = -1, int nOldSel = -1); |
135 | ||
136 | // the currently selected page (-1 if none) | |
137 | int GetSelection() const; | |
138 | void SetSelection(int nSel); | |
139 | // the page that was selected before the change (-1 if none) | |
140 | int GetOldSelection() const; | |
141 | void SetOldSelection(int nOldSel); | |
142 | }; | |
143 | ||
144 | ||
145 | ||
146 | //--------------------------------------------------------------------------- | |
147 | %newgroup | |
148 | ||
149 | enum { | |
150 | // styles | |
151 | wxNB_FIXEDWIDTH, | |
152 | wxNB_TOP, | |
153 | wxNB_LEFT, | |
154 | wxNB_RIGHT, | |
155 | wxNB_BOTTOM, | |
156 | wxNB_MULTILINE, | |
157 | ||
158 | // hittest flags | |
159 | wxNB_HITTEST_NOWHERE = 1, // not on tab | |
160 | wxNB_HITTEST_ONICON = 2, // on icon | |
161 | wxNB_HITTEST_ONLABEL = 4, // on label | |
162 | wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL, | |
163 | ||
164 | }; | |
165 | ||
166 | ||
167 | ||
ab1f7d2a RD |
168 | MustHaveApp(wxNotebook); |
169 | ||
1c272b5d | 170 | class wxNotebook : public wxBookCtrlBase { |
d14a1e28 | 171 | public: |
2b9048c5 RD |
172 | %pythonAppend wxNotebook "self._setOORInfo(self)" |
173 | %pythonAppend wxNotebook() "" | |
b39c3fa0 | 174 | %typemap(out) wxNotebook*; // turn off this typemap |
d14a1e28 RD |
175 | |
176 | wxNotebook(wxWindow *parent, | |
13baae2c | 177 | wxWindowID id=-1, |
d14a1e28 RD |
178 | const wxPoint& pos = wxDefaultPosition, |
179 | const wxSize& size = wxDefaultSize, | |
180 | long style = 0, | |
a356336e | 181 | const wxString& name = wxPyNotebookNameStr); |
1b8c7ba6 | 182 | %RenameCtor(PreNotebook, wxNotebook()); |
d14a1e28 | 183 | |
b39c3fa0 RD |
184 | // Turn it back on again |
185 | %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); } | |
186 | ||
d14a1e28 | 187 | bool Create(wxWindow *parent, |
d5573410 | 188 | wxWindowID id=-1, |
d14a1e28 RD |
189 | const wxPoint& pos = wxDefaultPosition, |
190 | const wxSize& size = wxDefaultSize, | |
191 | long style = 0, | |
a356336e | 192 | const wxString& name = wxPyNotebookNameStr); |
d14a1e28 RD |
193 | |
194 | ||
195 | // get the number of rows for a control with wxNB_MULTILINE style (not all | |
196 | // versions support it - they will always return 1 then) | |
197 | virtual int GetRowCount() const; | |
198 | ||
199 | // set the padding between tabs (in pixels) | |
200 | virtual void SetPadding(const wxSize& padding); | |
201 | ||
202 | // set the size of the tabs for wxNB_FIXEDWIDTH controls | |
203 | virtual void SetTabSize(const wxSize& sz); | |
204 | ||
205 | // hit test, returns which tab is hit and, optionally, where (icon, label) | |
206 | // (not implemented on all platforms) | |
322913ce RD |
207 | DocDeclAStr( |
208 | virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const, | |
209 | "HitTest(Point pt) -> (tab, where)", | |
d07d2bc9 RD |
210 | "Returns the tab which is hit, and flags indicating where using |
211 | wx.NB_HITTEST flags.", ""); | |
d14a1e28 RD |
212 | |
213 | // implement some base class functions | |
214 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; | |
215 | ||
880715c9 RD |
216 | static wxVisualAttributes |
217 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
d14a1e28 RD |
218 | }; |
219 | ||
220 | ||
221 | ||
1c272b5d | 222 | class wxNotebookEvent : public wxBookCtrlBaseEvent |
d14a1e28 RD |
223 | { |
224 | public: | |
225 | wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
226 | int nSel = -1, int nOldSel = -1); | |
227 | ||
228 | }; | |
229 | ||
230 | // notebook control event types | |
231 | %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED; | |
232 | %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING; | |
233 | ||
234 | ||
235 | %pythoncode { | |
236 | %# wxNotebook events | |
237 | EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 ) | |
238 | EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 ) | |
239 | } | |
240 | ||
241 | ||
242 | %pythoncode { | |
243 | %#---------------------------------------------------------------------------- | |
244 | ||
245 | class NotebookPage(wx.Panel): | |
246 | """ | |
247 | There is an old (and apparently unsolvable) bug when placing a | |
248 | window with a nonstandard background colour in a wxNotebook on | |
249 | wxGTK, as the notbooks's background colour would always be used | |
250 | when the window is refreshed. The solution is to place a panel in | |
251 | the notbook and the coloured window on the panel, sized to cover | |
252 | the panel. This simple class does that for you, just put an | |
253 | instance of this in the notebook and make your regular window a | |
254 | child of this one and it will handle the resize for you. | |
255 | """ | |
256 | def __init__(self, parent, id=-1, | |
257 | pos=wx.DefaultPosition, size=wx.DefaultSize, | |
258 | style=wx.TAB_TRAVERSAL, name="panel"): | |
259 | wx.Panel.__init__(self, parent, id, pos, size, style, name) | |
260 | self.child = None | |
261 | EVT_SIZE(self, self.OnSize) | |
9694b21a | 262 | |
d14a1e28 RD |
263 | def OnSize(self, evt): |
264 | if self.child is None: | |
265 | children = self.GetChildren() | |
266 | if len(children): | |
267 | self.child = children[0] | |
268 | if self.child: | |
269 | self.child.SetPosition((0,0)) | |
270 | self.child.SetSize(self.GetSize()) | |
271 | ||
272 | } | |
273 | ||
274 | //--------------------------------------------------------------------------- | |
275 | %newgroup | |
276 | ||
277 | ||
278 | enum | |
279 | { | |
280 | // default alignment: left everywhere except Mac where it is top | |
281 | wxLB_DEFAULT = 0, | |
282 | ||
283 | // put the list control to the left/right/top/bottom of the page area | |
284 | wxLB_TOP = 0x1, | |
285 | wxLB_BOTTOM = 0x2, | |
286 | wxLB_LEFT = 0x4, | |
287 | wxLB_RIGHT = 0x8, | |
288 | ||
289 | // the mask which can be used to extract the alignment from the style | |
290 | wxLB_ALIGN_MASK = 0xf, | |
291 | }; | |
292 | ||
293 | ||
294 | ||
ab1f7d2a RD |
295 | MustHaveApp(wxListbook); |
296 | ||
d14a1e28 | 297 | // wxListCtrl and wxNotebook combination |
1c272b5d | 298 | class wxListbook : public wxBookCtrlBase |
d14a1e28 RD |
299 | { |
300 | public: | |
2b9048c5 RD |
301 | %pythonAppend wxListbook "self._setOORInfo(self)" |
302 | %pythonAppend wxListbook() "" | |
d14a1e28 RD |
303 | |
304 | wxListbook(wxWindow *parent, | |
13baae2c | 305 | wxWindowID id=-1, |
d14a1e28 RD |
306 | const wxPoint& pos = wxDefaultPosition, |
307 | const wxSize& size = wxDefaultSize, | |
308 | long style = 0, | |
309 | const wxString& name = wxPyEmptyString); | |
1b8c7ba6 | 310 | %RenameCtor(PreListbook, wxListbook()); |
d14a1e28 RD |
311 | |
312 | bool Create(wxWindow *parent, | |
d5573410 | 313 | wxWindowID id=-1, |
d14a1e28 RD |
314 | const wxPoint& pos = wxDefaultPosition, |
315 | const wxSize& size = wxDefaultSize, | |
316 | long style = 0, | |
317 | const wxString& name = wxPyEmptyString); | |
318 | ||
dd9f7fea | 319 | // returns True if we have wxLB_TOP or wxLB_BOTTOM style |
d14a1e28 RD |
320 | bool IsVertical() const; |
321 | ||
9694b21a | 322 | wxListView* GetListView(); |
d14a1e28 RD |
323 | }; |
324 | ||
325 | ||
326 | ||
1c272b5d | 327 | class wxListbookEvent : public wxBookCtrlBaseEvent |
d14a1e28 RD |
328 | { |
329 | public: | |
330 | wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
331 | int nSel = -1, int nOldSel = -1); | |
332 | }; | |
333 | ||
334 | ||
335 | %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED; | |
336 | %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING; | |
337 | ||
338 | %pythoncode { | |
339 | EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 ) | |
340 | EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 ) | |
341 | } | |
342 | ||
343 | ||
9694b21a RD |
344 | //--------------------------------------------------------------------------- |
345 | ||
9694b21a RD |
346 | |
347 | /* | |
348 | * wxChoicebook flags | |
349 | */ | |
350 | enum { | |
351 | wxCHB_DEFAULT, | |
352 | wxCHB_TOP, | |
353 | wxCHB_BOTTOM, | |
354 | wxCHB_LEFT, | |
355 | wxCHB_RIGHT, | |
356 | wxCHB_ALIGN_MASK | |
357 | }; | |
358 | ||
359 | ||
360 | MustHaveApp(wxChoicebook); | |
361 | ||
1c272b5d | 362 | class wxChoicebook : public wxBookCtrlBase |
9694b21a RD |
363 | { |
364 | public: | |
365 | %pythonAppend wxChoicebook "self._setOORInfo(self)" | |
366 | %pythonAppend wxChoicebook() "" | |
367 | ||
368 | wxChoicebook(wxWindow *parent, | |
369 | wxWindowID id, | |
370 | const wxPoint& pos = wxDefaultPosition, | |
371 | const wxSize& size = wxDefaultSize, | |
372 | long style = 0, | |
373 | const wxString& name = wxPyEmptyString); | |
1b8c7ba6 | 374 | %RenameCtor(PreChoicebook, wxChoicebook()); |
9694b21a RD |
375 | |
376 | // quasi ctor | |
377 | bool Create(wxWindow *parent, | |
378 | wxWindowID id, | |
379 | const wxPoint& pos = wxDefaultPosition, | |
380 | const wxSize& size = wxDefaultSize, | |
381 | long style = 0, | |
382 | const wxString& name = wxPyEmptyString); | |
383 | ||
384 | ||
385 | // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style | |
386 | bool IsVertical() const { return HasFlag(wxCHB_BOTTOM | wxCHB_TOP); } | |
387 | ||
388 | virtual bool DeleteAllPages(); | |
389 | }; | |
390 | ||
391 | ||
1c272b5d | 392 | class wxChoicebookEvent : public wxBookCtrlBaseEvent |
9694b21a RD |
393 | { |
394 | public: | |
395 | wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
396 | int nSel = -1, int nOldSel = -1); | |
397 | }; | |
398 | ||
399 | %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED; | |
400 | %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING; | |
401 | ||
402 | %pythoncode { | |
403 | EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 ) | |
404 | EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 ) | |
405 | } | |
406 | ||
d14a1e28 RD |
407 | //--------------------------------------------------------------------------- |
408 | %newgroup; | |
409 | ||
aeee37c3 | 410 | // WXWIN_COMPATIBILITY_2_4 |
d14a1e28 RD |
411 | |
412 | class wxBookCtrlSizer: public wxSizer | |
413 | { | |
414 | public: | |
2b9048c5 | 415 | %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)" |
d14a1e28 | 416 | |
1c272b5d | 417 | wxBookCtrlSizer( wxBookCtrlBase *nb ); |
9694b21a | 418 | |
d14a1e28 RD |
419 | void RecalcSizes(); |
420 | wxSize CalcMin(); | |
1c272b5d | 421 | wxBookCtrlBase *GetControl(); |
d14a1e28 RD |
422 | }; |
423 | ||
424 | ||
425 | class wxNotebookSizer: public wxSizer { | |
426 | public: | |
2b9048c5 | 427 | %pythonAppend wxNotebookSizer "self._setOORInfo(self)" |
d14a1e28 RD |
428 | |
429 | wxNotebookSizer( wxNotebook *nb ); | |
9694b21a | 430 | |
d14a1e28 RD |
431 | void RecalcSizes(); |
432 | wxSize CalcMin(); | |
433 | wxNotebook *GetNotebook(); | |
434 | }; | |
435 | ||
496d695b RD |
436 | |
437 | %pythoncode { NotebookSizer = wx._deprecated(NotebookSizer, "NotebookSizer is no longer needed.") } | |
438 | %pythoncode { BookCtrlSizer = wx._deprecated(BookCtrlSizer, "BookCtrlSizer is no longer needed.") } | |
439 | ||
440 | ||
d14a1e28 | 441 | //--------------------------------------------------------------------------- |