]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_notebook.i
Build fix for motif.
[wxWidgets.git] / wxPython / src / _notebook.i
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
18 MAKE_CONST_WXSTRING(NotebookNameStr);
19
20 //---------------------------------------------------------------------------
21 %newgroup
22
23
24 enum {
25 wxBK_DEFAULT,
26 wxBK_TOP,
27 wxBK_BOTTOM,
28 wxBK_LEFT,
29 wxBK_RIGHT,
30 wxBK_ALIGN_MASK,
31 wxBK_BUTTONBAR
32 };
33
34
35 // TODO: Virtualize this class so other book controls can be derived in Python
36
37 MustHaveApp(wxBookCtrlBase);
38
39 // Common base class for wxList/Tree/Notebook
40 class wxBookCtrlBase : public wxControl
41 {
42 public:
43 // This is an ABC, it can't be constructed...
44
45 // wxBookCtrlBase(wxWindow *parent,
46 // wxWindowID id,
47 // const wxPoint& pos = wxDefaultPosition,
48 // const wxSize& size = wxDefaultSize,
49 // long style = 0,
50 // const wxString& name = wxPyEmptyString);
51 // %RenameCtor(PreBookCtrlBase, wxBookCtrlBase());
52 // bool Create(wxWindow *parent,
53 // wxWindowID id,
54 // const wxPoint& pos = wxDefaultPosition,
55 // const wxSize& size = wxDefaultSize,
56 // long style = 0,
57 // const wxString& name = wxPyEmptyString);
58
59
60 // get number of pages in the dialog
61 virtual size_t GetPageCount() const;
62
63 // get the panel which represents the given page
64 virtual wxWindow *GetPage(size_t n);
65
66 // get the current page or NULL if none
67 wxWindow* GetCurrentPage() const;
68
69 // get the currently selected page or wxNOT_FOUND if none
70 virtual int GetSelection() const/* = 0*/;
71
72 // set/get the title of a page
73 virtual bool SetPageText(size_t n, const wxString& strText)/* = 0*/;
74 virtual wxString GetPageText(size_t n) const/* = 0*/;
75
76
77 // image list stuff: each page may have an image associated with it (all
78 // images belong to the same image list)
79
80 // sets the image list to use, it is *not* deleted by the control
81 virtual void SetImageList(wxImageList *imageList);
82
83 // as SetImageList() but we will delete the image list ourselves
84 %disownarg( wxImageList *imageList );
85 void AssignImageList(wxImageList *imageList);
86 %cleardisown( wxImageList *imageList );
87
88 // get pointer (may be NULL) to the associated image list
89 wxImageList* GetImageList() const;
90
91 // sets/returns item's image index in the current image list
92 virtual int GetPageImage(size_t n) const/* = 0*/;
93 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
94
95
96 // resize the notebook so that all pages will have the specified size
97 virtual void SetPageSize(const wxSize& size);
98
99 // calculate the size of the control from the size of its page
100 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
101
102
103 // get/set size of area between book control area and page area
104 unsigned int GetInternalBorder() const;
105 void SetInternalBorder(unsigned int internalBorder);
106
107 // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
108 bool IsVertical() const;
109
110 // Sets/gets the margin around the controller
111 void SetControlMargin(int margin);
112 int GetControlMargin() const;
113
114 // set/get option to shrink to fit current page
115 void SetFitToCurrentPage(bool fit);
116 bool GetFitToCurrentPage() const;
117
118 // returns the sizer containing the control, if any
119 wxSizer* GetControlSizer() const;
120
121
122 // remove one page from the control and delete it
123 virtual bool DeletePage(size_t n);
124
125 // remove one page from the notebook, without deleting it
126 virtual bool RemovePage(size_t n);
127
128 // remove all pages and delete them
129 virtual bool DeleteAllPages();
130
131 // adds a new page to the control
132 virtual bool AddPage(wxWindow *page,
133 const wxString& text,
134 bool select = false,
135 int imageId = -1);
136
137 // the same as AddPage(), but adds the page at the specified position
138 virtual bool InsertPage(size_t n,
139 wxWindow *page,
140 const wxString& text,
141 bool select = false,
142 int imageId = -1)/* = 0*/;
143
144 // set the currently selected page, return the index of the previously
145 // selected one (or -1 on error)
146 //
147 // NB: this function will _not_ generate PAGE_CHANGING/ED events
148 virtual int SetSelection(size_t n)/* = 0*/;
149
150
151 // cycle thru the pages
152 void AdvanceSelection(bool forward = true);
153
154 DocDeclAStr(
155 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
156 "HitTest(Point pt) -> (tab, where)",
157 "Returns the page/tab which is hit, and flags indicating where using
158 wx.NB_HITTEST flags.", "");
159
160 static wxVisualAttributes
161 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
162 };
163
164
165
166 class wxBookCtrlBaseEvent : public wxNotifyEvent
167 {
168 public:
169 wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
170 int nSel = -1, int nOldSel = -1);
171
172 // the currently selected page (-1 if none)
173 int GetSelection() const;
174 void SetSelection(int nSel);
175 // the page that was selected before the change (-1 if none)
176 int GetOldSelection() const;
177 void SetOldSelection(int nOldSel);
178 };
179
180
181
182 //---------------------------------------------------------------------------
183 %newgroup
184
185 enum {
186 // styles
187 wxNB_FIXEDWIDTH,
188 wxNB_TOP,
189 wxNB_LEFT,
190 wxNB_RIGHT,
191 wxNB_BOTTOM,
192 wxNB_MULTILINE,
193 wxNB_NOPAGETHEME,
194
195 // hittest flags
196 wxNB_HITTEST_NOWHERE = 1, // not on tab
197 wxNB_HITTEST_ONICON = 2, // on icon
198 wxNB_HITTEST_ONLABEL = 4, // on label
199 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
200
201 };
202
203
204
205 MustHaveApp(wxNotebook);
206
207 class wxNotebook : public wxBookCtrlBase {
208 public:
209 %pythonAppend wxNotebook "self._setOORInfo(self)"
210 %pythonAppend wxNotebook() ""
211 %typemap(out) wxNotebook*; // turn off this typemap
212
213 wxNotebook(wxWindow *parent,
214 wxWindowID id=-1,
215 const wxPoint& pos = wxDefaultPosition,
216 const wxSize& size = wxDefaultSize,
217 long style = 0,
218 const wxString& name = wxPyNotebookNameStr);
219 %RenameCtor(PreNotebook, wxNotebook());
220
221 // Turn it back on again
222 %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); }
223
224 bool Create(wxWindow *parent,
225 wxWindowID id=-1,
226 const wxPoint& pos = wxDefaultPosition,
227 const wxSize& size = wxDefaultSize,
228 long style = 0,
229 const wxString& name = wxPyNotebookNameStr);
230
231
232 // get the number of rows for a control with wxNB_MULTILINE style (not all
233 // versions support it - they will always return 1 then)
234 virtual int GetRowCount() const;
235
236 // set the padding between tabs (in pixels)
237 virtual void SetPadding(const wxSize& padding);
238
239 // set the size of the tabs for wxNB_FIXEDWIDTH controls
240 virtual void SetTabSize(const wxSize& sz);
241
242 // implement some base class functions
243 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
244
245 // On platforms that support it, get the theme page background colour,
246 // else invalid colour
247 wxColour GetThemeBackgroundColour() const;
248
249 static wxVisualAttributes
250 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
251 };
252
253
254
255 class wxNotebookEvent : public wxBookCtrlBaseEvent
256 {
257 public:
258 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
259 int nSel = -1, int nOldSel = -1);
260
261 };
262
263 // notebook control event types
264 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
265 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
266
267
268 %pythoncode {
269 %# wxNotebook events
270 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
271 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
272 }
273
274
275 %pythoncode {
276 %#----------------------------------------------------------------------------
277
278 class NotebookPage(wx.Panel):
279 """
280 There is an old (and apparently unsolvable) bug when placing a
281 window with a nonstandard background colour in a wx.Notebook on
282 wxGTK1, as the notbooks's background colour would always be used
283 when the window is refreshed. The solution is to place a panel in
284 the notbook and the coloured window on the panel, sized to cover
285 the panel. This simple class does that for you, just put an
286 instance of this in the notebook and make your regular window a
287 child of this one and it will handle the resize for you.
288 """
289 def __init__(self, parent, id=-1,
290 pos=wx.DefaultPosition, size=wx.DefaultSize,
291 style=wx.TAB_TRAVERSAL, name="panel"):
292 wx.Panel.__init__(self, parent, id, pos, size, style, name)
293 self.child = None
294 self.Bind(wx.EVT_SIZE, self.OnSize)
295
296 def OnSize(self, evt):
297 if self.child is None:
298 children = self.GetChildren()
299 if len(children):
300 self.child = children[0]
301 if self.child:
302 self.child.SetPosition((0,0))
303 self.child.SetSize(self.GetSize())
304
305 }
306
307 //---------------------------------------------------------------------------
308 %newgroup
309
310
311 enum
312 {
313 // default alignment: left everywhere except Mac where it is top
314 wxLB_DEFAULT = 0,
315
316 // put the list control to the left/right/top/bottom of the page area
317 wxLB_TOP = 0x1,
318 wxLB_BOTTOM = 0x2,
319 wxLB_LEFT = 0x4,
320 wxLB_RIGHT = 0x8,
321
322 // the mask which can be used to extract the alignment from the style
323 wxLB_ALIGN_MASK = 0xf,
324 };
325
326
327
328 MustHaveApp(wxListbook);
329
330 // wxListCtrl and wxNotebook combination
331 class wxListbook : public wxBookCtrlBase
332 {
333 public:
334 %pythonAppend wxListbook "self._setOORInfo(self)"
335 %pythonAppend wxListbook() ""
336
337 wxListbook(wxWindow *parent,
338 wxWindowID id=-1,
339 const wxPoint& pos = wxDefaultPosition,
340 const wxSize& size = wxDefaultSize,
341 long style = 0,
342 const wxString& name = wxPyEmptyString);
343 %RenameCtor(PreListbook, wxListbook());
344
345 bool Create(wxWindow *parent,
346 wxWindowID id=-1,
347 const wxPoint& pos = wxDefaultPosition,
348 const wxSize& size = wxDefaultSize,
349 long style = 0,
350 const wxString& name = wxPyEmptyString);
351
352 wxListView* GetListView();
353 };
354
355
356
357 class wxListbookEvent : public wxBookCtrlBaseEvent
358 {
359 public:
360 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
361 int nSel = -1, int nOldSel = -1);
362 };
363
364
365 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
366 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
367
368 %pythoncode {
369 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
370 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
371 }
372
373
374 //---------------------------------------------------------------------------
375
376
377 /*
378 * wxChoicebook flags
379 */
380 enum {
381 wxCHB_DEFAULT,
382 wxCHB_TOP,
383 wxCHB_BOTTOM,
384 wxCHB_LEFT,
385 wxCHB_RIGHT,
386 wxCHB_ALIGN_MASK
387 };
388
389
390 MustHaveApp(wxChoicebook);
391
392 class wxChoicebook : public wxBookCtrlBase
393 {
394 public:
395 %pythonAppend wxChoicebook "self._setOORInfo(self)"
396 %pythonAppend wxChoicebook() ""
397
398 wxChoicebook(wxWindow *parent,
399 wxWindowID id,
400 const wxPoint& pos = wxDefaultPosition,
401 const wxSize& size = wxDefaultSize,
402 long style = 0,
403 const wxString& name = wxPyEmptyString);
404 %RenameCtor(PreChoicebook, wxChoicebook());
405
406 // quasi ctor
407 bool Create(wxWindow *parent,
408 wxWindowID id,
409 const wxPoint& pos = wxDefaultPosition,
410 const wxSize& size = wxDefaultSize,
411 long style = 0,
412 const wxString& name = wxPyEmptyString);
413
414
415 // returns the choice control
416 wxChoice* GetChoiceCtrl() const;
417
418 virtual bool DeleteAllPages();
419 };
420
421
422 class wxChoicebookEvent : public wxBookCtrlBaseEvent
423 {
424 public:
425 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
426 int nSel = -1, int nOldSel = -1);
427 };
428
429 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
430 %constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
431
432 %pythoncode {
433 EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 )
434 EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 )
435 }
436
437 //---------------------------------------------------------------------------
438 %newgroup;
439
440 MustHaveApp(wxTreebook);
441
442 class wxTreebook : public wxBookCtrlBase
443 {
444 public:
445 %pythonAppend wxTreebook "self._setOORInfo(self)"
446 %pythonAppend wxTreebook() ""
447
448
449 // This ctor creates the tree book control
450 wxTreebook(wxWindow *parent,
451 wxWindowID id,
452 const wxPoint& pos = wxDefaultPosition,
453 const wxSize& size = wxDefaultSize,
454 long style = wxBK_DEFAULT,
455 const wxString& name = wxPyEmptyString);
456
457 %RenameCtor(PreTreebook, wxTreebook());
458
459
460 // Really creates the control
461 bool Create(wxWindow *parent,
462 wxWindowID id,
463 const wxPoint& pos = wxDefaultPosition,
464 const wxSize& size = wxDefaultSize,
465 long style = wxBK_DEFAULT,
466 const wxString& name = wxPyEmptyString);
467
468
469 // Notice that page pointer may be NULL in which case the next non NULL
470 // page (usually the first child page of a node) is shown when this page is
471 // selected
472
473 // Inserts a new page just before the page indicated by page.
474 // The new page is placed on the same level as page.
475 virtual bool InsertPage(size_t pos,
476 wxWindow *page,
477 const wxString& text,
478 bool select = false,
479 int imageId = wxNOT_FOUND);
480
481 // Inserts a new sub-page to the end of children of the page at given pos.
482 virtual bool InsertSubPage(size_t pos,
483 wxWindow *page,
484 const wxString& text,
485 bool select = false,
486 int imageId = wxNOT_FOUND);
487
488 // Adds a new page at top level after all other pages.
489 virtual bool AddPage(wxWindow *page,
490 const wxString& text,
491 bool select = false,
492 int imageId = wxNOT_FOUND);
493
494 // Adds a new child-page to the last top-level page inserted.
495 // Useful when constructing 1 level tree structure.
496 virtual bool AddSubPage(wxWindow *page,
497 const wxString& text,
498 bool select = false,
499 int imageId = wxNOT_FOUND);
500
501 // Deletes the page and ALL its children. Could trigger page selection
502 // change in a case when selected page is removed. In that case its parent
503 // is selected (or the next page if no parent).
504 virtual bool DeletePage(size_t pos);
505
506
507 // Tree operations
508 // ---------------
509
510 // Gets the page node state -- node is expanded or collapsed
511 virtual bool IsNodeExpanded(size_t pos) const;
512
513 // Expands or collapses the page node. Returns the previous state.
514 // May generate page changing events (if selected page
515 // is under the collapsed branch, then parent is autoselected).
516 virtual bool ExpandNode(size_t pos, bool expand = true);
517
518 // shortcut for ExpandNode(pos, false)
519 bool CollapseNode(size_t pos);
520
521 // get the parent page or wxNOT_FOUND if this is a top level page
522 int GetPageParent(size_t pos) const;
523
524 // the tree control we use for showing the pages index tree
525 wxTreeCtrl* GetTreeCtrl() const;
526
527 };
528
529
530 class wxTreebookEvent : public wxBookCtrlBaseEvent
531 {
532 public:
533 wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
534 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND);
535 };
536
537 %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED;
538 %constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING;
539 %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED;
540 %constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED;
541
542
543 %pythoncode {
544 EVT_TREEBOOK_PAGE_CHANGED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, 1 )
545 EVT_TREEBOOK_PAGE_CHANGING= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, 1)
546 EVT_TREEBOOK_NODE_COLLAPSED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, 1 )
547 EVT_TREEBOOK_NODE_EXPANDED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, 1 )
548 }
549
550 //---------------------------------------------------------------------------
551 %newgroup;
552
553 MustHaveApp(wxTreebook);
554
555 class wxToolbook : public wxBookCtrlBase
556 {
557 public:
558 %pythonAppend wxToolbook "self._setOORInfo(self)"
559 %pythonAppend wxToolbook() ""
560
561
562 // This ctor creates the tree book control
563 wxToolbook(wxWindow *parent,
564 wxWindowID id,
565 const wxPoint& pos = wxDefaultPosition,
566 const wxSize& size = wxDefaultSize,
567 long style = wxBK_DEFAULT,
568 const wxString& name = wxPyEmptyString);
569
570 %RenameCtor(PreToolbook, wxToolbook());
571
572 // quasi ctor
573 bool Create(wxWindow *parent,
574 wxWindowID id,
575 const wxPoint& pos = wxDefaultPosition,
576 const wxSize& size = wxDefaultSize,
577 long style = 0,
578 const wxString& name = wxEmptyString);
579
580
581 wxToolBarBase* GetToolBar() const;
582
583 // Not part of the wxBookctrl API, but must be called in OnIdle or
584 // by application to realize the toolbar and select the initial page.
585 void Realize();
586 };
587
588
589 class wxToolbookEvent : public wxBookCtrlBaseEvent
590 {
591 public:
592 wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
593 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND);
594 };
595
596
597 %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
598 %constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
599
600
601 %pythoncode {
602 EVT_TOOLBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, 1)
603 EVT_TOOLBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, 1)
604 }
605
606 //---------------------------------------------------------------------------