]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/notebook.h
Fix compile warning when building DLLs
[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)
1e6feb95
VZ
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_UNIV_NOTEBOOK_H_
13#define _WX_UNIV_NOTEBOOK_H_
14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
a3870b2f 16 #pragma interface "univnotebook.h"
1e6feb95
VZ
17#endif
18
b5435dcc
MB
19#include "wx/arrstr.h"
20
1e6feb95
VZ
21class WXDLLEXPORT wxSpinButton;
22
23// ----------------------------------------------------------------------------
24// the actions supported by this control
25// ----------------------------------------------------------------------------
26
27// change the page: to the next/previous/given one
28#define wxACTION_NOTEBOOK_NEXT _T("nexttab")
29#define wxACTION_NOTEBOOK_PREV _T("prevtab")
30#define wxACTION_NOTEBOOK_GOTO _T("gototab")
31
32// ----------------------------------------------------------------------------
33// wxNotebook
34// ----------------------------------------------------------------------------
35
36class WXDLLEXPORT wxNotebook : public wxNotebookBase
37{
38public:
39 // ctors and such
40 // --------------
41
1169a919 42 wxNotebook();
1e6feb95
VZ
43
44 wxNotebook(wxWindow *parent,
45 wxWindowID id,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 long style = 0,
1169a919 49 const wxString& name = wxNOTEBOOK_NAME);
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,
57 const wxString& name = wxNOTEBOOK_NAME);
58
59 // dtor
60 virtual ~wxNotebook();
61
62 // implement wxNotebookBase pure virtuals
63 // --------------------------------------
64
15aad3b9 65 virtual int SetSelection(size_t nPage);
1e6feb95
VZ
66 virtual int GetSelection() const { return m_sel; }
67
15aad3b9
VZ
68 virtual bool SetPageText(size_t nPage, const wxString& strText);
69 virtual wxString GetPageText(size_t nPage) const;
1e6feb95 70
15aad3b9
VZ
71 virtual int GetPageImage(size_t nPage) const;
72 virtual bool SetPageImage(size_t nPage, int nImage);
1e6feb95
VZ
73
74 virtual void SetPageSize(const wxSize& size);
75 virtual void SetPadding(const wxSize& padding);
76 virtual void SetTabSize(const wxSize& sz);
77
2ce7af35 78 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
1e6feb95
VZ
79
80 virtual bool DeleteAllPages();
81
15aad3b9 82 virtual bool InsertPage(size_t nPage,
1e6feb95
VZ
83 wxNotebookPage *pPage,
84 const wxString& strText,
85 bool bSelect = FALSE,
86 int imageId = -1);
87
88 // style tests
89 // -----------
90
91 // return TRUE if all tabs have the same width
d7787243 92 bool FixedSizeTabs() const { return HasFlag(wxNB_FIXEDWIDTH); }
1e6feb95
VZ
93
94 // return wxTOP/wxBOTTOM/wxRIGHT/wxLEFT
95 wxDirection GetTabOrientation() const;
96
97 // return TRUE if the notebook has tabs at the sidesand not at the top (or
98 // bottom) as usual
99 bool IsVertical() const;
100
101 // hit testing
102 // -----------
103
e450aa69 104 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
1e6feb95
VZ
105
106 // input handling
107 // --------------
108
109 virtual bool PerformAction(const wxControlAction& action,
110 long numArg = 0l,
111 const wxString& strArg = wxEmptyString);
112
113 // refresh the currently selected tab
114 void RefreshCurrent();
115
116protected:
15aad3b9 117 virtual wxNotebookPage *DoRemovePage(size_t nPage);
1e6feb95
VZ
118
119 // drawing
120 virtual void DoDraw(wxControlRenderer *renderer);
121 void DoDrawTab(wxDC& dc, const wxRect& rect, size_t n);
122
123 // resizing
124 virtual wxSize DoGetBestClientSize() const;
125 virtual void DoMoveWindow(int x, int y, int width, int height);
126 virtual void DoSetSize(int x, int y,
127 int width, int height,
128 int sizeFlags = wxSIZE_AUTO);
129
130 // common part of all ctors
131 void Init();
132
133 // resize the tab to fit its title (and icon if any)
134 void ResizeTab(int page);
135
136 // recalculate the geometry of the notebook completely
137 void Relayout();
138
139 // is the spin button currently shown?
140 bool HasSpinBtn() const;
141
142 // calculate last (fully) visible tab: updates m_lastVisible
143 void CalcLastVisibleTab();
144
145 // show or hide the spin control for tabs scrolling depending on whether it
146 // is needed or not
147 void UpdateSpinBtn();
148
149 // position the spin button
150 void PositionSpinBtn();
151
152 // refresh the given tab only
1d8c3e58 153 void RefreshTab(int page, bool forceSelected = FALSE);
1e6feb95
VZ
154
155 // refresh all tabs
156 void RefreshAllTabs();
157
158 // get the tab rect (inefficient, don't use this in a loop)
159 wxRect GetTabRect(int page) const;
160
161 // get the rectangle containing all tabs
162 wxRect GetAllTabsRect() const;
163
164 // get the part occupied by the tabs - slightly smaller than
165 // GetAllTabsRect() because the tabs may be indented from it
166 wxRect GetTabsPart() const;
167
168 // calculate the tab size (without padding)
169 wxSize CalcTabSize(int page) const;
170
171 // get the (cached) size of a tab
172 void GetTabSize(int page, wxCoord *w, wxCoord *h) const;
173
174 // get the (cached) width of the tab
175 wxCoord GetTabWidth(int page) const
176 { return FixedSizeTabs() ? m_widthMax : m_widths[page]; }
177
178 // return TRUE if the tab has an associated image
179 bool HasImage(int page) const
180 { return m_imageList && m_images[page] != -1; }
181
182 // get the part of the notebook reserved for the pages (slightly larger
183 // than GetPageRect() as we draw a border and leave marginin between)
184 wxRect GetPagePart() const;
185
186 // get the page rect in our client coords
187 wxRect GetPageRect() const;
188
189 // get our client size from the page size
190 wxSize GetSizeForPage(const wxSize& size) const;
191
1e6feb95
VZ
192 // scroll the tabs so that the first page shown becomes the given one
193 void ScrollTo(int page);
194
195 // scroll the tabs so that the first page shown becomes the given one
196 void ScrollLastTo(int page);
197
198 // the pages titles
199 wxArrayString m_titles;
200
201 // the current selection
202 size_t m_sel;
203
204 // the spin button to change the pages
205 wxSpinButton *m_spinbtn;
206
207 // the offset of the first page shown (may be changed with m_spinbtn)
208 wxCoord m_offset;
209
210 // the first and last currently visible tabs: the name is not completely
211 // accurate as m_lastVisible is, in fact, the first tab which is *not*
212 // visible: so the visible tabs are those with indexes such that
213 // m_firstVisible <= n < m_lastVisible
214 size_t m_firstVisible,
215 m_lastVisible;
216
217 // the last fully visible item, usually just m_lastVisible - 1 but may be
218 // different from it
219 size_t m_lastFullyVisible;
220
221 // the height of tabs in a normal notebook or the width of tabs in a
222 // notebook with tabs on a side
223 wxCoord m_heightTab;
224
225 // the biggest height (or width) of a notebook tab (used only if
226 // FixedSizeTabs()) or -1 if not calculated yet
227 wxCoord m_widthMax;
228
229 // the cached widths (or heights) of tabs
230 wxArrayInt m_widths;
231
232 // the icon indices
233 wxArrayInt m_images;
234
235 // the accel indexes for labels
236 wxArrayInt m_accels;
237
238 // the padding
239 wxSize m_sizePad;
240
241 DECLARE_DYNAMIC_CLASS(wxNotebook)
242};
243
244// ----------------------------------------------------------------------------
245// wxStdNotebookInputHandler: translates SPACE and ENTER keys and the left mouse
246// click into button press/release actions
247// ----------------------------------------------------------------------------
248
249class WXDLLEXPORT wxStdNotebookInputHandler : public wxStdInputHandler
250{
251public:
252 wxStdNotebookInputHandler(wxInputHandler *inphand);
253
23645bfa 254 virtual bool HandleKey(wxInputConsumer *consumer,
1e6feb95
VZ
255 const wxKeyEvent& event,
256 bool pressed);
23645bfa 257 virtual bool HandleMouse(wxInputConsumer *consumer,
1e6feb95 258 const wxMouseEvent& event);
23645bfa
VS
259 virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
260 virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
261 virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
1e6feb95
VZ
262
263protected:
23645bfa 264 void HandleFocusChange(wxInputConsumer *consumer);
1e6feb95
VZ
265};
266
267#endif // _WX_UNIV_NOTEBOOK_H_
268