]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/notebook.h
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 WXDLLEXPORT 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 _T("nexttab")
25 #define wxACTION_NOTEBOOK_PREV _T("prevtab")
26 #define wxACTION_NOTEBOOK_GOTO _T("gototab")
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 class WXDLLEXPORT 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
);
67 virtual int GetSelection() const { return (int) m_sel
; }
69 virtual bool SetPageText(size_t nPage
, const wxString
& strText
);
70 virtual wxString
GetPageText(size_t nPage
) const;
72 virtual int GetPageImage(size_t nPage
) const;
73 virtual bool SetPageImage(size_t nPage
, int nImage
);
75 virtual void SetPageSize(const wxSize
& size
);
76 virtual void SetPadding(const wxSize
& padding
);
77 virtual void SetTabSize(const wxSize
& sz
);
79 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
81 virtual bool DeleteAllPages();
83 virtual bool InsertPage(size_t nPage
,
84 wxNotebookPage
*pPage
,
85 const wxString
& strText
,
92 // return true if all tabs have the same width
93 bool FixedSizeTabs() const { return HasFlag(wxNB_FIXEDWIDTH
); }
95 // return wxTOP/wxBOTTOM/wxRIGHT/wxLEFT
96 wxDirection
GetTabOrientation() const;
98 // return true if the notebook has tabs at the sidesand not at the top (or
100 bool IsVertical() const;
105 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
110 virtual bool PerformAction(const wxControlAction
& action
,
112 const wxString
& strArg
= wxEmptyString
);
114 static wxInputHandler
*GetStdInputHandler(wxInputHandler
*handlerDef
);
115 virtual wxInputHandler
*DoGetStdInputHandler(wxInputHandler
*handlerDef
)
117 return GetStdInputHandler(handlerDef
);
120 // refresh the currently selected tab
121 void RefreshCurrent();
124 virtual wxNotebookPage
*DoRemovePage(size_t nPage
);
127 virtual void DoDraw(wxControlRenderer
*renderer
);
128 void DoDrawTab(wxDC
& dc
, const wxRect
& rect
, size_t n
);
131 virtual wxSize
DoGetBestClientSize() const;
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 // common part of all ctors
140 // resize the tab to fit its title (and icon if any)
141 void ResizeTab(int page
);
143 // recalculate the geometry of the notebook completely
146 // is the spin button currently shown?
147 bool HasSpinBtn() const;
149 // calculate last (fully) visible tab: updates m_lastVisible
150 void CalcLastVisibleTab();
152 // show or hide the spin control for tabs scrolling depending on whether it
154 void UpdateSpinBtn();
156 // position the spin button
157 void PositionSpinBtn();
159 // refresh the given tab only
160 void RefreshTab(int page
, bool forceSelected
= false);
163 void RefreshAllTabs();
165 // get the tab rect (inefficient, don't use this in a loop)
166 wxRect
GetTabRect(int page
) const;
168 // get the rectangle containing all tabs
169 wxRect
GetAllTabsRect() const;
171 // get the part occupied by the tabs - slightly smaller than
172 // GetAllTabsRect() because the tabs may be indented from it
173 wxRect
GetTabsPart() const;
175 // calculate the tab size (without padding)
176 wxSize
CalcTabSize(int page
) const;
178 // get the (cached) size of a tab
179 void GetTabSize(int page
, wxCoord
*w
, wxCoord
*h
) const;
181 // get the (cached) width of the tab
182 wxCoord
GetTabWidth(int page
) const
183 { return FixedSizeTabs() ? m_widthMax
: m_widths
[page
]; }
185 // return true if the tab has an associated image
186 bool HasImage(int page
) const
187 { return m_imageList
&& m_images
[page
] != -1; }
189 // get the part of the notebook reserved for the pages (slightly larger
190 // than GetPageRect() as we draw a border and leave marginin between)
191 wxRect
GetPagePart() const;
193 // get the page rect in our client coords
194 wxRect
GetPageRect() const;
196 // get our client size from the page size
197 wxSize
GetSizeForPage(const wxSize
& size
) const;
199 // scroll the tabs so that the first page shown becomes the given one
200 void ScrollTo(int page
);
202 // scroll the tabs so that the first page shown becomes the given one
203 void ScrollLastTo(int page
);
206 wxArrayString m_titles
;
208 // the current selection
211 // the spin button to change the pages
212 wxSpinButton
*m_spinbtn
;
214 // the offset of the first page shown (may be changed with m_spinbtn)
217 // the first and last currently visible tabs: the name is not completely
218 // accurate as m_lastVisible is, in fact, the first tab which is *not*
219 // visible: so the visible tabs are those with indexes such that
220 // m_firstVisible <= n < m_lastVisible
221 size_t m_firstVisible
,
224 // the last fully visible item, usually just m_lastVisible - 1 but may be
226 size_t m_lastFullyVisible
;
228 // the height of tabs in a normal notebook or the width of tabs in a
229 // notebook with tabs on a side
232 // the biggest height (or width) of a notebook tab (used only if
233 // FixedSizeTabs()) or -1 if not calculated yet
236 // the cached widths (or heights) of tabs
242 // the accel indexes for labels
248 DECLARE_DYNAMIC_CLASS(wxNotebook
)
251 #endif // _WX_UNIV_NOTEBOOK_H_