1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8                           gradienteditor  -  description
9                              -------------------
10     begin                : Mit Mai 26 2004
11     copyright            : (C) 2004 by Franz Schmid
12     email                : Franz.Schmid@altmuehlnet.de
13  ***************************************************************************/
14 
15 /***************************************************************************
16  *                                                                         *
17  *   This program is free software; you can redistribute it and/or modify  *
18  *   it under the terms of the GNU General Public License as published by  *
19  *   the Free Software Foundation; either version 2 of the License, or     *
20  *   (at your option) any later version.                                   *
21  *                                                                         *
22  ***************************************************************************/
23 
24 #ifndef DASHEDITOR_H
25 #define DASHEDITOR_H
26 
27 #include <QElapsedTimer>
28 #include <QFrame>
29 #include <QHBoxLayout>
30 #include <QLayout>
31 #include <QList>
32 #include <QMouseEvent>
33 #include <QPaintEvent>
34 #include <QVBoxLayout>
35 
36 class QDoubleSpinBox;
37 class QEvent;
38 class QLabel;
39 
40 #include "scribusapi.h"
41 #include "vgradient.h"
42 
43 class SCRIBUS_API DashPreview : public QFrame
44 {
45 	Q_OBJECT
46 
47 public:
48 	DashPreview(QWidget *pa);
~DashPreview()49 	~DashPreview() {};
50 
51 	void paintEvent(QPaintEvent *e) override;
52 	void mousePressEvent(QMouseEvent *m) override;
53 	void mouseReleaseEvent(QMouseEvent *) override;
54 	void mouseMoveEvent(QMouseEvent *m) override;
55 	void leaveEvent(QEvent*) override;
56 	void enterEvent(QEvent*) override;
57 
dashValues()58 	const QVector<double>& dashValues() const { return m_dashValues; }
59 	void setDashValues(const QVector<double>& vals);
60 
61 public slots:
62 	void setActStep(double t);
63 
64 private:
65 	bool  m_onlySelect { true };
66 	bool  m_outside { false };
67 	bool  m_mousePressed { false };
68 	int   m_currentStop { 0 };
69 	QElapsedTimer m_moveTimer;
70 
71 	QVector<double> m_dashValues;
72 	QList<double>   m_stops;
73 
74 signals:
75 	void currStep(double);
76 	void dashChanged();
77 };
78 
79 class SCRIBUS_API DashEditor : public QFrame
80 {
81 	Q_OBJECT
82 
83 public:
84 	DashEditor(QWidget *pa);
~DashEditor()85 	~DashEditor() {};
86 
87 	void setDashValues(QVector<double> vals, double linewidth, double offset);
88 	QVector<double> getDashValues(double linewidth);
89 
90 	DashPreview *Preview;
91 	QLabel *Desc;
92 	QDoubleSpinBox *Position;
93 	QLabel *Desc2;
94 	QDoubleSpinBox *Offset;
95 
96 protected:
97 	void changeEvent(QEvent *e) override;
98 
99 public slots:
100 	void setPos(double);
101 	void languageChange();
102 
103 signals:
104 	void dashChanged();
105 };
106 
107 #endif
108 
109