• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • 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     KDE_CONSTRUCTOR_DEPRECATED KNumInput(QWidget *parent, KNumInput* below);
00062     
00066     ~KNumInput();
00067 
00085     virtual void setLabel(const QString & label, Qt::Alignment a = Qt::AlignLeft | Qt::AlignTop);
00086 
00090     QString label() const;
00091 
00095     bool showSlider() const;
00096 
00103     void setSteps(int minor, int major);
00104 
00110     virtual QSize sizeHint() const;
00111 
00112 protected:
00117     QSlider *slider() const;
00118       
00124     void layout(bool deep);
00125 
00134     virtual void doLayout() = 0;
00135 
00136 private:
00137     friend class KNumInputPrivate;
00138     KNumInputPrivate * const d;
00139     
00140     Q_DISABLE_COPY(KNumInput)
00141 };
00142 
00143 /* ------------------------------------------------------------------------ */
00144 
00170 class KDEUI_EXPORT KIntNumInput : public KNumInput
00171 {
00172     Q_OBJECT
00173     Q_PROPERTY( int value READ value WRITE setValue USER true )
00174     Q_PROPERTY( int minimum READ minimum WRITE setMinimum )
00175     Q_PROPERTY( int maximum READ maximum WRITE setMaximum )
00176     Q_PROPERTY( int singleStep READ singleStep WRITE setSingleStep )
00177     Q_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint )
00178     Q_PROPERTY( double relativeValue READ relativeValue WRITE setRelativeValue )
00179     Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
00180     Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
00181     Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
00182     Q_PROPERTY( bool sliderEnabled READ showSlider WRITE setSliderEnabled )
00183 
00184 public:
00189     explicit KIntNumInput(QWidget *parent=0);
00201     explicit KIntNumInput(int value, QWidget *parent=0,int base = 10);
00202 
00221     KDE_CONSTRUCTOR_DEPRECATED KIntNumInput(KNumInput* below, int value, QWidget *parent, int base = 10);
00222 
00228     virtual ~KIntNumInput();
00229 
00233     int value() const;
00234 
00238     double relativeValue() const;
00239 
00243     int referencePoint() const;
00244 
00249     QString suffix() const;
00254     QString prefix() const;
00259     QString specialValueText() const;
00260 
00269     void setRange(int min, int max, int singleStep=1);
00270 
00274     KDE_DEPRECATED void setRange(int min, int max, int singleStep, bool slider);
00275 
00280     void setSliderEnabled(bool enabled=true);
00281 
00285     void setMinimum(int min);
00289     int minimum() const;
00293     void setMaximum(int max);
00297     int maximum() const;
00298 
00302     int singleStep() const;
00303 
00307     void setSingleStep(int step);
00308 
00315     void setSpecialValueText(const QString& text);
00316 
00317     virtual void setLabel(const QString & label, Qt::Alignment a = Qt::AlignLeft | Qt::AlignTop);
00318 
00326     virtual QSize minimumSizeHint() const;
00327     
00328 public Q_SLOTS:
00332     void setValue(int);
00333 
00337     void setRelativeValue(double);
00338 
00342     void setReferencePoint(int);
00343 
00353     void setSuffix(const QString &suffix);
00354 
00361     void setSuffix(const KLocalizedString &suffix);
00362 
00370     void setPrefix(const QString &prefix);
00371 
00376     void setEditFocus( bool mark = true );
00377 
00378 Q_SIGNALS:
00383     void valueChanged(int);
00384 
00389     void relativeValueChanged(double);
00390 
00391 private Q_SLOTS:
00392     void spinValueChanged(int);
00393     void slotEmitRelativeValueChanged(int);
00394 
00395 protected:
00400     QSpinBox *spinBox() const;
00401       
00402     virtual void doLayout();
00403     void resizeEvent ( QResizeEvent * );
00404 
00405 private:
00406     void init(int value, int _base);
00407 
00408 private:
00409     class KIntNumInputPrivate;
00410     friend class KIntNumInputPrivate;
00411     KIntNumInputPrivate * const d;
00412     
00413     Q_DISABLE_COPY(KIntNumInput)
00414 };
00415 
00416 
00417 /* ------------------------------------------------------------------------ */
00418 
00419 class KDoubleLine;
00420 
00448 class KDEUI_EXPORT KDoubleNumInput : public KNumInput
00449 {
00450     Q_OBJECT
00451     Q_PROPERTY( double value READ value WRITE setValue USER true )
00452     Q_PROPERTY( double minimum READ minimum WRITE setMinimum )
00453     Q_PROPERTY( double maximum READ maximum WRITE setMaximum )
00454     Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep )
00455     Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
00456     Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
00457     Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
00458     Q_PROPERTY( int decimals READ decimals WRITE setDecimals )
00459     Q_PROPERTY( double referencePoint READ referencePoint WRITE setReferencePoint )
00460     Q_PROPERTY( double relativeValue READ relativeValue  WRITE setRelativeValue )
00461     Q_PROPERTY( bool sliderEnabled READ showSlider WRITE setSliderEnabled )
00462     Q_PROPERTY( double exponentRatio READ exponentRatio WRITE setExponentRatio )
00463 
00464 public:
00469     explicit KDoubleNumInput(QWidget *parent = 0);
00470 
00481     KDoubleNumInput(double lower, double upper, double value, QWidget *parent=0,double singleStep=0.01,
00482             int precision=2);
00483 
00487     virtual ~KDoubleNumInput();
00488 
00489 
00511     KDE_CONSTRUCTOR_DEPRECATED KDoubleNumInput(KNumInput* below,
00512             double lower, double upper, double value, QWidget *parent=0,double singleStep=0.02,
00513             int precision=2);
00514 
00518     double value() const;
00519 
00524     QString suffix() const;
00525 
00530     QString prefix() const;
00531 
00536     int decimals() const;
00537 
00542     QString specialValueText() const;
00543 
00550     void setRange(double min, double max, double singleStep=1, bool slider=true);
00551 
00556     void setSliderEnabled(bool enabled);
00557 
00561     void setMinimum(double min);
00565     double minimum() const;
00569     void setMaximum(double max);
00573     double maximum() const;
00574 
00578     double singleStep() const;
00579 
00583     void setSingleStep(double singleStep);
00584 
00588     void setDecimals(int decimals);
00589 
00590     KDE_DEPRECATED void setPrecision(int precision) { setDecimals(precision); }
00591 
00595     double referencePoint() const;
00596 
00600     double relativeValue() const;
00601 
00608     void setSpecialValueText(const QString& text);
00609 
00610     virtual void setLabel(const QString & label, Qt::Alignment a = Qt::AlignLeft | Qt::AlignTop);
00611     virtual QSize minimumSizeHint() const;
00612 
00617     double exponentRatio() const;
00618 
00623     void setExponentRatio(double dbl);
00624 public Q_SLOTS:
00628     void setValue(double);
00629 
00633     void setRelativeValue(double);
00634 
00640     void setReferencePoint(double ref);
00641 
00649     void setSuffix(const QString &suffix);
00650 
00657     void setPrefix(const QString &prefix);
00658 
00659 Q_SIGNALS:
00664     void valueChanged(double);
00671     void relativeValueChanged(double);
00672 
00673 private Q_SLOTS:
00674     void sliderMoved(int);
00675     void spinBoxChanged(double);
00676     void slotEmitRelativeValueChanged(double);
00677 
00678 protected:
00679     virtual void doLayout();
00680     void resizeEvent ( QResizeEvent * );
00681 
00682     friend class KDoubleLine;
00683 private:
00684     void init(double value, double lower, double upper,
00685     double singleStep, int precision);
00686     double mapSliderToSpin(int) const;
00687     void updateLegacyMembers();
00688 
00689 private:
00690     class KDoubleNumInputPrivate;
00691     friend class KDoubleNumInputPrivate;
00692     KDoubleNumInputPrivate * const d;
00693 
00694     Q_DISABLE_COPY(KDoubleNumInput)
00695 };
00696 
00697 
00698 /* ------------------------------------------------------------------------ */
00699 
00709 class KDEUI_EXPORT KIntSpinBox : public QSpinBox
00710 {
00711     Q_OBJECT
00712     Q_PROPERTY( int base READ base WRITE setBase )
00713 
00714 public:
00715 
00723     explicit KIntSpinBox( QWidget *parent = 0 );
00724 
00738     KIntSpinBox(int lower, int upper, int singleStep, int value, QWidget *parent,int base = 10);
00739 
00743     virtual ~KIntSpinBox();
00744 
00748     void setBase(int base);
00752     int base() const;
00757     void setEditFocus(bool mark);
00758 
00765     void setSuffix(const KLocalizedString &suffix);
00766 
00767     using QSpinBox::setSuffix;
00768 
00769 protected:
00770 
00775     virtual QString textFromValue(int) const;
00776 
00781     virtual int valueFromText(const QString &text) const;
00782 
00783 private:
00784     class KIntSpinBoxPrivate;
00785     friend class KIntSpinBoxPrivate;
00786     KIntSpinBoxPrivate *const d;
00787     
00788     Q_DISABLE_COPY(KIntSpinBox)
00789     Q_PRIVATE_SLOT(d, void updateSuffix(int))
00790 };
00791 
00792 #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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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