]>
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
, public wxWithImages
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.
76 Returns the image index for the given page.
78 virtual int GetPageImage(size_t nPage
) const = 0;
81 Sets the image index for the given page. @a image is an index into
82 the image list which was set with SetImageList().
84 virtual bool SetPageImage(size_t page
, int image
) = 0;
91 @name Page text functions
93 Each page has a text string attached.
94 The functions of this group manipulate that text.
99 Returns the string for the given page.
101 virtual wxString
GetPageText(size_t nPage
) const = 0;
104 Sets the text for the given page.
106 virtual bool SetPageText(size_t page
, const wxString
& text
) = 0;
112 @name Selection functions
114 The functions of this group manipulate the selection.
119 Returns the currently selected page, or @c wxNOT_FOUND if none was selected.
121 Note that this method may return either the previously or newly
122 selected page when called from the @c EVT_BOOKCTRL_PAGE_CHANGED handler
123 depending on the platform and so wxBookCtrlEvent::GetSelection should be
124 used instead in this case.
126 virtual int GetSelection() const = 0;
129 Returns the currently selected page or @NULL.
131 wxWindow
* GetCurrentPage() const;
134 Sets the selection for the given page, returning the previous selection.
136 Notice that the call to this function generates the page changing
137 events, use the ChangeSelection() function if you don't want these
138 events to be generated.
142 virtual int SetSelection(size_t page
) = 0;
145 Cycles through the tabs.
146 The call to this function generates the page changing events.
148 void AdvanceSelection(bool forward
= true);
151 Changes the selection for the given page, returning the previous selection.
153 This function behaves as SetSelection() but does @em not generate the
154 page changing events.
156 See @ref overview_events_prog for more information.
158 virtual int ChangeSelection(size_t page
) = 0;
165 Sets the width and height of the pages.
167 @note This method is currently not implemented for wxGTK.
169 virtual void SetPageSize(const wxSize
& size
);
172 Returns the index of the tab at the specified position or @c wxNOT_FOUND
173 if none. If @a flags parameter is non-@NULL, the position of the point
174 inside the tab is returned as well.
177 Specifies the point for the hit test.
179 Return value for detailed information. One of the following values:
180 <TABLE><TR><TD>wxBK_HITTEST_NOWHERE</TD>
181 <TD>There was no tab under this point.</TD></TR>
182 <TR><TD>wxBK_HITTEST_ONICON</TD>
183 <TD>The point was over an icon (currently wxMSW only).</TD></TR>
184 <TR><TD>wxBK_HITTEST_ONLABEL</TD>
185 <TD>The point was over a label (currently wxMSW only).</TD></TR>
186 <TR><TD>wxBK_HITTEST_ONITEM</TD>
187 <TD>The point was over an item, but not on the label or icon.</TD></TR>
188 <TR><TD>wxBK_HITTEST_ONPAGE</TD>
189 <TD>The point was over a currently selected page, not over any tab.
190 Note that this flag is present only if wxNOT_FOUND is returned.</TD></TR>
193 @return Returns the zero-based tab index or @c wxNOT_FOUND if there is no
194 tab at the specified position.
196 virtual int HitTest(const wxPoint
& pt
, long* flags
= NULL
) const;
201 @name Page management functions
203 Functions for adding/removing pages from this control.
210 The page must have the book control itself as the parent and must not
211 have been added to this control previously.
213 The call to this function may generate the page changing events.
216 Specifies the new page.
218 Specifies the text for the new page.
220 Specifies whether the page should be selected.
222 Specifies the optional image index for the new page.
224 @return @true if successful, @false otherwise.
226 @remarks Do not delete the page, it will be deleted by the book control.
230 virtual bool AddPage(wxWindow
* page
, const wxString
& text
,
231 bool select
= false, int imageId
= NO_IMAGE
);
236 virtual bool DeleteAllPages();
239 Deletes the specified page, and the associated window.
240 The call to this function generates the page changing events.
242 virtual bool DeletePage(size_t page
);
245 Inserts a new page at the specified position.
248 Specifies the position for the new page.
250 Specifies the new page.
252 Specifies the text for the new page.
254 Specifies whether the page should be selected.
256 Specifies the optional image index for the new page.
258 @return @true if successful, @false otherwise.
260 @remarks Do not delete the page, it will be deleted by the book control.
264 virtual bool InsertPage(size_t index
,
266 const wxString
& text
,
268 int imageId
= NO_IMAGE
) = 0;
271 Deletes the specified page, without deleting the associated window.
273 virtual bool RemovePage(size_t page
);
276 Returns the number of pages in the control.
278 virtual size_t GetPageCount() const;
281 Returns the window at the given page position.
283 wxWindow
* GetPage(size_t page
) const;
289 other functions which may be worth documenting:
294 // calculate the size of the control from the size of its page
295 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0;
297 // get/set size of area between book control area and page area
298 unsigned int GetInternalBorder() const { return m_internalBorder; }
299 void SetInternalBorder(unsigned int border) { m_internalBorder = border; }
301 // Sets/gets the margin around the controller
302 void SetControlMargin(int margin) { m_controlMargin = margin; }
303 int GetControlMargin() const { return m_controlMargin; }
305 // returns true if we have wxBK_TOP or wxBK_BOTTOM style
306 bool IsVertical() const { return HasFlag(wxBK_BOTTOM | wxBK_TOP); }
308 // set/get option to shrink to fit current page
309 void SetFitToCurrentPage(bool fit) { m_fitToCurrentPage = fit; }
310 bool GetFitToCurrentPage() const { return m_fitToCurrentPage; }
312 // returns the sizer containing the control, if any
313 wxSizer* GetControlSizer() const { return m_controlSizer; }
315 // we do have multiple pages
316 virtual bool HasMultiplePages() const { return true; }
318 // we don't want focus for ourselves
319 virtual bool AcceptsFocus() const { return false; }
321 // returns true if the platform should explicitly apply a theme border
322 virtual bool CanApplyThemeBorder() const { return false; }
327 wxBookCtrl is defined to one of the 'real' book controls.
329 See @ref overview_bookctrl for more info.
331 #define wxBookCtrl TheBestBookCtrlForTheCurrentPlatform
335 @class wxBookCtrlEvent
337 This class represents the events generated by book controls (wxNotebook,
338 wxListbook, wxChoicebook, wxTreebook, wxAuiNotebook).
340 The PAGE_CHANGING events are sent before the current page is changed.
341 It allows the program to examine the current page (which can be retrieved
342 with wxBookCtrlEvent::GetOldSelection) and to veto the page change by calling
343 wxNotifyEvent::Veto if, for example, the current values in the controls
344 of the old page are invalid.
346 The PAGE_CHANGED events are sent after the page has been changed and the
347 program cannot veto it any more, it just informs it about the page change.
349 To summarize, if the program is interested in validating the page values
350 before allowing the user to change it, it should process the PAGE_CHANGING
351 event, otherwise PAGE_CHANGED is probably enough. In any case, it is
352 probably unnecessary to process both events at once.
355 @category{events,bookctrl}
357 @see wxNotebook, wxListbook, wxChoicebook, wxTreebook, wxToolbook, wxAuiNotebook
359 class wxBookCtrlEvent
: public wxNotifyEvent
363 Constructor (used internally by wxWidgets only).
365 wxBookCtrlEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0,
366 int sel
= wxNOT_FOUND
, int oldSel
= wxNOT_FOUND
);
369 Returns the page that was selected before the change, @c wxNOT_FOUND if
372 int GetOldSelection() const;
375 Returns the currently selected page, or @c wxNOT_FOUND if none was
378 @note under Windows, GetSelection() will return the same value as
379 GetOldSelection() when called from the @c EVT_BOOKCTRL_PAGE_CHANGING
380 handler and not the page which is going to be selected.
382 int GetSelection() const;
385 Sets the id of the page selected before the change.
387 void SetOldSelection(int page
);
390 Sets the selection member variable.
392 void SetSelection(int page
);