kalarm/lib

spinbox2private.h

00001 /*
00002  *  spinbox2private.h  -  private classes for SpinBox2 (for Qt 3)
00003  *  Program:  kalarm
00004  *  Copyright (c) 2005 by David Jarvie <software@astrojar.org.uk>
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 SPINBOX2PRIVATE_H
00022 #define SPINBOX2PRIVATE_H
00023 
00024 #include <qcanvas.h>
00025 #include "spinbox.h"
00026 
00027 
00028 /*=============================================================================
00029 = Class ExtraSpinBox
00030 * Extra pair of spin buttons for SpinBox2.
00031 * The widget is actually a whole spin box, but only the buttons are displayed.
00032 =============================================================================*/
00033 
00034 class ExtraSpinBox : public SpinBox
00035 {
00036         Q_OBJECT
00037     public:
00038         ExtraSpinBox(QWidget* parent, const char* name = 0)
00039                      : SpinBox(parent, name), mNewStylePending(false) { }
00040         ExtraSpinBox(int minValue, int maxValue, int step, QWidget* parent, const char* name = 0)
00041                      : SpinBox(minValue, maxValue, step, parent, name), mNewStylePending(false) { }
00042     signals:
00043         void         styleUpdated();
00044     protected:
00045         virtual void paintEvent(QPaintEvent*);
00046         virtual void styleChange(QStyle&)    { mNewStylePending = true; }
00047     private:
00048         bool         mNewStylePending;  // style has changed, but not yet repainted
00049 };
00050 
00051 
00052 /*=============================================================================
00053 = Class SpinMirror
00054 * Displays the left-to-right mirror image of a pair of spin buttons, for use
00055 * as the extra spin buttons in a SpinBox2. All mouse clicks are passed on to
00056 * the real extra pair of spin buttons for processing.
00057 * Mirroring in this way allows styles with rounded corners to display correctly.
00058 =============================================================================*/
00059 
00060 class SpinMirror : public QCanvasView
00061 {
00062         Q_OBJECT
00063     public:
00064         SpinMirror(SpinBox*, QWidget* parent = 0, const char* name = 0);
00065         void         setReadOnly(bool ro)        { mReadOnly = ro; }
00066         bool         isReadOnly() const          { return mReadOnly; }
00067         void         setNormalButtons(const QPixmap&);
00068         void         redraw(const QPixmap&);
00069 
00070     public slots:
00071         virtual void resize(int w, int h);
00072 
00073     protected:
00074         virtual void contentsMousePressEvent(QMouseEvent* e)        { contentsMouseEvent(e); }
00075         virtual void contentsMouseReleaseEvent(QMouseEvent* e)      { contentsMouseEvent(e); }
00076         virtual void contentsMouseMoveEvent(QMouseEvent* e)         { contentsMouseEvent(e); }
00077         virtual void contentsMouseDoubleClickEvent(QMouseEvent* e)  { contentsMouseEvent(e); }
00078 
00079     private:
00080         void         contentsMouseEvent(QMouseEvent*);
00081 
00082         SpinBox*     mSpinbox;        // spinbox whose spin buttons are being mirrored
00083         QWidget*     mSpinWidget;     // spin buttons in mSpinbox
00084         QPixmap      mNormalButtons;  // image of spin buttons in unpressed state
00085         bool         mReadOnly;       // value cannot be changed
00086 };
00087 
00088 #endif // SPINBOX2PRIVATE_H
KDE Home | KDE Accessibility Home | Description of Access Keys