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