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
qlayoutengine_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 QLAYOUTENGINE_P_H
6#define QLAYOUTENGINE_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 purely as an
13// implementation detail. 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 "QtWidgets/qlayoutitem.h"
21#include "QtWidgets/qstyle.h"
22#include <QtCore/qcontainerfwd.h>
23
25
27{
28 inline void init(int stretchFactor = 0, int minSize = 0) {
29 stretch = stretchFactor;
30 minimumSize = sizeHint = minSize;
31 maximumSize = QLAYOUTSIZE_MAX;
32 expansive = false;
33 empty = true;
34 spacing = 0;
35 }
36
38 return (stretch > 0) ? minimumSize : sizeHint;
39 }
40 int effectiveSpacer(int uniformSpacer) const {
41 Q_ASSERT(uniformSpacer >= 0 || spacing >= 0);
42 return (uniformSpacer >= 0) ? uniformSpacer : spacing;
43 }
44
45 // parameters
52 bool empty;
53
54 // temporary storage
55 bool done;
56
57 // result
58 int pos;
59 int size;
60};
61
62Q_WIDGETS_EXPORT void qGeomCalc(QList<QLayoutStruct> &chain, int start, int count, int pos,
63 int space, int spacer = -1);
64Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint,
65 const QSize &minSize, const QSize &maxSize,
66 const QSizePolicy &sizePolicy);
67Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidgetItem *i);
68Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidget *w);
69Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint,
70 const QSize &minSize, const QSize &maxSize,
71 const QSizePolicy &sizePolicy, Qt::Alignment align = { });
72Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = { });
73Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = { });
74
75Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm);
76
77/*
78 Modify total maximum (max), total expansion (exp), and total empty
79 when adding boxmax/boxexp.
80
81 Expansive boxes win over non-expansive boxes.
82 Non-empty boxes win over empty boxes.
83*/
84static inline void qMaxExpCalc(int & max, bool &exp, bool &empty,
85 int boxmax, bool boxexp, bool boxempty)
86{
87 if (exp) {
88 if (boxexp)
89 max = qMax(max, boxmax);
90 } else {
91 if (boxexp || (empty && (!boxempty || max == 0)))
92 max = boxmax;
93 else if (empty == boxempty)
94 max = qMin(max, boxmax);
95 }
96 exp = exp || boxexp;
97 empty = empty && boxempty;
98}
99
100QT_END_NAMESPACE
101
102#endif // QLAYOUTENGINE_P_H
QList< QBoxLayoutItem * > list
QLayoutItem * replaceAt(int index, QLayoutItem *) override
void effectiveMargins(int *left, int *top, int *right, int *bottom) const
int validateIndex(int index) const
QList< QLayoutStruct > geomArray
Qt::Orientations expanding
\inmodule QtCore\reentrant
Definition qdatastream.h:50
Definition qlist.h:80
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:19
\inmodule QtCore
Definition qsize.h:26
static bool horz(QBoxLayout::Direction dir)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568
Q_WIDGETS_EXPORT void qGeomCalc(QList< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer=-1)
Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)
static void qMaxExpCalc(int &max, bool &exp, bool &empty, int boxmax, bool boxexp, bool boxempty)
Q_DECLARE_TYPEINFO(QSizePolicy, Q_PRIMITIVE_TYPE)
int mhfw(int w)
QBoxLayoutItem(QLayoutItem *it, int stretch_=0)
int hfw(int w)
QLayoutItem * item
void init(int stretchFactor=0, int minSize=0)
int effectiveSpacer(int uniformSpacer) const