2008-05-20 03:48:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: bookctrl.h
|
|
|
|
// Purpose: interface of wxBookCtrlBase
|
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-05-20 03:48:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-03-11 19:41:16 -04:00
|
|
|
/**
|
|
|
|
Bit flags returned by wxBookCtrl::HitTest().
|
|
|
|
|
2016-01-30 13:09:33 -05:00
|
|
|
Only one of wxBK_HITTEST_ONICON, wxBK_HITTEST_ONLABEL, wxBK_HITTEST_ONITEM
|
|
|
|
bits is set if point is over a tab.
|
2012-03-11 19:41:16 -04:00
|
|
|
Notice that wxOSX currently only returns wxBK_HITTEST_ONLABEL or
|
|
|
|
wxBK_HITTEST_NOWHERE and never the other values, so you should only test
|
|
|
|
for these two in the code that should be portable under OS X.
|
|
|
|
*/
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
/// No tab at the specified point.
|
|
|
|
wxBK_HITTEST_NOWHERE = 1,
|
|
|
|
|
|
|
|
/// The point is over an icon.
|
|
|
|
wxBK_HITTEST_ONICON = 2,
|
|
|
|
|
|
|
|
/// The point is over a tab label.
|
|
|
|
wxBK_HITTEST_ONLABEL = 4,
|
|
|
|
|
|
|
|
/// The point if over a tab item but not over its icon or label.
|
2016-01-30 13:09:33 -05:00
|
|
|
wxBK_HITTEST_ONITEM = 16,
|
2012-03-11 19:41:16 -04:00
|
|
|
|
|
|
|
/// The point is over the page area.
|
|
|
|
wxBK_HITTEST_ONPAGE = 8
|
|
|
|
};
|
|
|
|
|
2012-06-20 13:10:23 -04:00
|
|
|
/**
|
|
|
|
wxBookCtrl flags (common for wxNotebook, wxListbook, wxChoicebook, wxTreebook)
|
|
|
|
*/
|
|
|
|
#define wxBK_DEFAULT 0x0000
|
|
|
|
#define wxBK_TOP 0x0010
|
|
|
|
#define wxBK_BOTTOM 0x0020
|
|
|
|
#define wxBK_LEFT 0x0040
|
|
|
|
#define wxBK_RIGHT 0x0080
|
|
|
|
#define wxBK_ALIGN_MASK (wxBK_TOP | wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT)
|
|
|
|
|
|
|
|
|
2008-05-20 03:48:30 -04:00
|
|
|
/**
|
|
|
|
@class wxBookCtrlBase
|
|
|
|
|
2008-10-13 06:27:19 -04:00
|
|
|
A book control is a convenient way of displaying multiple pages of information,
|
|
|
|
displayed one page at a time. wxWidgets has five variants of this control:
|
|
|
|
|
|
|
|
@li wxChoicebook: controlled by a wxChoice
|
|
|
|
@li wxListbook: controlled by a wxListCtrl
|
|
|
|
@li wxNotebook: uses a row of tabs
|
|
|
|
@li wxTreebook: controlled by a wxTreeCtrl
|
|
|
|
@li wxToolbook: controlled by a wxToolBar
|
|
|
|
|
|
|
|
This abstract class is the parent of all these book controls, and provides
|
|
|
|
their basic interface.
|
|
|
|
This is a pure virtual class so you cannot allocate it directly.
|
2008-05-20 03:48:30 -04:00
|
|
|
|
|
|
|
@library{wxcore}
|
2009-02-20 06:34:52 -05:00
|
|
|
@category{bookctrl}
|
2008-05-20 03:48:30 -04:00
|
|
|
|
|
|
|
@see @ref overview_bookctrl
|
|
|
|
*/
|
2011-09-10 20:35:32 -04:00
|
|
|
class wxBookCtrlBase : public wxControl, public wxWithImages
|
2008-05-20 03:48:30 -04:00
|
|
|
{
|
|
|
|
public:
|
2011-08-21 10:08:49 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
/// Symbolic constant indicating that no image should be used.
|
|
|
|
NO_IMAGE = -1
|
|
|
|
};
|
|
|
|
|
2008-10-13 06:27:19 -04:00
|
|
|
/**
|
|
|
|
Default ctor.
|
|
|
|
*/
|
|
|
|
wxBookCtrlBase();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructs the book control with the given parameters.
|
|
|
|
See Create() for two-step construction.
|
|
|
|
*/
|
|
|
|
wxBookCtrlBase(wxWindow *parent,
|
|
|
|
wxWindowID winid,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxEmptyString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructs the book control with the given parameters.
|
|
|
|
*/
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID winid,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxEmptyString);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@name Image list functions
|
|
|
|
|
|
|
|
Each page may have an attached image.
|
|
|
|
The functions of this group manipulate that image.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the image index for the given page.
|
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
virtual int GetPageImage(size_t nPage) const = 0;
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the image index for the given page. @a image is an index into
|
|
|
|
the image list which was set with SetImageList().
|
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
virtual bool SetPageImage(size_t page, int image) = 0;
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@name Page text functions
|
|
|
|
|
|
|
|
Each page has a text string attached.
|
|
|
|
The functions of this group manipulate that text.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the string for the given page.
|
|
|
|
*/
|
|
|
|
virtual wxString GetPageText(size_t nPage) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the text for the given page.
|
|
|
|
*/
|
|
|
|
virtual bool SetPageText(size_t page, const wxString& text) = 0;
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@name Selection functions
|
|
|
|
|
|
|
|
The functions of this group manipulate the selection.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the currently selected page, or @c wxNOT_FOUND if none was selected.
|
|
|
|
|
|
|
|
Note that this method may return either the previously or newly
|
|
|
|
selected page when called from the @c EVT_BOOKCTRL_PAGE_CHANGED handler
|
|
|
|
depending on the platform and so wxBookCtrlEvent::GetSelection should be
|
|
|
|
used instead in this case.
|
|
|
|
*/
|
|
|
|
virtual int GetSelection() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the currently selected page or @NULL.
|
|
|
|
*/
|
|
|
|
wxWindow* GetCurrentPage() const;
|
|
|
|
|
|
|
|
/**
|
2013-03-29 15:53:18 -04:00
|
|
|
Sets the selection to the given page, returning the previous selection.
|
2008-10-13 06:27:19 -04:00
|
|
|
|
2009-01-31 12:14:41 -05:00
|
|
|
Notice that the call to this function generates the page changing
|
|
|
|
events, use the ChangeSelection() function if you don't want these
|
|
|
|
events to be generated.
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
@see GetSelection()
|
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
virtual int SetSelection(size_t page) = 0;
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Cycles through the tabs.
|
|
|
|
The call to this function generates the page changing events.
|
|
|
|
*/
|
|
|
|
void AdvanceSelection(bool forward = true);
|
2008-05-20 03:48:30 -04:00
|
|
|
|
2008-10-13 06:27:19 -04:00
|
|
|
/**
|
2013-03-29 15:53:18 -04:00
|
|
|
Changes the selection to the given page, returning the previous selection.
|
2008-10-13 06:27:19 -04:00
|
|
|
|
2009-01-31 12:14:41 -05:00
|
|
|
This function behaves as SetSelection() but does @em not generate the
|
|
|
|
page changing events.
|
|
|
|
|
2009-02-07 10:22:14 -05:00
|
|
|
See @ref overview_events_prog for more information.
|
2008-10-13 06:27:19 -04:00
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
virtual int ChangeSelection(size_t page) = 0;
|
2008-10-13 06:27:19 -04:00
|
|
|
|
2013-03-29 15:53:13 -04:00
|
|
|
/**
|
|
|
|
Returns the index of the specified tab window or @c wxNOT_FOUND
|
|
|
|
if not found.
|
|
|
|
|
|
|
|
@param page One of the control pages.
|
|
|
|
@return The zero-based tab index or @c wxNOT_FOUND if not found.
|
|
|
|
|
|
|
|
@since 2.9.5
|
|
|
|
*/
|
|
|
|
int FindPage(const wxWindow* page) const;
|
|
|
|
|
2008-10-13 06:27:19 -04:00
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the width and height of the pages.
|
|
|
|
|
|
|
|
@note This method is currently not implemented for wxGTK.
|
|
|
|
*/
|
|
|
|
virtual void SetPageSize(const wxSize& size);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the index of the tab at the specified position or @c wxNOT_FOUND
|
|
|
|
if none. If @a flags parameter is non-@NULL, the position of the point
|
|
|
|
inside the tab is returned as well.
|
|
|
|
|
|
|
|
@param pt
|
|
|
|
Specifies the point for the hit test.
|
|
|
|
@param flags
|
2012-03-11 19:41:16 -04:00
|
|
|
Return more details about the point, see returned value is a
|
|
|
|
combination of ::wxBK_HITTEST_NOWHERE, ::wxBK_HITTEST_ONICON,
|
|
|
|
::wxBK_HITTEST_ONLABEL, ::wxBK_HITTEST_ONITEM,
|
|
|
|
::wxBK_HITTEST_ONPAGE.
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
@return Returns the zero-based tab index or @c wxNOT_FOUND if there is no
|
|
|
|
tab at the specified position.
|
|
|
|
*/
|
|
|
|
virtual int HitTest(const wxPoint& pt, long* flags = NULL) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@name Page management functions
|
|
|
|
|
|
|
|
Functions for adding/removing pages from this control.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a new page.
|
2011-07-23 15:36:47 -04:00
|
|
|
|
|
|
|
The page must have the book control itself as the parent and must not
|
|
|
|
have been added to this control previously.
|
|
|
|
|
2008-10-13 06:27:19 -04:00
|
|
|
The call to this function may generate the page changing events.
|
|
|
|
|
|
|
|
@param page
|
|
|
|
Specifies the new page.
|
|
|
|
@param text
|
|
|
|
Specifies the text for the new page.
|
|
|
|
@param select
|
|
|
|
Specifies whether the page should be selected.
|
|
|
|
@param imageId
|
|
|
|
Specifies the optional image index for the new page.
|
|
|
|
|
|
|
|
@return @true if successful, @false otherwise.
|
|
|
|
|
|
|
|
@remarks Do not delete the page, it will be deleted by the book control.
|
|
|
|
|
|
|
|
@see InsertPage()
|
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
virtual bool AddPage(wxWindow* page, const wxString& text,
|
2011-08-21 10:08:49 -04:00
|
|
|
bool select = false, int imageId = NO_IMAGE);
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes all pages.
|
|
|
|
*/
|
|
|
|
virtual bool DeleteAllPages();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes the specified page, and the associated window.
|
|
|
|
The call to this function generates the page changing events.
|
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
virtual bool DeletePage(size_t page);
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Inserts a new page at the specified position.
|
|
|
|
|
|
|
|
@param index
|
|
|
|
Specifies the position for the new page.
|
|
|
|
@param page
|
|
|
|
Specifies the new page.
|
|
|
|
@param text
|
|
|
|
Specifies the text for the new page.
|
|
|
|
@param select
|
|
|
|
Specifies whether the page should be selected.
|
|
|
|
@param imageId
|
|
|
|
Specifies the optional image index for the new page.
|
|
|
|
|
|
|
|
@return @true if successful, @false otherwise.
|
|
|
|
|
|
|
|
@remarks Do not delete the page, it will be deleted by the book control.
|
|
|
|
|
|
|
|
@see AddPage()
|
|
|
|
*/
|
|
|
|
virtual bool InsertPage(size_t index,
|
|
|
|
wxWindow* page,
|
|
|
|
const wxString& text,
|
|
|
|
bool select = false,
|
2011-08-21 10:08:49 -04:00
|
|
|
int imageId = NO_IMAGE) = 0;
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes the specified page, without deleting the associated window.
|
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
virtual bool RemovePage(size_t page);
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of pages in the control.
|
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
virtual size_t GetPageCount() const;
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the window at the given page position.
|
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
wxWindow* GetPage(size_t page) const;
|
2008-10-13 06:27:19 -04:00
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
other functions which may be worth documenting:
|
|
|
|
|
|
|
|
// geometry
|
|
|
|
// --------
|
|
|
|
|
|
|
|
// calculate the size of the control from the size of its page
|
|
|
|
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0;
|
|
|
|
|
|
|
|
// get/set size of area between book control area and page area
|
|
|
|
unsigned int GetInternalBorder() const { return m_internalBorder; }
|
|
|
|
void SetInternalBorder(unsigned int border) { m_internalBorder = border; }
|
|
|
|
|
|
|
|
// Sets/gets the margin around the controller
|
|
|
|
void SetControlMargin(int margin) { m_controlMargin = margin; }
|
|
|
|
int GetControlMargin() const { return m_controlMargin; }
|
|
|
|
|
|
|
|
// returns true if we have wxBK_TOP or wxBK_BOTTOM style
|
|
|
|
bool IsVertical() const { return HasFlag(wxBK_BOTTOM | wxBK_TOP); }
|
|
|
|
|
|
|
|
// set/get option to shrink to fit current page
|
|
|
|
void SetFitToCurrentPage(bool fit) { m_fitToCurrentPage = fit; }
|
|
|
|
bool GetFitToCurrentPage() const { return m_fitToCurrentPage; }
|
|
|
|
|
|
|
|
// returns the sizer containing the control, if any
|
|
|
|
wxSizer* GetControlSizer() const { return m_controlSizer; }
|
|
|
|
|
|
|
|
// we do have multiple pages
|
|
|
|
virtual bool HasMultiplePages() const { return true; }
|
|
|
|
|
|
|
|
// we don't want focus for ourselves
|
|
|
|
virtual bool AcceptsFocus() const { return false; }
|
|
|
|
|
|
|
|
// returns true if the platform should explicitly apply a theme border
|
|
|
|
virtual bool CanApplyThemeBorder() const { return false; }
|
|
|
|
*/
|
2008-05-20 03:48:30 -04:00
|
|
|
};
|
|
|
|
|
2008-10-13 07:03:01 -04:00
|
|
|
/**
|
|
|
|
wxBookCtrl is defined to one of the 'real' book controls.
|
|
|
|
|
|
|
|
See @ref overview_bookctrl for more info.
|
|
|
|
*/
|
|
|
|
#define wxBookCtrl TheBestBookCtrlForTheCurrentPlatform
|
|
|
|
|
2008-08-01 09:46:46 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxBookCtrlEvent
|
|
|
|
|
|
|
|
This class represents the events generated by book controls (wxNotebook,
|
2011-10-02 06:29:00 -04:00
|
|
|
wxListbook, wxChoicebook, wxTreebook, wxAuiNotebook).
|
2008-10-13 06:27:19 -04:00
|
|
|
|
2008-08-01 09:46:46 -04:00
|
|
|
The PAGE_CHANGING events are sent before the current page is changed.
|
|
|
|
It allows the program to examine the current page (which can be retrieved
|
|
|
|
with wxBookCtrlEvent::GetOldSelection) and to veto the page change by calling
|
|
|
|
wxNotifyEvent::Veto if, for example, the current values in the controls
|
|
|
|
of the old page are invalid.
|
|
|
|
|
2008-10-13 06:27:19 -04:00
|
|
|
The PAGE_CHANGED events are sent after the page has been changed and the
|
|
|
|
program cannot veto it any more, it just informs it about the page change.
|
2008-08-01 09:46:46 -04:00
|
|
|
|
|
|
|
To summarize, if the program is interested in validating the page values
|
|
|
|
before allowing the user to change it, it should process the PAGE_CHANGING
|
|
|
|
event, otherwise PAGE_CHANGED is probably enough. In any case, it is
|
|
|
|
probably unnecessary to process both events at once.
|
|
|
|
|
|
|
|
@library{wxcore}
|
2009-02-20 06:34:52 -05:00
|
|
|
@category{events,bookctrl}
|
2008-08-01 09:46:46 -04:00
|
|
|
|
2011-10-02 06:29:00 -04:00
|
|
|
@see wxNotebook, wxListbook, wxChoicebook, wxTreebook, wxToolbook, wxAuiNotebook
|
2008-08-01 09:46:46 -04:00
|
|
|
*/
|
|
|
|
class wxBookCtrlEvent : public wxNotifyEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor (used internally by wxWidgets only).
|
|
|
|
*/
|
|
|
|
wxBookCtrlEvent(wxEventType eventType = wxEVT_NULL, int id = 0,
|
2008-10-13 06:27:19 -04:00
|
|
|
int sel = wxNOT_FOUND, int oldSel = wxNOT_FOUND);
|
2008-08-01 09:46:46 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the page that was selected before the change, @c wxNOT_FOUND if
|
|
|
|
none was selected.
|
|
|
|
*/
|
|
|
|
int GetOldSelection() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the currently selected page, or @c wxNOT_FOUND if none was
|
|
|
|
selected.
|
2008-10-13 06:27:19 -04:00
|
|
|
|
2008-08-01 09:46:46 -04:00
|
|
|
@note under Windows, GetSelection() will return the same value as
|
2008-10-13 06:27:19 -04:00
|
|
|
GetOldSelection() when called from the @c EVT_BOOKCTRL_PAGE_CHANGING
|
|
|
|
handler and not the page which is going to be selected.
|
2008-08-01 09:46:46 -04:00
|
|
|
*/
|
|
|
|
int GetSelection() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the id of the page selected before the change.
|
|
|
|
*/
|
|
|
|
void SetOldSelection(int page);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the selection member variable.
|
|
|
|
*/
|
|
|
|
void SetSelection(int page);
|
|
|
|
};
|
|
|
|
|