]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/notebook.h
Add lambda-friendly wxDialog::ShowWindowModalThenDo().
[wxWidgets.git] / include / wx / univ / notebook.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/notebook.h
3// Purpose: universal version of wxNotebook
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 01.02.01
442b35b5 7// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
65571936 8// Licence: wxWindows licence
1e6feb95
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_UNIV_NOTEBOOK_H_
12#define _WX_UNIV_NOTEBOOK_H_
13
b5435dcc
MB
14#include "wx/arrstr.h"
15
b5dbe15d 16class WXDLLIMPEXP_FWD_CORE wxSpinButton;
1e6feb95
VZ
17
18// ----------------------------------------------------------------------------
19// the actions supported by this control
20// ----------------------------------------------------------------------------
21
22// change the page: to the next/previous/given one
9a83f860
VZ
23#define wxACTION_NOTEBOOK_NEXT wxT("nexttab")
24#define wxACTION_NOTEBOOK_PREV wxT("prevtab")
25#define wxACTION_NOTEBOOK_GOTO wxT("gototab")
1e6feb95
VZ
26
27// ----------------------------------------------------------------------------
28// wxNotebook
29// ----------------------------------------------------------------------------
30
53a2db12 31class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
1e6feb95
VZ
32{
33public:
34 // ctors and such
35 // --------------
36
6463b9f5 37 wxNotebook() { Init(); }
1e6feb95
VZ
38
39 wxNotebook(wxWindow *parent,
40 wxWindowID id,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = 0,
630ad6c6 44 const wxString& name = wxNotebookNameStr)
6463b9f5
JS
45 {
46 Init();
47
48 (void)Create(parent, id, pos, size, style, name);
49 }
1e6feb95
VZ
50
51 // quasi ctor
52 bool Create(wxWindow *parent,
53 wxWindowID id,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 long style = 0,
630ad6c6 57 const wxString& name = wxNotebookNameStr);
1e6feb95
VZ
58
59 // dtor
60 virtual ~wxNotebook();
61
62 // implement wxNotebookBase pure virtuals
63 // --------------------------------------
64
1d6fcbcc 65 virtual int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
1e6feb95 66
1d6fcbcc
VZ
67 // changes selected page without sending events
68 int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
69
15aad3b9
VZ
70 virtual bool SetPageText(size_t nPage, const wxString& strText);
71 virtual wxString GetPageText(size_t nPage) const;
1e6feb95 72
15aad3b9
VZ
73 virtual int GetPageImage(size_t nPage) const;
74 virtual bool SetPageImage(size_t nPage, int nImage);
1e6feb95
VZ
75
76 virtual void SetPageSize(const wxSize& size);
77 virtual void SetPadding(const wxSize& padding);
78 virtual void SetTabSize(const wxSize& sz);
79
2ce7af35 80 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
1e6feb95
VZ
81
82 virtual bool DeleteAllPages();
83
15aad3b9 84 virtual bool InsertPage(size_t nPage,
1e6feb95
VZ
85 wxNotebookPage *pPage,
86 const wxString& strText,
a290fa5a 87 bool bSelect = false,
1871b9fa 88 int imageId = NO_IMAGE);
1e6feb95
VZ
89
90 // style tests
91 // -----------
92
a290fa5a 93 // return true if all tabs have the same width
d7787243 94 bool FixedSizeTabs() const { return HasFlag(wxNB_FIXEDWIDTH); }
1e6feb95
VZ
95
96 // return wxTOP/wxBOTTOM/wxRIGHT/wxLEFT
97 wxDirection GetTabOrientation() const;
98
a290fa5a 99 // return true if the notebook has tabs at the sidesand not at the top (or
1e6feb95
VZ
100 // bottom) as usual
101 bool IsVertical() const;
102
103 // hit testing
104 // -----------
105
e450aa69 106 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
1e6feb95
VZ
107
108 // input handling
109 // --------------
110
111 virtual bool PerformAction(const wxControlAction& action,
112 long numArg = 0l,
113 const wxString& strArg = wxEmptyString);
114
9467bdb7
VZ
115 static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
116 virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
117 {
118 return GetStdInputHandler(handlerDef);
119 }
120
1e6feb95
VZ
121 // refresh the currently selected tab
122 void RefreshCurrent();
123
124protected:
15aad3b9 125 virtual wxNotebookPage *DoRemovePage(size_t nPage);
1e6feb95
VZ
126
127 // drawing
128 virtual void DoDraw(wxControlRenderer *renderer);
129 void DoDrawTab(wxDC& dc, const wxRect& rect, size_t n);
130
131 // resizing
1e6feb95
VZ
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);
136
1d6fcbcc
VZ
137 int DoSetSelection(size_t nPage, int flags = 0);
138
1e6feb95
VZ
139 // common part of all ctors
140 void Init();
141
142 // resize the tab to fit its title (and icon if any)
143 void ResizeTab(int page);
144
145 // recalculate the geometry of the notebook completely
146 void Relayout();
147
148 // is the spin button currently shown?
149 bool HasSpinBtn() const;
150
151 // calculate last (fully) visible tab: updates m_lastVisible
152 void CalcLastVisibleTab();
153
154 // show or hide the spin control for tabs scrolling depending on whether it
155 // is needed or not
156 void UpdateSpinBtn();
157
158 // position the spin button
159 void PositionSpinBtn();
160
161 // refresh the given tab only
a290fa5a 162 void RefreshTab(int page, bool forceSelected = false);
1e6feb95
VZ
163
164 // refresh all tabs
165 void RefreshAllTabs();
166
167 // get the tab rect (inefficient, don't use this in a loop)
168 wxRect GetTabRect(int page) const;
169
170 // get the rectangle containing all tabs
171 wxRect GetAllTabsRect() const;
172
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;
176
177 // calculate the tab size (without padding)
178 wxSize CalcTabSize(int page) const;
179
180 // get the (cached) size of a tab
181 void GetTabSize(int page, wxCoord *w, wxCoord *h) const;
182
183 // get the (cached) width of the tab
184 wxCoord GetTabWidth(int page) const
185 { return FixedSizeTabs() ? m_widthMax : m_widths[page]; }
186
a290fa5a 187 // return true if the tab has an associated image
1e6feb95 188 bool HasImage(int page) const
f340c9ca 189 { return HasImageList() && m_images[page] != -1; }
1e6feb95
VZ
190
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;
194
195 // get the page rect in our client coords
196 wxRect GetPageRect() const;
197
198 // get our client size from the page size
199 wxSize GetSizeForPage(const wxSize& size) const;
200
1e6feb95 201 // scroll the tabs so that the first page shown becomes the given one
1f1dee6b 202 void ScrollTo(size_t page);
1e6feb95
VZ
203
204 // scroll the tabs so that the first page shown becomes the given one
1f1dee6b 205 void ScrollLastTo(size_t page);
1e6feb95
VZ
206
207 // the pages titles
208 wxArrayString m_titles;
209
1e6feb95
VZ
210 // the spin button to change the pages
211 wxSpinButton *m_spinbtn;
212
213 // the offset of the first page shown (may be changed with m_spinbtn)
214 wxCoord m_offset;
215
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,
221 m_lastVisible;
222
223 // the last fully visible item, usually just m_lastVisible - 1 but may be
224 // different from it
225 size_t m_lastFullyVisible;
226
227 // the height of tabs in a normal notebook or the width of tabs in a
228 // notebook with tabs on a side
229 wxCoord m_heightTab;
230
231 // the biggest height (or width) of a notebook tab (used only if
232 // FixedSizeTabs()) or -1 if not calculated yet
233 wxCoord m_widthMax;
234
235 // the cached widths (or heights) of tabs
236 wxArrayInt m_widths;
237
238 // the icon indices
239 wxArrayInt m_images;
240
241 // the accel indexes for labels
242 wxArrayInt m_accels;
243
244 // the padding
245 wxSize m_sizePad;
246
247 DECLARE_DYNAMIC_CLASS(wxNotebook)
248};
249
1e6feb95
VZ
250#endif // _WX_UNIV_NOTEBOOK_H_
251