]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_notebook.i
Add *wxTopLevelWindowGTK*RequestUserAttention*int*;
[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
23// TODO: Virtualize this class so other book controls can be derived in Python
24
1c272b5d 25MustHaveApp(wxBookCtrlBase);
ab1f7d2a 26
d14a1e28 27// Common base class for wxList/Tree/Notebook
1c272b5d 28class wxBookCtrlBase : public wxControl
d14a1e28
RD
29{
30public:
31 // This is an ABC, it can't be constructed...
32
1c272b5d 33// wxBookCtrlBase(wxWindow *parent,
d14a1e28
RD
34// wxWindowID id,
35// const wxPoint& pos = wxDefaultPosition,
36// const wxSize& size = wxDefaultSize,
37// long style = 0,
38// const wxString& name = wxPyEmptyString);
1b8c7ba6 39// %RenameCtor(PreBookCtrlBase, wxBookCtrlBase());
d14a1e28
RD
40// bool Create(wxWindow *parent,
41// wxWindowID id,
42// const wxPoint& pos = wxDefaultPosition,
43// const wxSize& size = wxDefaultSize,
44// long style = 0,
45// const wxString& name = wxPyEmptyString);
46
47
48 // get number of pages in the dialog
49 virtual size_t GetPageCount() const;
50
51 // get the panel which represents the given page
52 virtual wxWindow *GetPage(size_t n);
53
fbb9eac0
RD
54 // get the current page or NULL if none
55 wxWindow* GetCurrentPage() const;
56
d14a1e28
RD
57 // get the currently selected page or wxNOT_FOUND if none
58 virtual int GetSelection() const/* = 0*/;
59
60 // set/get the title of a page
61 virtual bool SetPageText(size_t n, const wxString& strText)/* = 0*/;
62 virtual wxString GetPageText(size_t n) const/* = 0*/;
63
64
65 // image list stuff: each page may have an image associated with it (all
66 // images belong to the same image list)
67
68 // sets the image list to use, it is *not* deleted by the control
69 virtual void SetImageList(wxImageList *imageList);
70
71 // as SetImageList() but we will delete the image list ourselves
8668c242 72 %apply SWIGTYPE *DISOWN { wxImageList *imageList };
d14a1e28 73 void AssignImageList(wxImageList *imageList);
8668c242 74 %clear wxImageList *imageList;
d14a1e28
RD
75
76 // get pointer (may be NULL) to the associated image list
77 wxImageList* GetImageList() const;
78
79 // sets/returns item's image index in the current image list
80 virtual int GetPageImage(size_t n) const/* = 0*/;
81 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
82
83
84 // resize the notebook so that all pages will have the specified size
85 virtual void SetPageSize(const wxSize& size);
86
87 // calculate the size of the control from the size of its page
88 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
89
90
91
92 // remove one page from the control and delete it
93 virtual bool DeletePage(size_t n);
94
95 // remove one page from the notebook, without deleting it
96 virtual bool RemovePage(size_t n);
97
98 // remove all pages and delete them
99 virtual bool DeleteAllPages();
100
101 // adds a new page to the control
102 virtual bool AddPage(wxWindow *page,
103 const wxString& text,
a72f4631 104 bool select = false,
d14a1e28
RD
105 int imageId = -1);
106
107 // the same as AddPage(), but adds the page at the specified position
108 virtual bool InsertPage(size_t n,
109 wxWindow *page,
110 const wxString& text,
a72f4631 111 bool select = false,
d14a1e28
RD
112 int imageId = -1)/* = 0*/;
113
114 // set the currently selected page, return the index of the previously
115 // selected one (or -1 on error)
116 //
117 // NB: this function will _not_ generate PAGE_CHANGING/ED events
118 virtual int SetSelection(size_t n)/* = 0*/;
119
120
121 // cycle thru the pages
a72f4631 122 void AdvanceSelection(bool forward = true);
880715c9
RD
123
124 static wxVisualAttributes
125 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
d14a1e28
RD
126};
127
128
129
1c272b5d 130class wxBookCtrlBaseEvent : public wxNotifyEvent
d14a1e28
RD
131{
132public:
1c272b5d 133 wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
d14a1e28
RD
134 int nSel = -1, int nOldSel = -1);
135
136 // the currently selected page (-1 if none)
137 int GetSelection() const;
138 void SetSelection(int nSel);
139 // the page that was selected before the change (-1 if none)
140 int GetOldSelection() const;
141 void SetOldSelection(int nOldSel);
142};
143
144
145
146//---------------------------------------------------------------------------
147%newgroup
148
149enum {
150 // styles
151 wxNB_FIXEDWIDTH,
152 wxNB_TOP,
153 wxNB_LEFT,
154 wxNB_RIGHT,
155 wxNB_BOTTOM,
156 wxNB_MULTILINE,
9c7d6396 157 wxNB_NOPAGETHEME,
d14a1e28
RD
158
159 // hittest flags
160 wxNB_HITTEST_NOWHERE = 1, // not on tab
161 wxNB_HITTEST_ONICON = 2, // on icon
162 wxNB_HITTEST_ONLABEL = 4, // on label
163 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
164
165};
166
167
168
ab1f7d2a
RD
169MustHaveApp(wxNotebook);
170
1c272b5d 171class wxNotebook : public wxBookCtrlBase {
d14a1e28 172public:
2b9048c5
RD
173 %pythonAppend wxNotebook "self._setOORInfo(self)"
174 %pythonAppend wxNotebook() ""
b39c3fa0 175 %typemap(out) wxNotebook*; // turn off this typemap
d14a1e28
RD
176
177 wxNotebook(wxWindow *parent,
13baae2c 178 wxWindowID id=-1,
d14a1e28
RD
179 const wxPoint& pos = wxDefaultPosition,
180 const wxSize& size = wxDefaultSize,
181 long style = 0,
a356336e 182 const wxString& name = wxPyNotebookNameStr);
1b8c7ba6 183 %RenameCtor(PreNotebook, wxNotebook());
d14a1e28 184
b39c3fa0
RD
185 // Turn it back on again
186 %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); }
187
d14a1e28 188 bool Create(wxWindow *parent,
d5573410 189 wxWindowID id=-1,
d14a1e28
RD
190 const wxPoint& pos = wxDefaultPosition,
191 const wxSize& size = wxDefaultSize,
192 long style = 0,
a356336e 193 const wxString& name = wxPyNotebookNameStr);
d14a1e28
RD
194
195
196 // get the number of rows for a control with wxNB_MULTILINE style (not all
197 // versions support it - they will always return 1 then)
198 virtual int GetRowCount() const;
199
200 // set the padding between tabs (in pixels)
201 virtual void SetPadding(const wxSize& padding);
202
203 // set the size of the tabs for wxNB_FIXEDWIDTH controls
204 virtual void SetTabSize(const wxSize& sz);
205
206 // hit test, returns which tab is hit and, optionally, where (icon, label)
207 // (not implemented on all platforms)
322913ce
RD
208 DocDeclAStr(
209 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
210 "HitTest(Point pt) -> (tab, where)",
d07d2bc9
RD
211 "Returns the tab which is hit, and flags indicating where using
212wx.NB_HITTEST flags.", "");
d14a1e28
RD
213
214 // implement some base class functions
215 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
216
9c7d6396
RD
217 // On platforms that support it, get the theme page background colour,
218 // else invalid colour
219 wxColour GetThemeBackgroundColour() const;
220
880715c9
RD
221 static wxVisualAttributes
222 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
d14a1e28
RD
223};
224
225
226
1c272b5d 227class wxNotebookEvent : public wxBookCtrlBaseEvent
d14a1e28
RD
228{
229public:
230 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
231 int nSel = -1, int nOldSel = -1);
232
233};
234
235// notebook control event types
236%constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
237%constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
238
239
240%pythoncode {
241 %# wxNotebook events
242 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
243 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
244}
245
246
247%pythoncode {
248%#----------------------------------------------------------------------------
249
250class NotebookPage(wx.Panel):
251 """
252 There is an old (and apparently unsolvable) bug when placing a
9718d66a 253 window with a nonstandard background colour in a wx.Notebook on
ac3b7152 254 wxGTK1, as the notbooks's background colour would always be used
d14a1e28
RD
255 when the window is refreshed. The solution is to place a panel in
256 the notbook and the coloured window on the panel, sized to cover
257 the panel. This simple class does that for you, just put an
258 instance of this in the notebook and make your regular window a
259 child of this one and it will handle the resize for you.
260 """
261 def __init__(self, parent, id=-1,
262 pos=wx.DefaultPosition, size=wx.DefaultSize,
263 style=wx.TAB_TRAVERSAL, name="panel"):
264 wx.Panel.__init__(self, parent, id, pos, size, style, name)
265 self.child = None
9718d66a 266 self.Bind(wx.EVT_SIZE, self.OnSize)
9694b21a 267
d14a1e28
RD
268 def OnSize(self, evt):
269 if self.child is None:
270 children = self.GetChildren()
271 if len(children):
272 self.child = children[0]
273 if self.child:
274 self.child.SetPosition((0,0))
275 self.child.SetSize(self.GetSize())
276
277}
278
279//---------------------------------------------------------------------------
280%newgroup
281
282
283enum
284{
285 // default alignment: left everywhere except Mac where it is top
286 wxLB_DEFAULT = 0,
287
288 // put the list control to the left/right/top/bottom of the page area
289 wxLB_TOP = 0x1,
290 wxLB_BOTTOM = 0x2,
291 wxLB_LEFT = 0x4,
292 wxLB_RIGHT = 0x8,
293
294 // the mask which can be used to extract the alignment from the style
295 wxLB_ALIGN_MASK = 0xf,
296};
297
298
299
ab1f7d2a
RD
300MustHaveApp(wxListbook);
301
d14a1e28 302// wxListCtrl and wxNotebook combination
1c272b5d 303class wxListbook : public wxBookCtrlBase
d14a1e28
RD
304{
305public:
2b9048c5
RD
306 %pythonAppend wxListbook "self._setOORInfo(self)"
307 %pythonAppend wxListbook() ""
d14a1e28
RD
308
309 wxListbook(wxWindow *parent,
13baae2c 310 wxWindowID id=-1,
d14a1e28
RD
311 const wxPoint& pos = wxDefaultPosition,
312 const wxSize& size = wxDefaultSize,
313 long style = 0,
314 const wxString& name = wxPyEmptyString);
1b8c7ba6 315 %RenameCtor(PreListbook, wxListbook());
d14a1e28
RD
316
317 bool Create(wxWindow *parent,
d5573410 318 wxWindowID id=-1,
d14a1e28
RD
319 const wxPoint& pos = wxDefaultPosition,
320 const wxSize& size = wxDefaultSize,
321 long style = 0,
322 const wxString& name = wxPyEmptyString);
323
dd9f7fea 324 // returns True if we have wxLB_TOP or wxLB_BOTTOM style
d14a1e28
RD
325 bool IsVertical() const;
326
9694b21a 327 wxListView* GetListView();
d14a1e28
RD
328};
329
330
331
1c272b5d 332class wxListbookEvent : public wxBookCtrlBaseEvent
d14a1e28
RD
333{
334public:
335 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
336 int nSel = -1, int nOldSel = -1);
337};
338
339
340%constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
341%constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
342
343%pythoncode {
344 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
345 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
346}
347
348
9694b21a
RD
349//---------------------------------------------------------------------------
350
9694b21a
RD
351
352/*
353 * wxChoicebook flags
354 */
355enum {
356 wxCHB_DEFAULT,
357 wxCHB_TOP,
358 wxCHB_BOTTOM,
359 wxCHB_LEFT,
360 wxCHB_RIGHT,
361 wxCHB_ALIGN_MASK
362};
363
364
365MustHaveApp(wxChoicebook);
366
1c272b5d 367class wxChoicebook : public wxBookCtrlBase
9694b21a
RD
368{
369public:
370 %pythonAppend wxChoicebook "self._setOORInfo(self)"
371 %pythonAppend wxChoicebook() ""
372
373 wxChoicebook(wxWindow *parent,
374 wxWindowID id,
375 const wxPoint& pos = wxDefaultPosition,
376 const wxSize& size = wxDefaultSize,
377 long style = 0,
378 const wxString& name = wxPyEmptyString);
1b8c7ba6 379 %RenameCtor(PreChoicebook, wxChoicebook());
9694b21a
RD
380
381 // quasi ctor
382 bool Create(wxWindow *parent,
383 wxWindowID id,
384 const wxPoint& pos = wxDefaultPosition,
385 const wxSize& size = wxDefaultSize,
386 long style = 0,
387 const wxString& name = wxPyEmptyString);
388
389
390 // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
88609ec9
RD
391 bool IsVertical() const;
392
393 // returns the choice control
394 wxChoice* GetChoiceCtrl() const;
9694b21a
RD
395
396 virtual bool DeleteAllPages();
397};
398
399
1c272b5d 400class wxChoicebookEvent : public wxBookCtrlBaseEvent
9694b21a
RD
401{
402public:
403 wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
404 int nSel = -1, int nOldSel = -1);
405};
406
407%constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
408%constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
409
410%pythoncode {
411 EVT_CHOICEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 )
412 EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 )
413}
414
d14a1e28
RD
415//---------------------------------------------------------------------------
416%newgroup;
417
aeee37c3 418// WXWIN_COMPATIBILITY_2_4
d14a1e28
RD
419
420class wxBookCtrlSizer: public wxSizer
421{
422public:
2b9048c5 423 %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)"
d14a1e28 424
1c272b5d 425 wxBookCtrlSizer( wxBookCtrlBase *nb );
9694b21a 426
d14a1e28
RD
427 void RecalcSizes();
428 wxSize CalcMin();
1c272b5d 429 wxBookCtrlBase *GetControl();
d14a1e28
RD
430};
431
432
433class wxNotebookSizer: public wxSizer {
434public:
2b9048c5 435 %pythonAppend wxNotebookSizer "self._setOORInfo(self)"
d14a1e28
RD
436
437 wxNotebookSizer( wxNotebook *nb );
9694b21a 438
d14a1e28
RD
439 void RecalcSizes();
440 wxSize CalcMin();
441 wxNotebook *GetNotebook();
442};
443
874cc425
RD
444%pythoncode { NotebookSizer.__init__ = wx._deprecated(NotebookSizer.__init__, "NotebookSizer is no longer needed.") }
445%pythoncode { BookCtrlSizer.__init__ = wx._deprecated(BookCtrlSizer.__init__, "BookCtrlSizer is no longer needed.") }
496d695b
RD
446
447
d14a1e28 448//---------------------------------------------------------------------------