1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.widgets.tabbar; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.coreevent; 19 import qt.core.namespace; 20 import qt.core.point; 21 import qt.core.rect; 22 import qt.core.size; 23 import qt.core.string; 24 import qt.core.variant; 25 import qt.gui.color; 26 import qt.gui.event; 27 import qt.gui.icon; 28 import qt.helpers; 29 import qt.widgets.styleoption; 30 import qt.widgets.widget; 31 32 /+ QT_REQUIRE_CONFIG(tabbar); 33 34 35 class QIcon; +/ 36 extern(C++, class) struct QTabBarPrivate; 37 /+ class QStyleOptionTab; +/ 38 39 class /+ Q_WIDGETS_EXPORT +/ QTabBar: QWidget 40 { 41 mixin(Q_OBJECT); 42 43 /+ Q_PROPERTY(Shape shape READ shape WRITE setShape) 44 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged) 45 Q_PROPERTY(int count READ count) 46 Q_PROPERTY(bool drawBase READ drawBase WRITE setDrawBase) 47 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) 48 Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode) 49 Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons) 50 Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable) 51 Q_PROPERTY(SelectionBehavior selectionBehaviorOnRemove READ selectionBehaviorOnRemove WRITE setSelectionBehaviorOnRemove) 52 Q_PROPERTY(bool expanding READ expanding WRITE setExpanding) 53 Q_PROPERTY(bool movable READ isMovable WRITE setMovable) 54 Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode) 55 Q_PROPERTY(bool autoHide READ autoHide WRITE setAutoHide) 56 Q_PROPERTY(bool changeCurrentOnDrag READ changeCurrentOnDrag WRITE setChangeCurrentOnDrag) +/ 57 58 public: 59 /+ explicit +/this(QWidget parent = null); 60 ~this(); 61 62 enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast, 63 TriangularNorth, TriangularSouth, TriangularWest, TriangularEast 64 } 65 /+ Q_ENUM(Shape) +/ 66 67 enum ButtonPosition { 68 LeftSide, 69 RightSide 70 } 71 72 enum SelectionBehavior { 73 SelectLeftTab, 74 SelectRightTab, 75 SelectPreviousTab 76 } 77 78 final Shape shape() const; 79 final void setShape(Shape shape); 80 81 final int addTab(ref const(QString) text); 82 final int addTab(ref const(QIcon) icon, ref const(QString) text); 83 84 final int insertTab(int index, ref const(QString) text); 85 final int insertTab(int index, ref const(QIcon) icon, ref const(QString) text); 86 87 final void removeTab(int index); 88 final void moveTab(int from, int to); 89 90 final bool isTabEnabled(int index) const; 91 final void setTabEnabled(int index, bool enabled); 92 93 final bool isTabVisible(int index) const; 94 final void setTabVisible(int index, bool visible); 95 96 final QString tabText(int index) const; 97 final void setTabText(int index, ref const(QString) text); 98 99 final QColor tabTextColor(int index) const; 100 final void setTabTextColor(int index, ref const(QColor) color); 101 102 final QIcon tabIcon(int index) const; 103 final void setTabIcon(int index, ref const(QIcon) icon); 104 105 final /+ Qt:: +/qt.core.namespace.TextElideMode elideMode() const; 106 final void setElideMode(/+ Qt:: +/qt.core.namespace.TextElideMode mode); 107 108 /+ #ifndef QT_NO_TOOLTIP +/ 109 version(QT_NO_TOOLTIP){}else 110 { 111 final void setTabToolTip(int index, ref const(QString) tip); 112 final QString tabToolTip(int index) const; 113 } 114 /+ #endif 115 116 #if QT_CONFIG(whatsthis) +/ 117 final void setTabWhatsThis(int index, ref const(QString) text); 118 final QString tabWhatsThis(int index) const; 119 /+ #endif +/ 120 121 final void setTabData(int index, ref const(QVariant) data); 122 final QVariant tabData(int index) const; 123 124 final QRect tabRect(int index) const; 125 final int tabAt(ref const(QPoint) pos) const; 126 127 final int currentIndex() const; 128 final int count() const; 129 130 override QSize sizeHint() const; 131 override QSize minimumSizeHint() const; 132 133 final void setDrawBase(bool drawTheBase); 134 final bool drawBase() const; 135 136 final QSize iconSize() const; 137 final void setIconSize(ref const(QSize) size); 138 139 final bool usesScrollButtons() const; 140 final void setUsesScrollButtons(bool useButtons); 141 142 final bool tabsClosable() const; 143 final void setTabsClosable(bool closable); 144 145 final void setTabButton(int index, ButtonPosition position, QWidget widget); 146 final QWidget tabButton(int index, ButtonPosition position) const; 147 148 final SelectionBehavior selectionBehaviorOnRemove() const; 149 final void setSelectionBehaviorOnRemove(SelectionBehavior behavior); 150 151 final bool expanding() const; 152 final void setExpanding(bool enabled); 153 154 final bool isMovable() const; 155 final void setMovable(bool movable); 156 157 final bool documentMode() const; 158 final void setDocumentMode(bool set); 159 160 final bool autoHide() const; 161 final void setAutoHide(bool hide); 162 163 final bool changeCurrentOnDrag() const; 164 final void setChangeCurrentOnDrag(bool change); 165 166 version(QT_NO_ACCESSIBILITY){}else 167 { 168 final QString accessibleTabName(int index) const; 169 final void setAccessibleTabName(int index, ref const(QString) name); 170 } 171 172 public /+ Q_SLOTS +/: 173 @QSlot final void setCurrentIndex(int index); 174 175 /+ Q_SIGNALS +/public: 176 @QSignal final void currentChanged(int index); 177 @QSignal final void tabCloseRequested(int index); 178 @QSignal final void tabMoved(int from, int to); 179 @QSignal final void tabBarClicked(int index); 180 @QSignal final void tabBarDoubleClicked(int index); 181 182 protected: 183 /+ virtual +/ QSize tabSizeHint(int index) const; 184 /+ virtual +/ QSize minimumTabSizeHint(int index) const; 185 /+ virtual +/ void tabInserted(int index); 186 /+ virtual +/ void tabRemoved(int index); 187 /+ virtual +/ void tabLayoutChange(); 188 189 override bool event(QEvent ); 190 override void resizeEvent(QResizeEvent ); 191 override void showEvent(QShowEvent ); 192 override void hideEvent(QHideEvent ); 193 override void paintEvent(QPaintEvent ); 194 override void mousePressEvent (QMouseEvent ); 195 override void mouseMoveEvent (QMouseEvent ); 196 override void mouseReleaseEvent (QMouseEvent ); 197 /+ #if QT_CONFIG(wheelevent) +/ 198 override void wheelEvent(QWheelEvent event); 199 /+ #endif +/ 200 override void keyPressEvent(QKeyEvent ); 201 override void changeEvent(QEvent ); 202 override void timerEvent(QTimerEvent event); 203 final void initStyleOption(QStyleOptionTab* option, int tabIndex) const; 204 205 version(QT_NO_ACCESSIBILITY){}else 206 { 207 /+ friend class QAccessibleTabBar; +/ 208 } 209 private: 210 /+ Q_DISABLE_COPY(QTabBar) +/ 211 /+ Q_DECLARE_PRIVATE(QTabBar) +/ 212 /+ Q_PRIVATE_SLOT(d_func(), void _q_scrollTabs()) 213 Q_PRIVATE_SLOT(d_func(), void _q_closeTab()) +/ 214 } 215