source: trunk/src/gui/graphicsview/qgraphicswidget_p.h@ 787

Last change on this file since 787 was 769, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

File size: 7.0 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_P_H
43#define QGRAPHICSWIDGET_P_H
44
45//
46// W A R N I N G
47// -------------
48//
49// This file is not part of the Qt API. It exists for the convenience
50// of other Qt classes. This header file may change from version to
51// version without notice, or even be removed.
52//
53// We mean it.
54//
55
56#include <private/qobject_p.h>
57#include "qgraphicsitem_p.h"
58#include "qgraphicswidget.h"
59#include <QtGui/qfont.h>
60#include <QtGui/qpalette.h>
61#include <QtGui/qsizepolicy.h>
62#include <QtGui/qstyle.h>
63
64QT_BEGIN_NAMESPACE
65
66class QGraphicsLayout;
67class QStyleOptionTitleBar;
68
69#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
70
71class QGraphicsWidgetPrivate : public QGraphicsItemPrivate
72{
73 Q_DECLARE_PUBLIC(QGraphicsWidget)
74public:
75 QGraphicsWidgetPrivate()
76 : margins(0),
77 layout(0),
78 inheritedPaletteResolveMask(0),
79 inheritedFontResolveMask(0),
80 inSetGeometry(0),
81 polished(0),
82 inSetPos(0),
83 focusPolicy(Qt::NoFocus),
84 focusNext(0),
85 focusPrev(0),
86 windowFlags(0),
87 windowData(0),
88 setWindowFrameMargins(false),
89 windowFrameMargins(0)
90 { }
91 virtual ~QGraphicsWidgetPrivate();
92
93 void init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags);
94 qreal titleBarHeight(const QStyleOptionTitleBar &options) const;
95
96 // Margins
97 enum {Left, Top, Right, Bottom};
98 mutable qreal *margins;
99 void ensureMargins() const;
100
101 void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = 0);
102 void setLayout_helper(QGraphicsLayout *l);
103
104 // Layouts
105 QGraphicsLayout *layout;
106 void setLayoutDirection_helper(Qt::LayoutDirection direction);
107 void resolveLayoutDirection();
108
109 // Style
110 QPalette palette;
111 uint inheritedPaletteResolveMask;
112 void setPalette_helper(const QPalette &palette);
113 void resolvePalette(uint inheritedMask);
114 void updatePalette(const QPalette &palette);
115 QPalette naturalWidgetPalette() const;
116 QFont font;
117 uint inheritedFontResolveMask;
118 void setFont_helper(const QFont &font);
119 void resolveFont(uint inheritedMask);
120 void updateFont(const QFont &font);
121 QFont naturalWidgetFont() const;
122
123 // Window specific
124 void initStyleOptionTitleBar(QStyleOptionTitleBar *option);
125 void adjustWindowFlags(Qt::WindowFlags *wFlags);
126 void windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
127 void windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event);
128 void windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event);
129 void windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event);
130 void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event);
131 bool hasDecoration() const;
132
133 void setGeometryFromSetPos();
134
135 // State
136 inline int attributeToBitIndex(Qt::WidgetAttribute att) const
137 {
138 int bit = -1;
139 switch (att) {
140 case Qt::WA_SetLayoutDirection: bit = 0; break;
141 case Qt::WA_RightToLeft: bit = 1; break;
142 case Qt::WA_SetStyle: bit = 2; break;
143 case Qt::WA_Resized: bit = 3; break;
144 case Qt::WA_DeleteOnClose: bit = 4; break;
145 case Qt::WA_NoSystemBackground: bit = 5; break;
146 case Qt::WA_OpaquePaintEvent: bit = 6; break;
147 case Qt::WA_SetPalette: bit = 7; break;
148 case Qt::WA_SetFont: bit = 8; break;
149 case Qt::WA_WindowPropagation: bit = 9; break;
150 default: break;
151 }
152 return bit;
153 }
154 inline void setAttribute(Qt::WidgetAttribute att, bool value)
155 {
156 int bit = attributeToBitIndex(att);
157 if (bit == -1) {
158 qWarning("QGraphicsWidget::setAttribute: unsupported attribute %d", int(att));
159 return;
160 }
161 if (value)
162 attributes |= (1 << bit);
163 else
164 attributes &= ~(1 << bit);
165 }
166 inline bool testAttribute(Qt::WidgetAttribute att) const
167 {
168 int bit = attributeToBitIndex(att);
169 if (bit == -1)
170 return false;
171 return (attributes & (1 << bit)) != 0;
172 }
173 quint32 attributes : 10;
174 quint32 inSetGeometry : 1;
175 quint32 polished: 1;
176 quint32 inSetPos : 1;
177
178 // Focus
179 Qt::FocusPolicy focusPolicy;
180 QGraphicsWidget *focusNext;
181 QGraphicsWidget *focusPrev;
182
183 // Windows
184 Qt::WindowFlags windowFlags;
185 struct WindowData {
186 QString windowTitle;
187 QStyle::SubControl hoveredSubControl;
188 Qt::WindowFrameSection grabbedSection;
189 uint buttonMouseOver : 1;
190 uint buttonSunken : 1;
191 QRectF startGeometry;
192 QRect buttonRect;
193 WindowData()
194 : hoveredSubControl(QStyle::SC_None)
195 , grabbedSection(Qt::NoSection)
196 , buttonMouseOver(false)
197 , buttonSunken(false)
198 {}
199 } *windowData;
200 void ensureWindowData();
201
202 bool setWindowFrameMargins;
203 mutable qreal *windowFrameMargins;
204 void ensureWindowFrameMargins() const;
205
206#ifndef QT_NO_ACTION
207 QList<QAction *> actions;
208#endif
209};
210
211#endif //!defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
212
213QT_END_NAMESPACE
214
215#endif //QGRAPHICSWIDGET_P_H
216
Note: See TracBrowser for help on using the repository browser.