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