]> git.saurik.com Git - wxWidgets.git/blame - interface/notebook.h
Trying to make wxString readable again
[wxWidgets.git] / interface / notebook.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: notebook.h
e54c96f1 3// Purpose: interface of wxNotebookEvent
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxNotebookEvent
11 @wxheader{notebook.h}
7c913512 12
23324ae1
FM
13 This class represents the events generated by a notebook control: currently,
14 there are two of them. The PAGE_CHANGING event is sent before the current
15 page is changed. It allows the program to examine the current page (which
7c913512 16 can be retrieved with
23324ae1
FM
17 wxNotebookEvent::GetOldSelection) and to veto the page
18 change by calling wxNotifyEvent::Veto if, for example, the
19 current values in the controls of the old page are invalid.
7c913512 20
23324ae1
FM
21 The second event - PAGE_CHANGED - is sent after the page has been changed and
22 the program cannot veto it any more, it just informs it about the page change.
7c913512 23
23324ae1
FM
24 To summarize, if the program is interested in validating the page values
25 before allowing the user to change it, it should process the PAGE_CHANGING
26 event, otherwise PAGE_CHANGED is probably enough. In any case, it is probably
27 unnecessary to process both events at once.
7c913512 28
23324ae1
FM
29 @library{wxcore}
30 @category{events}
7c913512 31
e54c96f1 32 @see wxNotebook
23324ae1
FM
33*/
34class wxNotebookEvent : public wxNotifyEvent
35{
36public:
37 /**
38 Constructor (used internally by wxWidgets only).
39 */
4cc4bfaf 40 wxNotebookEvent(wxEventType eventType = wxEVT_NULL, int id = 0,
23324ae1
FM
41 int sel = -1,
42 int oldSel = -1);
43
44 /**
45 Returns the page that was selected before the change, -1 if none was selected.
46 */
328f5751 47 int GetOldSelection() const;
23324ae1
FM
48
49 /**
50 Returns the currently selected page, or -1 if none was selected.
1f1d2182 51 @note under Windows, GetSelection() will return the same value as
23324ae1
FM
52 GetOldSelection() when called from
53 @c EVT_NOTEBOOK_PAGE_CHANGING handler and not the page which is going to
54 be selected. Also note that the values of selection and old selection returned
7c913512 55 for an event generated in response to a call to
23324ae1
FM
56 wxNotebook::SetSelection shouldn't be trusted
57 as they are currently inconsistent under different platforms (but in this case
58 you presumably don't need them anyhow as you already have the corresponding
59 information).
60 */
328f5751 61 int GetSelection() const;
23324ae1
FM
62
63 /**
64 Sets the id of the page selected before the change.
65 */
66 void SetOldSelection(int page);
67
68 /**
69 Sets the selection member variable.
70 */
71 void SetSelection(int page);
72};
73
74
e54c96f1 75
23324ae1
FM
76/**
77 @class wxNotebook
78 @wxheader{notebook.h}
7c913512 79
23324ae1
FM
80 This class represents a notebook control, which manages multiple windows with
81 associated tabs.
7c913512 82
23324ae1
FM
83 To use the class, create a wxNotebook object and call wxNotebook::AddPage or
84 wxNotebook::InsertPage,
85 passing a window to be used as the page. Do not explicitly delete the window
86 for a page that is currently
87 managed by wxNotebook.
7c913512 88
23324ae1 89 @b wxNotebookPage is a typedef for wxWindow.
7c913512 90
23324ae1 91 @beginStyleTable
8c6791e4 92 @style{wxNB_TOP}
23324ae1 93 Place tabs on the top side.
8c6791e4 94 @style{wxNB_LEFT}
23324ae1 95 Place tabs on the left side.
8c6791e4 96 @style{wxNB_RIGHT}
23324ae1 97 Place tabs on the right side.
8c6791e4 98 @style{wxNB_BOTTOM}
23324ae1 99 Place tabs under instead of above the notebook pages.
8c6791e4 100 @style{wxNB_FIXEDWIDTH}
23324ae1 101 (Windows only) All tabs will have same width.
8c6791e4 102 @style{wxNB_MULTILINE}
23324ae1 103 (Windows only) There can be several rows of tabs.
8c6791e4 104 @style{wxNB_NOPAGETHEME}
23324ae1
FM
105 (Windows only) Display a solid colour on notebook pages, and not a
106 gradient, which can reduce performance.
8c6791e4 107 @style{wxNB_FLAT}
23324ae1
FM
108 (Windows CE only) Show tabs in a flat style.
109 @endStyleTable
7c913512 110
23324ae1
FM
111 @library{wxcore}
112 @category{miscwnd}
7c913512 113
e54c96f1 114 @see wxBookCtrl(), wxNotebookEvent, wxImageList, @ref overview_samplenotebook
23324ae1
FM
115 "notebook sample"
116*/
117class wxNotebook : public wxBookCtrl overview
118{
119public:
120 //@{
121 /**
122 Constructs a notebook control.
23324ae1
FM
123 Note that sometimes you can reduce flicker by passing the wxCLIP_CHILDREN
124 window style.
3c4f71cc 125
7c913512 126 @param parent
4cc4bfaf 127 The parent window. Must be non-@NULL.
7c913512 128 @param id
4cc4bfaf 129 The window identifier.
7c913512 130 @param pos
4cc4bfaf 131 The window position.
7c913512 132 @param size
4cc4bfaf 133 The window size.
7c913512 134 @param style
4cc4bfaf 135 The window style. See wxNotebook.
7c913512 136 @param name
4cc4bfaf 137 The name of the control (used only under Motif).
23324ae1
FM
138 */
139 wxNotebook();
7c913512
FM
140 wxNotebook(wxWindow* parent, wxWindowID id,
141 const wxPoint& pos = wxDefaultPosition,
142 const wxSize& size = wxDefaultSize,
143 long style = 0,
144 const wxString& name = wxNotebookNameStr);
23324ae1
FM
145 //@}
146
147 /**
148 Destroys the wxNotebook object.
149 */
a6052817 150 virtual ~wxNotebook();
23324ae1
FM
151
152 /**
153 Adds a new page.
23324ae1 154 The call to this function may generate the page changing events.
3c4f71cc 155
7c913512 156 @param page
4cc4bfaf 157 Specifies the new page.
7c913512 158 @param text
4cc4bfaf 159 Specifies the text for the new page.
7c913512 160 @param select
4cc4bfaf 161 Specifies whether the page should be selected.
7c913512 162 @param imageId
4cc4bfaf 163 Specifies the optional image index for the new page.
3c4f71cc 164
23324ae1 165 @returns @true if successful, @false otherwise.
3c4f71cc 166
23324ae1 167 @remarks Do not delete the page, it will be deleted by the notebook.
3c4f71cc 168
4cc4bfaf 169 @see InsertPage()
23324ae1
FM
170 */
171 bool AddPage(wxNotebookPage* page, const wxString& text,
4cc4bfaf 172 bool select = false,
23324ae1
FM
173 int imageId = -1);
174
175 /**
176 Cycles through the tabs.
23324ae1
FM
177 The call to this function generates the page changing events.
178 */
4cc4bfaf 179 void AdvanceSelection(bool forward = true);
23324ae1
FM
180
181 /**
182 Sets the image list for the page control and takes ownership of
183 the list.
3c4f71cc 184
4cc4bfaf 185 @see wxImageList, SetImageList()
23324ae1
FM
186 */
187 void AssignImageList(wxImageList* imageList);
188
189 /**
190 Changes the selection for the given page, returning the previous selection.
23324ae1
FM
191 The call to this function does not generate the page changing events.
192 This is the only difference with SetSelection().
193 See @ref overview_progevent "this topic" for more info.
194 */
a6052817 195 virtual int ChangeSelection(size_t page);
23324ae1
FM
196
197 /**
198 Creates a notebook control. See wxNotebook() for a description
199 of the parameters.
200 */
201 bool Create(wxWindow* parent, wxWindowID id,
202 const wxPoint& pos = wxDefaultPosition,
a6052817
FM
203 const wxSize& size = wxDefaultSize,
204 long style = 0,
23324ae1
FM
205 const wxString& name = wxNotebookNameStr);
206
207 /**
208 Deletes all pages.
209 */
a6052817 210 virtual bool DeleteAllPages();
23324ae1
FM
211
212 /**
213 Deletes the specified page, and the associated window.
23324ae1
FM
214 The call to this function generates the page changing events.
215 */
216 bool DeletePage(size_t page);
217
218 /**
219 Returns the currently selected notebook page or @NULL.
220 */
328f5751 221 wxWindow* GetCurrentPage() const;
23324ae1
FM
222
223 /**
224 Returns the associated image list.
3c4f71cc 225
4cc4bfaf 226 @see wxImageList, SetImageList()
23324ae1 227 */
328f5751 228 wxImageList* GetImageList() const;
23324ae1
FM
229
230 /**
231 Returns the window at the given page position.
232 */
233 wxNotebookPage* GetPage(size_t page);
234
235 /**
236 Returns the number of pages in the notebook control.
237 */
328f5751 238 size_t GetPageCount() const;
23324ae1
FM
239
240 /**
241 Returns the image index for the given page.
242 */
a6052817 243 virtual int GetPageImage(size_t nPage) const;
23324ae1
FM
244
245 /**
246 Returns the string for the given page.
247 */
a6052817 248 virtual wxString GetPageText(size_t nPage) const;
23324ae1
FM
249
250 /**
251 Returns the number of rows in the notebook control.
252 */
a6052817 253 virtual int GetRowCount() const;
23324ae1
FM
254
255 /**
256 Returns the currently selected page, or -1 if none was selected.
23324ae1
FM
257 Note that this method may return either the previously or newly selected page
258 when called from the @c EVT_NOTEBOOK_PAGE_CHANGED handler depending on
259 the platform and so
260 wxNotebookEvent::GetSelection should be
261 used instead in this case.
262 */
a6052817 263 virtual int GetSelection() const;
23324ae1
FM
264
265 /**
266 If running under Windows and themes are enabled for the application, this
267 function
268 returns a suitable colour for painting the background of a notebook page, and
269 can be passed
270 to @c SetBackgroundColour. Otherwise, an uninitialised colour will be returned.
271 */
a6052817 272 virtual wxColour GetThemeBackgroundColour() const;
23324ae1
FM
273
274 /**
275 Returns the index of the tab at the specified position or @c wxNOT_FOUND
4cc4bfaf 276 if none. If @a flags parameter is non-@NULL, the position of the point
23324ae1 277 inside the tab is returned as well.
3c4f71cc 278
7c913512 279 @param pt
4cc4bfaf 280 Specifies the point for the hit test.
7c913512 281 @param flags
4cc4bfaf 282 Return value for detailed information. One of the following values:
3c4f71cc
VS
283
284
285
286
287
288
289
4cc4bfaf 290 wxBK_HITTEST_NOWHERE
3c4f71cc
VS
291
292
293
294
4cc4bfaf 295 There was no tab under this point.
3c4f71cc
VS
296
297
298
299
300
4cc4bfaf 301 wxBK_HITTEST_ONICON
3c4f71cc
VS
302
303
304
305
4cc4bfaf 306 The point was over an icon (currently wxMSW only).
3c4f71cc
VS
307
308
309
310
311
4cc4bfaf 312 wxBK_HITTEST_ONLABEL
3c4f71cc
VS
313
314
315
316
4cc4bfaf 317 The point was over a label (currently wxMSW only).
3c4f71cc
VS
318
319
320
321
322
4cc4bfaf 323 wxBK_HITTEST_ONITEM
3c4f71cc
VS
324
325
326
327
4cc4bfaf 328 The point was over an item, but not on the label or icon.
3c4f71cc
VS
329
330
331
332
333
4cc4bfaf 334 wxBK_HITTEST_ONPAGE
3c4f71cc
VS
335
336
337
338
4cc4bfaf
FM
339 The point was over a currently selected page, not over any tab. Note that
340 this flag is present only if wxNOT_FOUND is returned.
3c4f71cc 341
23324ae1 342 @returns Returns the zero-based tab index or wxNOT_FOUND if there is no
4cc4bfaf 343 tab is at the specified position.
23324ae1 344 */
a6052817 345 virtual int HitTest(const wxPoint& pt, long* = NULL) const;
23324ae1
FM
346
347 /**
348 Inserts a new page at the specified position.
3c4f71cc 349
7c913512 350 @param index
4cc4bfaf 351 Specifies the position for the new page.
7c913512 352 @param page
4cc4bfaf 353 Specifies the new page.
7c913512 354 @param text
4cc4bfaf 355 Specifies the text for the new page.
7c913512 356 @param select
4cc4bfaf 357 Specifies whether the page should be selected.
7c913512 358 @param imageId
4cc4bfaf 359 Specifies the optional image index for the new page.
3c4f71cc 360
23324ae1 361 @returns @true if successful, @false otherwise.
3c4f71cc 362
23324ae1 363 @remarks Do not delete the page, it will be deleted by the notebook.
3c4f71cc 364
4cc4bfaf 365 @see AddPage()
23324ae1
FM
366 */
367 bool InsertPage(size_t index, wxNotebookPage* page,
368 const wxString& text,
4cc4bfaf 369 bool select = false,
23324ae1
FM
370 int imageId = -1);
371
372 /**
373 An event handler function, called when the page selection is changed.
3c4f71cc 374
4cc4bfaf 375 @see wxNotebookEvent
23324ae1
FM
376 */
377 void OnSelChange(wxNotebookEvent& event);
378
379 /**
380 Deletes the specified page, without deleting the associated window.
381 */
382 bool RemovePage(size_t page);
383
384 /**
385 Sets the image list for the page control. It does not take
386 ownership of the image list, you must delete it yourself.
3c4f71cc 387
4cc4bfaf 388 @see wxImageList, AssignImageList()
23324ae1
FM
389 */
390 void SetImageList(wxImageList* imageList);
391
392 /**
393 Sets the amount of space around each page's icon and label, in pixels.
1f1d2182 394 @note The vertical padding cannot be changed in wxGTK.
23324ae1
FM
395 */
396 void SetPadding(const wxSize& padding);
397
398 /**
4cc4bfaf 399 Sets the image index for the given page. @a image is an index into
23324ae1
FM
400 the image list which was set with SetImageList().
401 */
a6052817 402 virtual bool SetPageImage(size_t page, int image);
23324ae1
FM
403
404 /**
405 Sets the width and height of the pages.
1f1d2182 406 @note This method is currently not implemented for wxGTK.
23324ae1 407 */
a6052817 408 virtual void SetPageSize(const wxSize& size);
23324ae1
FM
409
410 /**
411 Sets the text for the given page.
412 */
a6052817 413 virtual bool SetPageText(size_t page, const wxString& text);
23324ae1
FM
414
415 /**
416 Sets the selection for the given page, returning the previous selection.
23324ae1 417 The call to this function generates the page changing events.
23324ae1
FM
418 This function is deprecated and should not be used in new code. Please use the
419 ChangeSelection() function instead.
3c4f71cc 420
4cc4bfaf 421 @see GetSelection()
23324ae1 422 */
a6052817 423 virtual int SetSelection(size_t page);
23324ae1 424};
e54c96f1 425