source: trunk/src/gui/widgets/qtabwidget.h@ 792

Last change on this file since 792 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 8.6 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QTABWIDGET_H
43#define QTABWIDGET_H
44
45#include <QtGui/qwidget.h>
46#include <QtGui/qicon.h>
47
48QT_BEGIN_HEADER
49
50QT_BEGIN_NAMESPACE
51
52QT_MODULE(Gui)
53
54#ifndef QT_NO_TABWIDGET
55
56class QTabBar;
57class QTabWidgetPrivate;
58class QStyleOptionTabWidgetFrame;
59
60class Q_GUI_EXPORT QTabWidget : public QWidget
61{
62 Q_OBJECT
63 Q_ENUMS(TabPosition TabShape)
64 Q_PROPERTY(TabPosition tabPosition READ tabPosition WRITE setTabPosition)
65 Q_PROPERTY(TabShape tabShape READ tabShape WRITE setTabShape)
66 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
67 Q_PROPERTY(int count READ count)
68 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
69 Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
70 Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
71 Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
72 Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
73 Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
74
75public:
76 explicit QTabWidget(QWidget *parent = 0);
77 ~QTabWidget();
78
79 int addTab(QWidget *widget, const QString &);
80 int addTab(QWidget *widget, const QIcon& icon, const QString &label);
81
82 int insertTab(int index, QWidget *widget, const QString &);
83 int insertTab(int index, QWidget *widget, const QIcon& icon, const QString &label);
84
85 void removeTab(int index);
86
87 bool isTabEnabled(int index) const;
88 void setTabEnabled(int index, bool);
89
90 QString tabText(int index) const;
91 void setTabText(int index, const QString &);
92
93 QIcon tabIcon(int index) const;
94 void setTabIcon(int index, const QIcon & icon);
95
96#ifndef QT_NO_TOOLTIP
97 void setTabToolTip(int index, const QString & tip);
98 QString tabToolTip(int index) const;
99#endif
100
101#ifndef QT_NO_WHATSTHIS
102 void setTabWhatsThis(int index, const QString &text);
103 QString tabWhatsThis(int index) const;
104#endif
105
106 int currentIndex() const;
107 QWidget *currentWidget() const;
108 QWidget *widget(int index) const;
109 int indexOf(QWidget *widget) const;
110 int count() const;
111
112 enum TabPosition { North, South, West, East
113#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
114 , Top = North, Bottom = South
115#endif
116 };
117 TabPosition tabPosition() const;
118 void setTabPosition(TabPosition);
119
120 bool tabsClosable() const;
121 void setTabsClosable(bool closeable);
122
123 bool isMovable() const;
124 void setMovable(bool movable);
125
126 enum TabShape { Rounded, Triangular };
127 TabShape tabShape() const;
128 void setTabShape(TabShape s);
129
130 QSize sizeHint() const;
131 QSize minimumSizeHint() const;
132
133 void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
134 QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
135
136 Qt::TextElideMode elideMode() const;
137 void setElideMode(Qt::TextElideMode);
138
139 QSize iconSize() const;
140 void setIconSize(const QSize &size);
141
142 bool usesScrollButtons() const;
143 void setUsesScrollButtons(bool useButtons);
144
145 bool documentMode() const;
146 void setDocumentMode(bool set);
147
148 void clear();
149
150public Q_SLOTS:
151 void setCurrentIndex(int index);
152 void setCurrentWidget(QWidget *widget);
153
154Q_SIGNALS:
155 void currentChanged(int index);
156 void tabCloseRequested(int index);
157
158protected:
159 virtual void tabInserted(int index);
160 virtual void tabRemoved(int index);
161
162 void showEvent(QShowEvent *);
163 void resizeEvent(QResizeEvent *);
164 void keyPressEvent(QKeyEvent *);
165 void paintEvent(QPaintEvent *);
166 void setTabBar(QTabBar *);
167 QTabBar* tabBar() const;
168 void changeEvent(QEvent *);
169 bool event(QEvent *);
170 void initStyleOption(QStyleOptionTabWidgetFrame *option) const;
171
172#ifdef QT3_SUPPORT
173public:
174 QT3_SUPPORT_CONSTRUCTOR QTabWidget(QWidget *parent, const char *name, Qt::WindowFlags f = 0);
175
176 inline QT3_SUPPORT void insertTab(QWidget * w, const QString &s, int index = -1) { insertTab(index, w, s); }
177 inline QT3_SUPPORT void insertTab(QWidget *child, const QIcon& icon,
178 const QString &label, int index = -1) { insertTab(index, child, icon, label); }
179
180 inline QT3_SUPPORT void changeTab(QWidget *w, const QString &s) {setTabText(indexOf(w), s); }
181 inline QT3_SUPPORT void changeTab(QWidget *w, const QIcon& icon,
182 const QString &label) { int idx = indexOf(w); setTabText(idx, label); setTabIcon(idx, icon); }
183
184 inline QT3_SUPPORT bool isTabEnabled( QWidget *w) const {return isTabEnabled(indexOf(w)); }
185 inline QT3_SUPPORT void setTabEnabled(QWidget *w, bool b) { setTabEnabled(indexOf(w), b); }
186
187 inline QT3_SUPPORT QString tabLabel(QWidget *w) const {return tabText(indexOf(w)); }
188 inline QT3_SUPPORT void setTabLabel(QWidget *w, const QString &l) { setTabText(indexOf(w), l); }
189
190 inline QT3_SUPPORT QIcon tabIconSet(QWidget * w) const {return tabIcon(indexOf(w)); }
191 inline QT3_SUPPORT void setTabIconSet(QWidget * w, const QIcon & icon) { setTabIcon(indexOf(w), icon); }
192
193 inline QT3_SUPPORT void removeTabToolTip(QWidget * w) {
194#ifndef QT_NO_TOOLTIP
195 setTabToolTip(indexOf(w), QString());
196#else
197 Q_UNUSED(w);
198#endif
199 }
200 inline QT3_SUPPORT void setTabToolTip(QWidget * w, const QString & tip) {
201#ifndef QT_NO_TOOLTIP
202 setTabToolTip(indexOf(w), tip);
203#else
204 Q_UNUSED(w);
205 Q_UNUSED(tip);
206#endif
207 }
208
209 inline QT3_SUPPORT QString tabToolTip(QWidget * w) const {
210#ifndef QT_NO_TOOLTIP
211 return tabToolTip(indexOf(w));
212#else
213 Q_UNUSED(w);
214 return QString();
215#endif
216 }
217
218 inline QT3_SUPPORT QWidget * currentPage() const { return currentWidget(); }
219 inline QT3_SUPPORT QWidget *page(int index) const { return widget(index); }
220 inline QT3_SUPPORT QString label(int index) const { return tabText(index); }
221 inline QT3_SUPPORT int currentPageIndex() const { return currentIndex(); }
222
223 inline QT3_SUPPORT int margin() const { return 0; }
224 inline QT3_SUPPORT void setMargin(int) {}
225
226public Q_SLOTS:
227 inline QT_MOC_COMPAT void setCurrentPage(int index) { setCurrentIndex(index); }
228 inline QT_MOC_COMPAT void showPage(QWidget *w) { setCurrentIndex(indexOf(w)); }
229 inline QT_MOC_COMPAT void removePage(QWidget *w) { removeTab(indexOf(w)); }
230
231Q_SIGNALS:
232 QT_MOC_COMPAT void currentChanged(QWidget *);
233 QT_MOC_COMPAT void selected(const QString&);
234#endif // QT3_SUPPORT
235
236private:
237 Q_DECLARE_PRIVATE(QTabWidget)
238 Q_DISABLE_COPY(QTabWidget)
239 Q_PRIVATE_SLOT(d_func(), void _q_showTab(int))
240 Q_PRIVATE_SLOT(d_func(), void _q_removeTab(int))
241 Q_PRIVATE_SLOT(d_func(), void _q_tabMoved(int, int))
242 void setUpLayout(bool = false);
243 friend class Q3TabDialog;
244};
245
246#endif // QT_NO_TABWIDGET
247
248QT_END_NAMESPACE
249
250QT_END_HEADER
251
252#endif // QTABWIDGET_H
Note: See TracBrowser for help on using the repository browser.