1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/notebook.h
3 // Purpose: universal version of wxNotebook
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_NOTEBOOK_H_
13 #define _WX_UNIV_NOTEBOOK_H_
15 #include "wx/arrstr.h"
17 class WXDLLIMPEXP_FWD_CORE wxSpinButton
;
19 // ----------------------------------------------------------------------------
20 // the actions supported by this control
21 // ----------------------------------------------------------------------------
23 // change the page: to the next/previous/given one
24 #define wxACTION_NOTEBOOK_NEXT wxT("nexttab")
25 #define wxACTION_NOTEBOOK_PREV wxT("prevtab")
26 #define wxACTION_NOTEBOOK_GOTO wxT("gototab")
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 class WXDLLIMPEXP_CORE wxNotebook
: public wxNotebookBase
38 wxNotebook() { Init(); }
40 wxNotebook(wxWindow
*parent
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
,
45 const wxString
& name
= wxNotebookNameStr
)
49 (void)Create(parent
, id
, pos
, size
, style
, name
);
53 bool Create(wxWindow
*parent
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
58 const wxString
& name
= wxNotebookNameStr
);
61 virtual ~wxNotebook();
63 // implement wxNotebookBase pure virtuals
64 // --------------------------------------
66 virtual int SetSelection(size_t nPage
) { return DoSetSelection(nPage
, SetSelection_SendEvent
); }
68 // changes selected page without sending events
69 int ChangeSelection(size_t nPage
) { return DoSetSelection(nPage
); }
71 virtual bool SetPageText(size_t nPage
, const wxString
& strText
);
72 virtual wxString
GetPageText(size_t nPage
) const;
74 virtual int GetPageImage(size_t nPage
) const;
75 virtual bool SetPageImage(size_t nPage
, int nImage
);
77 virtual void SetPageSize(const wxSize
& size
);
78 virtual void SetPadding(const wxSize
& padding
);
79 virtual void SetTabSize(const wxSize
& sz
);
81 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
83 virtual bool DeleteAllPages();
85 virtual bool InsertPage(size_t nPage
,
86 wxNotebookPage
*pPage
,
87 const wxString
& strText
,
89 int imageId
= NO_IMAGE
);
94 // return true if all tabs have the same width
95 bool FixedSizeTabs() const { return HasFlag(wxNB_FIXEDWIDTH
); }
97 // return wxTOP/wxBOTTOM/wxRIGHT/wxLEFT
98 wxDirection
GetTabOrientation() const;
100 // return true if the notebook has tabs at the sidesand not at the top (or
102 bool IsVertical() const;
107 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
112 virtual bool PerformAction(const wxControlAction
& action
,
114 const wxString
& strArg
= wxEmptyString
);
116 static wxInputHandler
*GetStdInputHandler(wxInputHandler
*handlerDef
);
117 virtual wxInputHandler
*DoGetStdInputHandler(wxInputHandler
*handlerDef
)
119 return GetStdInputHandler(handlerDef
);
122 // refresh the currently selected tab
123 void RefreshCurrent();
126 virtual wxNotebookPage
*DoRemovePage(size_t nPage
);
129 virtual void DoDraw(wxControlRenderer
*renderer
);
130 void DoDrawTab(wxDC
& dc
, const wxRect
& rect
, size_t n
);
133 virtual wxSize
DoGetBestClientSize() const;
134 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
135 virtual void DoSetSize(int x
, int y
,
136 int width
, int height
,
137 int sizeFlags
= wxSIZE_AUTO
);
139 int DoSetSelection(size_t nPage
, int flags
= 0);
141 // common part of all ctors
144 // resize the tab to fit its title (and icon if any)
145 void ResizeTab(int page
);
147 // recalculate the geometry of the notebook completely
150 // is the spin button currently shown?
151 bool HasSpinBtn() const;
153 // calculate last (fully) visible tab: updates m_lastVisible
154 void CalcLastVisibleTab();
156 // show or hide the spin control for tabs scrolling depending on whether it
158 void UpdateSpinBtn();
160 // position the spin button
161 void PositionSpinBtn();
163 // refresh the given tab only
164 void RefreshTab(int page
, bool forceSelected
= false);
167 void RefreshAllTabs();
169 // get the tab rect (inefficient, don't use this in a loop)
170 wxRect
GetTabRect(int page
) const;
172 // get the rectangle containing all tabs
173 wxRect
GetAllTabsRect() const;
175 // get the part occupied by the tabs - slightly smaller than
176 // GetAllTabsRect() because the tabs may be indented from it
177 wxRect
GetTabsPart() const;
179 // calculate the tab size (without padding)
180 wxSize
CalcTabSize(int page
) const;
182 // get the (cached) size of a tab
183 void GetTabSize(int page
, wxCoord
*w
, wxCoord
*h
) const;
185 // get the (cached) width of the tab
186 wxCoord
GetTabWidth(int page
) const
187 { return FixedSizeTabs() ? m_widthMax
: m_widths
[page
]; }
189 // return true if the tab has an associated image
190 bool HasImage(int page
) const
191 { return m_imageList
&& m_images
[page
] != -1; }
193 // get the part of the notebook reserved for the pages (slightly larger
194 // than GetPageRect() as we draw a border and leave marginin between)
195 wxRect
GetPagePart() const;
197 // get the page rect in our client coords
198 wxRect
GetPageRect() const;
200 // get our client size from the page size
201 wxSize
GetSizeForPage(const wxSize
& size
) const;
203 // scroll the tabs so that the first page shown becomes the given one
204 void ScrollTo(size_t page
);
206 // scroll the tabs so that the first page shown becomes the given one
207 void ScrollLastTo(size_t page
);
210 wxArrayString m_titles
;
212 // the spin button to change the pages
213 wxSpinButton
*m_spinbtn
;
215 // the offset of the first page shown (may be changed with m_spinbtn)
218 // the first and last currently visible tabs: the name is not completely
219 // accurate as m_lastVisible is, in fact, the first tab which is *not*
220 // visible: so the visible tabs are those with indexes such that
221 // m_firstVisible <= n < m_lastVisible
222 size_t m_firstVisible
,
225 // the last fully visible item, usually just m_lastVisible - 1 but may be
227 size_t m_lastFullyVisible
;
229 // the height of tabs in a normal notebook or the width of tabs in a
230 // notebook with tabs on a side
233 // the biggest height (or width) of a notebook tab (used only if
234 // FixedSizeTabs()) or -1 if not calculated yet
237 // the cached widths (or heights) of tabs
243 // the accel indexes for labels
249 DECLARE_DYNAMIC_CLASS(wxNotebook
)
252 #endif // _WX_UNIV_NOTEBOOK_H_