1 /*
2  * DQt - D bindings for the Qt Toolkit
3  *
4  * GNU Lesser General Public License Usage
5  * This file may be used under the terms of the GNU Lesser
6  * General Public License version 3 as published by the Free Software
7  * Foundation and appearing in the file LICENSE.LGPL3 included in the
8  * packaging of this file. Please review the following information to
9  * ensure the GNU Lesser General Public License version 3 requirements
10  * will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
11  */
12 module qt.gui.validator;
13 extern(C++):
14 
15 import qt.config;
16 import qt.helpers;
17 version(QT_NO_VALIDATOR){}else
18 {
19     import qt.core.locale;
20     import qt.core.object;
21     import qt.core.regularexpression;
22     import qt.core.string;
23 }
24 
25 /+ #if QT_CONFIG(regularexpression)
26 #endif +/
27 
28 
29 version(QT_NO_VALIDATOR){}else
30 {
31 
32 extern(C++, class) struct QValidatorPrivate;
33 
34 /// Binding for C++ class [QValidator](https://doc.qt.io/qt-6/qvalidator.html).
35 abstract class /+ Q_GUI_EXPORT +/ QValidator : QObject
36 {
37     mixin(Q_OBJECT);
38 public:
39     mixin(changeItaniumMangling(q{mangleConstructorBaseObject}, q{
40     /+ explicit +/this(QObject  parent = null);
41     }));
42     ~this();
43 
44     enum State {
45         Invalid,
46         Intermediate,
47         Acceptable
48     }
49     /+ Q_ENUM(State) +/
50 
51     final void setLocale(ref const(QLocale) locale);
52     final QLocale locale() const;
53 
54     /+ virtual +/ abstract State validate(ref QString , ref int ) const;
55     /+ virtual +/ void fixup(ref QString ) const;
56 
57 /+ Q_SIGNALS +/public:
58     @QSignal final void changed();
59 
60 protected:
61     mixin(changeItaniumMangling(q{mangleConstructorBaseObject}, q{
62     this(ref QObjectPrivate d, QObject parent);
63     }));
64     mixin(changeItaniumMangling(q{mangleConstructorBaseObject}, q{
65     this(ref QValidatorPrivate d, QObject parent);
66     }));
67 
68 private:
69     /+ Q_DISABLE_COPY(QValidator) +/
70     /+ Q_DECLARE_PRIVATE(QValidator) +/
71     mixin(CREATE_CONVENIENCE_WRAPPERS);
72 }
73 
74 /// Binding for C++ class [QIntValidator](https://doc.qt.io/qt-6/qintvalidator.html).
75 class /+ Q_GUI_EXPORT +/ QIntValidator : QValidator
76 {
77     mixin(Q_OBJECT);
78     /+ Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
79     Q_PROPERTY(int top READ top WRITE setTop NOTIFY topChanged) +/
80 
81 public:
82     /+ explicit +/this(QObject  parent = null);
83     this(int bottom, int top, QObject parent = null);
84     ~this();
85 
86     override QValidator.State validate(ref QString , ref int ) const;
87     override void fixup(ref QString input) const;
88 
89     final void setBottom(int);
90     final void setTop(int);
91     final void setRange(int bottom, int top);
92 
93     final int bottom() const { return b; }
94     final int top() const { return t; }
95 /+ Q_SIGNALS +/public:
96     @QSignal final void bottomChanged(int bottom);
97     @QSignal final void topChanged(int top);
98 
99 private:
100     /+ Q_DISABLE_COPY(QIntValidator) +/
101 
102     int b;
103     int t;
104     mixin(CREATE_CONVENIENCE_WRAPPERS);
105 }
106 
107 extern(C++, class) struct QDoubleValidatorPrivate;
108 
109 /// Binding for C++ class [QDoubleValidator](https://doc.qt.io/qt-6/qdoublevalidator.html).
110 class /+ Q_GUI_EXPORT +/ QDoubleValidator : QValidator
111 {
112     mixin(Q_OBJECT);
113     /+ Q_PROPERTY(double bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
114     Q_PROPERTY(double top READ top WRITE setTop NOTIFY topChanged)
115     Q_PROPERTY(int decimals READ decimals WRITE setDecimals NOTIFY decimalsChanged)
116     Q_PROPERTY(Notation notation READ notation WRITE setNotation NOTIFY notationChanged) +/
117 
118 public:
119     /+ explicit +/this(QObject  parent = null);
120     this(double bottom, double top, int decimals, QObject parent = null);
121     ~this();
122 
123     enum Notation {
124         StandardNotation,
125         ScientificNotation
126     }
127     /+ Q_ENUM(Notation) +/
128     override QValidator.State validate(ref QString , ref int ) const;
129 
130     final void setRange(double bottom, double top, int decimals = 0);
131     final void setBottom(double);
132     final void setTop(double);
133     final void setDecimals(int);
134     final void setNotation(Notation);
135 
136     final double bottom() const { return b; }
137     final double top() const { return t; }
138     final int decimals() const { return dec; }
139     final Notation notation() const;
140 
141 /+ Q_SIGNALS +/public:
142     @QSignal final void bottomChanged(double bottom);
143     @QSignal final void topChanged(double top);
144     @QSignal final void decimalsChanged(int decimals);
145     @QSignal final void notationChanged(Notation notation);
146 
147 private:
148     /+ Q_DECLARE_PRIVATE(QDoubleValidator) +/
149     /+ Q_DISABLE_COPY(QDoubleValidator) +/
150 
151     double b;
152     double t;
153     int dec;
154     mixin(CREATE_CONVENIENCE_WRAPPERS);
155 }
156 
157 /+ #if QT_CONFIG(regularexpression) +/
158 
159 extern(C++, class) struct QRegularExpressionValidatorPrivate;
160 
161 /// Binding for C++ class [QRegularExpressionValidator](https://doc.qt.io/qt-6/qregularexpressionvalidator.html).
162 class /+ Q_GUI_EXPORT +/ QRegularExpressionValidator : QValidator
163 {
164     mixin(Q_OBJECT);
165     /+ Q_PROPERTY(QRegularExpression regularExpression READ regularExpression WRITE setRegularExpression NOTIFY regularExpressionChanged) +/
166 
167 public:
168     /+ explicit +/this(QObject parent = null);
169     /+ explicit +/this(ref const(QRegularExpression) re, QObject parent = null);
170     ~this();
171 
172     override QValidator.State validate(ref QString input, ref int pos) const;
173 
174     final QRegularExpression regularExpression() const;
175 
176 public /+ Q_SLOTS +/:
177     @QSlot final void setRegularExpression(ref const(QRegularExpression) re);
178 
179 /+ Q_SIGNALS +/public:
180     @QSignal final void regularExpressionChanged(ref const(QRegularExpression) re);
181 
182 private:
183     /+ Q_DISABLE_COPY(QRegularExpressionValidator) +/
184     /+ Q_DECLARE_PRIVATE(QRegularExpressionValidator) +/
185     mixin(CREATE_CONVENIENCE_WRAPPERS);
186 }
187 
188 /+ #endif +/ // QT_CONFIG(regularexpression)
189 
190 }
191 
192 version(QT_NO_VALIDATOR)
193 {
194 extern(C++, class) struct QValidator;
195 }
196 
197