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