1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/notebook.h
3 // Purpose: universal version of wxNotebook
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIV_NOTEBOOK_H_
12 #define _WX_UNIV_NOTEBOOK_H_
14 #include "wx/arrstr.h"
16 class WXDLLIMPEXP_FWD_CORE wxSpinButton
;
18 // ----------------------------------------------------------------------------
19 // the actions supported by this control
20 // ----------------------------------------------------------------------------
22 // change the page: to the next/previous/given one
23 #define wxACTION_NOTEBOOK_NEXT wxT("nexttab")
24 #define wxACTION_NOTEBOOK_PREV wxT("prevtab")
25 #define wxACTION_NOTEBOOK_GOTO wxT("gototab")
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class WXDLLIMPEXP_CORE wxNotebook
: public wxNotebookBase
37 wxNotebook() { Init(); }
39 wxNotebook(wxWindow
*parent
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
44 const wxString
& name
= wxNotebookNameStr
)
48 (void)Create(parent
, id
, pos
, size
, style
, name
);
52 bool Create(wxWindow
*parent
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
57 const wxString
& name
= wxNotebookNameStr
);
60 virtual ~wxNotebook();
62 // implement wxNotebookBase pure virtuals
63 // --------------------------------------
65 virtual int SetSelection(size_t nPage
) { return DoSetSelection(nPage
, SetSelection_SendEvent
); }
67 // changes selected page without sending events
68 int ChangeSelection(size_t nPage
) { return DoSetSelection(nPage
); }
70 virtual bool SetPageText(size_t nPage
, const wxString
& strText
);
71 virtual wxString
GetPageText(size_t nPage
) const;
73 virtual int GetPageImage(size_t nPage
) const;
74 virtual bool SetPageImage(size_t nPage
, int nImage
);
76 virtual void SetPageSize(const wxSize
& size
);
77 virtual void SetPadding(const wxSize
& padding
);
78 virtual void SetTabSize(const wxSize
& sz
);
80 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
82 virtual bool DeleteAllPages();
84 virtual bool InsertPage(size_t nPage
,
85 wxNotebookPage
*pPage
,
86 const wxString
& strText
,
88 int imageId
= NO_IMAGE
);
93 // return true if all tabs have the same width
94 bool FixedSizeTabs() const { return HasFlag(wxNB_FIXEDWIDTH
); }
96 // return wxTOP/wxBOTTOM/wxRIGHT/wxLEFT
97 wxDirection
GetTabOrientation() const;
99 // return true if the notebook has tabs at the sidesand not at the top (or
101 bool IsVertical() const;
106 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
111 virtual bool PerformAction(const wxControlAction
& action
,
113 const wxString
& strArg
= wxEmptyString
);
115 static wxInputHandler
*GetStdInputHandler(wxInputHandler
*handlerDef
);
116 virtual wxInputHandler
*DoGetStdInputHandler(wxInputHandler
*handlerDef
)
118 return GetStdInputHandler(handlerDef
);
121 // refresh the currently selected tab
122 void RefreshCurrent();
125 virtual wxNotebookPage
*DoRemovePage(size_t nPage
);
128 virtual void DoDraw(wxControlRenderer
*renderer
);
129 void DoDrawTab(wxDC
& dc
, const wxRect
& rect
, size_t n
);
132 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
133 virtual void DoSetSize(int x
, int y
,
134 int width
, int height
,
135 int sizeFlags
= wxSIZE_AUTO
);
137 int DoSetSelection(size_t nPage
, int flags
= 0);
139 // common part of all ctors
142 // resize the tab to fit its title (and icon if any)
143 void ResizeTab(int page
);
145 // recalculate the geometry of the notebook completely
148 // is the spin button currently shown?
149 bool HasSpinBtn() const;
151 // calculate last (fully) visible tab: updates m_lastVisible
152 void CalcLastVisibleTab();
154 // show or hide the spin control for tabs scrolling depending on whether it
156 void UpdateSpinBtn();
158 // position the spin button
159 void PositionSpinBtn();
161 // refresh the given tab only
162 void RefreshTab(int page
, bool forceSelected
= false);
165 void RefreshAllTabs();
167 // get the tab rect (inefficient, don't use this in a loop)
168 wxRect
GetTabRect(int page
) const;
170 // get the rectangle containing all tabs
171 wxRect
GetAllTabsRect() const;
173 // get the part occupied by the tabs - slightly smaller than
174 // GetAllTabsRect() because the tabs may be indented from it
175 wxRect
GetTabsPart() const;
177 // calculate the tab size (without padding)
178 wxSize
CalcTabSize(int page
) const;
180 // get the (cached) size of a tab
181 void GetTabSize(int page
, wxCoord
*w
, wxCoord
*h
) const;
183 // get the (cached) width of the tab
184 wxCoord
GetTabWidth(int page
) const
185 { return FixedSizeTabs() ? m_widthMax
: m_widths
[page
]; }
187 // return true if the tab has an associated image
188 bool HasImage(int page
) const
189 { return HasImageList() && m_images
[page
] != -1; }
191 // get the part of the notebook reserved for the pages (slightly larger
192 // than GetPageRect() as we draw a border and leave marginin between)
193 wxRect
GetPagePart() const;
195 // get the page rect in our client coords
196 wxRect
GetPageRect() const;
198 // get our client size from the page size
199 wxSize
GetSizeForPage(const wxSize
& size
) const;
201 // scroll the tabs so that the first page shown becomes the given one
202 void ScrollTo(size_t page
);
204 // scroll the tabs so that the first page shown becomes the given one
205 void ScrollLastTo(size_t page
);
208 wxArrayString m_titles
;
210 // the spin button to change the pages
211 wxSpinButton
*m_spinbtn
;
213 // the offset of the first page shown (may be changed with m_spinbtn)
216 // the first and last currently visible tabs: the name is not completely
217 // accurate as m_lastVisible is, in fact, the first tab which is *not*
218 // visible: so the visible tabs are those with indexes such that
219 // m_firstVisible <= n < m_lastVisible
220 size_t m_firstVisible
,
223 // the last fully visible item, usually just m_lastVisible - 1 but may be
225 size_t m_lastFullyVisible
;
227 // the height of tabs in a normal notebook or the width of tabs in a
228 // notebook with tabs on a side
231 // the biggest height (or width) of a notebook tab (used only if
232 // FixedSizeTabs()) or -1 if not calculated yet
235 // the cached widths (or heights) of tabs
241 // the accel indexes for labels
247 DECLARE_DYNAMIC_CLASS(wxNotebook
)
250 #endif // _WX_UNIV_NOTEBOOK_H_