]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/bookctrl.h
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     interface of wxBookCtrlBase 
   4 // Author:      wxWidgets team 
   6 // Licence:     wxWindows license 
   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
 
  39         Constructs the book control with the given parameters. 
  40         See Create() for two-step construction. 
  42     wxBookCtrlBase(wxWindow 
*parent
, 
  44                    const wxPoint
& pos 
= wxDefaultPosition
, 
  45                    const wxSize
& size 
= wxDefaultSize
, 
  47                    const wxString
& name 
= wxEmptyString
); 
  50         Constructs the book control with the given parameters. 
  52     bool Create(wxWindow 
*parent
, 
  54                 const wxPoint
& pos 
= wxDefaultPosition
, 
  55                 const wxSize
& size 
= wxDefaultSize
, 
  57                 const wxString
& name 
= wxEmptyString
); 
  61         @name Image list functions 
  63         Each page may have an attached image. 
  64         The functions of this group manipulate that image. 
  69         Sets the image list for the page control and takes ownership of the list. 
  71         @see wxImageList, SetImageList() 
  73     void AssignImageList(wxImageList
* imageList
); 
  76         Returns the associated image list. 
  78         @see wxImageList, SetImageList() 
  80     wxImageList
* GetImageList() const; 
  83         Returns the image index for the given page. 
  85     virtual int GetPageImage(size_t nPage
) const; 
  88         Sets the image list for the page control. 
  89         It does not take ownership of the image list, you must delete it yourself. 
  91         @see wxImageList, AssignImageList() 
  93     virtual void SetImageList(wxImageList
* imageList
); 
  96         Sets the image index for the given page. @a image is an index into 
  97         the image list which was set with SetImageList(). 
  99     virtual bool SetPageImage(size_t page
, int image
); 
 106         @name Page text functions 
 108         Each page has a text string attached. 
 109         The functions of this group manipulate that text. 
 114         Returns the string for the given page. 
 116     virtual wxString 
GetPageText(size_t nPage
) const = 0; 
 119         Sets the text for the given page. 
 121     virtual bool SetPageText(size_t page
, const wxString
& text
) = 0; 
 127         @name Selection functions 
 129         The functions of this group manipulate the selection. 
 134         Returns the currently selected page, or @c wxNOT_FOUND if none was selected. 
 136         Note that this method may return either the previously or newly 
 137         selected page when called from the @c EVT_BOOKCTRL_PAGE_CHANGED handler 
 138         depending on the platform and so wxBookCtrlEvent::GetSelection should be 
 139         used instead in this case. 
 141     virtual int GetSelection() const = 0; 
 144         Returns the currently selected page or @NULL. 
 146     wxWindow
* GetCurrentPage() const; 
 149         Sets the selection for the given page, returning the previous selection. 
 150         The call to this function generates the page changing events. 
 153         This function is deprecated and should not be used in new code. 
 154         Please use the ChangeSelection() function instead. 
 158     virtual int SetSelection(size_t page
); 
 161         Cycles through the tabs. 
 162         The call to this function generates the page changing events. 
 164     void AdvanceSelection(bool forward 
= true); 
 167         Changes the selection for the given page, returning the previous selection. 
 169         The call to this function does NOT generate the page changing events. 
 170         This is the only difference with SetSelection(). 
 171         See @ref overview_eventhandling_prog for more infomation. 
 173     virtual int ChangeSelection(size_t page
); 
 180         Sets the width and height of the pages. 
 182         @note This method is currently not implemented for wxGTK. 
 184     virtual void SetPageSize(const wxSize
& size
); 
 187         Returns the index of the tab at the specified position or @c wxNOT_FOUND 
 188         if none. If @a flags parameter is non-@NULL, the position of the point 
 189         inside the tab is returned as well. 
 192             Specifies the point for the hit test. 
 194             Return value for detailed information. One of the following values: 
 195             <TABLE><TR><TD>wxBK_HITTEST_NOWHERE</TD> 
 196             <TD>There was no tab under this point.</TD></TR> 
 197             <TR><TD>wxBK_HITTEST_ONICON</TD> 
 198             <TD>The point was over an icon (currently wxMSW only).</TD></TR> 
 199             <TR><TD>wxBK_HITTEST_ONLABEL</TD> 
 200             <TD>The point was over a label (currently wxMSW only).</TD></TR> 
 201             <TR><TD>wxBK_HITTEST_ONITEM</TD> 
 202             <TD>The point was over an item, but not on the label or icon.</TD></TR> 
 203             <TR><TD>wxBK_HITTEST_ONPAGE</TD> 
 204             <TD>The point was over a currently selected page, not over any tab. 
 205             Note that this flag is present only if wxNOT_FOUND is returned.</TD></TR> 
 208         @return Returns the zero-based tab index or @c wxNOT_FOUND if there is no 
 209                 tab at the specified position. 
 211     virtual int HitTest(const wxPoint
& pt
, long* flags 
= NULL
) const; 
 216         @name Page management functions 
 218         Functions for adding/removing pages from this control. 
 224         The call to this function may generate the page changing events. 
 227             Specifies the new page. 
 229             Specifies the text for the new page. 
 231             Specifies whether the page should be selected. 
 233             Specifies the optional image index for the new page. 
 235         @return @true if successful, @false otherwise. 
 237         @remarks Do not delete the page, it will be deleted by the book control. 
 241     bool AddPage(wxWindow
* page
, 
 242                  const wxString
& text
, 
 244                  int imageId 
= wxNOT_FOUND
); 
 249     virtual bool DeleteAllPages(); 
 252         Deletes the specified page, and the associated window. 
 253         The call to this function generates the page changing events. 
 255     bool DeletePage(size_t page
); 
 258         Inserts a new page at the specified position. 
 261             Specifies the position for the new page. 
 263             Specifies the new page. 
 265             Specifies the text for the new page. 
 267             Specifies whether the page should be selected. 
 269             Specifies the optional image index for the new page. 
 271         @return @true if successful, @false otherwise. 
 273         @remarks Do not delete the page, it will be deleted by the book control. 
 277     virtual bool InsertPage(size_t index
, 
 279                             const wxString
& text
, 
 281                             int imageId 
= wxNOT_FOUND
) = 0; 
 284         Deletes the specified page, without deleting the associated window. 
 286     bool RemovePage(size_t page
); 
 289         Returns the number of pages in the control. 
 291     size_t GetPageCount() const; 
 294         Returns the window at the given page position. 
 296     wxWindow
