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

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

trunk: Merged in qt 4.6.2 sources.

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 // State
134 inline int attributeToBitIndex(Qt::WidgetAttribute att) const
135 {
136 int bit = -1;
137 switch (att) {
138 case Qt::WA_SetLayoutDirection: bit = 0; break;
139 case Qt::WA_RightToLeft: bit = 1; break;
140 case Qt::WA_SetStyle: bit = 2; break;
141 case Qt::WA_Resized: bit = 3; break;
142 case Qt::WA_DeleteOnClose: bit = 4; break;
143 case Qt::WA_NoSystemBackground: bit = 5; break;
144 case Qt::WA_OpaquePaintEvent: bit = 6; break;
145 case Qt::WA_SetPalette: bit = 7; break;
146 case Qt::WA_SetFont: bit = 8; break;
147 case Qt::WA_WindowPropagation: bit = 9; break;
148 default: break;
149 }
150 return bit;
151 }
152 inline void setAttribute(Qt::WidgetAttribute att, bool value)
153 {
154 int bit = attributeToBitIndex(att);
155 if (bit == -1) {
156 qWarning("QGraphicsWidget::setAttribute: unsupported attribute %d", int(att));
157 return;
158 }
159 if (value)
160 attributes |= (1 << bit);
161 else
162 attributes &= ~(1 << bit);
163 }
164 inline bool testAttribute(Qt::WidgetAttribute att) const
165 {
166 int bit = attributeToBitIndex(att);
167 if (bit == -1)
168 return false;
169 return (attributes & (1 << bit)) != 0;
170 }
171 quint32 attributes : 10;
172 quint32 inSetGeometry : 1;
173 quint32 polished: 1;
174 quint32 inSetPos : 1;
175
176 // Focus
177 Qt::FocusPolicy focusPolicy;
178 QGraphicsWidget *focusNext;
179 QGraphicsWidget *focusPrev;
180
181 // Windows
182 Qt::WindowFlags windowFlags;
183 struct WindowData {
184 QString windowTitle;
185 QStyle::SubControl hoveredSubControl;
186 Qt::WindowFrameSection grabbedSection;
187 uint buttonMouseOver : 1;
188 uint buttonSunken : 1;
189 QRectF startGeometry;
190 QRect buttonRect;
191 WindowData()
192 : hoveredSubControl(QStyle::SC_None)
193 , grabbedSection(Qt::NoSection)
194 , buttonMouseOver(false)
195 , buttonSunken(false)
196 {}
197 } *windowData;
198 void ensureWindowData();
199
200 bool setWindowFrameMargins;
201 mutable qreal *windowFrameMargins;
202 void ensureWindowFrameMargins() const;
203
204#ifndef QT_NO_ACTION
205 QList<QAction *> actions;
206#endif
207};
208
209#endif //!defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
210
211QT_END_NAMESPACE
212
213#endif //QGRAPHICSWIDGET_P_H
214
Note: See TracBrowser for help on using the repository browser.