0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the demonstration applications of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#ifndef XFORM_H
|
|
43 |
#define XFORM_H
|
|
44 |
|
|
45 |
#include "arthurwidgets.h"
|
|
46 |
|
|
47 |
#include <QBasicTimer>
|
|
48 |
#include <QPolygonF>
|
|
49 |
|
|
50 |
class HoverPoints;
|
|
51 |
QT_FORWARD_DECLARE_CLASS(QLineEdit)
|
|
52 |
|
|
53 |
class XFormView : public ArthurFrame
|
|
54 |
{
|
|
55 |
public:
|
|
56 |
Q_OBJECT
|
|
57 |
|
|
58 |
Q_PROPERTY(XFormType type READ type WRITE setType)
|
|
59 |
Q_PROPERTY(bool animation READ animation WRITE setAnimation)
|
|
60 |
Q_PROPERTY(qreal shear READ shear WRITE setShear)
|
|
61 |
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation)
|
|
62 |
Q_PROPERTY(qreal scale READ scale WRITE setScale)
|
|
63 |
Q_PROPERTY(QString text READ text WRITE setText)
|
|
64 |
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
|
|
65 |
Q_ENUMS(XFormType)
|
|
66 |
|
|
67 |
public:
|
|
68 |
enum XFormType { VectorType, PixmapType, TextType };
|
|
69 |
|
|
70 |
XFormView(QWidget *parent);
|
|
71 |
void paint(QPainter *);
|
|
72 |
void drawVectorType(QPainter *painter);
|
|
73 |
void drawPixmapType(QPainter *painter);
|
|
74 |
void drawTextType(QPainter *painter);
|
|
75 |
QSize sizeHint() const { return QSize(500, 500); }
|
|
76 |
|
|
77 |
void mousePressEvent(QMouseEvent *e);
|
|
78 |
void resizeEvent(QResizeEvent *e);
|
|
79 |
HoverPoints *hoverPoints() { return pts; }
|
|
80 |
|
|
81 |
bool animation() const { return timer.isActive(); }
|
|
82 |
qreal shear() const { return m_shear; }
|
|
83 |
qreal scale() const { return m_scale; }
|
|
84 |
qreal rotation() const { return m_rotation; }
|
|
85 |
void setShear(qreal s);
|
|
86 |
void setScale(qreal s);
|
|
87 |
void setRotation(qreal r);
|
|
88 |
|
|
89 |
XFormType type() const;
|
|
90 |
QPixmap pixmap() const;
|
|
91 |
QString text() const;
|
|
92 |
|
|
93 |
public slots:
|
|
94 |
void setAnimation(bool animate);
|
|
95 |
void updateCtrlPoints(const QPolygonF &);
|
|
96 |
void changeRotation(int rotation);
|
|
97 |
void changeScale(int scale);
|
|
98 |
void changeShear(int shear);
|
|
99 |
|
|
100 |
void setText(const QString &);
|
|
101 |
void setPixmap(const QPixmap &);
|
|
102 |
void setType(XFormType t);
|
|
103 |
|
|
104 |
void setVectorType();
|
|
105 |
void setPixmapType();
|
|
106 |
void setTextType();
|
|
107 |
void reset();
|
|
108 |
|
|
109 |
signals:
|
|
110 |
void rotationChanged(int rotation);
|
|
111 |
void scaleChanged(int scale);
|
|
112 |
void shearChanged(int shear);
|
|
113 |
|
|
114 |
protected:
|
|
115 |
void timerEvent(QTimerEvent *e);
|
|
116 |
void wheelEvent(QWheelEvent *);
|
|
117 |
|
|
118 |
private:
|
|
119 |
QPolygonF ctrlPoints;
|
|
120 |
HoverPoints *pts;
|
|
121 |
qreal m_rotation;
|
|
122 |
qreal m_scale;
|
|
123 |
qreal m_shear;
|
|
124 |
XFormType m_type;
|
|
125 |
QPixmap m_pixmap;
|
|
126 |
QString m_text;
|
|
127 |
QBasicTimer timer;
|
|
128 |
};
|
|
129 |
|
|
130 |
class XFormWidget : public QWidget
|
|
131 |
{
|
|
132 |
Q_OBJECT
|
|
133 |
public:
|
|
134 |
XFormWidget(QWidget *parent);
|
|
135 |
|
|
136 |
private:
|
|
137 |
XFormView *view;
|
|
138 |
QLineEdit *textEditor;
|
|
139 |
};
|
|
140 |
|
|
141 |
#endif // XFORM_H
|