~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to demos/pathstroke/pathstroke.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef PATHSTROKE_H
 
2
 
 
3
#include <QtGui>
 
4
#include "arthurwidgets.h"
 
5
 
 
6
class PathStrokeRenderer : public ArthurFrame
 
7
{
 
8
    Q_OBJECT
 
9
public:
 
10
    enum PathMode { CurveMode, LineMode };
 
11
 
 
12
    PathStrokeRenderer(QWidget *parent);
 
13
 
 
14
    void paint(QPainter *);
 
15
    void mousePressEvent(QMouseEvent *e);
 
16
    void mouseMoveEvent(QMouseEvent *e);
 
17
    void mouseReleaseEvent(QMouseEvent *e);
 
18
    void timerEvent(QTimerEvent *e);
 
19
 
 
20
    QSize sizeHint() const { return QSize(500, 500); }
 
21
 
 
22
public slots:
 
23
    void setPenWidth(int penWidth) { m_penWidth = penWidth / 10.0; update(); }
 
24
    void setAnimation(bool animation);
 
25
 
 
26
    void setFlatCap() { m_capStyle = Qt::FlatCap; update(); }
 
27
    void setSquareCap() { m_capStyle = Qt::SquareCap; update(); }
 
28
    void setRoundCap() { m_capStyle = Qt::RoundCap; update(); }
 
29
 
 
30
    void setBevelJoin() { m_joinStyle = Qt::BevelJoin; update(); }
 
31
    void setMiterJoin() { m_joinStyle = Qt::MiterJoin; update(); }
 
32
    void setRoundJoin() { m_joinStyle = Qt::RoundJoin; update(); }
 
33
 
 
34
    void setCurveMode() { m_pathMode = CurveMode; update(); }
 
35
    void setLineMode() { m_pathMode = LineMode; update(); }
 
36
 
 
37
    void setSolidLine() { m_penStyle = Qt::SolidLine; update(); }
 
38
    void setDashLine() { m_penStyle = Qt::DashLine; update(); }
 
39
    void setDotLine() { m_penStyle = Qt::DotLine; update(); }
 
40
    void setDashDotLine() { m_penStyle = Qt::DashDotLine; update(); }
 
41
    void setDashDotDotLine() { m_penStyle = Qt::DashDotDotLine; update(); }
 
42
    void setCustomDashLine() { m_penStyle = Qt::NoPen; update(); }
 
43
 
 
44
private:
 
45
    void initializePoints();
 
46
    void updatePoints();
 
47
 
 
48
    QBasicTimer m_timer;
 
49
 
 
50
    PathMode m_pathMode;
 
51
 
 
52
    bool m_wasAnimated;
 
53
 
 
54
    double m_penWidth;
 
55
    int m_pointCount;
 
56
    int m_pointSize;
 
57
    int m_activePoint;
 
58
    QVector<QPointF> m_points;
 
59
    QVector<QPointF> m_vectors;
 
60
 
 
61
    Qt::PenJoinStyle m_joinStyle;
 
62
    Qt::PenCapStyle m_capStyle;
 
63
 
 
64
    Qt::PenStyle m_penStyle;
 
65
};
 
66
 
 
67
class PathStrokeWidget : public QWidget
 
68
{
 
69
    Q_OBJECT
 
70
public:
 
71
    PathStrokeWidget();
 
72
 
 
73
private:
 
74
    PathStrokeRenderer *m_renderer;
 
75
};
 
76
 
 
77
#endif // PATHSTROKE_H