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.tabwidget; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.coreevent; 19 import qt.core.namespace; 20 import qt.core.size; 21 import qt.core.string; 22 import qt.gui.event; 23 import qt.gui.icon; 24 import qt.helpers; 25 import qt.widgets.styleoption; 26 import qt.widgets.tabbar; 27 import qt.widgets.widget; 28 29 /+ QT_REQUIRE_CONFIG(tabwidget); 30 31 32 class QTabBar; +/ 33 extern(C++, class) struct QTabWidgetPrivate; 34 /+ class QStyleOptionTabWidgetFrame; +/ 35 36 class /+ Q_WIDGETS_EXPORT +/ QTabWidget : QWidget 37 { 38 mixin(Q_OBJECT); 39 /+ Q_PROPERTY(TabPosition tabPosition READ tabPosition WRITE setTabPosition) 40 Q_PROPERTY(TabShape tabShape READ tabShape WRITE setTabShape) 41 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged) 42 Q_PROPERTY(int count READ count) 43 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) 44 Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode) 45 Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons) 46 Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode) 47 Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable) 48 Q_PROPERTY(bool movable READ isMovable WRITE setMovable) 49 Q_PROPERTY(bool tabBarAutoHide READ tabBarAutoHide WRITE setTabBarAutoHide) +/ 50 51 public: 52 /+ explicit +/this(QWidget parent = null); 53 ~this(); 54 55 final int addTab(QWidget widget, ref const(QString) ); 56 final int addTab(QWidget widget, const(QString) label) 57 { 58 return addTab(widget, label); 59 } 60 final int addTab(QWidget widget, ref const(QIcon) icon, ref const(QString) label); 61 final int addTab(QWidget widget, const(QIcon) icon, const(QString) label) 62 { 63 return addTab(widget, icon, label); 64 } 65 66 final int insertTab(int index, QWidget widget, ref const(QString) ); 67 final int insertTab(int index, QWidget widget, ref const(QIcon) icon, ref const(QString) label); 68 69 final void removeTab(int index); 70 71 final bool isTabEnabled(int index) const; 72 final void setTabEnabled(int index, bool enabled); 73 74 final bool isTabVisible(int index) const; 75 final void setTabVisible(int index, bool visible); 76 77 final QString tabText(int index) const; 78 final void setTabText(int index, ref const(QString) text); 79 final void setTabText(int index, const(QString) text) 80 { 81 setTabText(index, text); 82 } 83 84 final QIcon tabIcon(int index) const; 85 final void setTabIcon(int index, ref const(QIcon) icon); 86 87 /+ #ifndef QT_NO_TOOLTIP +/ 88 version(QT_NO_TOOLTIP){}else 89 { 90 final void setTabToolTip(int index, ref const(QString) tip); 91 final QString tabToolTip(int index) const; 92 } 93 /+ #endif 94 95 #if QT_CONFIG(whatsthis) +/ 96 final void setTabWhatsThis(int index, ref const(QString) text); 97 final QString tabWhatsThis(int index) const; 98 /+ #endif +/ 99 100 final int currentIndex() const; 101 final QWidget currentWidget() const; 102 final QWidget widget(int index) const; 103 final int indexOf(QWidget widget) const; 104 final int count() const; 105 106 enum TabPosition { North, South, West, East } 107 /+ Q_ENUM(TabPosition) +/ 108 final TabPosition tabPosition() const; 109 final void setTabPosition(TabPosition position); 110 111 final bool tabsClosable() const; 112 final void setTabsClosable(bool closeable); 113 114 final bool isMovable() const; 115 final void setMovable(bool movable); 116 117 enum TabShape { Rounded, Triangular } 118 /+ Q_ENUM(TabShape) +/ 119 final TabShape tabShape() const; 120 final void setTabShape(TabShape s); 121 122 override QSize sizeHint() const; 123 override QSize minimumSizeHint() const; 124 override int heightForWidth(int width) const; 125 override bool hasHeightForWidth() const; 126 127 final void setCornerWidget(QWidget w, /+ Qt:: +/qt.core.namespace.Corner corner = /+ Qt:: +/qt.core.namespace.Corner.TopRightCorner); 128 final QWidget cornerWidget(/+ Qt:: +/qt.core.namespace.Corner corner = /+ Qt:: +/qt.core.namespace.Corner.TopRightCorner) const; 129 130 final /+ Qt:: +/qt.core.namespace.TextElideMode elideMode() const; 131 final void setElideMode(/+ Qt:: +/qt.core.namespace.TextElideMode mode); 132 133 final QSize iconSize() const; 134 final void setIconSize(ref const(QSize) size); 135 136 final bool usesScrollButtons() const; 137 final void setUsesScrollButtons(bool useButtons); 138 139 final bool documentMode() const; 140 final void setDocumentMode(bool set); 141 142 final bool tabBarAutoHide() const; 143 final void setTabBarAutoHide(bool enabled); 144 145 final void clear(); 146 147 final QTabBar tabBar() const; 148 149 public /+ Q_SLOTS +/: 150 @QSlot final void setCurrentIndex(int index); 151 @QSlot final void setCurrentWidget(QWidget widget); 152 153 /+ Q_SIGNALS +/public: 154 @QSignal final void currentChanged(int index); 155 @QSignal final void tabCloseRequested(int index); 156 @QSignal final void tabBarClicked(int index); 157 @QSignal final void tabBarDoubleClicked(int index); 158 159 protected: 160 /+ virtual +/ void tabInserted(int index); 161 /+ virtual +/ void tabRemoved(int index); 162 163 override void showEvent(QShowEvent ); 164 override void resizeEvent(QResizeEvent ); 165 override void keyPressEvent(QKeyEvent ); 166 override void paintEvent(QPaintEvent ); 167 final void setTabBar(QTabBar ); 168 override void changeEvent(QEvent ); 169 override bool event(QEvent ); 170 final void initStyleOption(QStyleOptionTabWidgetFrame* option) const; 171 172 173 private: 174 /+ Q_DECLARE_PRIVATE(QTabWidget) +/ 175 /+ Q_DISABLE_COPY(QTabWidget) +/ 176 /+ Q_PRIVATE_SLOT(d_func(), void _q_showTab(int)) 177 Q_PRIVATE_SLOT(d_func(), void _q_removeTab(int)) 178 Q_PRIVATE_SLOT(d_func(), void _q_tabMoved(int, int)) +/ 179 final void setUpLayout(bool /+ = false +/); 180 } 181