]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_notebook.i
reSWIGged
[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
172 wxNotebook(wxWindow *parent,
173 wxWindowID id=-1,
174 const wxPoint& pos = wxDefaultPosition,
175 const wxSize& size = wxDefaultSize,
176 long style = 0,
177 const wxString& name = wxPyNOTEBOOK_NAME);
178 %name(PreNotebook)wxNotebook();
179
180 bool Create(wxWindow *parent,
181 wxWindowID id=-1,
182 const wxPoint& pos = wxDefaultPosition,
183 const wxSize& size = wxDefaultSize,
184 long style = 0,
185 const wxString& name = wxPyNOTEBOOK_NAME);
186
187
188 // get the number of rows for a control with wxNB_MULTILINE style (not all
189 // versions support it - they will always return 1 then)
190 virtual int GetRowCount() const;
191
192 // set the padding between tabs (in pixels)
193 virtual void SetPadding(const wxSize& padding);
194
195 // set the size of the tabs for wxNB_FIXEDWIDTH controls
196 virtual void SetTabSize(const wxSize& sz);
197
198 // hit test, returns which tab is hit and, optionally, where (icon, label)
199 // (not implemented on all platforms)
200 DocDeclAStr(
201 virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const,
202 "HitTest(Point pt) -> (tab, where)",
203 "Returns the tab which is hit, and flags indicating where using
204 wx.NB_HITTEST flags.", "");
205
206 // implement some base class functions
207 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
208
209 #ifdef __WXMSW__
210 // Windows only: attempts to apply the UX theme page background to this page
211 void ApplyThemeBackground(wxWindow* window, const wxColour& colour);
212 #endif
213
214 static wxVisualAttributes
215 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
216 };
217
218
219
220 class wxNotebookEvent : public wxBookCtrlEvent
221 {
222 public:
223 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
224 int nSel = -1, int nOldSel = -1);
225
226 };
227
228 // notebook control event types
229 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
230 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
231
232
233 %pythoncode {
234 %# wxNotebook events
235 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
236 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
237 }
238
239
240 %pythoncode {
241 %#----------------------------------------------------------------------------
242
243 class NotebookPage(wx.Panel):
244 """
245 There is an old (and apparently unsolvable) bug when placing a
246 window with a nonstandard background colour in a wxNotebook on
247 wxGTK, as the notbooks's background colour would always be used
248 when the window is refreshed. The solution is to place a panel in
249 the notbook and the coloured window on the panel, sized to cover
250 the panel. This simple class does that for you, just put an
251 instance of this in the notebook and make your regular window a
252 child of this one and it will handle the resize for you.
253 """
254 def __init__(self, parent, id=-1,
255 pos=wx.DefaultPosition, size=wx.DefaultSize,
256 style=wx.TAB_TRAVERSAL, name="panel"):
257 wx.Panel.__init__(self, parent, id, pos, size, style, name)
258 self.child = None
259 EVT_SIZE(self, self.OnSize)
260
261 def OnSize(self, evt):
262 if self.child is None:
263 children = self.GetChildren()
264 if len(children):
265 self.child = children[0]
266 if self.child:
267 self.child.SetPosition((0,0))
268 self.child.SetSize(self.GetSize())
269
270 }
271
272 //---------------------------------------------------------------------------
273 %newgroup
274
275
276 enum
277 {
278 // default alignment: left everywhere except Mac where it is top
279 wxLB_DEFAULT = 0,
280
281 // put the list control to the left/right/top/bottom of the page area
282 wxLB_TOP = 0x1,
283 wxLB_BOTTOM = 0x2,
284 wxLB_LEFT = 0x4,
285 wxLB_RIGHT = 0x8,
286
287 // the mask which can be used to extract the alignment from the style
288 wxLB_ALIGN_MASK = 0xf,
289 };
290
291
292
293 MustHaveApp(wxListbook);
294
295 // wxListCtrl and wxNotebook combination
296 class wxListbook : public wxBookCtrl
297 {
298 public:
299 %pythonAppend wxListbook "self._setOORInfo(self)"
300 %pythonAppend wxListbook() ""
301
302 wxListbook(wxWindow *parent,
303 wxWindowID id=-1,
304 const wxPoint& pos = wxDefaultPosition,
305 const wxSize& size = wxDefaultSize,
306 long style = 0,
307 const wxString& name = wxPyEmptyString);
308 %name(PreListbook)wxListbook();
309
310 bool Create(wxWindow *parent,
311 wxWindowID id=-1,
312 const wxPoint& pos = wxDefaultPosition,
313 const wxSize& size = wxDefaultSize,
314 long style = 0,
315 const wxString& name = wxPyEmptyString);
316
317 // returns True if we have wxLB_TOP or wxLB_BOTTOM style
318 bool IsVertical() const;
319
320 };
321
322
323
324 class wxListbookEvent : public wxBookCtrlEvent
325 {
326 public:
327 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
328 int nSel = -1, int nOldSel = -1);
329 };
330
331
332 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
333 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
334
335 %pythoncode {
336 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
337 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
338 }
339
340
341 //---------------------------------------------------------------------------
342 %newgroup;
343
344
345 class wxBookCtrlSizer: public wxSizer
346 {
347 public:
348 %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)"
349
350 wxBookCtrlSizer( wxBookCtrl *nb );
351
352 void RecalcSizes();
353 wxSize CalcMin();
354 wxBookCtrl *GetControl();
355 };
356
357
358 class wxNotebookSizer: public wxSizer {
359 public:
360 %pythonAppend wxNotebookSizer "self._setOORInfo(self)"
361
362 wxNotebookSizer( wxNotebook *nb );
363
364 void RecalcSizes();
365 wxSize CalcMin();
366 wxNotebook *GetNotebook();
367 };
368
369 //---------------------------------------------------------------------------