source: trunk/src/gui/graphicsview/qgraphicslayoutitem.h@ 116

Last change on this file since 116 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.6 KB
Line 
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
48QT_BEGIN_HEADER
49
50QT_BEGIN_NAMESPACE
51
52QT_MODULE(Gui)
53
54#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
55
56class QGraphicsLayoutItemPrivate;
57class QGraphicsItem;
58class Q_GUI_EXPORT QGraphicsLayoutItem
59{
60public:
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
109protected:
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
117private:
118 QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
119 Q_DECLARE_PRIVATE(QGraphicsLayoutItem)
120
121 friend class QGraphicsLayout;
122};
123
124inline void QGraphicsLayoutItem::setMinimumSize(qreal aw, qreal ah)
125{ setMinimumSize(QSizeF(aw, ah)); }
126inline void QGraphicsLayoutItem::setPreferredSize(qreal aw, qreal ah)
127{ setPreferredSize(QSizeF(aw, ah)); }
128inline void QGraphicsLayoutItem::setMaximumSize(qreal aw, qreal ah)
129{ setMaximumSize(QSizeF(aw, ah)); }
130
131inline qreal QGraphicsLayoutItem::minimumWidth() const
132{ return effectiveSizeHint(Qt::MinimumSize).width(); }
133inline qreal QGraphicsLayoutItem::minimumHeight() const