author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 15 Mar 2010 12:43:09 +0200 | |
branch | RCL_3 |
changeset 6 | dee5afe5301f |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 PATHSTROKE_H |
|
43 |
#define PATHSTROKE_H |
|
44 |
||
45 |
#include "arthurwidgets.h" |
|
46 |
#include <QtGui> |
|
47 |
||
48 |
class PathStrokeRenderer : public ArthurFrame |
|
49 |
{ |
|
50 |
Q_OBJECT |
|
51 |
Q_PROPERTY(bool animation READ animation WRITE setAnimation) |
|
52 |
Q_PROPERTY(qreal penWidth READ realPenWidth WRITE setRealPenWidth) |
|
53 |
public: |
|
54 |
enum PathMode { CurveMode, LineMode }; |
|
55 |
||
56 |
PathStrokeRenderer(QWidget *parent, bool smallScreen = false); |
|
57 |
||
58 |
void paint(QPainter *); |
|
59 |
void mousePressEvent(QMouseEvent *e); |
|
60 |
void mouseMoveEvent(QMouseEvent *e); |
|
61 |
void mouseReleaseEvent(QMouseEvent *e); |
|
62 |
void timerEvent(QTimerEvent *e); |
|
63 |
bool event(QEvent *e); |
|
64 |
||
65 |
QSize sizeHint() const { return QSize(500, 500); } |
|
66 |
||
67 |
bool animation() const { return m_timer.isActive(); } |
|
68 |
||
69 |
qreal realPenWidth() const { return m_penWidth; } |
|
70 |
void setRealPenWidth(qreal penWidth) { m_penWidth = penWidth; update(); } |
|
71 |
||
72 |
signals: |
|
73 |
void clicked(); |
|
74 |
||
75 |
public slots: |
|
76 |
void setPenWidth(int penWidth) { m_penWidth = penWidth / 10.0; update(); } |
|
77 |
void setAnimation(bool animation); |
|
78 |
||
79 |
void setFlatCap() { m_capStyle = Qt::FlatCap; update(); } |
|
80 |
void setSquareCap() { m_capStyle = Qt::SquareCap; update(); } |
|
81 |
void setRoundCap() { m_capStyle = Qt::RoundCap; update(); } |
|
82 |
||
83 |
void setBevelJoin() { m_joinStyle = Qt::BevelJoin; update(); } |
|
84 |
void setMiterJoin() { m_joinStyle = Qt::MiterJoin; update(); } |
|
85 |
void setRoundJoin() { m_joinStyle = Qt::RoundJoin; update(); } |
|
86 |
||
87 |
void setCurveMode() { m_pathMode = CurveMode; update(); } |
|
88 |
void setLineMode() { m_pathMode = LineMode; update(); } |
|
89 |
||
90 |
void setSolidLine() { m_penStyle = Qt::SolidLine; update(); } |
|
91 |
void setDashLine() { m_penStyle = Qt::DashLine; update(); } |
|
92 |
void setDotLine() { m_penStyle = Qt::DotLine; update(); } |
|
93 |
void setDashDotLine() { m_penStyle = Qt::DashDotLine; update(); } |
|
94 |
void setDashDotDotLine() { m_penStyle = Qt::DashDotDotLine; update(); } |
|
95 |
void setCustomDashLine() { m_penStyle = Qt::NoPen; update(); } |
|
96 |
||
97 |
private: |
|
98 |
void initializePoints(); |
|
99 |
void updatePoints(); |
|
100 |
||
101 |
QBasicTimer m_timer; |
|
102 |
||
103 |
PathMode m_pathMode; |
|
104 |
||
105 |
bool m_wasAnimated; |
|
106 |
||
107 |
qreal m_penWidth; |
|
108 |
int m_pointCount; |
|
109 |
int m_pointSize; |
|
110 |
int m_activePoint; |
|
111 |
QVector<QPointF> m_points; |
|
112 |
QVector<QPointF> m_vectors; |
|
113 |
||
114 |
Qt::PenJoinStyle m_joinStyle; |
|
115 |
Qt::PenCapStyle m_capStyle; |
|
116 |
||
117 |
Qt::PenStyle m_penStyle; |
|
118 |
||
119 |
bool m_smallScreen; |
|
120 |
QPoint m_mousePress; |
|
121 |
bool m_mouseDrag; |
|
122 |
||
123 |
QHash<int, int> m_fingerPointMapping; |
|
124 |
}; |
|
125 |
||
126 |
class PathStrokeControls : public QWidget |
|
127 |
{ |
|
128 |
Q_OBJECT |
|
129 |
public: |
|
130 |
PathStrokeControls(QWidget* parent, PathStrokeRenderer* renderer, bool smallScreen); |
|
131 |
||
132 |
signals: |
|
133 |
void okPressed(); |
|
134 |
void quitPressed(); |
|
135 |
||
136 |
private: |
|
137 |
PathStrokeRenderer* m_renderer; |
|
138 |
||
139 |
QGroupBox *m_capGroup; |
|
140 |
QGroupBox *m_joinGroup; |
|
141 |
QGroupBox *m_styleGroup; |
|
142 |
QGroupBox *m_pathModeGroup; |
|
143 |
||
144 |
void createCommonControls(QWidget* parent); |
|
145 |
void layoutForDesktop(); |
|
146 |
void layoutForSmallScreens(); |
|
147 |
||
148 |
private slots: |
|
149 |
void emitQuitSignal(); |
|
150 |
void emitOkSignal(); |
|
151 |
||
152 |
}; |
|
153 |
||
154 |
class PathStrokeWidget : public QWidget |
|
155 |
{ |
|
156 |
Q_OBJECT |
|
157 |
public: |
|
158 |
PathStrokeWidget(bool smallScreen); |
|
159 |
void setStyle ( QStyle * style ); |
|
160 |
||
161 |
private: |
|
162 |
PathStrokeRenderer *m_renderer; |
|
163 |
PathStrokeControls *m_controls; |
|
164 |
||
165 |
private slots: |
|
166 |
void showControls(); |
|
167 |
void hideControls(); |
|
168 |
||
169 |
}; |
|
170 |
||
171 |
#endif // PATHSTROKE_H |