krita

kis_int_spinbox.h

00001 /*
00002  *  Copyright (c) 2006 Boudewijn Rempt <boud@valdyas.org>
00003  *  Copyright (c) 2006 Casper Boemann <cbr@boemann.dk>
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 #ifndef KIS_INT_SPINBOX_H_
00021 #define KIS_INT_SPINBOX_H_
00022 
00023 #include <qwidget.h>
00024 #include <qspinbox.h>
00025 #include <qslider.h>
00026 #include <qpopupmenu.h>
00027 
00028 #include <knumvalidator.h>
00029 
00030 class QLabel;
00031 class QLineEdit;
00032 class QLayout;
00033 class QValidator;
00034 
00035 class KisPopupSlider : public QPopupMenu {
00036     Q_OBJECT
00037 
00038 public:
00039 
00040     KisPopupSlider(int minValue, int maxValue, int pageStep, int value, Orientation orientation, QWidget * parent, const char * name = 0) 
00041         : QPopupMenu(parent, name)
00042     {
00043         m_slider = new QSlider(minValue, maxValue, pageStep, value, orientation, this, name);
00044         //m_slider->setTracking(false);
00045         insertItem(m_slider);
00046         connect(m_slider, SIGNAL(valueChanged(int)), SIGNAL(valueChanged(int)));
00047     }
00048     void setTickInterval(int i) { m_slider->setTickInterval(i); }
00049     void setRange(int minValue, int maxValue) { m_slider->setRange(minValue, maxValue); }
00050     void setValue(int val) { m_slider->setValue(val); }
00051     void setTickmarks(QSlider::TickSetting t) { m_slider->setTickmarks(t); }
00052     int lineStep () const{ return m_slider->lineStep(); }
00053     int minValue () const{ return m_slider->minValue(); }
00054     int maxValue () const{ return m_slider->maxValue(); }
00055     int value () const{ return m_slider->value(); }
00056     QSlider *m_slider;
00057 
00058 signals:
00059     void valueChanged(int);
00060 
00061 };
00062 
00073 class KisIntSpinbox : public QWidget
00074 {
00075 
00076     Q_OBJECT
00077     Q_PROPERTY( int value READ value WRITE setValue )
00078     Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
00079     Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
00080 
00081 public:
00082 
00090     KisIntSpinbox(QWidget *parent=0, const char *name=0);
00102     KisIntSpinbox(const QString & label, int value, QWidget* parent=0, const char *name=0);
00103 
00109     virtual ~KisIntSpinbox();
00110     
00114     int value() const;
00115 
00121     void setRange(int min, int max, int step=1);
00125     void setMinValue(int min);
00129     int minValue() const;
00133     void setMaxValue(int max);
00137     int maxValue() const;
00138 
00145     void setSteps(int minor, int major);
00146 
00147     void setLabel(const QString & label);
00148 
00149 public slots:
00153     void setValue(int);
00154 
00155 
00156     void spinboxValueChanged(int val);
00157     void sliderValueChanged(int val);
00158 
00159     void slotTimeout();
00160     
00161 signals:
00162 
00168     void valueChanged(int value);
00169 
00176     void valueChanged(int value, bool withSlider);
00177 
00183     void finishedChanging(int previous, int value);
00184 
00185 private slots:
00186     void slotAboutToShow();
00187     void slotAboutToHide();
00188 
00189 private:
00190     void init(int val);
00191 
00192 private:
00193 
00194     class KisIntSpinboxPrivate;
00195     KisIntSpinboxPrivate *d;
00196 };
00197 
00198 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys