Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:39

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QTABBAR_H
0005 #define QTABBAR_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qwidget.h>
0009 
0010 QT_REQUIRE_CONFIG(tabbar);
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 class QIcon;
0015 class QTabBarPrivate;
0016 class QStyleOptionTab;
0017 
0018 class Q_WIDGETS_EXPORT QTabBar: public QWidget
0019 {
0020     Q_OBJECT
0021 
0022     Q_PROPERTY(Shape shape READ shape WRITE setShape)
0023     Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
0024     Q_PROPERTY(int count READ count)
0025     Q_PROPERTY(bool drawBase READ drawBase WRITE setDrawBase)
0026     Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
0027     Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
0028     Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
0029     Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
0030     Q_PROPERTY(SelectionBehavior selectionBehaviorOnRemove READ selectionBehaviorOnRemove
0031                WRITE setSelectionBehaviorOnRemove)
0032     Q_PROPERTY(bool expanding READ expanding WRITE setExpanding)
0033     Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
0034     Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
0035     Q_PROPERTY(bool autoHide READ autoHide WRITE setAutoHide)
0036     Q_PROPERTY(bool changeCurrentOnDrag READ changeCurrentOnDrag WRITE setChangeCurrentOnDrag)
0037 
0038 public:
0039     explicit QTabBar(QWidget *parent = nullptr);
0040     ~QTabBar();
0041 
0042     enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast,
0043                  TriangularNorth, TriangularSouth, TriangularWest, TriangularEast
0044     };
0045     Q_ENUM(Shape)
0046 
0047     enum ButtonPosition {
0048         LeftSide,
0049         RightSide
0050     };
0051 
0052     enum SelectionBehavior {
0053         SelectLeftTab,
0054         SelectRightTab,
0055         SelectPreviousTab
0056     };
0057 
0058     Shape shape() const;
0059     void setShape(Shape shape);
0060 
0061     int addTab(const QString &text);
0062     int addTab(const QIcon &icon, const QString &text);
0063 
0064     int insertTab(int index, const QString &text);
0065     int insertTab(int index, const QIcon&icon, const QString &text);
0066 
0067     void removeTab(int index);
0068     void moveTab(int from, int to);
0069 
0070     bool isTabEnabled(int index) const;
0071     void setTabEnabled(int index, bool enabled);
0072 
0073     bool isTabVisible(int index) const;
0074     void setTabVisible(int index, bool visible);
0075 
0076     QString tabText(int index) const;
0077     void setTabText(int index, const QString &text);
0078 
0079     QColor tabTextColor(int index) const;
0080     void setTabTextColor(int index, const QColor &color);
0081 
0082     QIcon tabIcon(int index) const;
0083     void setTabIcon(int index, const QIcon &icon);
0084 
0085     Qt::TextElideMode elideMode() const;
0086     void setElideMode(Qt::TextElideMode mode);
0087 
0088 #if QT_CONFIG(tooltip)
0089     void setTabToolTip(int index, const QString &tip);
0090     QString tabToolTip(int index) const;
0091 #endif
0092 
0093 #if QT_CONFIG(whatsthis)
0094     void setTabWhatsThis(int index, const QString &text);
0095     QString tabWhatsThis(int index) const;
0096 #endif
0097 
0098     void setTabData(int index, const QVariant &data);
0099     QVariant tabData(int index) const;
0100 
0101     QRect tabRect(int index) const;
0102     int tabAt(const QPoint &pos) const;
0103 
0104     int currentIndex() const;
0105     int count() const;
0106 
0107     QSize sizeHint() const override;
0108     QSize minimumSizeHint() const override;
0109 
0110     void setDrawBase(bool drawTheBase);
0111     bool drawBase() const;
0112 
0113     QSize iconSize() const;
0114     void setIconSize(const QSize &size);
0115 
0116     bool usesScrollButtons() const;
0117     void setUsesScrollButtons(bool useButtons);
0118 
0119     bool tabsClosable() const;
0120     void setTabsClosable(bool closable);
0121 
0122     void setTabButton(int index, ButtonPosition position, QWidget *widget);
0123     QWidget *tabButton(int index, ButtonPosition position) const;
0124 
0125     SelectionBehavior selectionBehaviorOnRemove() const;
0126     void setSelectionBehaviorOnRemove(SelectionBehavior behavior);
0127 
0128     bool expanding() const;
0129     void setExpanding(bool enabled);
0130 
0131     bool isMovable() const;
0132     void setMovable(bool movable);
0133 
0134     bool documentMode() const;
0135     void setDocumentMode(bool set);
0136 
0137     bool autoHide() const;
0138     void setAutoHide(bool hide);
0139 
0140     bool changeCurrentOnDrag() const;
0141     void setChangeCurrentOnDrag(bool change);
0142 
0143 #if QT_CONFIG(accessibility)
0144     QString accessibleTabName(int index) const;
0145     void setAccessibleTabName(int index, const QString &name);
0146 #endif
0147 
0148 public Q_SLOTS:
0149     void setCurrentIndex(int index);
0150 
0151 Q_SIGNALS:
0152     void currentChanged(int index);
0153     void tabCloseRequested(int index);
0154     void tabMoved(int from, int to);
0155     void tabBarClicked(int index);
0156     void tabBarDoubleClicked(int index);
0157 
0158 protected:
0159     virtual QSize tabSizeHint(int index) const;
0160     virtual QSize minimumTabSizeHint(int index) const;
0161     virtual void tabInserted(int index);
0162     virtual void tabRemoved(int index);
0163     virtual void tabLayoutChange();
0164 
0165     bool event(QEvent *) override;
0166     void resizeEvent(QResizeEvent *) override;
0167     void showEvent(QShowEvent *) override;
0168     void hideEvent(QHideEvent *) override;
0169     void paintEvent(QPaintEvent *) override;
0170     void mousePressEvent(QMouseEvent *) override;
0171     void mouseMoveEvent(QMouseEvent *) override;
0172     void mouseReleaseEvent(QMouseEvent *) override;
0173     void mouseDoubleClickEvent(QMouseEvent *) override;
0174 #if QT_CONFIG(wheelevent)
0175     void wheelEvent(QWheelEvent *event) override;
0176 #endif
0177     void keyPressEvent(QKeyEvent *) override;
0178     void changeEvent(QEvent *) override;
0179     void timerEvent(QTimerEvent *event) override;
0180     virtual void initStyleOption(QStyleOptionTab *option, int tabIndex) const;
0181 
0182 #if QT_CONFIG(accessibility)
0183     friend class QAccessibleTabBar;
0184 #endif
0185 private:
0186     Q_DISABLE_COPY(QTabBar)
0187     Q_DECLARE_PRIVATE(QTabBar)
0188 };
0189 
0190 QT_END_NAMESPACE
0191 
0192 #endif // QTABBAR_H