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
qgraphicslayout_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 QGRAPHICSLAYOUT_P_H
6#define QGRAPHICSLAYOUT_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
23#include <QtWidgets/qstyle.h>
24#include <QtWidgets/qwidget.h>
25#include <QtWidgets/qstyleoption.h>
26
28
29QT_BEGIN_NAMESPACE
30
31class QGraphicsLayoutItem;
32class QGraphicsWidget;
33
34#ifdef QT_DEBUG
35inline bool qt_graphicsLayoutDebug()
36{
37 static int checked_env = -1;
38 if (checked_env == -1)
39 checked_env = !!qEnvironmentVariableIntValue("QT_GRAPHICSLAYOUT_DEBUG");
40 return checked_env;
41}
42#endif
43
44
46{
47public:
49 inline QLayoutStyleInfo(QStyle *style, QWidget *widget)
50 : m_valid(true), m_style(style), m_widget(widget)
51 {
52 Q_ASSERT(style);
53 if (widget) //###
54 m_styleOption.initFrom(widget);
55 m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &m_styleOption, widget);
56 m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &m_styleOption, widget);
57 }
58
59 inline void invalidate() { m_valid = false; m_style = nullptr; m_widget = nullptr; }
60
61 inline QStyle *style() const { return m_style; }
62 inline QWidget *widget() const { return m_widget; }
63
64 inline bool operator==(const QLayoutStyleInfo &other) const
65 { return m_style == other.m_style && m_widget == other.m_widget; }
66 inline bool operator!=(const QLayoutStyleInfo &other) const
67 { return !(*this == other); }
68
69 inline void setDefaultSpacing(Qt::Orientation o, qreal spacing){
70 if (spacing >= 0)
71 m_defaultSpacing[int(o) - 1] = spacing;
72 }
73
74 inline qreal defaultSpacing(Qt::Orientation o) const {
75 return m_defaultSpacing[int(o) - 1];
76 }
77
78 inline qreal perItemSpacing(QSizePolicy::ControlType control1,
79 QSizePolicy::ControlType control2,
80 Qt::Orientation orientation) const
81 {
82 Q_ASSERT(style());
83 return style()->layoutSpacing(control1, control2, orientation, &m_styleOption, widget());
84 }
85private:
86 bool m_valid;
87 QStyle *m_style;
88 QWidget *m_widget;
89 QStyleOption m_styleOption;
90 qreal m_defaultSpacing[2];
91};
92
93class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPrivate
94{
95 Q_DECLARE_PUBLIC(QGraphicsLayout)
96
97public:
98 QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(nullptr, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0),
99 activated(true) { }
100
101 void reparentChildItems(QGraphicsItem *newParent);
102 void getMargin(qreal *result, qreal userMargin, QStyle::PixelMetric pm) const;
103 Qt::LayoutDirection visualDirection() const;
104
105 void addChildLayoutItem(QGraphicsLayoutItem *item);
106 void activateRecursive(QGraphicsLayoutItem *item);
107
108 qreal left, top, right, bottom;
109 bool activated;
110};
111
112QT_END_NAMESPACE
113
114#endif
void setSizePolicy(QSizePolicy::Policy policy)
static QGraphicsAnchorPrivate * get(QGraphicsAnchor *q)
QGraphicsAnchorLayoutPrivate * layoutPrivate
void setDefaultSpacing(Qt::Orientation o, qreal spacing)
bool operator==(const QLayoutStyleInfo &other) const
bool operator!=(const QLayoutStyleInfo &other) const
qreal perItemSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation) const
qreal defaultSpacing(Qt::Orientation o) const
QWidget * widget() const
QStyle * style() const
QLayoutStyleInfo(QStyle *style, QWidget *widget)
QSimplexConstraint * constraint(const GraphPath &path) const
QT_REQUIRE_CONFIG(animation)
Q_DECLARE_TYPEINFO(GraphPath, Q_RELOCATABLE_TYPE)
QT_REQUIRE_CONFIG(graphicsview)
void refreshSizeHints(const QLayoutStyleInfo *styleInfo=nullptr)
AnchorVertexPair(AnchorVertex *v1, AnchorVertex *v2, AnchorData *data)
AnchorVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
ParallelAnchorData(AnchorData *first, AnchorData *second)
SequentialAnchorData(const QList< AnchorVertex * > &vertices, const QList< AnchorData * > &edges)