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 bool eventFilter(QObject *o, QEvent *e);
00045         QLineEdit * editor () const { return KIntSpinBox::editor(); }
00046 };
00047 
00048 class KOPROPERTY_EXPORT IntEdit : public Widget
00049 {
00050     Q_OBJECT
00051 
00052     public:
00053         IntEdit(Property *property, QWidget *parent=0, const char *name=0);
00054         virtual ~IntEdit();
00055 
00056         virtual QVariant value() const;
00057         virtual void setValue(const QVariant &value, bool emitChange=true);
00058         virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
00059 
00060     protected:
00061         virtual void setReadOnlyInternal(bool readOnly);
00062         void updateSpinWidgets();
00063 
00064     protected slots:
00065         void slotValueChanged(int value);
00066 
00067     private:
00068         IntSpinBox  *m_edit;
00069 };
00070 
00071 // Double editor
00072 
00073 class DoubleSpinBox : public KDoubleSpinBox
00074 {
00075     Q_OBJECT
00076 
00077     public:
00079         DoubleSpinBox(double lower, double upper, double step, double value=0, 
00080             int precision=2, DoubleEdit *parent=0);
00081         virtual ~DoubleSpinBox() {;}
00082 
00083         virtual bool eventFilter(QObject *o, QEvent *e);
00084         QLineEdit * editor () const { return KDoubleSpinBox::editor(); }
00085 
00086     public slots:
00087         virtual void setValue ( double value );
00088 };
00089 
00090 class KOPROPERTY_EXPORT DoubleEdit : public Widget
00091 {
00092     Q_OBJECT
00093 
00094     public:
00095         DoubleEdit(Property *property, QWidget *parent=0, const char *name=0);
00096         virtual ~DoubleEdit();
00097 
00098         virtual QVariant value() const;
00099         virtual void setValue(const QVariant &value, bool emitChange=true);
00100         virtual void drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value);
00101 
00102     protected:
00103         virtual void setReadOnlyInternal(bool readOnly);
00104         void updateSpinWidgets();
00105 
00106     protected slots:
00107         void slotValueChanged(double value);
00108 
00109     private:
00110         DoubleSpinBox  *m_edit;
00111 };
00112 
00113 }
00114 
00115 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys