knuminput.h
/*
* knuminput.h
*
* Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
* Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org>
* Copyright (c) 2002 Marc Mutz <mutz@kde.org>
*
* Requires the Qt widget libraries, available at no cost at
* http://www.troll.no/
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef K_NUMINPUT_H
#define K_NUMINPUT_H
#include <qwidget.h>
#include <qspinbox.h>
#include <kdelibs_export.h>
class QLabel;
class QSlider;
class QLineEdit;
class QLayout;
class QValidator;
class KIntSpinBox;
/* ------------------------------------------------------------------------ */
class KDEUI_EXPORT KNumInput : public QWidget
{
Q_OBJECT
Q_PROPERTY( QString label READ label WRITE setLabel )
public:
KNumInput(QWidget* parent=0, const char* name=0);
KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0);
~KNumInput();
virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop);
QString label() const;
bool showSlider() const { return m_slider; }
void setSteps(int minor, int major);
QSizePolicy sizePolicy() const;
virtual QSize sizeHint() const;
protected:
void layout(bool deep);
virtual void doLayout() = 0;
KNumInput* m_prev, *m_next;
int m_colw1, m_colw2;
QLabel* m_label;
QSlider* m_slider;
QSize m_sizeSlider, m_sizeLabel;
int m_alignment;
private:
void init();
protected:
virtual void virtual_hook( int id, void* data );
private:
class KNumInputPrivate;
KNumInputPrivate *d;
};
/* ------------------------------------------------------------------------ */
class KDEUI_EXPORT KIntNumInput : public KNumInput
{
Q_OBJECT
Q_PROPERTY( int value READ value WRITE setValue )
Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
Q_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint )
Q_PROPERTY( double relativeValue READ relativeValue WRITE setRelativeValue )
Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
public:
KIntNumInput(QWidget *parent=0, const char *name=0);
KIntNumInput(int value, QWidget* parent=0, int base = 10, const char *name=0);
KIntNumInput(KNumInput* below, int value, QWidget* parent=0, int base = 10, const char *name=0);
virtual ~KIntNumInput();
int value() const;
double relativeValue() const;
int referencePoint() const;
QString suffix() const;
QString prefix() const;
QString specialValueText() const;
void setRange(int min, int max, int step=1, bool slider=true);
void setMinValue(int min);
int minValue() const;
void setMaxValue(int max);
int maxValue() const;
void setSpecialValueText(const QString& text);
virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop);
virtual QSize minimumSizeHint() const;
public slots:
void setValue(int);
void setRelativeValue(double);
void setReferencePoint(int);
void setSuffix(const QString &suffix);
void setPrefix(const QString &prefix);
void setEditFocus( bool mark = true );
signals:
void valueChanged(int);
void relativeValueChanged(double);
private slots:
void spinValueChanged(int);
void slotEmitRelativeValueChanged(int);
protected:
virtual void doLayout();
void resizeEvent ( QResizeEvent * );
KIntSpinBox* m_spin;
QSize m_sizeSpin;
private:
void init(int value, int _base);
protected:
virtual void virtual_hook( int id, void* data );
private:
class KIntNumInputPrivate;
KIntNumInputPrivate *d;
};
/* ------------------------------------------------------------------------ */
class KDoubleLine;
class KDEUI_EXPORT KDoubleNumInput : public KNumInput
{
Q_OBJECT
Q_PROPERTY( double value READ value WRITE setValue )
Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
Q_PROPERTY( int precision READ precision WRITE setPrecision )
Q_PROPERTY( double referencePoint READ referencePoint WRITE setReferencePoint )
Q_PROPERTY( double relativeValue READ relativeValue WRITE setRelativeValue )
public:
KDoubleNumInput(QWidget *parent=0, const char *name=0);
KDoubleNumInput(double value, QWidget *parent=0, const char *name=0) KDE_DEPRECATED;
KDoubleNumInput(double lower, double upper, double value, double step=0.01,
int precision=2, QWidget *parent=0, const char *name=0);
virtual ~KDoubleNumInput();
KDoubleNumInput(KNumInput* below, double value, QWidget* parent=0, const char* name=0) KDE_DEPRECATED;
KDoubleNumInput(KNumInput* below,
double lower, double upper, double value, double step=0.02,
int precision=2, QWidget *parent=0, const char *name=0);
double value() const;
QString suffix() const;
QString prefix() const;
int precision() const;
QString specialValueText() const { return m_specialvalue; }
void setRange(double min, double max, double step=1, bool slider=true);
void setMinValue(double min);
double minValue() const;
void setMaxValue(double max);
double maxValue() const;
void setPrecision(int precision);
double referencePoint() const;
double relativeValue() const;
void setSpecialValueText(const QString& text);
virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop);
virtual QSize minimumSizeHint() const;
virtual bool eventFilter(QObject*, QEvent*);
public slots:
void setValue(double);
void setRelativeValue(double);
void setReferencePoint(double ref);
void setSuffix(const QString &suffix);
void setPrefix(const QString &prefix);
signals:
void valueChanged(double);
void relativeValueChanged(double);
private slots:
void sliderMoved(int);
void slotEmitRelativeValueChanged(double);
protected:
virtual void doLayout();
void resizeEvent ( QResizeEvent * );
virtual void resetEditBox();
// ### no longer used, remove when BIC allowed
KDoubleLine* edit;
bool m_range;
double m_lower, m_upper, m_step;
// ### end no longer used
QSize m_sizeEdit;
friend class KDoubleLine;
private:
void init(double value, double lower, double upper,
double step, int precision);
double mapSliderToSpin(int) const;
void updateLegacyMembers();
// ### no longer used, remove when BIC allowed:
QString m_specialvalue, m_prefix, m_suffix;
double m_value;
short m_precision;
// ### end remove when BIC allowed
protected:
virtual void virtual_hook( int id, void* data );
private:
class KDoubleNumInputPrivate;
KDoubleNumInputPrivate *d;
};
/* ------------------------------------------------------------------------ */
class KDEUI_EXPORT KIntSpinBox : public QSpinBox
{
Q_OBJECT
Q_PROPERTY( int base READ base WRITE setBase )
public:
KIntSpinBox( QWidget *parent=0, const char *name=0);
KIntSpinBox(int lower, int upper, int step, int value, int base = 10,
QWidget* parent = 0, const char* name = 0);
virtual ~KIntSpinBox();
void setBase(int base);
int base() const;
void setEditFocus(bool mark);
protected:
virtual QString mapValueToText(int);
virtual int mapTextToValue(bool*);
private:
int val_base;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KIntSpinBoxPrivate;
KIntSpinBoxPrivate *d;
};
/* --------------------------------------------------------------------------- */
class KDEUI_EXPORT KDoubleSpinBox : public QSpinBox {
Q_OBJECT
Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers )
Q_OVERRIDE( double maxValue READ maxValue WRITE setMaxValue )
Q_OVERRIDE( double minValue READ minValue WRITE setMinValue )
Q_OVERRIDE( double lineStep READ lineStep WRITE setLineStep )
Q_OVERRIDE( double value READ value WRITE setValue )
Q_PROPERTY( int precision READ precision WRITE setPrecision )
public:
KDoubleSpinBox( QWidget * parent=0, const char * name=0 );
KDoubleSpinBox( double lower, double upper, double step, double value,
int precision=2, QWidget * parent=0, const char * name=0 );
virtual ~KDoubleSpinBox();
bool acceptLocalizedNumbers() const;
virtual void setAcceptLocalizedNumbers( bool accept );
void setRange( double lower, double upper, double step=0.01, int precision=2 );
int precision() const;
void setPrecision( int precision );
virtual void setPrecision( int precision, bool force );
double value() const;
double minValue() const;
void setMinValue( double value );
double maxValue() const;
void setMaxValue( double value );
double lineStep() const;
void setLineStep( double step );
void setValidator( const QValidator * );
signals:
void valueChanged( double value );
public slots:
virtual void setValue( double value );
protected:
virtual QString mapValueToText(int);
virtual int mapTextToValue(bool*);
protected slots:
void slotValueChanged( int value );
protected:
virtual void virtual_hook( int id, void* data );
private:
typedef QSpinBox base;
void updateValidator();
int maxPrecision() const;
class Private;
Private * d;
};
#endif // K_NUMINPUT_H
KDoubleNumInput::specialValueText
QString specialValueText() const
Definition: knuminput.h:547
KNumInput::showSlider
bool showSlider() const
Definition: knuminput.h:98
KDoubleSpinBox
A spin box for fractional numbers.
Definition: knuminput.h:834
KNumInput
You need to inherit from this class if you want to implement K*NumInput for a different variable type...
Definition: knuminput.h:49
KIntSpinBox
A QSpinBox with support for arbitrary base numbers.
Definition: knuminput.h:704
KDoubleNumInput
An input control for real numbers, consisting of a spinbox and a slider.
Definition: knuminput.h:432
KNumInput::doLayout
virtual void doLayout()=0
You need to overwrite this method and implement your layout calculations there.
KNumInput::setLabel
virtual void setLabel(const QString &label, int a=AlignLeft|AlignTop)
Sets the text and alignment of the main description label.
Definition: knuminput.cpp:101
KIntNumInput
An input widget for integer numbers, consisting of a spinbox and a slider.
Definition: knuminput.h:187

KDE Home | KDE Accessibility Home | Description of Access Keys