]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/bookctrl.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxBookCtrlBase
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 A book control is a convenient way of displaying multiple pages of information,
13 displayed one page at a time. wxWidgets has five variants of this control:
15 @li wxChoicebook: controlled by a wxChoice
16 @li wxListbook: controlled by a wxListCtrl
17 @li wxNotebook: uses a row of tabs
18 @li wxTreebook: controlled by a wxTreeCtrl
19 @li wxToolbook: controlled by a wxToolBar
21 This abstract class is the parent of all these book controls, and provides
22 their basic interface.
23 This is a pure virtual class so you cannot allocate it directly.
28 @see @ref overview_bookctrl
30 class wxBookCtrlBase
: public wxControl
35 /// Symbolic constant indicating that no image should be used.
45 Constructs the book control with the given parameters.
46 See Create() for two-step construction.
48 wxBookCtrlBase(wxWindow
*parent
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
53 const wxString
& name
= wxEmptyString
);
56 Constructs the book control with the given parameters.
58 bool Create(wxWindow
*parent
,
60 const wxPoint
& pos
= wxDefaultPosition
,
61 const wxSize
& size
= wxDefaultSize
,
63 const wxString
& name
= wxEmptyString
);
67 @name Image list functions
69 Each page may have an attached image.
70 The functions of this group manipulate that image.
75 Sets the image list for the page control and takes ownership of the list.
77 @see wxImageList, SetImageList()
79 void AssignImageList(wxImageList
* imageList
);
82 Returns the associated image list.
84 @see wxImageList, SetImageList()
86 wxImageList
* GetImageList() const;
89 Returns the image index for the given page.
91 virtual int GetPageImage(size_t nPage
) const = 0;
94 Sets the image list for the page control.
95 It does not take ownership of the image list, you must delete it yourself.
97 @see wxImageList, AssignImageList()
99 virtual void SetImageList(wxImageList
* imageList
);
102 Sets the image index for the given page. @a image is an index into
103 the image list which was set with SetImageList().
105 virtual bool SetPageImage(size_t page
, int image
) = 0;
112 @name Page text functions
114 Each page has a text string attached.
115 The functions of this group manipulate that text.
120 Returns the string for the given page.
122 virtual wxString
GetPageText(size_t nPage
) const = 0;
125 Sets the text for the given page.
127 virtual bool SetPageText(size_t page
, const wxString
& text
) = 0;
133 @name Selection functions
135 The functions of this group manipulate the selection.
140 Returns the currently selected page, or @c wxNOT_FOUND if none was selected.
142 Note that this method may return either the previously or newly
143 selected page when called from the @c EVT_BOOKCTRL_PAGE_CHANGED handler
144 depending on the platform and so wxBookCtrlEvent::GetSelection should be
145 used instead in this case.
147 virtual int GetSelection() const = 0;
150 Returns the currently selected page or @NULL.
152 wxWindow
* GetCurrentPage() const;
155 Sets the selection for the given page, returning the previous selection.
157 Notice that the call to this function generates the page changing
158 events, use the ChangeSelection() function if you don't want these
159 events to be generated.
163 virtual int SetSelection(size_t page
) = 0;
166 Cycles through the tabs.
167 The call to this function generates the page changing events.
169 void AdvanceSelection(bool forward
= true);
172 Changes the selection for the given page, returning the previous selection.
174 This function behaves as SetSelection() but does @em not generate the
175 page changing events.
177 See @ref overview_events_prog for more information.
179 virtual int ChangeSelection(size_t page
) = 0;
186 Sets the width and height of the pages.
188 @note This method is currently not implemented for wxGTK.
190 virtual void SetPageSize(const wxSize
& size
);
193 Returns the index of the tab at the specified position or @c wxNOT_FOUND
194 if none. If @a flags parameter is non-@NULL, the position of the point
195 inside the tab is returned as well.
198 Specifies the point for the hit test.
200 Return value for detailed information. One of the following values:
201 <TABLE><TR><TD>wxBK_HITTEST_NOWHERE</TD>
202 <TD>There was no tab under this point.</TD></TR>
203 <TR><TD>wxBK_HITTEST_ONICON</TD>
204 <TD>The point was over an icon (currently wxMSW only).</TD></TR>
205 <TR><TD>wxBK_HITTEST_ONLABEL</TD>
206 <TD>The point was over a label (currently wxMSW only).</TD></TR>
207 <TR><TD>wxBK_HITTEST_ONITEM</TD>
208 <TD>The point was over an item, but not on the label or icon.</TD></TR>
209 <TR><TD>wxBK_HITTEST_ONPAGE</TD>
210 <TD>The point was over a currently selected page, not over any tab.
211 Note that this flag is present only if wxNOT_FOUND is returned.</TD></TR>
214 @return Returns the zero-based tab index or @c wxNOT_FOUND if there is no
215 tab at the specified position.
217 virtual int HitTest(const wxPoint
& pt
, long* flags
= NULL
) const;
222 @name Page management functions
224 Functions for adding/removing pages from this control.
231 The page must have the book control itself as the parent and must not
232 have been added to this control previously.
234 The call to this function may generate the page changing events.
237 Specifies the new page.
239 Specifies the text for the new page.
241 Specifies whether the page should be selected.
243 Specifies the optional image index for the new page.
245 @return @true if successful, @false otherwise.
247 @remarks Do not delete the page, it will be deleted by the book control.
251 virtual bool AddPage(wxWindow
* page
, const wxString
& text
,
252 bool select
= false, int imageId
= NO_IMAGE
);
257 virtual bool DeleteAllPages();
260 Deletes the specified page, and the associated window.
261 The call to this function generates the page changing events.
263 virtual bool DeletePage(size_t page
);
266 Inserts a new page at the specified position.
269 Specifies the position for the new page.
271 Specifies the new page.
273 Specifies the text for the new page.
275 Specifies whether the page should be selected.
277 Specifies the optional image index for the new page.
279 @return @true if successful, @false otherwise.
281 @remarks Do not delete the page, it will be deleted by the book control.
285 virtual bool InsertPage(size_t index
,
287 const wxString
& text
,
289 int imageId
= NO_IMAGE
) = 0;
292 Deletes the specified page, without deleting the associated window.
294 virtual bool RemovePage(size_t page
);
297 Returns the number of pages in the control.
299 virtual size_t GetPageCount() const;
302 Returns the window at the given page position.
304 wxWindow
* GetPage(size_t page
) const;
310 other functions which may be worth documenting:
315 // calculate the size of the control from the size of its page
316 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0;
318 // get/set size of area between book control area and page area
319 unsigned int GetInternalBorder() const { return m_internalBorder; }
320 void SetInternalBorder(unsigned int border) { m_internalBorder = border; }
322 // Sets/gets the margin around the controller
323 void SetControlMargin(int margin) { m_controlMargin = margin; }
324 int GetControlMargin() const { return m_controlMargin; }
326 // returns true if we have wxBK_TOP or wxBK_BOTTOM style
327 bool IsVertical() const { return HasFlag(wxBK_BOTTOM | wxBK_TOP); }
329 // set/get option to shrink to fit current page
330 void SetFitToCurrentPage(bool fit) { m_fitToCurrentPage = fit; }
331 bool GetFitToCurrentPage() const { return m_fitToCurrentPage; }
333 // returns the sizer containing the control, if any
334 wxSizer* GetControlSizer() const { return m_controlSizer; }
336 // we do have multiple pages
337 virtual bool HasMultiplePages() const { return true; }
339 // we don't want focus for ourselves
340 virtual bool AcceptsFocus() const { return false; }
342 // returns true if the platform should explicitly apply a theme border
343 virtual bool CanApplyThemeBorder() const { return false; }
348 wxBookCtrl is defined to one of the 'real' book controls.
350 See @ref overview_bookctrl for more info.
352 #define wxBookCtrl TheBestBookCtrlForTheCurrentPlatform
356 @class wxBookCtrlEvent
358 This class represents the events generated by book controls (wxNotebook,
359 wxListbook, wxChoicebook, wxTreebook).
361 The PAGE_CHANGING events are sent before the current page is changed.
362 It allows the program to examine the current page (which can be retrieved
363 with wxBookCtrlEvent::GetOldSelection) and to veto the page change by calling
364 wxNotifyEvent::Veto if, for example, the current values in the controls
365 of the old page are invalid.
367 The PAGE_CHANGED events are sent after the page has been changed and the
368 program cannot veto it any more, it just informs it about the page change.
370 To summarize, if the program is interested in validating the page values
371 before allowing the user to change it, it should process the PAGE_CHANGING
372 event, otherwise PAGE_CHANGED is probably enough. In any case, it is
373 probably unnecessary to process both events at once.
376 @category{events,bookctrl}
378 @see wxNotebook, wxListbook, wxChoicebook, wxTreebook, wxToolbook
380 class wxBookCtrlEvent
: public wxNotifyEvent
384 Constructor (used internally by wxWidgets only).
386 wxBookCtrlEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0,
387 int sel
= wxNOT_FOUND
, int oldSel
= wxNOT_FOUND
);
390 Returns the page that was selected before the change, @c wxNOT_FOUND if
393 int GetOldSelection() const;
396 Returns the currently selected page, or @c wxNOT_FOUND if none was
399 @note under Windows, GetSelection() will return the same value as
400 GetOldSelection() when called from the @c EVT_BOOKCTRL_PAGE_CHANGING
401 handler and not the page which is going to be selected.
403 int GetSelection() const;
406 Sets the id of the page selected before the change.
408 void SetOldSelection(int page
);
411 Sets the selection member variable.
413 void SetSelection(int page
);