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