1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QGRAPHICSLAYOUTITEM_H |
41 | #define QGRAPHICSLAYOUTITEM_H |
42 | |
43 | #include <QtWidgets/qtwidgetsglobal.h> |
44 | #include <QtCore/qscopedpointer.h> |
45 | #include <QtWidgets/qsizepolicy.h> |
46 | #include <QtGui/qevent.h> |
47 | |
48 | QT_REQUIRE_CONFIG(graphicsview); |
49 | |
50 | QT_BEGIN_NAMESPACE |
51 | |
52 | class QGraphicsLayoutItemPrivate; |
53 | class QGraphicsItem; |
54 | class Q_WIDGETS_EXPORT QGraphicsLayoutItem |
55 | { |
56 | public: |
57 | QGraphicsLayoutItem(QGraphicsLayoutItem *parent = nullptr, bool isLayout = false); |
58 | virtual ~QGraphicsLayoutItem(); |
59 | |
60 | void setSizePolicy(const QSizePolicy &policy); |
61 | void setSizePolicy(QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType = QSizePolicy::DefaultType); |
62 | QSizePolicy sizePolicy() const; |
63 | |
64 | void setMinimumSize(const QSizeF &size); |
65 | inline void setMinimumSize(qreal w, qreal h); |
66 | QSizeF minimumSize() const; |
67 | void setMinimumWidth(qreal width); |
68 | inline qreal minimumWidth() const; |
69 | void setMinimumHeight(qreal height); |
70 | inline qreal minimumHeight() const; |
71 | |
72 | void setPreferredSize(const QSizeF &size); |
73 | inline void setPreferredSize(qreal w, qreal h); |
74 | QSizeF preferredSize() const; |
75 | void setPreferredWidth(qreal width); |
76 | inline qreal preferredWidth() const; |
77 | void setPreferredHeight(qreal height); |
78 | inline qreal preferredHeight() const; |
79 | |
80 | void setMaximumSize(const QSizeF &size); |
81 | inline void setMaximumSize(qreal w, qreal h); |
82 | QSizeF maximumSize() const; |
83 | void setMaximumWidth(qreal width); |
84 | inline qreal maximumWidth() const; |
85 | void setMaximumHeight(qreal height); |
86 | inline qreal maximumHeight() const; |
87 | |
88 | virtual void setGeometry(const QRectF &rect); |
89 | QRectF geometry() const; |
90 | virtual void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const; |
91 | QRectF contentsRect() const; |
92 | |
93 | QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; |
94 | |
95 | virtual void updateGeometry(); |
96 | |
97 | virtual bool isEmpty() const; |
98 | QGraphicsLayoutItem *parentLayoutItem() const; |
99 | void setParentLayoutItem(QGraphicsLayoutItem *parent); |
100 | |
101 | bool isLayout() const; |
102 | QGraphicsItem *graphicsItem() const; |
103 | bool ownedByLayout() const; |
104 | |
105 | protected: |
106 | void setGraphicsItem(QGraphicsItem *item); |
107 | void setOwnedByLayout(bool ownedByLayout); |
108 | QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd); |
109 | |
110 | virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0; |
111 | QScopedPointer<QGraphicsLayoutItemPrivate> d_ptr; |
112 | |
113 | private: |
114 | QSizeF *effectiveSizeHints(const QSizeF &constraint) const; |
115 | Q_DECLARE_PRIVATE(QGraphicsLayoutItem) |
116 | |
117 | friend class QGraphicsLayout; |
118 | }; |
119 | |
120 | #ifndef Q_CLANG_QDOC |
121 | Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "org.qt-project.Qt.QGraphicsLayoutItem" ) |
122 | #endif |
123 | |
124 | inline void QGraphicsLayoutItem::setMinimumSize(qreal aw, qreal ah) |
125 | { setMinimumSize(QSizeF(aw, ah)); } |
126 | inline void QGraphicsLayoutItem::setPreferredSize(qreal aw, qreal ah) |
127 | { setPreferredSize(QSizeF(aw, ah)); } |
128 | inline void QGraphicsLayoutItem::setMaximumSize(qreal aw, qreal ah) |
129 | { setMaximumSize(QSizeF(aw, ah)); } |
130 | |
131 | inline qreal QGraphicsLayoutItem::minimumWidth() const |
132 | { return effectiveSizeHint(Qt::MinimumSize).width(); } |
133 | inline qreal QGraphicsLayoutItem::minimumHeight() const |
134 | { return effectiveSizeHint(Qt::MinimumSize).height(); } |
135 | |
136 | inline qreal QGraphicsLayoutItem::preferredWidth() const |
137 | { return effectiveSizeHint(Qt::PreferredSize).width(); } |
138 | inline qreal QGraphicsLayoutItem::preferredHeight() const |
139 | { return effectiveSizeHint(Qt::PreferredSize).height(); } |
140 | |
141 | inline qreal QGraphicsLayoutItem::maximumWidth() const |
142 | { return effectiveSizeHint(Qt::MaximumSize).width(); } |
143 | inline qreal QGraphicsLayoutItem::maximumHeight() const |
144 | { return effectiveSizeHint(Qt::MaximumSize).height(); } |
145 | |
146 | QT_END_NAMESPACE |
147 | |
148 | #endif |
149 | |