Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativeanchors_p_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QDECLARATIVEANCHORS_P_H
43 #define QDECLARATIVEANCHORS_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists purely as an
50 // implementation detail.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55
56 #include "QtQuick1/private/qdeclarativeanchors_p.h"
57 #include "QtQuick1/private/qdeclarativeitemchangelistener_p.h"
58 #include <private/qobject_p.h>
59
60 QT_BEGIN_NAMESPACE
61
62 // NOTE: if you change this then also update the copy in qdeclarativev4compiler_p_p.h
63 class QDeclarative1AnchorLine
64 {
65 public:
66     QDeclarative1AnchorLine() : item(0), anchorLine(Invalid) {}
67
68     enum AnchorLine {
69         Invalid = 0x0,
70         Left = 0x01,
71         Right = 0x02,
72         Top = 0x04,
73         Bottom = 0x08,
74         HCenter = 0x10,
75         VCenter = 0x20,
76         Baseline = 0x40,
77         Horizontal_Mask = Left | Right | HCenter,
78         Vertical_Mask = Top | Bottom | VCenter | Baseline
79     };
80
81     QGraphicsObject *item;
82     AnchorLine anchorLine;
83 };
84
85 inline bool operator==(const QDeclarative1AnchorLine& a, const QDeclarative1AnchorLine& b)
86 {
87     return a.item == b.item && a.anchorLine == b.anchorLine;
88 }
89
90 class QDeclarative1AnchorsPrivate : public QObjectPrivate, public QDeclarativeItemChangeListener
91 {
92     Q_DECLARE_PUBLIC(QDeclarative1Anchors)
93 public:
94     QDeclarative1AnchorsPrivate(QGraphicsObject *i)
95       : componentComplete(true), updatingMe(false), updatingHorizontalAnchor(0),
96         updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0),
97         centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
98         margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)
99     {
100     }
101
102     void clearItem(QGraphicsObject *);
103
104     void addDepend(QGraphicsObject *);
105     void remDepend(QGraphicsObject *);
106     bool isItemComplete() const;
107
108     bool componentComplete:1;
109     bool updatingMe:1;
110     uint updatingHorizontalAnchor:2;
111     uint updatingVerticalAnchor:2;
112     uint updatingFill:2;
113     uint updatingCenterIn:2;
114
115     void setItemHeight(qreal);
116     void setItemWidth(qreal);
117     void setItemX(qreal);
118     void setItemY(qreal);
119     void setItemPos(const QPointF &);
120     void setItemSize(const QSizeF &);
121
122     void updateOnComplete();
123     void updateMe();
124
125     // QDeclarativeItemGeometryListener interface
126     void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &);
127     void _q_widgetDestroyed(QObject *);
128     void _q_widgetGeometryChanged();
129     QDeclarative1AnchorsPrivate *anchorPrivate() { return this; }
130
131     bool checkHValid() const;
132     bool checkVValid() const;
133     bool checkHAnchorValid(QDeclarative1AnchorLine anchor) const;
134     bool checkVAnchorValid(QDeclarative1AnchorLine anchor) const;
135     bool calcStretch(const QDeclarative1AnchorLine &edge1, const QDeclarative1AnchorLine &edge2, qreal offset1, qreal offset2, QDeclarative1AnchorLine::AnchorLine line, qreal &stretch);
136
137     bool isMirrored() const;
138     void updateHorizontalAnchors();
139     void updateVerticalAnchors();
140     void fillChanged();
141     void centerInChanged();
142
143     QGraphicsObject *item;
144     QDeclarative1Anchors::Anchors usedAnchors;
145
146     QGraphicsObject *fill;
147     QGraphicsObject *centerIn;
148
149     QDeclarative1AnchorLine left;
150     QDeclarative1AnchorLine right;
151     QDeclarative1AnchorLine top;
152     QDeclarative1AnchorLine bottom;
153     QDeclarative1AnchorLine vCenter;
154     QDeclarative1AnchorLine hCenter;
155     QDeclarative1AnchorLine baseline;
156
157     qreal leftMargin;
158     qreal rightMargin;
159     qreal topMargin;
160     qreal bottomMargin;
161     qreal margins;
162     qreal vCenterOffset;
163     qreal hCenterOffset;
164     qreal baselineOffset;
165 };
166
167 QT_END_NAMESPACE
168
169 Q_DECLARE_METATYPE(QDeclarative1AnchorLine)
170
171 #endif