| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** All rights reserved. | 
|---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
|---|
| 6 | ** | 
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit. | 
|---|
| 8 | ** | 
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 10 | ** Commercial Usage | 
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 14 | ** a written agreement between you and Nokia. | 
|---|
| 15 | ** | 
|---|
| 16 | ** GNU Lesser General Public License Usage | 
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 20 | ** packaging of this file.  Please review the following information to | 
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 23 | ** | 
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional | 
|---|
| 25 | ** rights.  These rights are described in the Nokia Qt LGPL Exception | 
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this 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 have questions regarding the use of this file, please contact | 
|---|
| 37 | ** Nokia at qt-info@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #ifndef QGRAPHICSWIDGET_H | 
|---|
| 43 | #define QGRAPHICSWIDGET_H | 
|---|
| 44 |  | 
|---|
| 45 | #include <QtGui/qfont.h> | 
|---|
| 46 | #include <QtGui/qgraphicslayoutitem.h> | 
|---|
| 47 | #include <QtGui/qgraphicsitem.h> | 
|---|
| 48 | #include <QtGui/qpalette.h> | 
|---|
| 49 |  | 
|---|
| 50 | QT_BEGIN_HEADER | 
|---|
| 51 |  | 
|---|
| 52 | QT_BEGIN_NAMESPACE | 
|---|
| 53 |  | 
|---|
| 54 | QT_MODULE(Gui) | 
|---|
| 55 |  | 
|---|
| 56 | class QFont; | 
|---|
| 57 | class QFontMetrics; | 
|---|
| 58 | class QGraphicsLayout; | 
|---|
| 59 | class QGraphicsSceneMoveEvent; | 
|---|
| 60 | class QGraphicsWidgetPrivate; | 
|---|
| 61 | class QGraphicsSceneResizeEvent; | 
|---|
| 62 | class QStyle; | 
|---|
| 63 | class QStyleOption; | 
|---|
| 64 |  | 
|---|
| 65 | #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW | 
|---|
| 66 |  | 
|---|
| 67 | class QGraphicsWidgetPrivate; | 
|---|
| 68 |  | 
|---|
| 69 | class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLayoutItem | 
|---|
| 70 | { | 
|---|
| 71 | Q_OBJECT | 
|---|
| 72 | Q_INTERFACES(QGraphicsItem QGraphicsLayoutItem) | 
|---|
| 73 | Q_PROPERTY(QPalette palette READ palette WRITE setPalette) | 
|---|
| 74 | Q_PROPERTY(QFont font READ font WRITE setFont) | 
|---|
| 75 | Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection) | 
|---|
| 76 | Q_PROPERTY(QSizeF size READ size WRITE resize NOTIFY geometryChanged) | 
|---|
| 77 | Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize) | 
|---|
| 78 | Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize) | 
|---|
| 79 | Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize) | 
|---|
| 80 | Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy) | 
|---|
| 81 | Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy) | 
|---|
| 82 | Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags) | 
|---|
| 83 | Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle) | 
|---|
| 84 | Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry NOTIFY geometryChanged) | 
|---|
| 85 | Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground) | 
|---|
| 86 | Q_PROPERTY(QGraphicsLayout* layout READ layout WRITE setLayout NOTIFY layoutChanged) | 
|---|
| 87 | public: | 
|---|
| 88 | QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | 
|---|
| 89 | ~QGraphicsWidget(); | 
|---|
| 90 | QGraphicsLayout *layout() const; | 
|---|
| 91 | void setLayout(QGraphicsLayout *layout); | 
|---|
| 92 | void adjustSize(); | 
|---|
| 93 |  | 
|---|
| 94 | Qt::LayoutDirection layoutDirection() const; | 
|---|
| 95 | void setLayoutDirection(Qt::LayoutDirection direction); | 
|---|
| 96 | void unsetLayoutDirection(); | 
|---|
| 97 |  | 
|---|
| 98 | QStyle *style() const; | 
|---|
| 99 | void setStyle(QStyle *style); | 
|---|
| 100 |  | 
|---|
| 101 | QFont font() const; | 
|---|
| 102 | void setFont(const QFont &font); | 
|---|
| 103 |  | 
|---|
| 104 | QPalette palette() const; | 
|---|
| 105 | void setPalette(const QPalette &palette); | 
|---|
| 106 |  | 
|---|
| 107 | bool autoFillBackground() const; | 
|---|
| 108 | void setAutoFillBackground(bool enabled); | 
|---|
| 109 |  | 
|---|
| 110 | void resize(const QSizeF &size); | 
|---|
| 111 | inline void resize(qreal w, qreal h) { resize(QSizeF(w, h)); } | 
|---|
| 112 | QSizeF size() const; | 
|---|
| 113 |  | 
|---|
| 114 | void setGeometry(const QRectF &rect); | 
|---|
| 115 | inline void setGeometry(qreal x, qreal y, qreal w, qreal h); | 
|---|
| 116 | inline QRectF rect() const { return QRectF(QPointF(), size()); } | 
|---|
| 117 |  | 
|---|
| 118 | void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom); | 
|---|
| 119 | void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const; | 
|---|
| 120 |  | 
|---|
| 121 | void setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom); | 
|---|
| 122 | void getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const; | 
|---|
| 123 | void unsetWindowFrameMargins(); | 
|---|
| 124 | QRectF windowFrameGeometry() const; | 
|---|
| 125 | QRectF windowFrameRect() const; | 
|---|
| 126 |  | 
|---|
| 127 | // Window handling | 
|---|
| 128 | Qt::WindowFlags windowFlags() const; | 
|---|
| 129 | Qt::WindowType windowType() const; | 
|---|
| 130 | void setWindowFlags(Qt::WindowFlags wFlags); | 
|---|
| 131 | bool isActiveWindow() const; | 
|---|
| 132 | void setWindowTitle(const QString &title); | 
|---|
| 133 | QString windowTitle() const; | 
|---|
| 134 |  | 
|---|
| 135 | // Focus handling | 
|---|
| 136 | Qt::FocusPolicy focusPolicy() const; | 
|---|
| 137 | void setFocusPolicy(Qt::FocusPolicy policy); | 
|---|
| 138 | static void setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second); | 
|---|
| 139 | QGraphicsWidget *focusWidget() const; | 
|---|
| 140 |  | 
|---|
| 141 | #ifndef QT_NO_SHORTCUT | 
|---|
| 142 | int grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context = Qt::WindowShortcut); | 
|---|
| 143 | void releaseShortcut(int id); | 
|---|
| 144 | void setShortcutEnabled(int id, bool enabled = true); | 
|---|
| 145 | void setShortcutAutoRepeat(int id, bool enabled = true); | 
|---|
| 146 | #endif | 
|---|
| 147 |  | 
|---|
| 148 | #ifndef QT_NO_ACTION | 
|---|
| 149 | //actions | 
|---|
| 150 | void addAction(QAction *action); | 
|---|
| 151 | void addActions(QList<QAction*> actions); | 
|---|
| 152 | void insertAction(QAction *before, QAction *action); | 
|---|
| 153 | void insertActions(QAction *before, QList<QAction*> actions); | 
|---|
| 154 | void removeAction(QAction *action); | 
|---|
| 155 | QList<QAction*> actions() const; | 
|---|
| 156 | #endif | 
|---|
| 157 |  | 
|---|
| 158 | void setAttribute(Qt::WidgetAttribute attribute, bool on = true); | 
|---|
| 159 | bool testAttribute(Qt::WidgetAttribute attribute) const; | 
|---|
| 160 |  | 
|---|
| 161 | enum { | 
|---|
| 162 | Type = 11 | 
|---|
| 163 | }; | 
|---|
| 164 | int type() const; | 
|---|
| 165 |  | 
|---|
| 166 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | 
|---|
| 167 | virtual void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | 
|---|
| 168 | QRectF boundingRect() const; | 
|---|
| 169 | QPainterPath shape() const; | 
|---|
| 170 |  | 
|---|
| 171 | #if 0 | 
|---|
| 172 | void dumpFocusChain(); | 
|---|
| 173 | #endif | 
|---|
| 174 |  | 
|---|
| 175 | // ### Qt 5: Disambiguate | 
|---|
| 176 | #ifdef Q_NO_USING_KEYWORD | 
|---|
| 177 | const QObjectList &children() const { return QObject::children(); } | 
|---|
| 178 | #else | 
|---|
| 179 | using QObject::children; | 
|---|
| 180 | #endif | 
|---|
| 181 |  | 
|---|
| 182 | Q_SIGNALS: | 
|---|
| 183 | void geometryChanged(); | 
|---|
| 184 | void layoutChanged(); | 
|---|
| 185 |  | 
|---|
| 186 | public Q_SLOTS: | 
|---|
| 187 | bool close(); | 
|---|
| 188 |  | 
|---|
| 189 | protected: | 
|---|
| 190 | virtual void initStyleOption(QStyleOption *option) const; | 
|---|
| 191 |  | 
|---|
| 192 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; | 
|---|
| 193 | void updateGeometry(); | 
|---|
| 194 |  | 
|---|
| 195 | // Notification | 
|---|
| 196 | QVariant itemChange(GraphicsItemChange change, const QVariant &value); | 
|---|
| 197 | virtual QVariant propertyChange(const QString &propertyName, const QVariant &value); | 
|---|
| 198 |  | 
|---|
| 199 | // Scene events | 
|---|
| 200 | bool sceneEvent(QEvent *event); | 
|---|
| 201 | virtual bool windowFrameEvent(QEvent *e); | 
|---|
| 202 | virtual Qt::WindowFrameSection windowFrameSectionAt(const QPointF& pos) const; | 
|---|
| 203 |  | 
|---|
| 204 | // Base event handlers | 
|---|
| 205 | bool event(QEvent *event); | 
|---|
| 206 | //virtual void actionEvent(QActionEvent *event); | 
|---|
| 207 | virtual void changeEvent(QEvent *event); | 
|---|
| 208 | virtual void closeEvent(QCloseEvent *event); | 
|---|
| 209 | //void create(WId window = 0, bool initializeWindow = true, bool destroyOldWindow = true); | 
|---|
| 210 | //void destroy(bool destroyWindow = true, bool destroySubWindows = true); | 
|---|
| 211 | void focusInEvent(QFocusEvent *event); | 
|---|
| 212 | virtual bool focusNextPrevChild(bool next); | 
|---|
| 213 | void focusOutEvent(QFocusEvent *event); | 
|---|
| 214 | virtual void hideEvent(QHideEvent *event); | 
|---|
| 215 | //virtual bool macEvent(EventHandlerCallRef caller, EventRef event); | 
|---|
| 216 | //virtual int metric(PaintDeviceMetric m ) const; | 
|---|
| 217 | virtual void moveEvent(QGraphicsSceneMoveEvent *event); | 
|---|
| 218 | virtual void polishEvent(); | 
|---|
| 219 | //virtual bool qwsEvent(QWSEvent *event); | 
|---|
| 220 | //void resetInputContext (); | 
|---|
| 221 | virtual void resizeEvent(QGraphicsSceneResizeEvent *event); | 
|---|
| 222 | virtual void showEvent(QShowEvent *event); | 
|---|
| 223 | //virtual void tabletEvent(QTabletEvent *event); | 
|---|
| 224 | //virtual bool winEvent(MSG *message, long *result); | 
|---|
| 225 | //virtual bool x11Event(XEvent *event); | 
|---|
| 226 | virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event); | 
|---|
| 227 | virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); | 
|---|
| 228 | virtual void grabMouseEvent(QEvent *event); | 
|---|
| 229 | virtual void ungrabMouseEvent(QEvent *event); | 
|---|
| 230 | virtual void grabKeyboardEvent(QEvent *event); | 
|---|
| 231 | virtual void ungrabKeyboardEvent(QEvent *event); | 
|---|
| 232 | QGraphicsWidget(QGraphicsWidgetPrivate &, QGraphicsItem *parent, QGraphicsScene *, Qt::WindowFlags wFlags = 0); | 
|---|
| 233 |  | 
|---|
| 234 | private: | 
|---|
| 235 | Q_DISABLE_COPY(QGraphicsWidget) | 
|---|
| 236 | Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsWidget) | 
|---|
| 237 | friend class QGraphicsScene; | 
|---|
| 238 | friend class QGraphicsScenePrivate; | 
|---|
| 239 | friend class QGraphicsView; | 
|---|
| 240 | friend class QGraphicsItem; | 
|---|
| 241 | friend class QGraphicsItemPrivate; | 
|---|
| 242 | friend class QGraphicsLayout; | 
|---|
| 243 | friend class QWidget; | 
|---|
| 244 | friend class QApplication; | 
|---|
| 245 | }; | 
|---|
| 246 |  | 
|---|
| 247 | inline void QGraphicsWidget::setGeometry(qreal ax, qreal ay, qreal aw, qreal ah) | 
|---|
| 248 | { setGeometry(QRectF(ax, ay, aw, ah)); } | 
|---|
| 249 |  | 
|---|
| 250 | #endif | 
|---|
| 251 |  | 
|---|
| 252 | QT_END_NAMESPACE | 
|---|
| 253 |  | 
|---|
| 254 | QT_END_HEADER | 
|---|
| 255 |  | 
|---|
| 256 | #endif | 
|---|
| 257 |  | 
|---|