• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kalarm/lib

spinbox2.h

Go to the documentation of this file.
00001 /*
00002  *  spinbox2.h  -  spin box with extra pair of spin buttons
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2008 by David Jarvie <djarvie@kde.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program 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
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef SPINBOX2_H
00022 #define SPINBOX2_H
00023 
00024 #include <QFrame>
00025 class QShowEvent;
00026 class QResizeEvent;
00027 class SpinMirror;
00028 class ExtraSpinBox;
00029 
00030 #include "spinbox.h"
00031 
00032 
00057 class SpinBox2 : public QFrame
00058 {
00059         Q_OBJECT
00060     public:
00064         explicit SpinBox2(QWidget* parent = 0);
00071         SpinBox2(int minValue, int maxValue, int pageStep = 1, QWidget* parent = 0);
00075         virtual void     setReadOnly(bool readOnly);
00077         bool             isReadOnly() const          { return mSpinbox->isReadOnly(); }
00079         void             setSelectOnStep(bool sel)   { mSpinbox->setSelectOnStep(sel); }
00083         void             setReverseWithLayout(bool reverse);
00085         bool             reverseButtons() const      { return mRightToLeft  &&  !mReverseWithLayout; }
00086 
00088         QString          text() const                { return mSpinbox->text(); }
00090         QString          prefix() const              { return mSpinbox->prefix(); }
00092         QString          suffix() const              { return mSpinbox->suffix(); }
00094         void             setPrefix(const QString& text)  { mSpinbox->setPrefix(text); }
00096         void             setSuffix(const QString& text)  { mSpinbox->setSuffix(text); }
00098         QString          cleanText() const           { return mSpinbox->cleanText(); }
00099 
00103         void             setSpecialValueText(const QString& text)  { mSpinbox->setSpecialValueText(text); }
00107         QString          specialValueText() const    { return mSpinbox->specialValueText(); }
00108 
00112         void             setWrapping(bool on);
00116         bool             wrapping() const            { return mSpinbox->wrapping(); }
00117 
00119         void             setAlignment(Qt::Alignment a) { mSpinbox->setAlignment(a); }
00121         void             setButtonSymbols(QSpinBox::ButtonSymbols);
00123         QSpinBox::ButtonSymbols buttonSymbols() const   { return mSpinbox->buttonSymbols(); }
00124 
00126         virtual QValidator::State validate(QString&, int& /*pos*/) const  { return QValidator::Acceptable; }
00127 
00128         virtual QSize    sizeHint() const;
00129         virtual QSize    minimumSizeHint() const;
00130 
00132         int              minimum() const             { return mMinValue; }
00134         int              maximum() const             { return mMaxValue; }
00136         virtual void     setMinimum(int val);
00138         virtual void     setMaximum(int val);
00140         void             setRange(int minValue, int maxValue)   { setMinimum(minValue);  setMaximum(maxValue); }
00142         int              value() const               { return mSpinbox->value(); }
00144         int              bound(int val) const;
00145 
00147         QRect            upRect() const              { return mSpinbox->upRect(); }
00149         QRect            downRect() const            { return mSpinbox->downRect(); }
00151         QRect            up2Rect() const;
00153         QRect            down2Rect() const;
00154 
00159         int              singleStep() const          { return mSingleStep; }
00164         int              singleShiftStep() const     { return mSingleShiftStep; }
00169         int              pageStep() const            { return mPageStep; }
00174         int              pageShiftStep() const       { return mPageShiftStep; }
00179         void             setSingleStep(int step);
00186         void             setSteps(int line, int page);
00193         void             setShiftSteps(int line, int page);
00194 
00198         void             addPage()                   { addValue(mPageStep); }
00202         void             subtractPage()              { addValue(-mPageStep); }
00206         void             addSingle()                 { addValue(mSingleStep); }
00210         void             subtractSingle()            { addValue(-mSingleStep); }
00212         void             addValue(int change)        { mSpinbox->addValue(change); }
00216         virtual void     stepBy(int increment)       { addValue(increment); }
00217 
00218     public slots:
00220         void             setValue(int val)           { mSpinbox->setValue(val); }
00224         virtual void     pageUp()                    { addValue(mPageStep); }
00228         virtual void     pageDown()                  { addValue(-mPageStep); }
00230         void             selectAll()                 { mSpinbox->selectAll(); }
00232         virtual void     setEnabled(bool enabled);
00233 
00234     signals:
00236         void             valueChanged(int value);
00238         void             valueChanged(const QString& valueText);
00239 
00240     protected:
00241         virtual QString  textFromValue(int v) const    { return mSpinbox->textFromVal(v); }
00242         virtual int      valueFromText(const QString& t) const  { return mSpinbox->valFromText(t); }
00243         virtual void     paintEvent(QPaintEvent*);
00244         virtual void     showEvent(QShowEvent*);
00245         virtual void     styleChange(QStyle&);
00246         virtual void     getMetrics() const;
00247 
00248         mutable int      wUpdown2;        // width of second spin widget
00249         mutable int      wSpinboxHide;    // width at left of 'mSpinbox' hidden by second spin widget
00250         mutable QPoint   mButtonPos;      // position of buttons inside mirror widget
00251 
00252     protected slots:
00253         virtual void     valueChange();
00254         virtual void     stepPage(int);
00255 
00256     private slots:
00257         void             updateMirrorButtons();
00258         void             updateMirrorFrame();
00259         void             paintTimer();
00260 
00261     private:
00262         void             init();
00263         void             arrange();
00264         void             updateMirror();
00265         bool             eventFilter(QObject*, QEvent*);
00266         void             spinboxResized(QResizeEvent*);
00267         void             setUpdown2Size();
00268         int              whichButton(QObject* spinWidget, const QPoint&);
00269         void             setShiftStepping(bool on);
00270 
00271         // Visible spin box class.
00272         // Declared here to allow use of mSpinBox in inline methods.
00273         class MainSpinBox : public SpinBox
00274         {
00275             public:
00276                 MainSpinBox(SpinBox2* sb2, QWidget* parent)
00277                                 : SpinBox(parent), owner(sb2) { }
00278                 MainSpinBox(int minValue, int maxValue, SpinBox2* sb2, QWidget* parent)
00279                                 : SpinBox(minValue, maxValue, parent), owner(sb2) { }
00280                 virtual QString textFromValue(int v) const  { return owner->textFromValue(v); }
00281                 virtual int     valueFromText(const QString& t) const
00282                                                             { return owner->valueFromText(t); }
00283                 QString         textFromVal(int v) const    { return SpinBox::textFromValue(v); }
00284                 int             valFromText(const QString& t) const
00285                                                             { return SpinBox::valueFromText(t); }
00286                 virtual int     shiftStepAdjustment(int oldValue, int shiftStep);
00287                 virtual QValidator::State validate(QString& text, int& pos) const
00288                                                             { return owner->validate(text, pos); }
00289             protected:
00290                 virtual void    resizeEvent(QResizeEvent* e) { owner->spinboxResized(e); SpinBox::resizeEvent(e); }
00291             private:
00292                 SpinBox2* owner;   // owner SpinBox2
00293         };
00294 
00295         enum { NO_BUTTON = -1, UP, DOWN, UP2, DOWN2 };
00296 
00297         static int       mRightToLeft;    // widgets are mirrored right to left
00298         QFrame*          mSpinboxFrame;   // contains the main spin box
00299         ExtraSpinBox*    mUpdown2;        // the extra pair of spin buttons
00300         MainSpinBox*     mSpinbox;        // the visible spin box
00301         SpinMirror*      mSpinMirror;     // image of the extra pair of spin buttons
00302         int              mMinValue;
00303         int              mMaxValue;
00304         int              mSingleStep;         // right button increment
00305         int              mSingleShiftStep;    // right button increment with shift pressed
00306         int              mPageStep;           // left button increment
00307         int              mPageShiftStep;      // left button increment with shift pressed
00308         bool             mReverseWithLayout;  // reverse button positions if reverse layout (default = true)
00309 
00310     friend class MainSpinBox;
00311 };
00312 
00313 #endif // SPINBOX2_H

kalarm/lib

Skip menu "kalarm/lib"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
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