source: trunk/src/gui/graphicsview/qgraphicswidget.h@ 765

Last change on this file since 765 was 651, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 9.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
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 [email protected].
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
50QT_BEGIN_HEADER
51
52QT_BEGIN_NAMESPACE
53
54QT_MODULE(Gui)
55
56class QFont;
57class QFontMetrics;
58class QGraphicsLayout;
59class QGraphicsSceneMoveEvent;
60class QGraphicsWidgetPrivate;
61class QGraphicsSceneResizeEvent;
62class QStyle;
63class QStyleOption;
64
65#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
66
67class QGraphicsWidgetPrivate;
68
69class 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)
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)
85public:
86 QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
87 ~QGraphicsWidget();
88
89 QGraphicsLayout *layout() const;
90 void setLayout(QGraphicsLayout *layout);
91 void adjustSize();
92
93 Qt::LayoutDirection layoutDirection() const;
94 void setLayoutDirection(Qt::LayoutDirection direction);
95 void unsetLayoutDirection();
96
97 QStyle *style() const;
98 void setStyle(QStyle *style);
99
100 QFont font() const;
101 void setFont(const QFont &font);
102
103 QPalette palette() const;
104 void setPalette(const QPalette &palette);
105
106 void resize(const QSizeF &size);
107 inline void resize(qreal w, qreal h) { resize(QSizeF(w, h)); }
108 QSizeF size() const;
109
110 void setGeometry(const QRectF &rect);
111 inline void setGeometry(qreal x, qreal y, qreal w, qreal h);
112 inline QRectF rect() const { return QRectF(QPointF(), size()); }
113
114 void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom);
115 void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
116
117 void setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom);
118 void getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
119 void unsetWindowFrameMargins();
120 QRectF windowFrameGeometry() const;
121 QRectF windowFrameRect() const;
122
123 // Window handling
124 Qt::WindowFlags windowFlags() const;
125 Qt::WindowType windowType() const;
126 void setWindowFlags(Qt::WindowFlags wFlags);
127 bool isActiveWindow() const;
128 void setWindowTitle(const QString &title);
129 QString windowTitle() const;
130
131 // Focus handling
132 Qt::FocusPolicy focusPolicy() const;
133 void setFocusPolicy(Qt::FocusPolicy policy);
134 static void setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second);
135 QGraphicsWidget *focusWidget() const;
136
137#ifndef QT_NO_SHORTCUT
138 int grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context = Qt::WindowShortcut);
139 void releaseShortcut(int id);
140 void setShortcutEnabled(int id, bool enabled = true);
141 void setShortcutAutoRepeat(int id, bool enabled = true);
142#endif
143
144#ifndef QT_NO_ACTION
145 //actions
146 void addAction(QAction *action);
147 void addActions(QList<QAction*> actions);
148 void insertAction(QAction *before, QAction *action);
149 void insertActions(QAction *before, QList<QAction*> actions);
150 void removeAction(QAction *action);
151 QList<QAction*> actions() const;
152#endif