• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KDEUI

knuminput.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002  *  Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
00003  *  Copyright (c) 2000 Dirk Mueller <mueller@kde.org>
00004  *  Copyright (c) 2002 Marc Mutz <mutz@kde.org>
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Library General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public License
00017  *  along with this library; see the file COPYING.LIB.  If not, write to
00018  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  *  Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #ifndef K_NUMINPUT_H
00023 #define K_NUMINPUT_H
00024 
00025 #include <kdeui_export.h>
00026 
00027 #include <QtGui/QWidget>
00028 #include <QtGui/QSpinBox>
00029 
00030 class QSlider;
00031 class QSpinBox;
00032 class QValidator;
00033 
00034 class KIntSpinBox;
00035 class KNumInputPrivate;
00036 class KLocalizedString;
00037 
00043 class KDEUI_EXPORT KNumInput : public QWidget
00044 {
00045     Q_OBJECT
00046     Q_PROPERTY( QString label READ label WRITE setLabel )
00047 public:
00054     explicit KNumInput(QWidget* parent=0);
00055 
00061 #ifndef KDE_NO_DEPRECATED
00062     KDE_CONSTRUCTOR_DEPRECATED KNumInput(QWidget *parent, KNumInput* below);
00063 #endif
00064 
00068     ~KNumInput();
00069 
00087     virtual void setLabel(const QString & label, Qt::Alignment a = Qt::AlignLeft | Qt::AlignTop);
00088 
00092     QString label() const;
00093 
00097     bool showSlider() const;
00098 
00105     void setSteps(int minor, int major);
00106 
00112     virtual QSize sizeHint() const;
00113 
00114 protected:
00119     QSlider *slider() const;
00120 
00126     void layout(bool deep);
00127 
00136     virtual void doLayout() = 0;
00137 
00138 private:
00139     friend class KNumInputPrivate;
00140     KNumInputPrivate * const d;
00141 
00142     Q_DISABLE_COPY(KNumInput)
00143 };
00144 
00145 /* ------------------------------------------------------------------------ */
00146 
00172 class KDEUI_EXPORT KIntNumInput : public KNumInput
00173 {
00174     Q_OBJECT
00175     Q_PROPERTY( int value READ value WRITE setValue NOTIFY valueChanged USER true )
00176     Q_PROPERTY( int minimum READ minimum WRITE setMinimum )
00177     Q_PROPERTY( int maximum READ maximum WRITE setMaximum )
00178     Q_PROPERTY( int singleStep READ singleStep WRITE setSingleStep )
00179     Q_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint )
00180     Q_PROPERTY( double relativeValue READ relativeValue WRITE setRelativeValue )
00181     Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
00182     Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
00183     Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
00184     Q_PROPERTY( bool sliderEnabled READ showSlider WRITE setSliderEnabled )
00185 
00186 public:
00191     explicit KIntNumInput(QWidget *parent=0);
00203     explicit KIntNumInput(int value, QWidget *parent=0,int base = 10);
00204 
00223 #ifndef KDE_NO_DEPRECATED
00224     KDE_CONSTRUCTOR_DEPRECATED KIntNumInput(KNumInput* below, int value, QWidget *parent, int base = 10);
00225 #endif
00226 
00232     virtual ~KIntNumInput();
00233 
00237     int value() const;
00238 
00242     double relativeValue() const;
00243 
00247     int referencePoint() const;
00248 
00253     QString suffix() const;
00258     QString prefix() const;
00263     QString specialValueText() const;
00264 
00273     void setRange(int min, int max, int singleStep=1);
00274 
00278 #ifndef KDE_NO_DEPRECATED
00279     KDE_DEPRECATED void setRange(int min, int max, int singleStep, bool slider);
00280 #endif
00281 
00286     void setSliderEnabled(bool enabled=true);
00287 
00291     void setMinimum(int min);
00295     int minimum() const;
00299     void setMaximum(int max);
00303     int maximum() const;
00304 
00308     int singleStep() const;
00309 
00313     void setSingleStep(int step);
00314 
00321     void setSpecialValueText(const QString& text);
00322 
00323     virtual void setLabel(const QString & label, Qt::Alignment a = Qt::AlignLeft | Qt::AlignTop);
00324 
00332     virtual QSize minimumSizeHint() const;
00333 
00334 public Q_SLOTS:
00338     void setValue(int);
00339 
00343     void setRelativeValue(double);
00344 
00348     void setReferencePoint(int);
00349 
00359     void setSuffix(const QString &suffix);
00360 
00367     void setSuffix(const KLocalizedString &suffix);
00368 
00376     void setPrefix(const QString &prefix);
00377 
00382     void setEditFocus( bool mark = true );
00383 
00384 Q_SIGNALS:
00389     void valueChanged(int);
00390 
00395     void relativeValueChanged(double);
00396 
00397 private Q_SLOTS:
00398     void spinValueChanged(int);
00399     void slotEmitRelativeValueChanged(int);
00400 
00401 protected:
00406     QSpinBox *spinBox() const;
00407 
00408     virtual void doLayout();
00409     void resizeEvent ( QResizeEvent * );
00410 
00411 private:
00412     void init(int value, int _base);
00413 
00414 private:
00415     class KIntNumInputPrivate;
00416     friend class KIntNumInputPrivate;
00417     KIntNumInputPrivate * const d;
00418 
00419     Q_DISABLE_COPY(KIntNumInput)
00420 };
00421 
00422 
00423 /* ------------------------------------------------------------------------ */
00424 
00425 class KDoubleLine;
00426 
00450 class KDEUI_EXPORT KDoubleNumInput : public KNumInput
00451 {
00452     Q_OBJECT
00453     Q_PROPERTY( double value READ value WRITE setValue NOTIFY valueChanged USER true )
00454     Q_PROPERTY( double minimum READ minimum WRITE setMinimum )
00455     Q_PROPERTY( double maximum READ maximum WRITE setMaximum )
00456     Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep )
00457     Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
00458     Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
00459     Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
00460     Q_PROPERTY( int decimals READ decimals WRITE setDecimals )
00461     Q_PROPERTY( double referencePoint READ referencePoint WRITE setReferencePoint )
00462     Q_PROPERTY( double relativeValue READ relativeValue  WRITE setRelativeValue )
00463     Q_PROPERTY( bool sliderEnabled READ showSlider WRITE setSliderEnabled )
00464     Q_PROPERTY( double exponentRatio READ exponentRatio WRITE setExponentRatio )
00465 
00466 public:
00471     explicit KDoubleNumInput(QWidget *parent = 0);
00472 
00483     KDoubleNumInput(double lower, double upper, double value, QWidget *parent=0,double singleStep=0.01,
00484             int precision=2);
00485 
00489     virtual ~KDoubleNumInput();
00490 
00491 
00513 #ifndef KDE_NO_DEPRECATED
00514     KDE_CONSTRUCTOR_DEPRECATED KDoubleNumInput(KNumInput* below,
00515             double lower, double upper, double value, QWidget *parent=0,double singleStep=0.02,
00516             int precision=2);
00517 #endif
00518 
00522     double value() const;
00523 
00528     QString suffix() const;
00529 
00534     QString prefix() const;
00535 
00540     int decimals() const;
00541 
00546     QString specialValueText() const;
00547 
00554     void setRange(double min, double max, double singleStep=1, bool slider=true);
00555 
00560     void setSliderEnabled(bool enabled);
00561 
00565     void setMinimum(double min);
00569     double minimum() const;
00573     void setMaximum(double max);
00577     double maximum() const;
00578 
00582     double singleStep() const;
00583 
00587     void setSingleStep(double singleStep);
00588 
00592     void setDecimals(int decimals);
00593 
00594 #ifndef KDE_NO_DEPRECATED
00595     KDE_DEPRECATED void setPrecision(int precision) { setDecimals(precision); }
00596 #endif
00597 
00601     double referencePoint() const;
00602 
00606     double relativeValue() const;
00607 
00614     void setSpecialValueText(const QString& text);
00615 
00616     virtual void setLabel(const QString & label, Qt::Alignment a = Qt::AlignLeft | Qt::AlignTop);
00617     virtual QSize minimumSizeHint() const;
00618 
00623     double exponentRatio() const;
00624 
00629     void setExponentRatio(double dbl);
00630 public Q_SLOTS:
00634     void setValue(double);
00635 
00639     void setRelativeValue(double);
00640 
00646     void setReferencePoint(double ref);
00647 
00655     void setSuffix(const QString &suffix);
00656 
00663     void setPrefix(const QString &prefix);
00664 
00665 Q_SIGNALS:
00670     void valueChanged(double);
00677     void relativeValueChanged(double);
00678 
00679 private Q_SLOTS:
00680     void sliderMoved(int);
00681     void spinBoxChanged(double);
00682     void slotEmitRelativeValueChanged(double);
00683 
00684 protected:
00685     virtual void doLayout();
00686     void resizeEvent ( QResizeEvent * );
00687 
00688     friend class KDoubleLine;
00689 private:
00690     void init(double value, double lower, double upper,
00691     double singleStep, int precision);
00692     double mapSliderToSpin(int) const;
00693     void updateLegacyMembers();
00694 
00695 private:
00696     class KDoubleNumInputPrivate;
00697     friend class KDoubleNumInputPrivate;
00698     KDoubleNumInputPrivate * const d;
00699 
00700     Q_DISABLE_COPY(KDoubleNumInput)
00701 };
00702 
00703 
00704 /* ------------------------------------------------------------------------ */
00705 
00717 class KDEUI_EXPORT KIntSpinBox : public QSpinBox
00718 {
00719     Q_OBJECT
00720     Q_PROPERTY( int base READ base WRITE setBase )
00721 
00722 public:
00723 
00731     explicit KIntSpinBox( QWidget *parent = 0 );
00732 
00746     KIntSpinBox(int lower, int upper, int singleStep, int value, QWidget *parent,int base = 10);
00747 
00751     virtual ~KIntSpinBox();
00752 
00756     void setBase(int base);
00760     int base() const;
00765     void setEditFocus(bool mark);
00766 
00773     void setSuffix(const KLocalizedString &suffix);
00774 
00775     using QSpinBox::setSuffix;
00776 
00777 protected:
00778 
00783     virtual QString textFromValue(int) const;
00784 
00789     virtual int valueFromText(const QString &text) const;
00790 
00791 private:
00792     class KIntSpinBoxPrivate;
00793     friend class KIntSpinBoxPrivate;
00794     KIntSpinBoxPrivate *const d;
00795 
00796     Q_DISABLE_COPY(KIntSpinBox)
00797     Q_PRIVATE_SLOT(d, void updateSuffix(int))
00798 };
00799 
00800 #endif // K_NUMINPUT_H

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal