| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# knuminput.h

    00001 /*
    00002  * knuminput.h
    00003  *
    00004  *  Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
    00005  *  Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org>
    00006  *  Copyright (c) 2002 Marc Mutz <mutz@kde.org>
    00007  *
    00008  *  Requires the Qt widget libraries, available at no cost at
    00009  *  http://www.troll.no/
    00010  *
    00011  *  This library is free software; you can redistribute it and/or
    00012  *  modify it under the terms of the GNU Library General Public
    00013  *  License as published by the Free Software Foundation; either
    00014  *  version 2 of the License, or (at your option) any later version.
    00015  *
    00016  *  This library is distributed in the hope that it will be useful,
    00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00019  *  Library General Public License for more details.
    00020  *
    00021  *  You should have received a copy of the GNU Library General Public License
    00022  *  along with this library; see the file COPYING.LIB.  If not, write to
    00023  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00024  *  Boston, MA 02111-1307, USA.
    00025  */
    00026
    00027 #ifndef K_NUMINPUT_H
    00028 #define K_NUMINPUT_H
    00029
    00030 #include <qwidget.h>
    00031 #include <qspinbox.h>
    00032 #include <kdelibs_export.h>
    00033
    00034 class QLabel;
    00035 class QSlider;
    00036 class QLineEdit;
    00037 class QLayout;
    00038 class QValidator;
    00039
    00040 class KIntSpinBox;
    00041
    00042 /* ------------------------------------------------------------------------ */
    00043
    00049 class KDEUI_EXPORT KNumInput : public QWidget
    00050 {
    00051     Q_OBJECT
    00052     Q_PROPERTY( QString label READ label WRITE setLabel )
    00053 public:
    00059     KNumInput(QWidget* parent=0, const char* name=0);
    00060
    00066     KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0);
    00067     ~KNumInput();
    00068
    00087     virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop);
    00088
    00092     QString label() const;
    00093
    00098     bool showSlider() const { return m_slider; }
    00099
    00106     void setSteps(int minor, int major);
    00107
    00112     QSizePolicy sizePolicy() const;
    00113
    00119     virtual QSize sizeHint() const;
    00120
    00121 protected:
    00127     void layout(bool deep);
    00128
    00137     virtual void doLayout() = 0;
    00138
    00139     KNumInput* m_prev, *m_next;
    00140     int m_colw1, m_colw2;
    00141
    00142     QLabel*  m_label;
    00143     QSlider* m_slider;
    00144     QSize    m_sizeSlider, m_sizeLabel;
    00145
    00146     int      m_alignment;
    00147
    00148 private:
    00149     void init();
    00150
    00151 protected:
    00152     virtual void virtual_hook( int id, void* data );
    00153 private:
    00154     class KNumInputPrivate;
    00155     KNumInputPrivate *d;
    00156 };
    00157
    00158 /* ------------------------------------------------------------------------ */
    00159
    00187 class KDEUI_EXPORT KIntNumInput : public KNumInput
    00188 {
    00189     Q_OBJECT
    00190     Q_PROPERTY( int value READ value WRITE setValue )
    00191     Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
    00192     Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
    00193     Q_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint )
    00194     Q_PROPERTY( double relativeValue READ relativeValue WRITE setRelativeValue )
    00195     Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
    00196     Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
    00197     Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
    00198
    00199 public:
    00204     KIntNumInput(QWidget *parent=0, const char *name=0);
    00217     KIntNumInput(int value, QWidget* parent=0, int base = 10, const char *name=0);
    00218
    00236     KIntNumInput(KNumInput* below, int value, QWidget* parent=0, int base = 10, const char *name=0);
    00237
    00243     virtual ~KIntNumInput();
    00244
    00248     int value() const;
    00249
    00254     double relativeValue() const;
    00255
    00260     int referencePoint() const;
    00261
    00266     QString suffix() const;
    00271     QString prefix() const;
    00276     QString specialValueText() const;
    00277
    00284     void setRange(int min, int max, int step=1, bool slider=true);
    00288     void setMinValue(int min);
    00292     int minValue() const;
    00296     void setMaxValue(int max);
    00300     int maxValue() const;
    00301
    00308     void setSpecialValueText(const QString& text);
    00309
    00310     virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop);
    00311
    00319     virtual QSize minimumSizeHint() const;
    00320
    00321 public slots:
    00325     void setValue(int);
    00326
    00331     void setRelativeValue(double);
    00332
    00337     void setReferencePoint(int);
    00338
    00348     void setSuffix(const QString &suffix);
    00349
    00357     void setPrefix(const QString &prefix);
    00358
    00363     void setEditFocus( bool mark = true );
    00364
    00365 signals:
    00370     void valueChanged(int);
    00371
    00377     void relativeValueChanged(double);
    00378
    00379 private slots:
    00380     void spinValueChanged(int);
    00381     void slotEmitRelativeValueChanged(int);
    00382
    00383 protected:
    00384     virtual void doLayout();
    00385     void resizeEvent ( QResizeEvent * );
    00386
    00387     KIntSpinBox* m_spin;
    00388     QSize        m_sizeSpin;
    00389
    00390 private:
    00391     void init(int value, int _base);
    00392
    00393 protected:
    00394     virtual void virtual_hook( int id, void* data );
    00395 private:
    00396     class KIntNumInputPrivate;
    00397     KIntNumInputPrivate *d;
    00398 };
    00399
    00400
    00401 /* ------------------------------------------------------------------------ */
    00402
    00403 class KDoubleLine;
    00404
    00432 class KDEUI_EXPORT KDoubleNumInput : public KNumInput
    00433 {
    00434     Q_OBJECT
    00435     Q_PROPERTY( double value READ value WRITE setValue )
    00436     Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
    00437     Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
    00438     Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
    00439     Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
    00440     Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
    00441     Q_PROPERTY( int precision READ precision WRITE setPrecision )
    00442     Q_PROPERTY( double referencePoint READ referencePoint WRITE setReferencePoint )
    00443     Q_PROPERTY( double relativeValue READ relativeValue  WRITE setRelativeValue )
    00444
    00445 public:
    00450     KDoubleNumInput(QWidget *parent=0, const char *name=0);
    00451
    00460     KDoubleNumInput(double value, QWidget *parent=0, const char *name=0) KDE_DEPRECATED;
    00461
    00474     KDoubleNumInput(double lower, double upper, double value, double step=0.01,
    00475             int precision=2, QWidget *parent=0, const char *name=0);
    00476
    00480     virtual ~KDoubleNumInput();
    00481
    00493     KDoubleNumInput(KNumInput* below, double value, QWidget* parent=0, const char* name=0) KDE_DEPRECATED;
    00494
    00516     KDoubleNumInput(KNumInput* below,
    00517             double lower, double upper, double value, double step=0.02,
    00518             int precision=2, QWidget *parent=0, const char *name=0);
    00519
    00523     double value() const;
    00524
    00529     QString suffix() const;
    00530
    00535     QString prefix() const;
    00536
    00541     int precision() const;
    00542
    00547     QString specialValueText() const { return m_specialvalue; }
    00548
    00555     void setRange(double min, double max, double step=1, bool slider=true);
    00559     void setMinValue(double min);
    00563     double minValue() const;
    00567     void setMaxValue(double max);
    00571     double maxValue() const;
    00572
    00576     void setPrecision(int precision);
    00577
    00582     double referencePoint() const;
    00583
    00588     double relativeValue() const;
    00589
    00596     void setSpecialValueText(const QString& text);
    00597
    00598     virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop);
    00599     virtual QSize minimumSizeHint() const;
    00600     virtual bool eventFilter(QObject*, QEvent*);
    00601
    00602 public slots:
    00606     void setValue(double);
    00607
    00612     void setRelativeValue(double);
    00613
    00620     void setReferencePoint(double ref);
    00621
    00629     void setSuffix(const QString &suffix);
    00630
    00637     void setPrefix(const QString &prefix);
    00638
    00639 signals:
    00644     void valueChanged(double);
    00652     void relativeValueChanged(double);
    00653
    00654 private slots:
    00655     void sliderMoved(int);
    00656     void slotEmitRelativeValueChanged(double);
    00657
    00658 protected:
    00659     virtual void doLayout();
    00660     void resizeEvent ( QResizeEvent * );
    00661
    00662     virtual void resetEditBox();
    00663
    00664     // ### no longer used, remove when BIC allowed
    00665     KDoubleLine*   edit;
    00666
    00667     bool     m_range;
    00668     double   m_lower, m_upper, m_step;
    00669     // ### end no longer used
    00670
    00671     QSize    m_sizeEdit;
    00672
    00673     friend class KDoubleLine;
    00674 private:
    00675     void init(double value, double lower, double upper,
    00676           double step, int precision);
    00677     double mapSliderToSpin(int) const;
    00678     void updateLegacyMembers();
    00679     // ### no longer used, remove when BIC allowed:
    00680     QString  m_specialvalue, m_prefix, m_suffix;
    00681     double   m_value;
    00682     short    m_precision;
    00683     // ### end remove when BIC allowed
    00684
    00685 protected:
    00686     virtual void virtual_hook( int id, void* data );
    00687 private:
    00688     class KDoubleNumInputPrivate;
    00689     KDoubleNumInputPrivate *d;
    00690 };
    00691
    00692
    00693 /* ------------------------------------------------------------------------ */
    00694
    00704 class KDEUI_EXPORT KIntSpinBox : public QSpinBox
    00705 {
    00706     Q_OBJECT
    00707     Q_PROPERTY( int base READ base WRITE setBase )
    00708
    00709 public:
    00710
    00718     KIntSpinBox( QWidget *parent=0, const char *name=0);
    00719
    00734     KIntSpinBox(int lower, int upper, int step, int value, int base = 10,
    00735                 QWidget* parent = 0, const char* name = 0);
    00736
    00740     virtual ~KIntSpinBox();
    00741
    00745     void setBase(int base);
    00749     int base() const;
    00754     void setEditFocus(bool mark);
    00755
    00756 protected:
    00757
    00762     virtual QString mapValueToText(int);
    00763
    00768     virtual int mapTextToValue(bool*);
    00769
    00770 private:
    00771     int val_base;
    00772 protected:
    00773     virtual void virtual_hook( int id, void* data );
    00774 private:
    00775     class KIntSpinBoxPrivate;
    00776     KIntSpinBoxPrivate *d;
    00777 };
    00778
    00779
    00780 /* --------------------------------------------------------------------------- */
    00781
    00834 class KDEUI_EXPORT KDoubleSpinBox : public QSpinBox {
    00835   Q_OBJECT
    00836   Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers )
    00837   Q_OVERRIDE( double maxValue READ maxValue WRITE setMaxValue )
    00838   Q_OVERRIDE( double minValue READ minValue WRITE setMinValue )
    00839   Q_OVERRIDE( double lineStep READ lineStep WRITE setLineStep )
    00840   Q_OVERRIDE( double value READ value WRITE setValue )
    00841   Q_PROPERTY( int precision READ precision WRITE setPrecision )
    00842
    00843 public:
    00847   KDoubleSpinBox( QWidget * parent=0, const char * name=0 );
    00848
    00852   KDoubleSpinBox( double lower, double upper, double step, double value,
    00853           int precision=2, QWidget * parent=0, const char * name=0 );
    00854
    00855   virtual ~KDoubleSpinBox();
    00856
    00858   bool acceptLocalizedNumbers() const;
    00859
    00862   virtual void setAcceptLocalizedNumbers( bool accept );
    00863
    00867   void setRange( double lower, double upper, double step=0.01, int precision=2 );
    00868
    00871   int precision() const;
    00872
    00876   void setPrecision( int precision );
    00877
    00890   virtual void setPrecision( int precision, bool force );
    00891
    00893   double value() const;
    00894
    00896   double minValue() const;
    00897
    00904   void setMinValue( double value );
    00905
    00907   double maxValue() const;
    00908
    00915   void setMaxValue( double value );
    00916
    00918   double lineStep() const;
    00919
    00924   void setLineStep( double step );
    00925
    00927   void setValidator( const QValidator * );
    00928
    00929 signals:
    00931   void valueChanged( double value );
    00932
    00933 public slots:
    00937   virtual void setValue( double value );
    00938
    00939 protected:
    00940   virtual QString mapValueToText(int);
    00941   virtual int mapTextToValue(bool*);
    00942
    00943 protected slots:
    00944   void slotValueChanged( int value );
    00945
    00946 protected:
    00947  virtual void virtual_hook( int id, void* data );
    00948 private:
    00949   typedef QSpinBox base;
    00950   void updateValidator();
    00951   int maxPrecision() const;
    00952
    00953   class Private;
    00954   Private * d;
    00955 };
    00956
    00957 #endif // K_NUMINPUT_H

This file is part of the documentation for kdeui Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:20:19 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003