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.toolbar; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.coreevent; 19 import qt.core.namespace; 20 import qt.core.object; 21 import qt.core.point; 22 import qt.core.rect; 23 import qt.core.size; 24 import qt.core.string; 25 import qt.gui.event; 26 import qt.gui.icon; 27 import qt.helpers; 28 import qt.widgets.action; 29 import qt.widgets.styleoption; 30 import qt.widgets.widget; 31 version(QT_NO_ACTION){}else 32 import qt.widgets.event; 33 34 /+ QT_REQUIRE_CONFIG(toolbar); +/ 35 36 37 extern(C++, class) struct QToolBarPrivate; 38 39 /+ class QAction; 40 class QIcon; 41 class QMainWindow; 42 class QStyleOptionToolBar; +/ 43 44 class /+ Q_WIDGETS_EXPORT +/ QToolBar : QWidget 45 { 46 mixin(Q_OBJECT); 47 48 /+ Q_PROPERTY(bool movable READ isMovable WRITE setMovable NOTIFY movableChanged) 49 Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas NOTIFY allowedAreasChanged) 50 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) 51 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) 52 Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle 53 NOTIFY toolButtonStyleChanged) 54 Q_PROPERTY(bool floating READ isFloating) 55 Q_PROPERTY(bool floatable READ isFloatable WRITE setFloatable) +/ 56 57 public: 58 /+ explicit +/this(ref const(QString) title, QWidget parent = null); 59 /+ explicit +/this(QWidget parent = null); 60 ~this(); 61 62 final void setMovable(bool movable); 63 final bool isMovable() const; 64 65 final void setAllowedAreas(/+ Qt:: +/qt.core.namespace.ToolBarAreas areas); 66 final /+ Qt:: +/qt.core.namespace.ToolBarAreas allowedAreas() const; 67 68 /+ pragma(inline, true) final bool isAreaAllowed(/+ Qt:: +/qt.core.namespace.ToolBarArea area) const 69 { return (allowedAreas() & area) == area; }+/ 70 71 final void setOrientation(/+ Qt:: +/qt.core.namespace.Orientation orientation); 72 final /+ Qt:: +/qt.core.namespace.Orientation orientation() const; 73 74 final void clear(); 75 76 /+ using QWidget::addAction; +/ 77 final QAction addAction(ref const(QString) text); 78 final QAction addAction(ref const(QIcon) icon, ref const(QString) text); 79 final QAction addAction(ref const(QString) text, const(QObject) receiver, const(char)* member); 80 final QAction addAction(ref const(QIcon) icon, ref const(QString) text, 81 const(QObject) receiver, const(char)* member); 82 /+ #ifdef Q_CLANG_QDOC 83 template<typename Functor> 84 QAction *addAction(const QString &text, Functor functor); 85 template<typename Functor> 86 QAction *addAction(const QString &text, const QObject *context, Functor functor); 87 template<typename Functor> 88 QAction *addAction(const QIcon &icon, const QString &text, Functor functor); 89 template<typename Functor> 90 QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor); 91 #else +/ 92 // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) 93 /+ template<class Obj, typename Func1> +/ 94 /+ inline typename std::enable_if<!std::is_same<const char*, Func1>::value 95 && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type 96 addAction(const QString &text, const Obj *object, Func1 slot) 97 { 98 QAction *result = addAction(text); 99 connect(result, &QAction::triggered, object, std::move(slot)); 100 return result; 101 } +/ 102 // addAction(QString): Connect to a functor or function pointer (without context) 103 /+ template <typename Func1> +/ 104 /+ inline QAction *addAction(const QString &text, Func1 slot) 105 { 106 QAction *result = addAction(text); 107 connect(result, &QAction::triggered, slot); 108 return result; 109 } +/ 110 // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) 111 /+ template<class Obj, typename Func1> +/ 112 /+ inline typename std::enable_if<!std::is_same<const char*, Func1>::value 113 && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type 114 addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot) 115 { 116 QAction *result = addAction(actionIcon, text); 117 connect(result, &QAction::triggered, object, std::move(slot)); 118 return result; 119 } +/ 120 // addAction(QIcon, QString): Connect to a functor or function pointer (without context) 121 /+ template <typename Func1> +/ 122 /+ inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot) 123 { 124 QAction *result = addAction(actionIcon, text); 125 connect(result, &QAction::triggered, slot); 126 return result; 127 } +/ 128 /+ #endif +/ // !Q_CLANG_QDOC 129 130 final QAction addSeparator(); 131 final QAction insertSeparator(QAction before); 132 133 final QAction addWidget(QWidget widget); 134 final QAction insertWidget(QAction before, QWidget widget); 135 136 final QRect actionGeometry(QAction action) const; 137 final QAction actionAt(ref const(QPoint) p) const; 138 pragma(inline, true) final QAction actionAt(int ax, int ay) const 139 { auto tmp = QPoint(ax, ay); return actionAt(tmp); } 140 141 final QAction toggleViewAction() const; 142 143 final QSize iconSize() const; 144 final /+ Qt:: +/qt.core.namespace.ToolButtonStyle toolButtonStyle() const; 145 146 final QWidget widgetForAction(QAction action) const; 147 148 final bool isFloatable() const; 149 final void setFloatable(bool floatable); 150 final bool isFloating() const; 151 152 public /+ Q_SLOTS +/: 153 @QSlot final void setIconSize(ref const(QSize) iconSize); 154 @QSlot final void setToolButtonStyle(/+ Qt:: +/qt.core.namespace.ToolButtonStyle toolButtonStyle); 155 156 /+ Q_SIGNALS +/public: 157 @QSignal final void actionTriggered(QAction action); 158 @QSignal final void movableChanged(bool movable); 159 @QSignal final void allowedAreasChanged(/+ Qt:: +/qt.core.namespace.ToolBarAreas allowedAreas); 160 @QSignal final void orientationChanged(/+ Qt:: +/qt.core.namespace.Orientation orientation); 161 @QSignal final void iconSizeChanged(ref const(QSize) iconSize); 162 @QSignal final void toolButtonStyleChanged(/+ Qt:: +/qt.core.namespace.ToolButtonStyle toolButtonStyle); 163 @QSignal final void topLevelChanged(bool topLevel); 164 @QSignal final void visibilityChanged(bool visible); 165 166 protected: 167 override void actionEvent(QActionEvent event); 168 override void changeEvent(QEvent event); 169 override void paintEvent(QPaintEvent event); 170 override bool event(QEvent event); 171 final void initStyleOption(QStyleOptionToolBar* option) const; 172 173 174 private: 175 /+ Q_DECLARE_PRIVATE(QToolBar) +/ 176 /+ Q_DISABLE_COPY(QToolBar) +/ 177 /+ Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool)) 178 Q_PRIVATE_SLOT(d_func(), void _q_updateIconSize(const QSize &)) 179 Q_PRIVATE_SLOT(d_func(), void _q_updateToolButtonStyle(Qt::ToolButtonStyle)) +/ 180 181 /+ friend class QMainWindow; +/ 182 /+ friend class QMainWindowLayout; +/ 183 /+ friend class QToolBarLayout; +/ 184 /+ friend class QToolBarAreaLayout; +/ 185 } 186