Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgraphicswidget_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QGRAPHICSWIDGET_P_H
6#define QGRAPHICSWIDGET_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of other Qt classes. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include <private/qobject_p.h>
23#include <QtGui/qfont.h>
24#include <QtGui/qpalette.h>
25#include <QtWidgets/qsizepolicy.h>
26#include <QtWidgets/qstyle.h>
27
28#include <memory>
29
31
32QT_BEGIN_NAMESPACE
33
34class QGraphicsLayout;
35class QStyleOptionTitleBar;
36
38{
39 Q_DECLARE_PUBLIC(QGraphicsWidget)
40public:
42 virtual ~QGraphicsWidgetPrivate();
43
44 void init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags);
45 qreal titleBarHeight(const QStyleOptionTitleBar &options) const;
46
47 // Margins
49 void ensureMargins() const;
50
51 void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = nullptr);
52 void setLayout_helper(QGraphicsLayout *l);
53
54 // Layouts
55 QGraphicsLayout *layout;
56 void setLayoutDirection_helper(Qt::LayoutDirection direction);
58
59 // Style
62 void setPalette_helper(const QPalette &palette);
63 void resolvePalette(uint inheritedMask) override;
64 void updatePalette(const QPalette &palette);
66 QFont font;
68 void setFont_helper(const QFont &font);
69 void resolveFont(uint inheritedMask) override;
70 void updateFont(const QFont &font);
71 QFont naturalWidgetFont() const;
72
73 // Window specific
74 void initStyleOptionTitleBar(QStyleOptionTitleBar *option);
75 void adjustWindowFlags(Qt::WindowFlags *wFlags);
76 void windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
77 void windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event);
78 void windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event);
79 void windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event);
80 void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event);
81 bool hasDecoration() const;
82
83 // Private Properties
84 qreal width() const override;
85 void setWidth(qreal) override;
86 void resetWidth() override;
87
88 qreal height() const override;
89 void setHeight(qreal) override;
90 void resetHeight() override;
92
93 // State
94 inline int attributeToBitIndex(Qt::WidgetAttribute att) const
95 {
96 int bit = -1;
97 switch (att) {
98 case Qt::WA_SetLayoutDirection: bit = 0; break;
99 case Qt::WA_RightToLeft: bit = 1; break;
100 case Qt::WA_SetStyle: bit = 2; break;
101 case Qt::WA_Resized: bit = 3; break;
102 case Qt::WA_DeleteOnClose: bit = 4; break;
103 case Qt::WA_NoSystemBackground: bit = 5; break;
104 case Qt::WA_OpaquePaintEvent: bit = 6; break;
105 case Qt::WA_SetPalette: bit = 7; break;
106 case Qt::WA_SetFont: bit = 8; break;
107 case Qt::WA_WindowPropagation: bit = 9; break;
108 default: break;
109 }
110 return bit;
111 }
112 inline void setAttribute(Qt::WidgetAttribute att, bool value)
113 {
114 int bit = attributeToBitIndex(att);
115 if (bit == -1) {
116 qWarning("QGraphicsWidget::setAttribute: unsupported attribute %d", int(att));
117 return;
118 }
119 if (value)
120 attributes |= (1 << bit);
121 else
122 attributes &= ~(1 << bit);
123 }
124 inline bool testAttribute(Qt::WidgetAttribute att) const
125 {
126 int bit = attributeToBitIndex(att);
127 if (bit == -1)
128 return false;
129 return (attributes & (1 << bit)) != 0;
130 }
136
137 // Focus
139 QGraphicsWidget *focusNext;
140 QGraphicsWidget *focusPrev;
141
142 // Windows
160 void ensureWindowData();
161
164 void ensureWindowFrameMargins() const;
165
166#ifndef QT_NO_ACTION
168#endif
169};
170
171QT_END_NAMESPACE
172
173#endif //QGRAPHICSWIDGET_P_H
void setAttribute(Qt::WidgetAttribute att, bool value)
void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void setFont_helper(const QFont &font)
QGraphicsWidget * focusPrev
void windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event)
std::unique_ptr< QMarginsF > margins
void setWidth(qreal) override
void ensureWindowFrameMargins() const
QGraphicsLayout * layout
void updatePalette(const QPalette &palette)
QList< QAction * > actions
void setLayoutDirection_helper(Qt::LayoutDirection direction)
qreal height() const override
std::unique_ptr< WindowData > windowData
void windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event)
bool testAttribute(Qt::WidgetAttribute att) const
qreal titleBarHeight(const QStyleOptionTitleBar &options) const
void updateFont(const QFont &font)
void resolveFont(uint inheritedMask) override
void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene=nullptr)
void setHeight(qreal) override
void init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags)
void initStyleOptionTitleBar(QStyleOptionTitleBar *option)
QPalette naturalWidgetPalette() const
void setPalette_helper(const QPalette &palette)
qreal width() const override
void windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event)
void resolvePalette(uint inheritedMask) override
std::unique_ptr< QMarginsF > windowFrameMargins
void setLayout_helper(QGraphicsLayout *l)
void adjustWindowFlags(Qt::WindowFlags *wFlags)
QGraphicsWidget * focusNext
int attributeToBitIndex(Qt::WidgetAttribute att) const
void windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
static bool g_instantInvalidatePropagation
QT_REQUIRE_CONFIG(graphicsview)