]>
git.saurik.com Git - wxWidgets.git/blob - interface/notebook.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxNotebookEvent
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxNotebookEvent
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
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.
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.
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.
34 class wxNotebookEvent
: public wxNotifyEvent
38 Constructor (used internally by wxWidgets only).
40 wxNotebookEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0,
45 Returns the page that was selected before the change, -1 if none was selected.
47 int GetOldSelection() const;
50 Returns the currently selected page, or -1 if none was selected.
51 @note under Windows, GetSelection() will return the same value as
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
55 for an event generated in response to a call to
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
61 int GetSelection() const;
64 Sets the id of the page selected before the change.
66 void SetOldSelection(int page
);
69 Sets the selection member variable.
71 void SetSelection(int page
);
80 This class represents a notebook control, which manages multiple windows with
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.
89 @b wxNotebookPage is a typedef for wxWindow.
93 Place tabs on the top side.
95 Place tabs on the left side.
97 Place tabs on the right side.
99 Place tabs under instead of above the notebook pages.
100 @style{wxNB_FIXEDWIDTH}
101 (Windows only) All tabs will have same width.
102 @style{wxNB_MULTILINE}
103 (Windows only) There can be several rows of tabs.
104 @style{wxNB_NOPAGETHEME}
105 (Windows only) Display a solid colour on notebook pages, and not a
106 gradient, which can reduce performance.
108 (Windows CE only) Show tabs in a flat style.
114 @see wxBookCtrl(), wxNotebookEvent, wxImageList, @ref overview_samplenotebook
117 class wxNotebook
: public wxBookCtrl overview
122 Constructs a notebook control.
123 Note that sometimes you can reduce flicker by passing the wxCLIP_CHILDREN
127 The parent window. Must be non-@NULL.
129 The window identifier.
135 The window style. See wxNotebook.
137 The name of the control (used only under Motif).
140 wxNotebook(wxWindow
* parent
, wxWindowID id
,
141 const wxPoint
& pos
= wxDefaultPosition
,
142 const wxSize
& size
= wxDefaultSize
,
144 const wxString
& name
= wxNotebookNameStr
);
148 Destroys the wxNotebook object.
150 virtual ~wxNotebook();
154 The call to this function may generate the page changing events.
157 Specifies the new page.
159 Specifies the text for the new page.
161 Specifies whether the page should be selected.
163 Specifies the optional image index for the new page.
165 @return @true if successful, @false otherwise.
167 @remarks Do not delete the page, it will be deleted by the notebook.
171 bool AddPage(wxNotebookPage
* page
, const wxString
& text
,
176 Cycles through the tabs.
177 The call to this function generates the page changing events.
179 void AdvanceSelection(bool forward
= true);
182 Sets the image list for the page control and takes ownership of
185 @see wxImageList, SetImageList()
187 void AssignImageList(wxImageList
* imageList
);
190 Changes the selection for the given page, returning the previous selection.
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.
195 virtual int ChangeSelection(size_t page
);
198 Creates a notebook control. See wxNotebook() for a description
201 bool Create(wxWindow
* parent
, wxWindowID id
,
202 const wxPoint
& pos
= wxDefaultPosition
,
203 const wxSize
& size
= wxDefaultSize
,
205 const wxString
& name
= wxNotebookNameStr
);
210 virtual bool DeleteAllPages();
213 Deletes the specified page, and the associated window.
214 The call to this function generates the page changing events.
216 bool DeletePage(size_t page
);
219 Returns the currently selected notebook page or @NULL.
221 wxWindow
* GetCurrentPage() const;
224 Returns the associated image list.
226 @see wxImageList, SetImageList()
228 wxImageList
* GetImageList() const;
231 Returns the window at the given page position.
233 wxNotebookPage
* GetPage(size_t page
);
236 Returns the number of pages in the notebook control.
238 size_t GetPageCount() const;
241 Returns the image index for the given page.
243 virtual int GetPageImage(size_t nPage
) const;
246 Returns the string for the given page.
248 virtual wxString
GetPageText(size_t nPage
) const;
251 Returns the number of rows in the notebook control.
253 virtual int GetRowCount() const;
256 Returns the currently selected page, or -1 if none was selected.
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
260 wxNotebookEvent::GetSelection should be
261 used instead in this case.
263 virtual int GetSelection() const;
266 If running under Windows and themes are enabled for the application, this
268 returns a suitable colour for painting the background of a notebook page, and
270 to @c SetBackgroundColour. Otherwise, an uninitialised colour will be returned.
272 virtual wxColour
GetThemeBackgroundColour() const;
275 Returns the index of the tab at the specified position or @c wxNOT_FOUND
276 if none. If @a flags parameter is non-@NULL, the position of the point
277 inside the tab is returned as well.
280 Specifies the point for the hit test.
282 Return value for detailed information. One of the following values:
295 There was no tab under this point.
306 The point was over an icon (currently wxMSW only).
317 The point was over a label (currently wxMSW only).
328 The point was over an item, but not on the label or icon.
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.
342 @return Returns the zero-based tab index or wxNOT_FOUND if there is no
343 tab is at the specified position.
345 virtual int HitTest(const wxPoint
& pt
, long* = NULL
) const;
348 Inserts a new page at the specified position.
351 Specifies the position for the new page.
353 Specifies the new page.
355 Specifies the text for the new page.
357 Specifies whether the page should be selected.
359 Specifies the optional image index for the new page.
361 @return @true if successful, @false otherwise.
363 @remarks Do not delete the page, it will be deleted by the notebook.
367 bool InsertPage(size_t index
, wxNotebookPage
* page
,
368 const wxString
& text
,
373 An event handler function, called when the page selection is changed.
377 void OnSelChange(wxNotebookEvent
& event
);
380 Deletes the specified page, without deleting the associated window.
382 bool RemovePage(size_t page
);
385 Sets the image list for the page control. It does not take
386 ownership of the image list, you must delete it yourself.
388 @see wxImageList, AssignImageList()
390 void SetImageList(wxImageList
* imageList
);
393 Sets the amount of space around each page's icon and label, in pixels.
394 @note The vertical padding cannot be changed in wxGTK.
396 void SetPadding(const wxSize
& padding
);
399 Sets the image index for the given page. @a image is an index into
400 the image list which was set with SetImageList().
402 virtual bool SetPageImage(size_t page
, int image
);
405 Sets the width and height of the pages.
406 @note This method is currently not implemented for wxGTK.
408 virtual void SetPageSize(const wxSize
& size
);
411 Sets the text for the given page.
413 virtual bool SetPageText(size_t page
, const wxString
& text
);
416 Sets the selection for the given page, returning the previous selection.
417 The call to this function generates the page changing events.
418 This function is deprecated and should not be used in new code. Please use the
419 ChangeSelection() function instead.
423 virtual int SetSelection(size_t page
);