kalarm/lib

spinbox2private.h
1/*
2 * spinbox2private.h - private classes for SpinBox2 (for TQt 3)
3 * Program: kalarm
4 * Copyright © 2005,2006,2008 by David Jarvie <djarvie@kde.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef SPINBOX2PRIVATE_H
22#define SPINBOX2PRIVATE_H
23
24#include <tqcanvas.h>
25#include "spinbox.h"
26
27
28/*=============================================================================
29= Class ExtraSpinBox
30* Extra pair of spin buttons for SpinBox2.
31* The widget is actually a whole spin box, but only the buttons are displayed.
32=============================================================================*/
33
34class ExtraSpinBox : public SpinBox
35{
36 TQ_OBJECT
37
38 public:
39 explicit ExtraSpinBox(TQWidget* parent, const char* name = 0)
40 : SpinBox(parent, name), mNewStylePending(false) { }
41 ExtraSpinBox(int minValue, int maxValue, int step, TQWidget* parent, const char* name = 0)
42 : SpinBox(minValue, maxValue, step, parent, name), mNewStylePending(false) { }
43 signals:
44 void styleUpdated();
45 protected:
46 virtual void paintEvent(TQPaintEvent*);
47 virtual void styleChange(TQStyle&) { mNewStylePending = true; }
48 private:
49 bool mNewStylePending; // style has changed, but not yet repainted
50};
51
52
53/*=============================================================================
54= Class SpinMirror
55* Displays the left-to-right mirror image of a pair of spin buttons, for use
56* as the extra spin buttons in a SpinBox2. All mouse clicks are passed on to
57* the real extra pair of spin buttons for processing.
58* Mirroring in this way allows styles with rounded corners to display correctly.
59=============================================================================*/
60
61class SpinMirror : public TQCanvasView
62{
63 TQ_OBJECT
64
65 public:
66 explicit SpinMirror(SpinBox*, TQFrame* spinFrame, TQWidget* parent = 0, const char* name = 0);
67 void setReadOnly(bool ro) { mReadOnly = ro; }
68 bool isReadOnly() const { return mReadOnly; }
69 void setNormalButtons(const TQPixmap&);
70 void redraw(const TQPixmap&);
71
72 public slots:
73 virtual void resize(int w, int h);
74 void redraw();
75
76 protected:
77 virtual void contentsMousePressEvent(TQMouseEvent* e) { contentsMouseEvent(e); }
78 virtual void contentsMouseReleaseEvent(TQMouseEvent* e) { contentsMouseEvent(e); }
79 virtual void contentsMouseMoveEvent(TQMouseEvent* e) { contentsMouseEvent(e); }
80 virtual void contentsMouseDoubleClickEvent(TQMouseEvent* e) { contentsMouseEvent(e); }
81 virtual void contentsWheelEvent(TQWheelEvent*);
82 virtual bool event(TQEvent*);
83
84 private:
85 void contentsMouseEvent(TQMouseEvent*);
86
87 SpinBox* mSpinbox; // spinbox whose spin buttons are being mirrored
88 TQFrame* mSpinFrame; // widget containing mSpinbox's spin buttons
89 TQWidget* mSpinWidget; // spin buttons in mSpinbox
90 TQPixmap mNormalButtons; // image of spin buttons in unpressed state
91 bool mReadOnly; // value cannot be changed
92};
93
94#endif // SPINBOX2PRIVATE_H
Spin box with accelerated shift key stepping and read-only option.
Definition: spinbox.h:43