1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEVALUETYPE_P_H
43 #define QDECLARATIVEVALUETYPE_P_H
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.
56 #include "qdeclarativeproperty.h"
57 #include "private/qdeclarativeproperty_p.h"
58 #include "private/qdeclarativenullablevalue_p_p.h"
60 #include <QtCore/qobject.h>
61 #include <QtCore/qrect.h>
62 #include <QtCore/qeasingcurve.h>
63 #include <QtCore/qvariant.h>
64 #include <QtGui/qvector2d.h>
65 #include <QtGui/qvector3d.h>
66 #include <QtGui/qvector4d.h>
67 #include <QtGui/qmatrix4x4.h>
68 #include <QtGui/qquaternion.h>
69 #include <QtGui/qfont.h>
73 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeValueType : public QObject
77 QDeclarativeValueType(QObject *parent = 0);
78 virtual void read(QObject *, int) = 0;
79 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags flags) = 0;
80 virtual QVariant value() = 0;
81 virtual void setValue(QVariant) = 0;
84 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeValueTypeFactory
87 QDeclarativeValueTypeFactory();
88 ~QDeclarativeValueTypeFactory();
89 static bool isValueType(int);
90 static QDeclarativeValueType *valueType(int);
92 static void registerValueTypes();
94 QDeclarativeValueType *operator[](int idx) const {
95 if (idx >= (int)QVariant::UserType) return 0;
96 else return valueTypes[idx];
100 QDeclarativeValueType *valueTypes[QVariant::UserType - 1];
103 class Q_AUTOTEST_EXPORT QDeclarativePointFValueType : public QDeclarativeValueType
105 Q_PROPERTY(qreal x READ x WRITE setX)
106 Q_PROPERTY(qreal y READ y WRITE setY)
109 QDeclarativePointFValueType(QObject *parent = 0);
111 virtual void read(QObject *, int);
112 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
113 virtual QVariant value();
114 virtual void setValue(QVariant value);
125 class Q_AUTOTEST_EXPORT QDeclarativePointValueType : public QDeclarativeValueType
127 Q_PROPERTY(int x READ x WRITE setX)
128 Q_PROPERTY(int y READ y WRITE setY)
131 QDeclarativePointValueType(QObject *parent = 0);
133 virtual void read(QObject *, int);
134 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
135 virtual QVariant value();
136 virtual void setValue(QVariant value);
147 class Q_AUTOTEST_EXPORT QDeclarativeSizeFValueType : public QDeclarativeValueType
149 Q_PROPERTY(qreal width READ width WRITE setWidth)
150 Q_PROPERTY(qreal height READ height WRITE setHeight)
153 QDeclarativeSizeFValueType(QObject *parent = 0);
155 virtual void read(QObject *, int);
156 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
157 virtual QVariant value();
158 virtual void setValue(QVariant value);
161 qreal height() const;
162 void setWidth(qreal);
163 void setHeight(qreal);
169 class Q_AUTOTEST_EXPORT QDeclarativeSizeValueType : public QDeclarativeValueType
171 Q_PROPERTY(int width READ width WRITE setWidth)
172 Q_PROPERTY(int height READ height WRITE setHeight)
175 QDeclarativeSizeValueType(QObject *parent = 0);
177 virtual void read(QObject *, int);
178 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
179 virtual QVariant value();
180 virtual void setValue(QVariant value);
191 class Q_AUTOTEST_EXPORT QDeclarativeRectFValueType : public QDeclarativeValueType
193 Q_PROPERTY(qreal x READ x WRITE setX)
194 Q_PROPERTY(qreal y READ y WRITE setY)
195 Q_PROPERTY(qreal width READ width WRITE setWidth)
196 Q_PROPERTY(qreal height READ height WRITE setHeight)
199 QDeclarativeRectFValueType(QObject *parent = 0);
201 virtual void read(QObject *, int);
202 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
203 virtual QVariant value();
204 virtual void setValue(QVariant value);
212 qreal height() const;
213 void setWidth(qreal);
214 void setHeight(qreal);
220 class Q_AUTOTEST_EXPORT QDeclarativeRectValueType : public QDeclarativeValueType
222 Q_PROPERTY(int x READ x WRITE setX)
223 Q_PROPERTY(int y READ y WRITE setY)
224 Q_PROPERTY(int width READ width WRITE setWidth)
225 Q_PROPERTY(int height READ height WRITE setHeight)
228 QDeclarativeRectValueType(QObject *parent = 0);
230 virtual void read(QObject *, int);
231 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
232 virtual QVariant value();
233 virtual void setValue(QVariant value);
249 class Q_AUTOTEST_EXPORT QDeclarativeVector2DValueType : public QDeclarativeValueType
251 Q_PROPERTY(qreal x READ x WRITE setX)
252 Q_PROPERTY(qreal y READ y WRITE setY)
255 QDeclarativeVector2DValueType(QObject *parent = 0);
257 virtual void read(QObject *, int);
258 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
259 virtual QVariant value();
260 virtual void setValue(QVariant value);
271 class Q_AUTOTEST_EXPORT QDeclarativeVector3DValueType : public QDeclarativeValueType
273 Q_PROPERTY(qreal x READ x WRITE setX)
274 Q_PROPERTY(qreal y READ y WRITE setY)
275 Q_PROPERTY(qreal z READ z WRITE setZ)
278 QDeclarativeVector3DValueType(QObject *parent = 0);
280 virtual void read(QObject *, int);
281 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
282 virtual QVariant value();
283 virtual void setValue(QVariant value);
296 class Q_AUTOTEST_EXPORT QDeclarativeVector4DValueType : public QDeclarativeValueType
298 Q_PROPERTY(qreal x READ x WRITE setX)
299 Q_PROPERTY(qreal y READ y WRITE setY)
300 Q_PROPERTY(qreal z READ z WRITE setZ)
301 Q_PROPERTY(qreal w READ w WRITE setW)
304 QDeclarativeVector4DValueType(QObject *parent = 0);
306 virtual void read(QObject *, int);
307 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
308 virtual QVariant value();
309 virtual void setValue(QVariant value);
324 class Q_AUTOTEST_EXPORT QDeclarativeQuaternionValueType : public QDeclarativeValueType
326 Q_PROPERTY(qreal scalar READ scalar WRITE setScalar)
327 Q_PROPERTY(qreal x READ x WRITE setX)
328 Q_PROPERTY(qreal y READ y WRITE setY)
329 Q_PROPERTY(qreal z READ z WRITE setZ)
332 QDeclarativeQuaternionValueType(QObject *parent = 0);
334 virtual void read(QObject *, int);
335 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
336 virtual QVariant value();
337 virtual void setValue(QVariant value);
339 qreal scalar() const;
343 void setScalar(qreal);
349 QQuaternion quaternion;
352 class Q_AUTOTEST_EXPORT QDeclarativeMatrix4x4ValueType : public QDeclarativeValueType
354 Q_PROPERTY(qreal m11 READ m11 WRITE setM11)
355 Q_PROPERTY(qreal m12 READ m12 WRITE setM12)
356 Q_PROPERTY(qreal m13 READ m13 WRITE setM13)
357 Q_PROPERTY(qreal m14 READ m14 WRITE setM14)
358 Q_PROPERTY(qreal m21 READ m21 WRITE setM21)
359 Q_PROPERTY(qreal m22 READ m22 WRITE setM22)
360 Q_PROPERTY(qreal m23 READ m23 WRITE setM23)
361 Q_PROPERTY(qreal m24 READ m24 WRITE setM24)
362 Q_PROPERTY(qreal m31 READ m31 WRITE setM31)
363 Q_PROPERTY(qreal m32 READ m32 WRITE setM32)
364 Q_PROPERTY(qreal m33 READ m33 WRITE setM33)
365 Q_PROPERTY(qreal m34 READ m34 WRITE setM34)
366 Q_PROPERTY(qreal m41 READ m41 WRITE setM41)
367 Q_PROPERTY(qreal m42 READ m42 WRITE setM42)
368 Q_PROPERTY(qreal m43 READ m43 WRITE setM43)
369 Q_PROPERTY(qreal m44 READ m44 WRITE setM44)
372 QDeclarativeMatrix4x4ValueType(QObject *parent = 0);
374 virtual void read(QObject *, int);
375 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
376 virtual QVariant value();
377 virtual void setValue(QVariant value);
379 qreal m11() const { return matrix(0, 0); }
380 qreal m12() const { return matrix(0, 1); }
381 qreal m13() const { return matrix(0, 2); }
382 qreal m14() const { return matrix(0, 3); }
383 qreal m21() const { return matrix(1, 0); }
384 qreal m22() const { return matrix(1, 1); }
385 qreal m23() const { return matrix(1, 2); }
386 qreal m24() const { return matrix(1, 3); }
387 qreal m31() const { return matrix(2, 0); }
388 qreal m32() const { return matrix(2, 1); }
389 qreal m33() const { return matrix(2, 2); }
390 qreal m34() const { return matrix(2, 3); }
391 qreal m41() const { return matrix(3, 0); }
392 qreal m42() const { return matrix(3, 1); }
393 qreal m43() const { return matrix(3, 2); }
394 qreal m44() const { return matrix(3, 3); }
396 void setM11(qreal value) { matrix(0, 0) = value; }
397 void setM12(qreal value) { matrix(0, 1) = value; }
398 void setM13(qreal value) { matrix(0, 2) = value; }
399 void setM14(qreal value) { matrix(0, 3) = value; }
400 void setM21(qreal value) { matrix(1, 0) = value; }
401 void setM22(qreal value) { matrix(1, 1) = value; }
402 void setM23(qreal value) { matrix(1, 2) = value; }
403 void setM24(qreal value) { matrix(1, 3) = value; }
404 void setM31(qreal value) { matrix(2, 0) = value; }
405 void setM32(qreal value) { matrix(2, 1) = value; }
406 void setM33(qreal value) { matrix(2, 2) = value; }
407 void setM34(qreal value) { matrix(2, 3) = value; }
408 void setM41(qreal value) { matrix(3, 0) = value; }
409 void setM42(qreal value) { matrix(3, 1) = value; }
410 void setM43(qreal value) { matrix(3, 2) = value; }
411 void setM44(qreal value) { matrix(3, 3) = value; }
417 class Q_AUTOTEST_EXPORT QDeclarativeEasingValueType : public QDeclarativeValueType
422 Q_PROPERTY(QDeclarativeEasingValueType::Type type READ type WRITE setType)
423 Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude)
424 Q_PROPERTY(qreal overshoot READ overshoot WRITE setOvershoot)
425 Q_PROPERTY(qreal period READ period WRITE setPeriod)
428 Linear = QEasingCurve::Linear,
429 InQuad = QEasingCurve::InQuad, OutQuad = QEasingCurve::OutQuad,
430 InOutQuad = QEasingCurve::InOutQuad, OutInQuad = QEasingCurve::OutInQuad,
431 InCubic = QEasingCurve::InCubic, OutCubic = QEasingCurve::OutCubic,
432 InOutCubic = QEasingCurve::InOutCubic, OutInCubic = QEasingCurve::OutInCubic,
433 InQuart = QEasingCurve::InQuart, OutQuart = QEasingCurve::OutQuart,
434 InOutQuart = QEasingCurve::InOutQuart, OutInQuart = QEasingCurve::OutInQuart,
435 InQuint = QEasingCurve::InQuint, OutQuint = QEasingCurve::OutQuint,
436 InOutQuint = QEasingCurve::InOutQuint, OutInQuint = QEasingCurve::OutInQuint,
437 InSine = QEasingCurve::InSine, OutSine = QEasingCurve::OutSine,
438 InOutSine = QEasingCurve::InOutSine, OutInSine = QEasingCurve::OutInSine,
439 InExpo = QEasingCurve::InExpo, OutExpo = QEasingCurve::OutExpo,
440 InOutExpo = QEasingCurve::InOutExpo, OutInExpo = QEasingCurve::OutInExpo,
441 InCirc = QEasingCurve::InCirc, OutCirc = QEasingCurve::OutCirc,
442 InOutCirc = QEasingCurve::InOutCirc, OutInCirc = QEasingCurve::OutInCirc,
443 InElastic = QEasingCurve::InElastic, OutElastic = QEasingCurve::OutElastic,
444 InOutElastic = QEasingCurve::InOutElastic, OutInElastic = QEasingCurve::OutInElastic,
445 InBack = QEasingCurve::InBack, OutBack = QEasingCurve::OutBack,
446 InOutBack = QEasingCurve::InOutBack, OutInBack = QEasingCurve::OutInBack,
447 InBounce = QEasingCurve::InBounce, OutBounce = QEasingCurve::OutBounce,
448 InOutBounce = QEasingCurve::InOutBounce, OutInBounce = QEasingCurve::OutInBounce,
449 InCurve = QEasingCurve::InCurve, OutCurve = QEasingCurve::OutCurve,
450 SineCurve = QEasingCurve::SineCurve, CosineCurve = QEasingCurve::CosineCurve
453 QDeclarativeEasingValueType(QObject *parent = 0);
455 virtual void read(QObject *, int);
456 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
457 virtual QVariant value();
458 virtual void setValue(QVariant value);
461 qreal amplitude() const;
462 qreal overshoot() const;
463 qreal period() const;
465 void setAmplitude(qreal);
466 void setOvershoot(qreal);
467 void setPeriod(qreal);
473 class Q_AUTOTEST_EXPORT QDeclarativeFontValueType : public QDeclarativeValueType
477 Q_ENUMS(Capitalization)
479 Q_PROPERTY(QString family READ family WRITE setFamily)
480 Q_PROPERTY(bool bold READ bold WRITE setBold)
481 Q_PROPERTY(FontWeight weight READ weight WRITE setWeight)
482 Q_PROPERTY(bool italic READ italic WRITE setItalic)
483 Q_PROPERTY(bool underline READ underline WRITE setUnderline)
484 Q_PROPERTY(bool overline READ overline WRITE setOverline)
485 Q_PROPERTY(bool strikeout READ strikeout WRITE setStrikeout)
486 Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize)
487 Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize)
488 Q_PROPERTY(Capitalization capitalization READ capitalization WRITE setCapitalization)
489 Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing)
490 Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing)
493 enum FontWeight { Light = QFont::Light,
494 Normal = QFont::Normal,
495 DemiBold = QFont::DemiBold,
497 Black = QFont::Black };
498 enum Capitalization { MixedCase = QFont::MixedCase,
499 AllUppercase = QFont::AllUppercase,
500 AllLowercase = QFont::AllLowercase,
501 SmallCaps = QFont::SmallCaps,
502 Capitalize = QFont::Capitalize };
504 QDeclarativeFontValueType(QObject *parent = 0);
506 virtual void read(QObject *, int);
507 virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
508 virtual QVariant value();
509 virtual void setValue(QVariant value);
511 QString family() const;
512 void setFamily(const QString &);
515 void setBold(bool b);
517 FontWeight weight() const;
518 void setWeight(FontWeight);
521 void setItalic(bool b);
523 bool underline() const;
524 void setUnderline(bool b);
526 bool overline() const;
527 void setOverline(bool b);
529 bool strikeout() const;
530 void setStrikeout(bool b);
532 qreal pointSize() const;
533 void setPointSize(qreal size);
535 int pixelSize() const;
536 void setPixelSize(int size);
538 Capitalization capitalization() const;
539 void setCapitalization(Capitalization);
541 qreal letterSpacing() const;
542 void setLetterSpacing(qreal spacing);
544 qreal wordSpacing() const;
545 void setWordSpacing(qreal spacing);
551 mutable QDeclarativeNullableValue<int> dpi;
556 #endif // QDECLARATIVEVALUETYPE_P_H