00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QTABWIDGET_H
00043 #define QTABWIDGET_H
00044
00045 #include <QtGui/qwidget.h>
00046 #include <QtGui/qicon.h>
00047
00048 QT_BEGIN_HEADER
00049
00050 QT_BEGIN_NAMESPACE
00051
00052 QT_MODULE(Gui)
00053
00054 #ifndef QT_NO_TABWIDGET
00055
00056 class QTabBar;
00057 class QTabWidgetPrivate;
00058 class QStyleOptionTabWidgetFrame;
00059
00060 class Q_GUI_EXPORT QTabWidget : public QWidget
00061 {
00062 Q_OBJECT
00063 Q_ENUMS(TabPosition TabShape)
00064 Q_PROPERTY(TabPosition tabPosition READ tabPosition WRITE setTabPosition)
00065 Q_PROPERTY(TabShape tabShape READ tabShape WRITE setTabShape)
00066 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
00067 Q_PROPERTY(int count READ count)
00068 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
00069 Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
00070 Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
00071 Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
00072 Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
00073 Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
00074
00075 public:
00076 explicit QTabWidget(QWidget *parent = 0);
00077 ~QTabWidget();
00078
00079 int addTab(QWidget *widget, const QString &);
00080 int addTab(QWidget *widget, const QIcon& icon, const QString &label);
00081
00082 int insertTab(int index, QWidget *widget, const QString &);
00083 int insertTab(int index, QWidget *widget, const QIcon& icon, const QString &label);
00084
00085 void removeTab(int index);
00086
00087 bool isTabEnabled(int index) const;
00088 void setTabEnabled(int index, bool);
00089
00090 QString tabText(int index) const;
00091 void setTabText(int index, const QString &);
00092
00093 QIcon tabIcon(int index) const;
00094 void setTabIcon(int index, const QIcon & icon);
00095
00096 #ifndef QT_NO_TOOLTIP
00097 void setTabToolTip(int index, const QString & tip);
00098 QString tabToolTip(int index) const;
00099 #endif
00100
00101 #ifndef QT_NO_WHATSTHIS
00102 void setTabWhatsThis(int index, const QString &text);
00103 QString tabWhatsThis(int index) const;
00104 #endif
00105
00106 int currentIndex() const;
00107 QWidget *currentWidget() const;
00108 QWidget *widget(int index) const;
00109 int indexOf(QWidget *widget) const;
00110 int count() const;
00111
00112 enum TabPosition { North, South, West, East
00113 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
00114 , Top = North, Bottom = South
00115 #endif
00116 };
00117 TabPosition tabPosition() const;
00118 void setTabPosition(TabPosition);
00119
00120 bool tabsClosable() const;
00121 void setTabsClosable(bool closeable);
00122
00123 bool isMovable() const;
00124 void setMovable(bool movable);
00125
00126 enum TabShape { Rounded, Triangular };
00127 TabShape tabShape() const;
00128 void setTabShape(TabShape s);
00129
00130 QSize sizeHint() const;
00131 QSize minimumSizeHint() const;
00132
00133 void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
00134 QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
00135
00136 Qt::TextElideMode elideMode() const;
00137 void setElideMode(Qt::TextElideMode);
00138
00139 QSize iconSize() const;
00140 void setIconSize(const QSize &size);
00141
00142 bool usesScrollButtons() const;
00143 void setUsesScrollButtons(bool useButtons);
00144
00145 bool documentMode() const;
00146 void setDocumentMode(bool set);
00147
00148 void clear();
00149
00150 public Q_SLOTS:
00151 void setCurrentIndex(int index);
00152 void setCurrentWidget(QWidget *widget);
00153
00154 Q_SIGNALS:
00155 void currentChanged(int index);
00156 void tabCloseRequested(int index);
00157
00158 protected:
00159 virtual void tabInserted(int index);
00160 virtual void tabRemoved(int index);
00161
00162 void showEvent(QShowEvent *);
00163 void resizeEvent(QResizeEvent *);
00164 void keyPressEvent(QKeyEvent *);
00165 void paintEvent(QPaintEvent *);
00166 void setTabBar(QTabBar *);
00167 QTabBar* tabBar() const;
00168 void changeEvent(QEvent *);
00169 bool event(QEvent *);
00170 void initStyleOption(QStyleOptionTabWidgetFrame *option) const;
00171
00172 #ifdef QT3_SUPPORT
00173 public:
00174 QT3_SUPPORT_CONSTRUCTOR QTabWidget(QWidget *parent, const char *name, Qt::WindowFlags f = 0);
00175
00176 inline QT3_SUPPORT void insertTab(QWidget * w, const QString &s, int index = -1) { insertTab(index, w, s); }
00177 inline QT3_SUPPORT void insertTab(QWidget *child, const QIcon& icon,
00178 const QString &label, int index = -1) { insertTab(index, child, icon, label); }
00179
00180 inline QT3_SUPPORT void changeTab(QWidget *w, const QString &s) {setTabText(indexOf(w), s); }
00181 inline QT3_SUPPORT void changeTab(QWidget *w, const QIcon& icon,
00182 const QString &label) { int idx = indexOf(w); setTabText(idx, label); setTabIcon(idx, icon); }
00183
00184 inline QT3_SUPPORT bool isTabEnabled( QWidget *w) const {return isTabEnabled(indexOf(w)); }
00185 inline QT3_SUPPORT void setTabEnabled(QWidget *w, bool b) { setTabEnabled(indexOf(w), b); }
00186
00187 inline QT3_SUPPORT QString tabLabel(QWidget *w) const {return tabText(indexOf(w)); }
00188 inline QT3_SUPPORT void setTabLabel(QWidget *w, const QString &l) { setTabText(indexOf(w), l); }
00189
00190 inline QT3_SUPPORT QIcon tabIconSet(QWidget * w) const {return tabIcon(indexOf(w)); }
00191 inline QT3_SUPPORT void setTabIconSet(QWidget * w, const QIcon & icon) { setTabIcon(indexOf(w), icon); }
00192
00193 inline QT3_SUPPORT void removeTabToolTip(QWidget * w) {
00194 #ifndef QT_NO_TOOLTIP
00195 setTabToolTip(indexOf(w), QString());
00196 #else
00197 Q_UNUSED(w);
00198 #endif
00199 }
00200 inline QT3_SUPPORT void setTabToolTip(QWidget * w, const QString & tip) {
00201 #ifndef QT_NO_TOOLTIP
00202 setTabToolTip(indexOf(w), tip);
00203 #else
00204 Q_UNUSED(w);
00205 Q_UNUSED(tip);
00206 #endif
00207 }
00208
00209 inline QT3_SUPPORT QString tabToolTip(QWidget * w) const {
00210 #ifndef QT_NO_TOOLTIP
00211 return tabToolTip(indexOf(w));
00212 #else
00213 Q_UNUSED(w);
00214 return QString();
00215 #endif
00216 }
00217
00218 inline QT3_SUPPORT QWidget * currentPage() const { return currentWidget(); }
00219 inline QT3_SUPPORT QWidget *page(int index) const { return widget(index); }
00220 inline QT3_SUPPORT QString label(int index) const { return tabText(index); }
00221 inline QT3_SUPPORT int currentPageIndex() const { return currentIndex(); }
00222
00223 inline QT3_SUPPORT int margin() const { return 0; }
00224 inline QT3_SUPPORT void setMargin(int) {}
00225
00226 public Q_SLOTS:
00227 inline QT_MOC_COMPAT void setCurrentPage(int index) { setCurrentIndex(index); }
00228 inline QT_MOC_COMPAT void showPage(QWidget *w) { setCurrentIndex(indexOf(w)); }
00229 inline QT_MOC_COMPAT void removePage(QWidget *w) { removeTab(indexOf(w)); }
00230
00231 Q_SIGNALS:
00232 QT_MOC_COMPAT void currentChanged(QWidget *);
00233 QT_MOC_COMPAT void selected(const QString&);
00234 #endif // QT3_SUPPORT
00235
00236 private:
00237 Q_DECLARE_PRIVATE(QTabWidget)
00238 Q_DISABLE_COPY(QTabWidget)
00239 Q_PRIVATE_SLOT(d_func(), void _q_showTab(int))
00240 Q_PRIVATE_SLOT(d_func(), void _q_removeTab(int))
00241 Q_PRIVATE_SLOT(d_func(), void _q_tabMoved(int, int))
00242 void setUpLayout(bool = false);
00243 friend class Q3TabDialog;
00244 };
00245
00246 #endif // QT_NO_TABWIDGET
00247
00248 QT_END_NAMESPACE
00249
00250 QT_END_HEADER
00251
00252 #endif // QTABWIDGET_H