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