]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_notebook.i
Fixes for later WinCE versions
[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 %{
19 DECLARE_DEF_STRING(NOTEBOOK_NAME);
20 %}
21
22 //---------------------------------------------------------------------------
23 %newgroup
24
25 // TODO: Virtualize this class so other book controls can be derived in Python
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 %addtofunc AssignImageList "args[1].thisown = 0"
70 void AssignImageList(wxImageList *imageList);
71
72 // get pointer (may be NULL) to the associated image list
73 wxImageList* GetImageList() const;
74
75 // sets/returns item's image index in the current image list
76 virtual int GetPageImage(size_t n) const/* = 0*/;
77 virtual bool SetPageImage(size_t n, int imageId)/* = 0*/;
78
79
80 // resize the notebook so that all pages will have the specified size
81 virtual void SetPageSize(const wxSize& size);
82
83 // calculate the size of the control from the size of its page
84 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const/* = 0*/;
85
86
87
88 // remove one page from the control and delete it
89 virtual bool DeletePage(size_t n);
90
91 // remove one page from the notebook, without deleting it
92 virtual bool RemovePage(size_t n);
93
94 // remove all pages and delete them
95 virtual bool DeleteAllPages();
96
97 // adds a new page to the control
98 virtual bool AddPage(wxWindow *page,
99 const wxString& text,
100 bool select = false,
101 int imageId = -1);
102
103 // the same as AddPage(), but adds the page at the specified position
104 virtual bool InsertPage(size_t n,
105 wxWindow *page,
106 const wxString& text,
107 bool select = false,
108 int imageId = -1)/* = 0*/;
109
110 // set the currently selected page, return the index of the previously
111 // selected one (or -1 on error)
112 //
113 // NB: this function will _not_ generate PAGE_CHANGING/ED events
114 virtual int SetSelection(size_t n)/* = 0*/;
115
116
117 // cycle thru the pages
118 void AdvanceSelection(bool forward = true);
119 };
120
121
122
123 class wxBookCtrlEvent : public wxNotifyEvent
124 {
125 public:
126 wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
127 int nSel = -1, int nOldSel = -1);
128
129 // the currently selected page (-1 if none)
130 int GetSelection() const;
131 void SetSelection(int nSel);
132 // the page that was selected before the change (-1 if none)
133 int GetOldSelection() const;
134 void SetOldSelection(int nOldSel);
135 };
136
137
138
139 //---------------------------------------------------------------------------
140 %newgroup
141
142 enum {
143 // styles
144 wxNB_FIXEDWIDTH,
145 wxNB_TOP,
146 wxNB_LEFT,
147 wxNB_RIGHT,
148 wxNB_BOTTOM,
149 wxNB_MULTILINE,
150
151 // hittest flags
152 wxNB_HITTEST_NOWHERE = 1, // not on tab
153 wxNB_HITTEST_ONICON = 2, // on icon
154 wxNB_HITTEST_ONLABEL = 4, // on label
155 wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL,
156
157 };
158
159
160
161 class wxNotebook : public wxBookCtrl {
162 public:
163 %addtofunc wxNotebook "self._setOORInfo(self)"
164 %addtofunc wxNotebook() ""
165
166 wxNotebook(wxWindow *parent,
167 wxWindowID id,
168 const wxPoint& pos = wxDefaultPosition,
169 const wxSize& size = wxDefaultSize,
170 long style = 0,
171 const wxString& name = wxPyNOTEBOOK_NAME);
172 %name(PreNotebook)wxNotebook();
173
174 bool Create(wxWindow *parent,
175 wxWindowID id,
176 const wxPoint& pos = wxDefaultPosition,
177 const wxSize& size = wxDefaultSize,
178 long style = 0,
179 const wxString& name = wxPyNOTEBOOK_NAME);
180
181
182 // get the number of rows for a control with wxNB_MULTILINE style (not all
183 // versions support it - they will always return 1 then)
184 virtual int GetRowCount() const;
185
186 // set the padding between tabs (in pixels)
187 virtual void SetPadding(const wxSize& padding);
188
189 // set the size of the tabs for wxNB_FIXEDWIDTH controls
190 virtual void SetTabSize(const wxSize& sz);
191
192 // hit test, returns which tab is hit and, optionally, where (icon, label)
193 // (not implemented on all platforms)
194 virtual int HitTest(const wxPoint& pt, long* OUTPUT) const;
195
196 // implement some base class functions
197 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
198
199 #ifdef __WXMSW__
200 // Windows only: attempts to apply the UX theme page background to this page
201 void ApplyThemeBackground(wxWindow* window, const wxColour& colour);
202 #endif
203 };
204
205
206
207 class wxNotebookEvent : public wxBookCtrlEvent
208 {
209 public:
210 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
211 int nSel = -1, int nOldSel = -1);
212
213 };
214
215 // notebook control event types
216 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
217 %constant wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
218
219
220 %pythoncode {
221 %# wxNotebook events
222 EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 )
223 EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 )
224 }
225
226
227 %pythoncode {
228 %#----------------------------------------------------------------------------
229
230 class NotebookPage(wx.Panel):
231 """
232 There is an old (and apparently unsolvable) bug when placing a
233 window with a nonstandard background colour in a wxNotebook on
234 wxGTK, as the notbooks's background colour would always be used
235 when the window is refreshed. The solution is to place a panel in
236 the notbook and the coloured window on the panel, sized to cover
237 the panel. This simple class does that for you, just put an
238 instance of this in the notebook and make your regular window a
239 child of this one and it will handle the resize for you.
240 """
241 def __init__(self, parent, id=-1,
242 pos=wx.DefaultPosition, size=wx.DefaultSize,
243 style=wx.TAB_TRAVERSAL, name="panel"):
244 wx.Panel.__init__(self, parent, id, pos, size, style, name)
245 self.child = None
246 EVT_SIZE(self, self.OnSize)
247
248 def OnSize(self, evt):
249 if self.child is None:
250 children = self.GetChildren()
251 if len(children):
252 self.child = children[0]
253 if self.child:
254 self.child.SetPosition((0,0))
255 self.child.SetSize(self.GetSize())
256
257 }
258
259 //---------------------------------------------------------------------------
260 %newgroup
261
262
263 enum
264 {
265 // default alignment: left everywhere except Mac where it is top
266 wxLB_DEFAULT = 0,
267
268 // put the list control to the left/right/top/bottom of the page area
269 wxLB_TOP = 0x1,
270 wxLB_BOTTOM = 0x2,
271 wxLB_LEFT = 0x4,
272 wxLB_RIGHT = 0x8,
273
274 // the mask which can be used to extract the alignment from the style
275 wxLB_ALIGN_MASK = 0xf,
276 };
277
278
279
280 // wxListCtrl and wxNotebook combination
281 class wxListbook : public wxBookCtrl
282 {
283 public:
284 %addtofunc wxListbook "self._setOORInfo(self)"
285 %addtofunc wxListbook() ""
286
287 wxListbook(wxWindow *parent,
288 wxWindowID id,
289 const wxPoint& pos = wxDefaultPosition,
290 const wxSize& size = wxDefaultSize,
291 long style = 0,
292 const wxString& name = wxPyEmptyString);
293 %name(PreListbook)wxListbook();
294
295 bool Create(wxWindow *parent,
296 wxWindowID id,
297 const wxPoint& pos = wxDefaultPosition,
298 const wxSize& size = wxDefaultSize,
299 long style = 0,
300 const wxString& name = wxPyEmptyString);
301
302 // returns true if we have wxLB_TOP or wxLB_BOTTOM style
303 bool IsVertical() const;
304
305 };
306
307
308
309 class wxListbookEvent : public wxBookCtrlEvent
310 {
311 public:
312 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
313 int nSel = -1, int nOldSel = -1);
314 };
315
316
317 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
318 %constant wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
319
320 %pythoncode {
321 EVT_LISTBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, 1 )
322 EVT_LISTBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, 1 )
323 }
324
325
326 //---------------------------------------------------------------------------
327 %newgroup;
328
329
330 class wxBookCtrlSizer: public wxSizer
331 {
332 public:
333 %addtofunc wxBookCtrlSizer "self._setOORInfo(self)"
334
335 wxBookCtrlSizer( wxBookCtrl *nb );
336
337 void RecalcSizes();
338 wxSize CalcMin();
339 wxBookCtrl *GetControl();
340 };
341
342
343 class wxNotebookSizer: public wxSizer {
344 public:
345 %addtofunc wxNotebookSizer "self._setOORInfo(self)"
346
347 wxNotebookSizer( wxNotebook *nb );
348
349 void RecalcSizes();
350 wxSize CalcMin();
351 wxNotebook *GetNotebook();
352 };
353
354 //---------------------------------------------------------------------------