1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QGRAPHICSLAYOUTITEM_H
|
---|
43 | #define QGRAPHICSLAYOUTITEM_H
|
---|
44 |
|
---|
45 | #include <QtGui/qsizepolicy.h>
|
---|
46 | #include <QtGui/qevent.h>
|
---|
47 |
|
---|
48 | QT_BEGIN_HEADER
|
---|
49 |
|
---|
50 | QT_BEGIN_NAMESPACE
|
---|
51 |
|
---|
52 | QT_MODULE(Gui)
|
---|
53 |
|
---|
54 | #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
|
---|
55 |
|
---|
56 | class QGraphicsLayoutItemPrivate;
|
---|
57 | class QGraphicsItem;
|
---|
58 | class Q_GUI_EXPORT QGraphicsLayoutItem
|
---|
59 | {
|
---|
60 | public:
|
---|
61 | QGraphicsLayoutItem(QGraphicsLayoutItem *parent = 0, bool isLayout = false);
|
---|
62 | virtual ~QGraphicsLayoutItem();
|
---|
63 |
|
---|
64 | void setSizePolicy(const QSizePolicy &policy);
|
---|
65 | void setSizePolicy(QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType = QSizePolicy::DefaultType);
|
---|
66 | QSizePolicy sizePolicy() const;
|
---|
67 |
|
---|
68 | void setMinimumSize(const QSizeF &size);
|
---|
69 | inline void setMinimumSize(qreal w, qreal h);
|
---|
70 | QSizeF minimumSize() const;
|
---|
71 | void setMinimumWidth(qreal width);
|
---|
72 | inline qreal minimumWidth() const;
|
---|
73 | void setMinimumHeight(qreal height);
|
---|
74 | inline qreal minimumHeight() const;
|
---|
75 |
|
---|
76 | void setPreferredSize(const QSizeF &size);
|
---|
77 | inline void setPreferredSize(qreal w, qreal h);
|
---|
78 | QSizeF preferredSize() const;
|
---|
79 | void setPreferredWidth(qreal width);
|
---|
80 | inline qreal preferredWidth() const;
|
---|
81 | void setPreferredHeight(qreal height);
|
---|
82 | inline qreal preferredHeight() const;
|
---|
83 |
|
---|
84 | void setMaximumSize(const QSizeF &size);
|
---|
85 | inline void setMaximumSize(qreal w, qreal h);
|
---|
86 | QSizeF maximumSize() const;
|
---|
87 | void setMaximumWidth(qreal width);
|
---|
88 | inline qreal maximumWidth() const;
|
---|
89 | void setMaximumHeight(qreal height);
|
---|
90 | inline qreal maximumHeight() const;
|
---|
91 |
|
---|
92 | virtual void setGeometry(const QRectF &rect);
|
---|
93 | QRectF geometry() const;
|
---|
94 | virtual void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
|
---|
95 | QRectF contentsRect() const;
|
---|
96 |
|
---|
97 | QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
|
---|
98 |
|
---|
99 | virtual void updateGeometry(); //### rename to sizeHintChanged()
|
---|
100 |
|
---|
101 | QGraphicsLayoutItem *parentLayoutItem() const;
|
---|
102 | void setParentLayoutItem(QGraphicsLayoutItem *parent);
|
---|
103 |
|
---|
104 | bool isLayout() const;
|
---|
105 | // ###Qt5: Make automatic reparenting work regardless of item/object/widget type.
|
---|
106 | QGraphicsItem *graphicsItem() const;
|
---|
107 | bool ownedByLayout() const;
|
---|
108 |
|
---|
109 | protected:
|
---|
110 | void setGraphicsItem(QGraphicsItem *item);
|
---|
111 | void setOwnedByLayout(bool ownedByLayout);
|
---|
112 | QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd);
|
---|
113 |
|
---|
114 | virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0;
|
---|
115 | QGraphicsLayoutItemPrivate *d_ptr;
|
---|
116 |
|
---|
117 | private:
|
---|
118 | QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
|
---|
119 | Q_DECLARE_PRIVATE(QGraphicsLayoutItem)
|
---|
120 |
|
---|
121 | friend class QGraphicsLayout;
|
---|
122 | };
|
---|
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 | #endif
|
---|
147 |
|
---|
148 | QT_END_NAMESPACE
|
---|
149 |
|
---|
150 | QT_END_HEADER
|
---|
151 |
|
---|
152 | #endif
|
---|