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