* GetPage(size_t page
); 
 302     other functions which may be worth documenting: 
 307     // calculate the size of the control from the size of its page 
 308     virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0; 
 310     // get/set size of area between book control area and page area 
 311     unsigned int GetInternalBorder() const { return m_internalBorder; } 
 312     void SetInternalBorder(unsigned int border) { m_internalBorder = border; } 
 314     // Sets/gets the margin around the controller 
 315     void SetControlMargin(int margin) { m_controlMargin = margin; } 
 316     int GetControlMargin() const { return m_controlMargin; } 
 318     // returns true if we have wxBK_TOP or wxBK_BOTTOM style 
 319     bool IsVertical() const { return HasFlag(wxBK_BOTTOM | wxBK_TOP); } 
 321     // set/get option to shrink to fit current page 
 322     void SetFitToCurrentPage(bool fit) { m_fitToCurrentPage = fit; } 
 323     bool GetFitToCurrentPage() const { return m_fitToCurrentPage; } 
 325     // returns the sizer containing the control, if any 
 326     wxSizer* GetControlSizer() const { return m_controlSizer; } 
 328     // we do have multiple pages 
 329     virtual bool HasMultiplePages() const { return true; } 
 331     // we don't want focus for ourselves 
 332     virtual bool AcceptsFocus() const { return false; } 
 334     // returns true if the platform should explicitly apply a theme border 
 335     virtual bool CanApplyThemeBorder() const { return false; } 
 340     wxBookCtrl is defined to one of the 'real' book controls. 
 342     See @ref overview_bookctrl for more info. 
 344 #define wxBookCtrl      TheBestBookCtrlForTheCurrentPlatform 
 348     @class wxBookCtrlEvent 
 350     This class represents the events generated by book controls (wxNotebook, 
 351     wxListbook, wxChoicebook, wxTreebook). 
 353     The PAGE_CHANGING events are sent before the current page is changed. 
 354     It allows the program to examine the current page (which can be retrieved 
 355     with wxBookCtrlEvent::GetOldSelection) and to veto the page change by calling 
 356     wxNotifyEvent::Veto if, for example, the current values in the controls 
 357     of the old page are invalid. 
 359     The PAGE_CHANGED events are sent after the page has been changed and the 
 360     program cannot veto it any more, it just informs it about the page change. 
 362     To summarize, if the program is interested in validating the page values 
 363     before allowing the user to change it, it should process the PAGE_CHANGING 
 364     event, otherwise PAGE_CHANGED is probably enough. In any case, it is 
 365     probably unnecessary to process both events at once. 
 370     @see wxNotebook, wxListbook, wxChoicebook, wxTreebook, wxToolbook 
 372 class wxBookCtrlEvent 
: public wxNotifyEvent
 
 376         Constructor (used internally by wxWidgets only). 
 378     wxBookCtrlEvent(wxEventType eventType 
= wxEVT_NULL
, int id 
= 0, 
 379                     int sel 
= wxNOT_FOUND
, int oldSel 
= wxNOT_FOUND
); 
 382         Returns the page that was selected before the change, @c wxNOT_FOUND if 
 385     int GetOldSelection() const; 
 388         Returns the currently selected page, or @c wxNOT_FOUND if none was 
 391         @note under Windows, GetSelection() will return the same value as 
 392               GetOldSelection() when called from the @c EVT_BOOKCTRL_PAGE_CHANGING 
 393               handler and not the page which is going to be selected. 
 395     int GetSelection() const; 
 398         Sets the id of the page selected before the change. 
 400     void SetOldSelection(int page
); 
 403         Sets the selection member variable. 
 405     void SetSelection(int page
);