1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/legal |
5 | ** |
6 | ** This file is part of the QtGui 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 Digia. For licensing terms and |
14 | ** conditions see http://qt.digia.com/licensing. For further information |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
24 | ** |
25 | ** In addition, as a special exception, Digia gives you certain additional |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
28 | ** |
29 | ** GNU General Public License Usage |
30 | ** Alternatively, this file may be used under the terms of the GNU |
31 | ** General Public License version 3.0 as published by the Free Software |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the |
33 | ** packaging of this file. Please review the following information to |
34 | ** ensure the GNU General Public License version 3.0 requirements will be |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #ifndef QGRAPHICSLAYOUTITEM_H |
43 | #define QGRAPHICSLAYOUTITEM_H |
44 | |
45 | #include <QtCore/qscopedpointer.h> |
46 | #include <QtGui/qsizepolicy.h> |
47 | #include <QtGui/qevent.h> |
48 | |
49 | QT_BEGIN_HEADER |
50 | |
51 | QT_BEGIN_NAMESPACE |
52 | |
53 | QT_MODULE(Gui) |
54 | |
55 | #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW |
56 | |
57 | class QGraphicsLayoutItemPrivate; |
58 | class QGraphicsItem; |
59 | class Q_GUI_EXPORT QGraphicsLayoutItem |
60 | { |
61 | public: |
62 | QGraphicsLayoutItem(QGraphicsLayoutItem *parent = 0, bool isLayout = false); |
63 | virtual ~QGraphicsLayoutItem(); |
64 | |
65 | void setSizePolicy(const QSizePolicy &policy); |
66 | void setSizePolicy(QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType = QSizePolicy::DefaultType); |
67 | QSizePolicy sizePolicy() const; |
68 | |
69 | void setMinimumSize(const QSizeF &size); |
70 | inline void setMinimumSize(qreal w, qreal h); |
71 | QSizeF minimumSize() const; |
72 | void setMinimumWidth(qreal width); |
73 | inline qreal minimumWidth() const; |
74 | void setMinimumHeight(qreal height); |
75 | inline qreal minimumHeight() const; |
76 | |
77 | void setPreferredSize(const QSizeF &size); |
78 | inline void setPreferredSize(qreal w, qreal h); |
79 | QSizeF preferredSize() const; |
80 | void setPreferredWidth(qreal width); |
81 | inline qreal preferredWidth() const; |
82 | void setPreferredHeight(qreal height); |
83 | inline qreal preferredHeight() const; |
84 | |
85 | void setMaximumSize(const QSizeF &size); |
86 | inline void setMaximumSize(qreal w, qreal h); |
87 | QSizeF maximumSize() const; |
88 | void setMaximumWidth(qreal width); |
89 | inline qreal maximumWidth() const; |
90 | void setMaximumHeight(qreal height); |
91 | inline qreal maximumHeight() const; |
92 | |
93 | virtual void setGeometry(const QRectF &rect); |
94 | QRectF geometry() const; |
95 | virtual void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const; |
96 | QRectF contentsRect() const; |
97 | |
98 | QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; |
99 | |
100 | virtual void updateGeometry(); //### rename to sizeHintChanged() |
101 | |
102 | QGraphicsLayoutItem *parentLayoutItem() const; |
103 | void setParentLayoutItem(QGraphicsLayoutItem *parent); |
104 | |
105 | bool isLayout() const; |
106 | // ###Qt5: Make automatic reparenting work regardless of item/object/widget type. |
107 | QGraphicsItem *graphicsItem() const; |
108 | bool ownedByLayout() const; |
109 | |
110 | protected: |
111 | void setGraphicsItem(QGraphicsItem *item); |
112 | void setOwnedByLayout(bool ownedByLayout); |
113 | QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd); |
114 | |
115 | virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0; |
116 | QScopedPointer<QGraphicsLayoutItemPrivate> d_ptr; |
117 | |
118 | private: |
119 | QSizeF *effectiveSizeHints(const QSizeF &constraint) const; |
120 | Q_DECLARE_PRIVATE(QGraphicsLayoutItem) |
121 | |
122 | friend class QGraphicsLayout; |
123 | }; |
124 | |
125 | Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "com.trolltech.Qt.QGraphicsLayoutItem" ) |
126 | |
127 | inline void QGraphicsLayoutItem::setMinimumSize(qreal aw, qreal ah) |
128 | { setMinimumSize(QSizeF(aw, ah)); } |
129 | inline void QGraphicsLayoutItem::setPreferredSize(qreal aw, qreal ah) |
130 | { setPreferredSize(QSizeF(aw, ah)); } |
131 | inline void QGraphicsLayoutItem::setMaximumSize(qreal aw, qreal ah) |
132 | { setMaximumSize(QSizeF(aw, ah)); } |
133 | |
134 | inline qreal QGraphicsLayoutItem::minimumWidth() const |
135 | { return effectiveSizeHint(Qt::MinimumSize).width(); } |
136 | inline qreal QGraphicsLayoutItem::minimumHeight() const |
137 | { return effectiveSizeHint(Qt::MinimumSize).height(); } |
138 | |
139 | inline qreal QGraphicsLayoutItem::preferredWidth() const |
140 | { return effectiveSizeHint(Qt::PreferredSize).width(); } |
141 | inline qreal QGraphicsLayoutItem::preferredHeight() const |
142 | { return effectiveSizeHint(Qt::PreferredSize).height(); } |
143 | |
144 | inline qreal QGraphicsLayoutItem::maximumWidth() const |
145 | { return effectiveSizeHint(Qt::MaximumSize).width(); } |
146 | inline qreal QGraphicsLayoutItem::maximumHeight() const |
147 | { return effectiveSizeHint(Qt::MaximumSize).height(); } |
148 | |
149 | #endif |
150 | |
151 | QT_END_NAMESPACE |
152 | |
153 | QT_END_HEADER |
154 | |
155 | #endif |
156 | |