src/gui/widgets/qtabbar.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    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 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QTABBAR_H
       
    43 #define QTABBAR_H
       
    44 
       
    45 #include <QtGui/qwidget.h>
       
    46 
       
    47 QT_BEGIN_HEADER
       
    48 
       
    49 QT_BEGIN_NAMESPACE
       
    50 
       
    51 QT_MODULE(Gui)
       
    52 
       
    53 #ifndef QT_NO_TABBAR
       
    54 
       
    55 class QIcon;
       
    56 class QTabBarPrivate;
       
    57 class QStyleOptionTab;
       
    58 
       
    59 class Q_GUI_EXPORT QTabBar: public QWidget
       
    60 {
       
    61     Q_OBJECT
       
    62 
       
    63     Q_ENUMS(Shape)
       
    64     Q_PROPERTY(Shape shape READ shape WRITE setShape)
       
    65     Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
       
    66     Q_PROPERTY(int count READ count)
       
    67     Q_PROPERTY(bool drawBase READ drawBase WRITE setDrawBase)
       
    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 tabsClosable READ tabsClosable WRITE setTabsClosable)
       
    72     Q_PROPERTY(SelectionBehavior selectionBehaviorOnRemove READ selectionBehaviorOnRemove WRITE setSelectionBehaviorOnRemove)
       
    73     Q_PROPERTY(bool expanding READ expanding WRITE setExpanding)
       
    74     Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
       
    75     Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
       
    76 
       
    77 public:
       
    78     explicit QTabBar(QWidget* parent=0);
       
    79     ~QTabBar();
       
    80 
       
    81     enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast,
       
    82                  TriangularNorth, TriangularSouth, TriangularWest, TriangularEast
       
    83 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
       
    84                 , RoundedAbove = RoundedNorth, RoundedBelow = RoundedSouth,
       
    85                 TriangularAbove = TriangularNorth, TriangularBelow = TriangularSouth
       
    86 #endif
       
    87     };
       
    88 
       
    89     enum ButtonPosition {
       
    90         LeftSide,
       
    91         RightSide
       
    92     };
       
    93 
       
    94     enum SelectionBehavior {
       
    95         SelectLeftTab,
       
    96         SelectRightTab,
       
    97         SelectPreviousTab
       
    98     };
       
    99 
       
   100     Shape shape() const;
       
   101     void setShape(Shape shape);
       
   102 
       
   103     int addTab(const QString &text);
       
   104     int addTab(const QIcon &icon, const QString &text);
       
   105 
       
   106     int insertTab(int index, const QString &text);
       
   107     int insertTab(int index, const QIcon&icon, const QString &text);
       
   108 
       
   109     void removeTab(int index);
       
   110     void moveTab(int from, int to);
       
   111 
       
   112     bool isTabEnabled(int index) const;
       
   113     void setTabEnabled(int index, bool);
       
   114 
       
   115     QString tabText(int index) const;
       
   116     void setTabText(int index, const QString &text);
       
   117 
       
   118     QColor tabTextColor(int index) const;
       
   119     void setTabTextColor(int index, const QColor &color);
       
   120 
       
   121     QIcon tabIcon(int index) const;
       
   122     void setTabIcon(int index, const QIcon &icon);
       
   123 
       
   124     Qt::TextElideMode elideMode() const;
       
   125     void setElideMode(Qt::TextElideMode);
       
   126 
       
   127 #ifndef QT_NO_TOOLTIP
       
   128     void setTabToolTip(int index, const QString &tip);
       
   129     QString tabToolTip(int index) const;
       
   130 #endif
       
   131 
       
   132 #ifndef QT_NO_WHATSTHIS
       
   133     void setTabWhatsThis(int index, const QString &text);
       
   134     QString tabWhatsThis(int index) const;
       
   135 #endif
       
   136 
       
   137     void setTabData(int index, const QVariant &data);
       
   138     QVariant tabData(int index) const;
       
   139 
       
   140     QRect tabRect(int index) const;
       
   141     int tabAt(const QPoint &pos) const;
       
   142 
       
   143     int currentIndex() const;
       
   144     int count() const;
       
   145 
       
   146     QSize sizeHint() const;
       
   147     QSize minimumSizeHint() const;
       
   148 
       
   149     void setDrawBase(bool drawTheBase);
       
   150     bool drawBase() const;
       
   151 
       
   152     QSize iconSize() const;
       
   153     void setIconSize(const QSize &size);
       
   154 
       
   155     bool usesScrollButtons() const;
       
   156     void setUsesScrollButtons(bool useButtons);
       
   157 
       
   158     bool tabsClosable() const;
       
   159     void setTabsClosable(bool closable);
       
   160 
       
   161     void setTabButton(int index, ButtonPosition position, QWidget *widget);
       
   162     QWidget *tabButton(int index, ButtonPosition position) const;
       
   163 
       
   164     SelectionBehavior selectionBehaviorOnRemove() const;
       
   165     void setSelectionBehaviorOnRemove(SelectionBehavior behavior);
       
   166 
       
   167     bool expanding() const;
       
   168     void setExpanding(bool enabled);
       
   169 
       
   170     bool isMovable() const;
       
   171     void setMovable(bool movable);
       
   172 
       
   173     bool documentMode() const;
       
   174     void setDocumentMode(bool set);
       
   175 
       
   176 public Q_SLOTS:
       
   177     void setCurrentIndex(int index);
       
   178 
       
   179 Q_SIGNALS:
       
   180     void currentChanged(int index);
       
   181     void tabCloseRequested(int index);
       
   182     void tabMoved(int from, int to);
       
   183 
       
   184 protected:
       
   185     virtual QSize tabSizeHint(int index) const;
       
   186     virtual void tabInserted(int index);
       
   187     virtual void tabRemoved(int index);
       
   188     virtual void tabLayoutChange();
       
   189 
       
   190     bool event(QEvent *);
       
   191     void resizeEvent(QResizeEvent *);
       
   192     void showEvent(QShowEvent *);
       
   193     void hideEvent(QHideEvent *);
       
   194     void paintEvent(QPaintEvent *);
       
   195     void mousePressEvent (QMouseEvent *);
       
   196     void mouseMoveEvent (QMouseEvent *);
       
   197     void mouseReleaseEvent (QMouseEvent *);
       
   198 #ifndef QT_NO_WHEELEVENT
       
   199     void wheelEvent(QWheelEvent *event);
       
   200 #endif
       
   201     void keyPressEvent(QKeyEvent *);
       
   202     void changeEvent(QEvent *);
       
   203     void initStyleOption(QStyleOptionTab *option, int tabIndex) const;
       
   204 
       
   205 #ifdef QT3_SUPPORT
       
   206 public Q_SLOTS:
       
   207     QT_MOC_COMPAT void setCurrentTab(int index) { setCurrentIndex(index); }
       
   208 Q_SIGNALS:
       
   209     QT_MOC_COMPAT void selected(int);
       
   210 #endif
       
   211 
       
   212     friend class QAccessibleTabBar;
       
   213 private:
       
   214     Q_DISABLE_COPY(QTabBar)
       
   215     Q_DECLARE_PRIVATE(QTabBar)
       
   216     Q_PRIVATE_SLOT(d_func(), void _q_scrollTabs())
       
   217     Q_PRIVATE_SLOT(d_func(), void _q_closeTab())
       
   218 };
       
   219 
       
   220 #endif // QT_NO_TABBAR
       
   221 
       
   222 QT_END_NAMESPACE
       
   223 
       
   224 QT_END_HEADER
       
   225 
       
   226 #endif // QTABBAR_H