Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QLAYOUTENGINE_P_H
5#define QLAYOUTENGINE_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 purely as an
12// implementation detail. 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 "QtWidgets/qlayoutitem.h"
20#include "QtWidgets/qstyle.h"
21#include <QtCore/qcontainerfwd.h>
22
24
26{
27 inline void init(int stretchFactor = 0, int minSize = 0) {
28 stretch = stretchFactor;
29 minimumSize = sizeHint = minSize;
31 expansive = false;
32 empty = true;
33 spacing = 0;
34 }
35
37 return (stretch > 0) ? minimumSize : sizeHint;
38 }
39 int effectiveSpacer(int uniformSpacer) const {
40 Q_ASSERT(uniformSpacer >= 0 || spacing >= 0);
41 return (uniformSpacer >= 0) ? uniformSpacer : spacing;
42 }
43
44 // parameters
51 bool empty;
52
53 // temporary storage
54 bool done;
55
56 // result
57 int pos;
58 int size;
59};
60
61Q_WIDGETS_EXPORT void qGeomCalc(QList<QLayoutStruct> &chain, int start, int count, int pos,
62 int space, int spacer = -1);
63Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint,
64 const QSize &minSize, const QSize &maxSize,
65 const QSizePolicy &sizePolicy);
66Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidgetItem *i);
67Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidget *w);
68Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint,
69 const QSize &minSize, const QSize &maxSize,
70 const QSizePolicy &sizePolicy, Qt::Alignment align = { });
71Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = { });
72Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = { });
73
74Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm);
75
76/*
77 Modify total maximum (max), total expansion (exp), and total empty
78 when adding boxmax/boxexp.
79
80 Expansive boxes win over non-expansive boxes.
81 Non-empty boxes win over empty boxes.
82*/
83static inline void qMaxExpCalc(int & max, bool &exp, bool &empty,
84 int boxmax, bool boxexp, bool boxempty)
85{
86 if (exp) {
87 if (boxexp)
88 max = qMax(max, boxmax);
89 } else {
90 if (boxexp || (empty && (!boxempty || max == 0)))
91 max = boxmax;
92 else if (empty == boxempty)
93 max = qMin(max, boxmax);
94 }
95 exp = exp || boxexp;
96 empty = empty && boxempty;
97}
98
100
101#endif // QLAYOUTENGINE_P_H
The QLayout class is the base class of geometry managers.
Definition qlayout.h:26
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
\inmodule QtCore
Definition qsize.h:25
PixelMetric
This enum describes the various available pixel metrics.
Definition qstyle.h:413
The QWidgetItem class is a layout item that represents a widget.
Definition qlayoutitem.h:86
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
Combined button and popup list for selecting options.
Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
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_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy, Qt::Alignment align={ })
Q_WIDGETS_EXPORT void qGeomCalc(QList< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer=-1)
QT_BEGIN_NAMESPACE constexpr int QLAYOUTSIZE_MAX
Definition qlayoutitem.h:16
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLfloat GLfloat GLfloat w
[0]
GLenum GLenum GLsizei count
GLuint start
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QVBoxLayout * layout
void init(int stretchFactor=0, int minSize=0)
int effectiveSpacer(int uniformSpacer) const