]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/notebook.h
46e82b622474868de0ce70264856687e8fa5f16b
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxNotebookEvent
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxNotebookEvent
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
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.
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.
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.
33 class wxNotebookEvent
: public wxNotifyEvent
37 Constructor (used internally by wxWidgets only).
39 wxNotebookEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0,
44 Returns the page that was selected before the change, -1 if none was selected.
46 int GetOldSelection() const;
49 Returns the currently selected page, or -1 if none was selected.
50 @note under Windows, GetSelection() will return the same value as
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
54 for an event generated in response to a call to
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
60 int GetSelection() const;
63 Sets the id of the page selected before the change.
65 void SetOldSelection(int page
);
68 Sets the selection member variable.
70 void SetSelection(int page
);
78 This class represents a notebook control, which manages multiple windows with
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.
87 @b wxNotebookPage is a typedef for wxWindow.
91 Place tabs on the top side.
93 Place tabs on the left side.
95 Place tabs on the right side.
97 Place tabs under instead of above the notebook pages.
98 @style{wxNB_FIXEDWIDTH}
99 (Windows only) All tabs will have same width.
100 @style{wxNB_MULTILINE}
101 (Windows only) There can be several rows of tabs.
102 @style{wxNB_NOPAGETHEME}
103 (Windows only) Display a solid colour on notebook pages, and not a
104 gradient, which can reduce performance.
106 (Windows CE only) Show tabs in a flat style.
112 @see wxBookCtrl(), wxNotebookEvent, wxImageList, @ref overview_samplenotebook
115 class wxNotebook
: public wxBookCtrl overview
120 Constructs a notebook control.
121 Note that sometimes you can reduce flicker by passing the wxCLIP_CHILDREN
125 The parent window. Must be non-@NULL.
127 The window identifier.
133 The window style. See wxNotebook.
135 The name of the control (used only under Motif).
138 wxNotebook(wxWindow
* parent
, wxWindowID id
,
139 const wxPoint
& pos
= wxDefaultPosition
,
140 const wxSize
& size
= wxDefaultSize
,
142 const wxString
& name
= wxNotebookNameStr
);
146 Destroys the wxNotebook object.
148 virtual ~wxNotebook();
152 The call to this function may generate the page changing events.
155 Specifies the new page.
157 Specifies the text for the new page.
159 Specifies whether the page should be selected.
161 Specifies the optional image index for the new page.
163 @return @true if successful, @false otherwise.
165 @remarks Do not delete the page, it will be deleted by the notebook.
169 bool AddPage(wxNotebookPage
* page
, const wxString
& text
,
174 Cycles through the tabs.
175 The call to this function generates the page changing events.
177 void AdvanceSelection(bool forward
= true);
180 Sets the image list for the page control and takes ownership of
183 @see wxImageList, SetImageList()
185 void AssignImageList(wxImageList
* imageList
);
188 Changes the selection for the given page, returning the previous selection.
189 The call to this function does not generate the page changing events.
190 This is the only difference with SetSelection().
191 See @ref overview_progevent "this topic" for more info.
193 virtual int ChangeSelection(size_t page
);
196 Creates a notebook control. See wxNotebook() for a description
199 bool Create(wxWindow
* parent
, wxWindowID id
,
200 const wxPoint
& pos
= wxDefaultPosition
,
201 const wxSize
& size
= wxDefaultSize
,
203 const wxString
& name
= wxNotebookNameStr
);
208 virtual bool DeleteAllPages();
211 Deletes the specified page, and the associated window.
212 The call to this function generates the page changing events.
214 bool DeletePage(size_t page
);
217 Returns the currently selected notebook page or @NULL.
219 wxWindow
* GetCurrentPage() const;
222 Returns the associated image list.
224 @see wxImageList, SetImageList()
226 wxImageList
* GetImageList() const;
229 Returns the window at the given page position.
231 wxNotebookPage
* GetPage(size_t page
);
234 Returns the number of pages in the notebook control.
236 size_t GetPageCount() const;
239 Returns the image index for the given page.
241 virtual int GetPageImage(size_t nPage
) const;
244 Returns the string for the given page.
246 virtual wxString
GetPageText(size_t nPage
) const;
249 Returns the number of rows in the notebook control.
251 virtual int GetRowCount() const;
254 Returns the currently selected page, or -1 if none was selected.
255 Note that this method may return either the previously or newly selected page
256 when called from the @c EVT_NOTEBOOK_PAGE_CHANGED handler depending on
258 wxNotebookEvent::GetSelection should be
259 used instead in this case.
261 virtual int GetSelection() const;
264 If running under Windows and themes are enabled for the application, this
266 returns a suitable colour for painting the background of a notebook page, and
268 to @c SetBackgroundColour. Otherwise, an uninitialised colour will be returned.
270 virtual wxColour
GetThemeBackgroundColour() const;
273 Returns the index of the tab at the specified position or @c wxNOT_FOUND
274 if none. If @a flags parameter is non-@NULL, the position of the point
275 inside the tab is returned as well.
278 Specifies the point for the hit test.
280 Return value for detailed information. One of the following values:
293 There was no tab under this point.
304 The point was over an icon (currently wxMSW only).
315 The point was over a label (currently wxMSW only).
326 The point was over an item, but not on the label or icon.
337 The point was over a currently selected page, not over any tab. Note that
338 this flag is present only if wxNOT_FOUND is returned.
340 @return Returns the zero-based tab index or wxNOT_FOUND if there is no
341 tab is at the specified position.
343 virtual int HitTest(const wxPoint
& pt
, long* = NULL
) const;
346 Inserts a new page at the specified position.
349 Specifies the position for the new page.
351 Specifies the new page.
353 Specifies the text for the new page.
355 Specifies whether the page should be selected.
357 Specifies the optional image index for the new page.
359 @return @true if successful, @false otherwise.
361 @remarks Do not delete the page, it will be deleted by the notebook.
365 bool InsertPage(size_t index
, wxNotebookPage
* page
,
366 const wxString
& text
,
371 An event handler function, called when the page selection is changed.
375 void OnSelChange(wxNotebookEvent
& event
);
378 Deletes the specified page, without deleting the associated window.
380 bool RemovePage(size_t page
);
383 Sets the image list for the page control. It does not take
384 ownership of the image list, you must delete it yourself.
386 @see wxImageList, AssignImageList()
388 void SetImageList(wxImageList
* imageList
);
391 Sets the amount of space around each page's icon and label, in pixels.
392 @note The vertical padding cannot be changed in wxGTK.
394 void SetPadding(const wxSize
& padding
);
397 Sets the image index for the given page. @a image is an index into
398 the image list which was set with SetImageList().
400 virtual bool SetPageImage(size_t page
, int image
);
403 Sets the width and height of the pages.
404 @note This method is currently not implemented for wxGTK.
406 virtual void SetPageSize(const wxSize
& size
);
409 Sets the text for the given page.
411 virtual bool SetPageText(size_t page
, const wxString
& text
);
414 Sets the selection for the given page, returning the previous selection.
415 The call to this function generates the page changing events.
416 This function is deprecated and should not be used in new code. Please use the
417 ChangeSelection() function instead.
421 virtual int SetSelection(size_t page
);