| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #ifndef QDYNAMICTOOLBAR_H | 
|---|
| 43 | #define QDYNAMICTOOLBAR_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_TOOLBAR | 
|---|
| 54 |  | 
|---|
| 55 | class QToolBarPrivate; | 
|---|
| 56 |  | 
|---|
| 57 | class QAction; | 
|---|
| 58 | class QIcon; | 
|---|
| 59 | class QMainWindow; | 
|---|
| 60 | class QStyleOptionToolBar; | 
|---|
| 61 |  | 
|---|
| 62 | class Q_GUI_EXPORT QToolBar : public QWidget | 
|---|
| 63 | { | 
|---|
| 64 | Q_OBJECT | 
|---|
| 65 |  | 
|---|
| 66 | Q_PROPERTY(bool movable READ isMovable WRITE setMovable | 
|---|
| 67 | DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0) | 
|---|
| 68 | NOTIFY movableChanged) | 
|---|
| 69 | Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas | 
|---|
| 70 | DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0) | 
|---|
| 71 | NOTIFY allowedAreasChanged) | 
|---|
| 72 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation | 
|---|
| 73 | DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) == 0) | 
|---|
| 74 | NOTIFY orientationChanged) | 
|---|
| 75 | Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) | 
|---|
| 76 | Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle | 
|---|
| 77 | NOTIFY toolButtonStyleChanged) | 
|---|
| 78 | Q_PROPERTY(bool floating READ isFloating) | 
|---|
| 79 | Q_PROPERTY(bool floatable READ isFloatable WRITE setFloatable) | 
|---|
| 80 |  | 
|---|
| 81 | public: | 
|---|
| 82 | explicit QToolBar(const QString &title, QWidget *parent = 0); | 
|---|
| 83 | explicit QToolBar(QWidget *parent = 0); | 
|---|
| 84 | ~QToolBar(); | 
|---|
| 85 |  | 
|---|
| 86 | void setMovable(bool movable); | 
|---|
| 87 | bool isMovable() const; | 
|---|
| 88 |  | 
|---|
| 89 | void setAllowedAreas(Qt::ToolBarAreas areas); | 
|---|
| 90 | Qt::ToolBarAreas allowedAreas() const; | 
|---|
| 91 |  | 
|---|
| 92 | inline bool isAreaAllowed(Qt::ToolBarArea area) const | 
|---|
| 93 | { return (allowedAreas() & area) == area; } | 
|---|
| 94 |  | 
|---|
| 95 | void setOrientation(Qt::Orientation orientation); | 
|---|
| 96 | Qt::Orientation orientation() const; | 
|---|
| 97 |  | 
|---|
| 98 | void clear(); | 
|---|
| 99 |  | 
|---|
| 100 | #ifdef Q_NO_USING_KEYWORD | 
|---|
| 101 | inline void addAction(QAction *action) | 
|---|
| 102 | { QWidget::addAction(action); } | 
|---|
| 103 | #else | 
|---|
| 104 | using QWidget::addAction; | 
|---|
| 105 | #endif | 
|---|
| 106 |  | 
|---|
| 107 | QAction *addAction(const QString &text); | 
|---|
| 108 | QAction *addAction(const QIcon &icon, const QString &text); | 
|---|
| 109 | QAction *addAction(const QString &text, const QObject *receiver, const char* member); | 
|---|
| 110 | QAction *addAction(const QIcon &icon, const QString &text, | 
|---|
| 111 | const QObject *receiver, const char* member); | 
|---|
| 112 |  | 
|---|
| 113 | QAction *addSeparator(); | 
|---|
| 114 | QAction *insertSeparator(QAction *before); | 
|---|
| 115 |  | 
|---|
| 116 | QAction *addWidget(QWidget *widget); | 
|---|
| 117 | QAction *insertWidget(QAction *before, QWidget *widget); | 
|---|
| 118 |  | 
|---|
| 119 | QRect actionGeometry(QAction *action) const; | 
|---|
| 120 | QAction *actionAt(const QPoint &p) const; | 
|---|
| 121 | inline QAction *actionAt(int x, int y) const; | 
|---|
| 122 |  | 
|---|
| 123 | QAction *toggleViewAction() const; | 
|---|
| 124 |  | 
|---|
| 125 | QSize iconSize() const; | 
|---|
| 126 | Qt::ToolButtonStyle toolButtonStyle() const; | 
|---|
| 127 |  | 
|---|
| 128 | QWidget *widgetForAction(QAction *action) const; | 
|---|
| 129 |  | 
|---|
| 130 | bool isFloatable() const; | 
|---|
| 131 | void setFloatable(bool floatable); | 
|---|
| 132 | bool isFloating() const; | 
|---|
| 133 |  | 
|---|
| 134 | public Q_SLOTS: | 
|---|
| 135 | void setIconSize(const QSize &iconSize); | 
|---|
| 136 | void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle); | 
|---|
| 137 |  | 
|---|
| 138 | Q_SIGNALS: | 
|---|
| 139 | void actionTriggered(QAction *action); | 
|---|
| 140 | void movableChanged(bool movable); | 
|---|
| 141 | void allowedAreasChanged(Qt::ToolBarAreas allowedAreas); | 
|---|
| 142 | void orientationChanged(Qt::Orientation orientation); | 
|---|
| 143 | void iconSizeChanged(const QSize &iconSize); | 
|---|
| 144 | void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle); | 
|---|
| 145 |  | 
|---|
| 146 | protected: | 
|---|
| 147 | void actionEvent(QActionEvent *event); | 
|---|
| 148 | void changeEvent(QEvent *event); | 
|---|
| 149 | void childEvent(QChildEvent *event); | 
|---|
| 150 | void paintEvent(QPaintEvent *event); | 
|---|
| 151 | void resizeEvent(QResizeEvent *event); | 
|---|
| 152 | bool event(QEvent *event); | 
|---|
| 153 | void initStyleOption(QStyleOptionToolBar *option) const; | 
|---|
| 154 |  | 
|---|
| 155 | #ifdef QT3_SUPPORT | 
|---|
| 156 | public: | 
|---|
| 157 | QT3_SUPPORT_CONSTRUCTOR QToolBar(QWidget *parent, const char *name); | 
|---|
| 158 | inline QT3_SUPPORT void setLabel(const QString &label) | 
|---|
| 159 | { setWindowTitle(label); } | 
|---|
| 160 | inline QT3_SUPPORT QString label() const | 
|---|
| 161 | { return windowTitle(); } | 
|---|
| 162 | #endif | 
|---|
| 163 |  | 
|---|
| 164 | private: | 
|---|
| 165 | Q_DECLARE_PRIVATE(QToolBar) | 
|---|
| 166 | Q_DISABLE_COPY(QToolBar) | 
|---|
| 167 | Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool)) | 
|---|
| 168 | Q_PRIVATE_SLOT(d_func(), void _q_updateIconSize(const QSize &)) | 
|---|
| 169 | Q_PRIVATE_SLOT(d_func(), void _q_updateToolButtonStyle(Qt::ToolButtonStyle)) | 
|---|
| 170 | Q_PRIVATE_SLOT(d_func(), void _q_waitForPopup()) | 
|---|
| 171 |  | 
|---|
| 172 | friend class QMainWindow; | 
|---|
| 173 | friend class QMainWindowLayout; | 
|---|
| 174 | friend class QToolBarLayout; | 
|---|
| 175 | friend class QToolBarAreaLayout; | 
|---|
| 176 | }; | 
|---|
| 177 |  | 
|---|
| 178 | inline QAction *QToolBar::actionAt(int ax, int ay) const | 
|---|
| 179 | { return actionAt(QPoint(ax, ay)); } | 
|---|
| 180 |  | 
|---|
| 181 | #endif // QT_NO_TOOLBAR | 
|---|
| 182 |  | 
|---|
| 183 | QT_END_NAMESPACE | 
|---|
| 184 |  | 
|---|
| 185 | QT_END_HEADER | 
|---|
| 186 |  | 
|---|
| 187 | #endif // QDYNAMICTOOLBAR_H | 
|---|