chalk

kis_int_spinbox.h
1/*
2 * Copyright (c) 2006 Boudewijn Rempt <boud@valdyas.org>
3 * Copyright (c) 2006 Casper Boemann <cbr@boemann.dk>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20#ifndef KIS_INT_SPINBOX_H_
21#define KIS_INT_SPINBOX_H_
22
23#include <tqwidget.h>
24#include <tqspinbox.h>
25#include <tqslider.h>
26#include <tqpopupmenu.h>
27
28#include <knumvalidator.h>
29
30class TQLabel;
31class TQLineEdit;
32class TQLayout;
33class TQValidator;
34
35class KisPopupSlider : public TQPopupMenu {
36 TQ_OBJECT
37
38
39public:
40
41 KisPopupSlider(int minValue, int maxValue, int pageStep, int value, TQt::Orientation orientation, TQWidget * parent, const char * name = 0)
42 : TQPopupMenu(parent, name)
43 {
44 m_slider = new TQSlider(minValue, maxValue, pageStep, value, orientation, this, name);
45 //m_slider->setTracking(false);
46 insertItem(m_slider);
47 connect(m_slider, TQ_SIGNAL(valueChanged(int)), TQ_SIGNAL(valueChanged(int)));
48 }
49 void setTickInterval(int i) { m_slider->setTickInterval(i); }
50 void setRange(int minValue, int maxValue) { m_slider->setRange(minValue, maxValue); }
51 void setValue(int val) { m_slider->setValue(val); }
52 void setTickmarks(TQSlider::TickSetting t) { m_slider->setTickmarks(t); }
53 int lineStep () const{ return m_slider->lineStep(); }
54 int minValue () const{ return m_slider->minValue(); }
55 int maxValue () const{ return m_slider->maxValue(); }
56 int value () const{ return m_slider->value(); }
57 TQSlider *m_slider;
58
59signals:
60 void valueChanged(int);
61
62};
63
74class KisIntSpinbox : public TQWidget
75{
76
77 TQ_OBJECT
78
79 TQ_PROPERTY( int value READ value WRITE setValue )
80 TQ_PROPERTY( int minValue READ minValue WRITE setMinValue )
81 TQ_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
82
83public:
84
92 KisIntSpinbox(TQWidget *parent=0, const char *name=0);
104 KisIntSpinbox(const TQString & label, int value, TQWidget* parent=0, const char *name=0);
105
111 virtual ~KisIntSpinbox();
112
116 int value() const;
117
123 void setRange(int min, int max, int step=1);
127 void setMinValue(int min);
131 int minValue() const;
135 void setMaxValue(int max);
139 int maxValue() const;
140
147 void setSteps(int minor, int major);
148
149 void setLabel(const TQString & label);
150
151public slots:
155 void setValue(int);
156
157
158 void spinboxValueChanged(int val);
159 void sliderValueChanged(int val);
160
161 void slotTimeout();
162
163signals:
164
171
178 void valueChanged(int value, bool withSlider);
179
185 void finishedChanging(int previous, int value);
186
187private slots:
188 void slotAboutToShow();
189 void slotAboutToHide();
190
191private:
192 void init(int val);
193
194private:
195
196 class KisIntSpinboxPrivate;
197 KisIntSpinboxPrivate *d;
198};
199
200#endif
An input widget for integer numbers, consisting of a spinbox and a dropdown slider.
void valueChanged(int value, bool withSlider)
Emitted every time the value changes (by calling setValue() or by user interaction).
int minValue() const
void setSteps(int minor, int major)
Sets the spacing of tickmarks for the slider.
void valueChanged(int value)
Emitted every time the value changes (by calling setValue() or by user interaction).
void finishedChanging(int previous, int value)
Emitted after the slider has been hidden, if the value was changed while it was shown.
int maxValue() const
virtual ~KisIntSpinbox()
Destructor.
void setRange(int min, int max, int step=1)
void setValue(int)
Sets the value of the control.
void setMinValue(int min)
Sets the minimum value.
void setMaxValue(int max)
Sets the maximum value.