lib

spinbox.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2004  Alexander Dymo <cloudtemple@mskat.net>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KPROPERTY_SPINBOX_H
00022 #define KPROPERTY_SPINBOX_H
00023 
00024 #include <knuminput.h>
00025 
00026 #include "../widget.h"
00027 
00028 namespace KoProperty {
00029 
00030 class IntEdit;
00031 class DoubleEdit;
00032 
00033 // Int Editor
00034 
00035 class IntSpinBox : public KIntSpinBox
00036 {
00037     Q_OBJECT
00038 
00039     public:
00040         IntSpinBox(int lower, int upper, int step, int value, int base=10, 
00041             IntEdit *parent=0, const char *name=0);
00042         virtual ~IntSpinBox() {;}
00043 
00044         virtual void setValue(const QVariant &value);
00045 
00046         virtual bool eventFilter(QObject *o, QEvent *e);
00047         QLineEdit * editor () const { return KIntSpinBox::editor(); }
00048 };
00049 
00050 class KOPROPERTY_EXPORT IntEdit : public Widget
00051 {
00052     Q_OBJECT
00053 
00054     public:
00055         IntEdit(Property *property, QWidget *parent=0, const char *name=0);
00056         virtual ~IntEdit();
00057 
00058         virtual QVariant value() const;
00059         virtual void setValue(const QVariant &value, bool emitChange=true);
00060         virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
00061 
00062     protected:
00063         virtual void setReadOnlyInternal(bool readOnly);
00064         void updateSpinWidgets();
00065 
00066     protected slots:
00067         void slotValueChanged(int value);
00068 
00069     private:
00070         IntSpinBox  *m_edit;
00071 };
00072 
00073 // Double editor
00074 
00075 class DoubleSpinBox : public KDoubleSpinBox
00076 {
00077     Q_OBJECT
00078 
00079     public:
00081         DoubleSpinBox(double lower, double upper, double step, double value=0, 
00082             int precision=2, DoubleEdit *parent=0);
00083         virtual ~DoubleSpinBox() {;}
00084 
00085         virtual bool eventFilter(QObject *o, QEvent *e);
00086         QLineEdit * editor () const { return KDoubleSpinBox::editor(); }
00087 
00088     public slots:
00089         virtual void setValue( const QVariant& value );
00090 };
00091 
00092 class KOPROPERTY_EXPORT DoubleEdit : public Widget
00093 {
00094     Q_OBJECT
00095 
00096     public:
00097         DoubleEdit(Property *property, QWidget *parent=0, const char *name=0);
00098         virtual ~DoubleEdit();
00099 
00100         virtual QVariant value() const;
00101         virtual void setValue(const QVariant &value, bool emitChange=true);
00102         virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
00103 
00104     protected:
00105         virtual void setReadOnlyInternal(bool readOnly);
00106         void updateSpinWidgets();
00107 
00108     protected slots:
00109         void slotValueChanged(double value);
00110 
00111     private:
00112         DoubleSpinBox  *m_edit;
00113 };
00114 
00115 }
00116 
00117 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys