Changeset View
Changeset View
Standalone View
Standalone View
libs/widgets/kis_double_parse_unit_spin_box.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2016 Laurent Valentin Jospin <laurent.valentin@famillejospin.ch> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | | ||||
19 | #ifndef KIS_DOUBLEPARSEUNITSPINBOX_H | ||||
20 | #define KIS_DOUBLEPARSEUNITSPINBOX_H | ||||
21 | | ||||
22 | #include <KoUnit.h> | ||||
23 | | ||||
24 | #include "kis_double_parse_spin_box.h" | ||||
25 | #include "kritawidgets_export.h" | ||||
26 | | ||||
27 | /*! | ||||
28 | * \brief The KisDoubleParseUnitSpinBox class is an evolution of the \see KoUnitDoubleSpinBox, but inherit from \see KisDoubleParseSpinBox to be able to parse math expressions. | ||||
29 | * | ||||
30 | * This class store the | ||||
31 | */ | ||||
32 | class KRITAWIDGETS_EXPORT KisDoubleParseUnitSpinBox : public KisDoubleParseSpinBox | ||||
33 | { | ||||
34 | | ||||
35 | Q_OBJECT | ||||
36 | | ||||
37 | public: | ||||
38 | KisDoubleParseUnitSpinBox(QWidget* parent = 0); | ||||
39 | ~KisDoubleParseUnitSpinBox(); | ||||
40 | | ||||
41 | /** | ||||
42 | * Set the new value in points which will then be converted to the current unit for display | ||||
43 | * @param newValue the new value | ||||
44 | * @see value() | ||||
45 | */ | ||||
46 | virtual void changeValue( double newValue ); | ||||
47 | /** | ||||
48 | * This spinbox shows the internal value after a conversion to the unit set here. | ||||
49 | */ | ||||
50 | virtual void setUnit(const KoUnit &unit); | ||||
51 | | ||||
52 | /// @return the current value, converted in points | ||||
53 | double value( ) const; | ||||
54 | | ||||
55 | /// Set minimum value in points. | ||||
56 | void setMinimum(double min); | ||||
57 | | ||||
58 | /// Set maximum value in points. | ||||
59 | void setMaximum(double max); | ||||
60 | | ||||
61 | /// Set step size in the current unit. | ||||
62 | void setLineStep(double step); | ||||
63 | | ||||
64 | /// Set step size in points. | ||||
65 | void setLineStepPt(double step); | ||||
66 | | ||||
67 | /// Set minimum, maximum value and the step size (all in points) | ||||
68 | void setMinMaxStep( double min, double max, double step ); | ||||
69 | | ||||
70 | /// reimplemented from superclass, will forward to KoUnitDoubleValidator | ||||
71 | virtual QValidator::State validate(QString &input, int &pos) const; | ||||
72 | | ||||
73 | /** | ||||
74 | * Transform the double in a nice text, using locale symbols | ||||
75 | * @param value the number as double | ||||
76 | * @return the resulting string | ||||
77 | */ | ||||
78 | virtual QString textFromValue( double value ) const; | ||||
79 | /** | ||||
80 | * Transfrom a string into a double, while taking care of locale specific symbols. | ||||
81 | * @param str the string to transform into a number | ||||
82 | * @return the value as double | ||||
83 | */ | ||||
84 | virtual double valueFromText( const QString& str ) const; | ||||
85 | | ||||
86 | Q_SIGNALS: | ||||
87 | /// emitted like valueChanged in the parent, but this one emits the point value | ||||
88 | void valueChangedPt( qreal ); | ||||
89 | | ||||
90 | | ||||
91 | private: | ||||
92 | class Private; | ||||
93 | Private * const d; | ||||
94 | | ||||
95 | private Q_SLOTS: | ||||
96 | // exists to do emits for valueChangedPt | ||||
97 | void privateValueChanged(); | ||||
98 | }; | ||||
99 | | ||||
100 | #endif // KIS_DOUBLEPARSEUNITSPINBOX_H |