Qt 4.8
qdeclarativevaluetype_p.h
Go to the documentation of this file.
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 QtDeclarative 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 QDECLARATIVEVALUETYPE_P_H
43 #define QDECLARATIVEVALUETYPE_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 "qdeclarativeproperty.h"
57 #include "private/qdeclarativeproperty_p.h"
58 #include "private/qdeclarativenullablevalue_p_p.h"
59 
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>
70 
72 
74 {
75  Q_OBJECT
76 public:
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;
82 };
83 
85 {
86 public:
89  static bool isValueType(int);
90  static QDeclarativeValueType *valueType(int);
91 
92  static void registerValueTypes();
93  static void registerValueTypesCompat();
94 
96  if (idx < 0 || idx >= (int)QVariant::UserType) return 0;
97  else return valueTypes[idx];
98  }
99 
100 private:
102 };
103 
105 {
108  Q_OBJECT
109 public:
111 
112  virtual void read(QObject *, int);
113  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
114  virtual QVariant value();
115  virtual void setValue(QVariant value);
116 
117  qreal x() const;
118  qreal y() const;
119  void setX(qreal);
120  void setY(qreal);
121 
122 private:
124 };
125 
127 {
128  int x;
129  int y;
130  Q_OBJECT
131 public:
132  QDeclarativePointValueType(QObject *parent = 0);
133 
134  virtual void read(QObject *, int);
135  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
136  virtual QVariant value();
137  virtual void setValue(QVariant value);
138 
139  int x() const;
140  int y() const;
141  void setX(int);
142  void setY(int);
143 
144 private:
146 };
147 
149 {
152  Q_OBJECT
153 public:
154  QDeclarativeSizeFValueType(QObject *parent = 0);
155 
156  virtual void read(QObject *, int);
157  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
158  virtual QVariant value();
159  virtual void setValue(QVariant value);
160 
161  qreal width() const;
162  qreal height() const;
163  void setWidth(qreal);
164  void setHeight(qreal);
165 
166 private:
168 };
169 
171 {
172  int width;
173  int height;
174  Q_OBJECT
175 public:
176  QDeclarativeSizeValueType(QObject *parent = 0);
177 
178  virtual void read(QObject *, int);
179  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
180  virtual QVariant value();
181  virtual void setValue(QVariant value);
182 
183  int width() const;
184  int height() const;
185  void setWidth(int);
186  void setHeight(int);
187 
188 private:
190 };
191 
193 {
198  Q_OBJECT
199 public:
200  QDeclarativeRectFValueType(QObject *parent = 0);
201 
202  virtual void read(QObject *, int);
203  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
204  virtual QVariant value();
205  virtual void setValue(QVariant value);
206 
207  qreal x() const;
208  qreal y() const;
209  void setX(qreal);
210  void setY(qreal);
211 
212  qreal width() const;
213  qreal height() const;
214  void setWidth(qreal);
215  void setHeight(qreal);
216 
217 private:
219 };
220 
222 {
223  int x;
224  int y;
225  int width;
226  int height;
227  Q_OBJECT
228 public:
229  QDeclarativeRectValueType(QObject *parent = 0);
230 
231  virtual void read(QObject *, int);
232  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
233  virtual QVariant value();
234  virtual void setValue(QVariant value);
235 
236  int x() const;
237  int y() const;
238  void setX(int);
239  void setY(int);
240 
241  int width() const;
242  int height() const;
243  void setWidth(int);
244  void setHeight(int);
245 
246 private:
248 };
249 
251 {
254  Q_OBJECT
255 public:
257 
258  virtual void read(QObject *, int);
259  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
260  virtual QVariant value();
261  virtual void setValue(QVariant value);
262 
263  qreal x() const;
264  qreal y() const;
265  void setX(qreal);
266  void setY(qreal);
267 
268 private:
270 };
271 
273 {
277  Q_OBJECT
278 public:
280 
281  virtual void read(QObject *, int);
282  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
283  virtual QVariant value();
284  virtual void setValue(QVariant value);
285 
286  qreal x() const;
287  qreal y() const;
288  qreal z() const;
289  void setX(qreal);
290  void setY(qreal);
291  void setZ(qreal);
292 
293 private:
295 };
296 
298 {
303  Q_OBJECT
304 public:
306 
307  virtual void read(QObject *, int);
308  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
309  virtual QVariant value();
310  virtual void setValue(QVariant value);
311 
312  qreal x() const;
313  qreal y() const;
314  qreal z() const;
315  qreal w() const;
316  void setX(qreal);
317  void setY(qreal);
318  void setZ(qreal);
319  void setW(qreal);
320 
321 private:
323 };
324 
326 {
331  Q_OBJECT
332 public:
334 
335  virtual void read(QObject *, int);
336  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
337  virtual QVariant value();
338  virtual void setValue(QVariant value);
339 
340  qreal scalar() const;
341  qreal x() const;
342  qreal y() const;
343  qreal z() const;
344  void setScalar(qreal);
345  void setX(qreal);
346  void setY(qreal);
347  void setZ(qreal);
348 
349 private:
351 };
352 
354 {
371  Q_OBJECT
372 public:
374 
375  virtual void read(QObject *, int);
376  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
377  virtual QVariant value();
378  virtual void setValue(QVariant value);
379 
380  qreal m11() const { return matrix(0, 0); }
381  qreal m12() const { return matrix(0, 1); }
382  qreal m13() const { return matrix(0, 2); }
383  qreal m14() const { return matrix(0, 3); }
384  qreal m21() const { return matrix(1, 0); }
385  qreal m22() const { return matrix(1, 1); }
386  qreal m23() const { return matrix(1, 2); }
387  qreal m24() const { return matrix(1, 3); }
388  qreal m31() const { return matrix(2, 0); }
389  qreal m32() const { return matrix(2, 1); }
390  qreal m33() const { return matrix(2, 2); }
391  qreal m34() const { return matrix(2, 3); }
392  qreal m41() const { return matrix(3, 0); }
393  qreal m42() const { return matrix(3, 1); }
394  qreal m43() const { return matrix(3, 2); }
395  qreal m44() const { return matrix(3, 3); }
396 
397  void setM11(qreal value) { matrix(0, 0) = value; }
398  void setM12(qreal value) { matrix(0, 1) = value; }
399  void setM13(qreal value) { matrix(0, 2) = value; }
400  void setM14(qreal value) { matrix(0, 3) = value; }
401  void setM21(qreal value) { matrix(1, 0) = value; }
402  void setM22(qreal value) { matrix(1, 1) = value; }
403  void setM23(qreal value) { matrix(1, 2) = value; }
404  void setM24(qreal value) { matrix(1, 3) = value; }
405  void setM31(qreal value) { matrix(2, 0) = value; }
406  void setM32(qreal value) { matrix(2, 1) = value; }
407  void setM33(qreal value) { matrix(2, 2) = value; }
408  void setM34(qreal value) { matrix(2, 3) = value; }
409  void setM41(qreal value) { matrix(3, 0) = value; }
410  void setM42(qreal value) { matrix(3, 1) = value; }
411  void setM43(qreal value) { matrix(3, 2) = value; }
412  void setM44(qreal value) { matrix(3, 3) = value; }
413 
414 private:
416 };
417 
419 {
420  Q_OBJECT
421  Q_ENUMS(Type)
422 
424  qreal amplitude;
425  qreal overshoot;
426  qreal period;
427 public:
428  enum Type {
452  };
453 
455 
456  virtual void read(QObject *, int);
457  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
458  virtual QVariant value();
459  virtual void setValue(QVariant value);
460 
461  Type type() const;
462  qreal amplitude() const;
463  qreal overshoot() const;
464  qreal period() const;
465  void setType(Type);
466  void setAmplitude(qreal);
467  void setOvershoot(qreal);
468  void setPeriod(qreal);
469 
470 private:
472 };
473 
475 {
476  Q_OBJECT
479 
480  QString family;
481  bool bold;
482  FontWeight weight;
483  bool italic;
484  bool underline;
485  bool overline;
486  bool strikeout;
489  Capitalization capitalization;
490  qreal letterSpacing;
491  qreal wordSpacing;
492 
493 public:
494  enum FontWeight { Light = QFont::Light,
495  Normal = QFont::Normal,
496  DemiBold = QFont::DemiBold,
497  Bold = QFont::Bold,
498  Black = QFont::Black };
499  enum Capitalization { MixedCase = QFont::MixedCase,
500  AllUppercase = QFont::AllUppercase,
501  AllLowercase = QFont::AllLowercase,
502  SmallCaps = QFont::SmallCaps,
503  Capitalize = QFont::Capitalize };
504 
505  QDeclarativeFontValueType(QObject *parent = 0);
506 
507  virtual void read(QObject *, int);
508  virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags);
509  virtual QVariant value();
510  virtual void setValue(QVariant value);
511 
512  QString family() const;
513  void setFamily(const QString &);
514 
515  bool bold() const;
516  void setBold(bool b);
517 
518  FontWeight weight() const;
519  void setWeight(FontWeight);
520 
521  bool italic() const;
522  void setItalic(bool b);
523 
524  bool underline() const;
525  void setUnderline(bool b);
526 
527  bool overline() const;
528  void setOverline(bool b);
529 
530  bool strikeout() const;
531  void setStrikeout(bool b);
532 
533  qreal pointSize() const;
534  void setPointSize(qreal size);
535 
536  int pixelSize() const;
537  void setPixelSize(int size);
538 
539  Capitalization capitalization() const;
540  void setCapitalization(Capitalization);
541 
542  qreal letterSpacing() const;
543  void setLetterSpacing(qreal spacing);
544 
545  qreal wordSpacing() const;
546  void setWordSpacing(qreal spacing);
547 
548 private:
553 };
554 
556 
557 #endif // QDECLARATIVEVALUETYPE_P_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QEasingCurve class provides easing curves for controlling animation.
Definition: qeasingcurve.h:55
The QVector4D class represents a vector or vertex in 4D space.
Definition: qvector4d.h:60
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63
The QVector2D class represents a vector or vertex in 2D space.
Definition: qvector2d.h:60
#define Q_DECLARATIVE_PRIVATE_EXPORT
#define Q_OBJECT
Definition: qobjectdefs.h:157
QDeclarativeValueType * operator[](int idx) const
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QDeclarativeNullableValue< int > dpi
static float pointSize(const QFontDef &fd, int dpi)
Definition: qfont_win.cpp:90