CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Loading...
Searching...
No Matches
ctkDoubleSpinBox.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Library: CTK
4
5 Copyright (c) Kitware Inc.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0.txt
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19=========================================================================*/
20
21#ifndef __ctkDoubleSpinBox_h
22#define __ctkDoubleSpinBox_h
23
24// Qt includes
25#include <QMetaType>
26#include <QString>
27#include <QWidget>
28
29class QDoubleSpinBox;
30class QEvent;
31class QKeyEvent;
32class QLineEdit;
33class QObject;
34
35// CTK includes
36#include "ctkWidgetsExport.h"
37
38class ctkDoubleSpinBoxPrivate;
39class ctkValueProxy;
40
45class CTK_WIDGETS_EXPORT ctkDoubleSpinBox : public QWidget
46{
47 Q_OBJECT
48 Q_ENUMS(SetMode)
49 Q_FLAGS(DecimalsOption DecimalsOptions)
50 Q_ENUMS(SizeHintPolicy)
51
52 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
53 Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
54 Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
55 Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
56 Q_PROPERTY(QString cleanText READ cleanText)
67 Q_PROPERTY(int decimals READ decimals WRITE setDecimals NOTIFY decimalsChanged)
72 Q_PROPERTY(DecimalsOptions decimalsOption READ decimalsOption WRITE setDecimalsOption)
73 Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
74 Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
75 Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
77 Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
80 Q_PROPERTY(SetMode setMode READ setMode WRITE setSetMode)
86 Q_PROPERTY(bool invertedControls READ invertedControls WRITE setInvertedControls)
90 Q_PROPERTY(SizeHintPolicy sizeHintPolicy READ sizeHintPolicy WRITE setSizeHintPolicy)
91
92public:
93
105 {
108 };
109
114 {
117 FixedDecimals = 0x000,
122 DecimalsByShortcuts = 0x001,
126 DecimalsByKey = 0x002,
129 DecimalsByValue = 0x004,
134 InsertDecimals = 0x008,
140 ReplaceDecimals = 0x010,
143 DecimalsAsMax = 0x020,
146 DecimalsAsMin = 0x040,
150 DecimalPointAlwaysVisible = 0x080
151 };
152 Q_DECLARE_FLAGS(DecimalsOptions, DecimalsOption)
153
155 {
157 SizeHintByValue
158 };
159
160 typedef QWidget Superclass;
161
164 explicit ctkDoubleSpinBox(QWidget* parent = 0);
165 explicit ctkDoubleSpinBox(ctkDoubleSpinBox::SetMode mode, QWidget* parent = 0);
167
170 double value() const;
171
174 double displayedValue() const;
175
181 void setDisplayedValue(double displayValue);
182
185 QString text() const;
186
189 QString cleanText() const;
190
192 Qt::Alignment alignment () const;
193 void setAlignment (Qt::Alignment flag);
194
196 void setFrame(bool frame);
197 bool hasFrame() const;
198
202 QString prefix() const;
203 void setPrefix(const QString &prefix);
204
208 QString suffix() const;
209 void setSuffix(const QString &suffix);
210
215 double singleStep() const;
216 void setSingleStep(double value);
217
219 double minimum() const;
220 void setMinimum(double min);
221 double maximum() const;
222 void setMaximum(double max);
223 void setRange(double min, double max);
224
228 int decimals() const;
229
233 double round(double value) const;
234
238 QDoubleSpinBox* spinBox() const;
239
242 QLineEdit* lineEdit()const;
243
247 void setSetMode(SetMode mode);
248
251 ctkDoubleSpinBox::DecimalsOptions decimalsOption();
252 void setDecimalsOption(ctkDoubleSpinBox::DecimalsOptions option);
253
259 void setInvertedControls(bool invertedControls);
260 bool invertedControls() const;
261
264 void setSizeHintPolicy(SizeHintPolicy newSizeHintPolicy);
268
279
282 virtual QSize sizeHint()const;
285 virtual QSize minimumSizeHint()const;
286
287public Q_SLOTS:
290 void setValue(double value);
291
294 void setValueIfDifferent(double value);
295
298 void setValueAlways(double value);
299
302 void stepUp();
303 void stepDown();
304
307 void setDecimals(int decimal);
308
309Q_SIGNALS:
312 void valueChanged(double);
313 void valueChanged(const QString &);
314
318
321
322protected:
323 ctkDoubleSpinBoxPrivate* const d_ptr;
324
326 virtual void keyPressEvent(QKeyEvent* event);
328 virtual bool eventFilter(QObject *obj, QEvent *event);
329
330 friend class ctkCoordinatesWidgetPrivate;
331private:
332 Q_DECLARE_PRIVATE(ctkDoubleSpinBox);
333 Q_DISABLE_COPY(ctkDoubleSpinBox);
334};
335
337Q_DECLARE_OPERATORS_FOR_FLAGS(ctkDoubleSpinBox::DecimalsOptions)
338
339#endif //__ctkDoubleSpinBox_h
Custom SpinBox The ctkDoubleSpinBox internaly uses a QDoubleSpinBox while it retain controls over it.
virtual QSize sizeHint() const
double value() const
QString prefix() const
void setRange(double min, double max)
QLineEdit * lineEdit() const
ctkDoubleSpinBox(ctkDoubleSpinBox::SetMode mode, QWidget *parent=0)
void setAlignment(Qt::Alignment flag)
bool hasFrame() const
QString text() const
QString suffix() const
void setInvertedControls(bool invertedControls)
ctkValueProxy * valueProxy() const
void setFrame(bool frame)
Set/Get the frame.
void setValueProxy(ctkValueProxy *proxy)
virtual ~ctkDoubleSpinBox()
ctkDoubleSpinBox::SetMode setMode() const
Set the spinbox mode when using a set*() method. /.
void valueChanged(const QString &)
int decimals() const
void setSizeHintPolicy(SizeHintPolicy newSizeHintPolicy)
virtual void keyPressEvent(QKeyEvent *event)
Reimplemented to support shortcuts.
double singleStep() const
double round(double value) const
double maximum() const
void setSetMode(SetMode mode)
ctkDoubleSpinBoxPrivate *const d_ptr
ctkDoubleSpinBox(QWidget *parent=0)
Qt::Alignment alignment() const
Set/Get the spinbox alignement.
QString cleanText() const
void setMaximum(double max)
void setMinimum(double min)
ctkDoubleSpinBox::DecimalsOptions decimalsOption()
bool invertedControls() const
void setSingleStep(double value)
void decimalsChanged(int)
Signal emitted when the decimals of the displayed are changed.
double displayedValue() const
void setValueIfDifferent(double value)
SizeHintPolicy sizeHintPolicy() const
void setDecimalsOption(ctkDoubleSpinBox::DecimalsOptions option)
void setValueAlways(double value)
void editingFinished()
virtual bool eventFilter(QObject *obj, QEvent *event)
Reimplemented to support shortcuts on the double spinbox.
void valueChanged(double)
void setSuffix(const QString &suffix)
void setValue(double value)
void setDisplayedValue(double displayValue)
void setDecimals(int decimal)
virtual QSize minimumSizeHint() const
void setPrefix(const QString &prefix)
QDoubleSpinBox * spinBox() const
double minimum() const
Set/Get the range of the spinbox. Default range is [0.0, 9.9].
Base class for value proxies. Value proxy allows to decouple the displayed value from the values acce...
Q_DECLARE_METATYPE(ctkDICOMPersonName)
Q_DECLARE_OPERATORS_FOR_FLAGS(ctkVTKDataSetModel::AttributeTypes)