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