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