kalarm/lib

spinbox2private.h

00001 /*
00002  *  spinbox2private.h  -  private classes for SpinBox2 (for TQt 3)
00003  *  Program:  kalarm
00004  *  Copyright © 2005,2006,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 SPINBOX2PRIVATE_H
00022 #define SPINBOX2PRIVATE_H
00023 
00024 #include <tqcanvas.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   TQ_OBJECT
00038     public:
00039         explicit ExtraSpinBox(TQWidget* parent, const char* name = 0)
00040                      : SpinBox(parent, name), mNewStylePending(false) { }
00041         ExtraSpinBox(int minValue, int maxValue, int step, TQWidget* parent, const char* name = 0)
00042                      : SpinBox(minValue, maxValue, step, parent, name), mNewStylePending(false) { }
00043     signals:
00044         void         styleUpdated();
00045     protected:
00046         virtual void paintEvent(TQPaintEvent*);
00047         virtual void styleChange(TQStyle&)    { mNewStylePending = true; }
00048     private:
00049         bool         mNewStylePending;  // style has changed, but not yet repainted
00050 };
00051 
00052 
00053 /*=============================================================================
00054 = Class SpinMirror
00055 * Displays the left-to-right mirror image of a pair of spin buttons, for use
00056 * as the extra spin buttons in a SpinBox2. All mouse clicks are passed on to
00057 * the real extra pair of spin buttons for processing.
00058 * Mirroring in this way allows styles with rounded corners to display correctly.
00059 =============================================================================*/
00060 
00061 class SpinMirror : public TQCanvasView
00062 {
00063         Q_OBJECT
00064   TQ_OBJECT
00065     public:
00066         explicit SpinMirror(SpinBox*, TQFrame* spinFrame, TQWidget* parent = 0, const char* name = 0);
00067         void         setReadOnly(bool ro)        { mReadOnly = ro; }
00068         bool         isReadOnly() const          { return mReadOnly; }
00069         void         setNormalButtons(const TQPixmap&);
00070         void         redraw(const TQPixmap&);
00071 
00072     public slots:
00073         virtual void resize(int w, int h);
00074         void         redraw();
00075 
00076     protected:
00077         virtual void contentsMousePressEvent(TQMouseEvent* e)        { contentsMouseEvent(e); }
00078         virtual void contentsMouseReleaseEvent(TQMouseEvent* e)      { contentsMouseEvent(e); }
00079         virtual void contentsMouseMoveEvent(TQMouseEvent* e)         { contentsMouseEvent(e); }
00080         virtual void contentsMouseDoubleClickEvent(TQMouseEvent* e)  { contentsMouseEvent(e); }
00081         virtual void contentsWheelEvent(TQWheelEvent*);
00082         virtual bool event(TQEvent*);
00083 
00084     private:
00085         void         contentsMouseEvent(TQMouseEvent*);
00086 
00087         SpinBox*     mSpinbox;        // spinbox whose spin buttons are being mirrored
00088         TQFrame*      mSpinFrame;      // widget containing mSpinbox's spin buttons
00089         TQWidget*     mSpinWidget;     // spin buttons in mSpinbox
00090         TQPixmap      mNormalButtons;  // image of spin buttons in unpressed state
00091         bool         mReadOnly;       // value cannot be changed
00092 };
00093 
00094 #endif // SPINBOX2PRIVATE_H