]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_notebook.i
cleanup - reformatting
[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
110 void SetShrinkMode(bool shrink);
111 bool GetShrinkMode() const;
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.
476 %Rename(InsertSubPage,
477 virtual bool, AddSubPage(size_t pos,
478 wxWindow *page,
479 const wxString& text,
480 bool select = false,
481 int imageId = wxNOT_FOUND));
482
483 // Adds a new page at top level after all other pages.
484 virtual bool AddPage(wxWindow *page,
485 const wxString& text,
486 bool select = false,
487 int imageId = wxNOT_FOUND);
488
489 // Adds a new child-page to the last top-level page inserted.
490 // Useful when constructing 1 level tree structure.
491 virtual bool AddSubPage(wxWindow *page,
492 const wxString& text,
493 bool select = false,
494 int imageId = wxNOT_FOUND);
495
496 // Deletes the page and ALL its children. Could trigger page selection
497 // change in a case when selected page is removed. In that case its parent
498 // is selected (or the next page if no parent).
499 virtual bool DeletePage(size_t pos);
d14a1e28 500
9694b21a 501
6aabc8da
RD
502 // Tree operations
503 // ---------------
504
505 // Gets the page node state -- node is expanded or collapsed
506 virtual bool IsNodeExpanded(size_t pos) const;
507
508 // Expands or collapses the page node. Returns the previous state.
509 // May generate page changing events (if selected page
510 // is under the collapsed branch, then parent is autoselected).
511 virtual bool ExpandNode(size_t pos, bool expand = true);
512
513 // shortcut for ExpandNode(pos, false)
514 bool CollapseNode(size_t pos);
515
516 // get the parent page or wxNOT_FOUND if this is a top level page
517 int GetPageParent(size_t pos) const;
518
519 // the tree control we use for showing the pages index tree
520 wxTreeCtrl* GetTreeCtrl() const;
521
522};
523
524
525class wxTreebookEvent : public wxBookCtrlBaseEvent
526{
527public:
528 wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
529 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND);
d14a1e28
RD
530};
531
6aabc8da
RD
532%constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED;
533%constant wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING;
534%constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED;
535%constant wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED;
d14a1e28 536
6aabc8da
RD
537
538%pythoncode {
539 EVT_TREEBOOK_PAGE_CHANGED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, 1 )
540 EVT_TREEBOOK_PAGE_CHANGING= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, 1)
541 EVT_TREEBOOK_NODE_COLLAPSED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, 1 )
542 EVT_TREEBOOK_NODE_EXPANDED= wx.PyEventBinder( wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, 1 )
543}
544
545//---------------------------------------------------------------------------
546%newgroup;
547
548MustHaveApp(wxTreebook);
549
550class wxToolbook : public wxBookCtrlBase
551{
d14a1e28 552public:
6aabc8da
RD
553 %pythonAppend wxToolbook "self._setOORInfo(self)"
554 %pythonAppend wxToolbook() ""
555
556
557 // This ctor creates the tree book control
558 wxToolbook(wxWindow *parent,
559 wxWindowID id,
560 const wxPoint& pos = wxDefaultPosition,
561 const wxSize& size = wxDefaultSize,
562 long style = wxBK_DEFAULT,
563 const wxString& name = wxPyEmptyString);
564
565 %RenameCtor(PreToolbook, wxToolbook());
566
567 // quasi ctor
568 bool Create(wxWindow *parent,
569 wxWindowID id,
570 const wxPoint& pos = wxDefaultPosition,
571 const wxSize& size = wxDefaultSize,
572 long style = 0,
573 const wxString& name = wxEmptyString);
d14a1e28 574
9694b21a 575
6aabc8da
RD
576 wxToolBarBase* GetToolBar() const;
577
578 // Not part of the wxBookctrl API, but must be called in OnIdle or
579 // by application to realize the toolbar and select the initial page.
580 void Realize();
581};
582
583
584class wxToolbookEvent : public wxBookCtrlBaseEvent
585{
586public:
587 wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
588 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND);
d14a1e28
RD
589};
590
6aabc8da
RD
591
592%constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
593%constant wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
594
595
596%pythoncode {
597 EVT_TOOLBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, 1)
598 EVT_TOOLBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, 1)
599}
496d695b 600
d14a1e28 601//---------------------------------------------------------------------------