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
4#ifndef QGRAPHICSWIDGET_P_H
5#define QGRAPHICSWIDGET_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include <private/qobject_p.h>
22#include <QtGui/qfont.h>
23#include <QtGui/qpalette.h>
24#include <QtWidgets/qsizepolicy.h>
25#include <QtWidgets/qstyle.h>
26
27#include <memory>
28
30
31QT_BEGIN_NAMESPACE
32
33class QGraphicsLayout;
34class QStyleOptionTitleBar;
35
37{
38 Q_DECLARE_PUBLIC(QGraphicsWidget)
39public:
41 virtual ~QGraphicsWidgetPrivate();
42
43 void init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags);
44 qreal titleBarHeight(const QStyleOptionTitleBar &options) const;
45
46 // Margins
48 void ensureMargins() const;
49
50 void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = nullptr);
51 void setLayout_helper(QGraphicsLayout *l);
52
53 // Layouts
54 QGraphicsLayout *layout;
55 void setLayoutDirection_helper(Qt::LayoutDirection direction);
57
58 // Style
61 void setPalette_helper(const QPalette &palette);
62 void resolvePalette(uint inheritedMask) override;
63 void updatePalette(const QPalette &palette);
65 QFont font;
67 void setFont_helper(const QFont &font);
68 void resolveFont(uint inheritedMask) override;
69 void updateFont(const QFont &font);
70 QFont naturalWidgetFont() const;
71
72 // Window specific
73 void initStyleOptionTitleBar(QStyleOptionTitleBar *option);
74 void adjustWindowFlags(Qt::WindowFlags *wFlags);
75 void windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
76 void windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event);
77 void windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event);
78 void windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event);
79 void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event);
80 bool hasDecoration() const;
81
82 // Private Properties
83 qreal width() const override;
84 void setWidth(qreal) override;
85 void resetWidth() override;
86
87 qreal height() const override;
88 void setHeight(qreal) override;
89 void resetHeight() override;
91
92 // State
93 inline int attributeToBitIndex(Qt::WidgetAttribute att) const
94 {
95 int bit = -1;
96 switch (att) {
97 case Qt::WA_SetLayoutDirection: bit = 0; break;
98 case Qt::WA_RightToLeft: bit = 1; break;
99 case Qt::WA_SetStyle: bit = 2; break;
100 case Qt::WA_Resized: bit = 3; break;
101 case Qt::WA_DeleteOnClose: bit = 4; break;
102 case Qt::WA_NoSystemBackground: bit = 5; break;
103 case Qt::WA_OpaquePaintEvent: bit = 6; break;
104 case Qt::WA_SetPalette: bit = 7; break;
105 case Qt::WA_SetFont: bit = 8; break;
106 case Qt::WA_WindowPropagation: bit = 9; break;
107 default: break;
108 }
109 return bit;
110 }
111 inline void setAttribute(Qt::WidgetAttribute att, bool value)
112 {
113 int bit = attributeToBitIndex(att);
114 if (bit == -1) {
115 qWarning("QGraphicsWidget::setAttribute: unsupported attribute %d", int(att));
116 return;
117 }
118 if (value)
119 attributes |= (1 << bit);
120 else
121 attributes &= ~(1 << bit);
122 }
123 inline bool testAttribute(Qt::WidgetAttribute att) const
124 {
125 int bit = attributeToBitIndex(att);
126 if (bit == -1)
127 return false;
128 return (attributes & (1 << bit)) != 0;
129 }
135
136 // Focus
138 QGraphicsWidget *focusNext;
139 QGraphicsWidget *focusPrev;
140
141 // Windows
159 void ensureWindowData();
160
163 void ensureWindowFrameMargins() const;
164
165#ifndef QT_NO_ACTION
167#endif
168};
169
170QT_END_NAMESPACE
171
172#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)