You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
koffice/chalk/ui/kis_int_spinbox.h

201 lines
5.5 KiB

/*
* Copyright (c) 2006 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2006 Casper Boemann <cbr@boemann.dk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KIS_INT_SPINBOX_H_
#define KIS_INT_SPINBOX_H_
#include <tqwidget.h>
#include <tqspinbox.h>
#include <tqslider.h>
#include <tqpopupmenu.h>
#include <knumvalidator.h>
class TQLabel;
class TQLineEdit;
class TQLayout;
class TQValidator;
class KisPopupSlider : public TQPopupMenu {
TQ_OBJECT
public:
KisPopupSlider(int minValue, int maxValue, int pageStep, int value, TQt::Orientation orientation, TQWidget * parent, const char * name = 0)
: TQPopupMenu(parent, name)
{
m_slider = new TQSlider(minValue, maxValue, pageStep, value, orientation, this, name);
//m_slider->setTracking(false);
insertItem(m_slider);
connect(m_slider, TQT_SIGNAL(valueChanged(int)), TQT_SIGNAL(valueChanged(int)));
}
void setTickInterval(int i) { m_slider->setTickInterval(i); }
void setRange(int minValue, int maxValue) { m_slider->setRange(minValue, maxValue); }
void setValue(int val) { m_slider->setValue(val); }
void setTickmarks(TQSlider::TickSetting t) { m_slider->setTickmarks(t); }
int lineStep () const{ return m_slider->lineStep(); }
int minValue () const{ return m_slider->minValue(); }
int maxValue () const{ return m_slider->maxValue(); }
int value () const{ return m_slider->value(); }
TQSlider *m_slider;
signals:
void valueChanged(int);
};
/**
* @short An input widget for integer numbers, consisting of a spinbox and
* a dropdown slider.
*
* KisIntSpinbox combines a TQSpinBox and a dropdown TQSlider
* to make an easy to use control for setting some integer
* parameter.
*
*
*/
class KisIntSpinbox : public TQWidget
{
TQ_OBJECT
TQ_PROPERTY( int value READ value WRITE setValue )
TQ_PROPERTY( int minValue READ minValue WRITE setMinValue )
TQ_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
public:
/**
* Constructs an input control for integer values
* with base 10 and initial value 0.
*
* @param parent parent TQWidget
* @param name internal name for this widget
*/
KisIntSpinbox(TQWidget *parent=0, const char *name=0);
/**
* Constructor
* It constructs a TQSpinBox that allows the input of integer numbers
* in the range of -INT_MAX to +INT_MAX.
* To enforce the value being in a range, use setRange().
*
* @param label the tabel (may contain &, and my be empty)
* @param value initial value for the control
* @param parent parent TQWidget
* @param name internal name for this widget
*/
KisIntSpinbox(const TQString & label, int value, TQWidget* parent=0, const char *name=0);
/**
* Destructor
*
*
*/
virtual ~KisIntSpinbox();
/**
* @return the current value.
*/
int value() const;
/**
* @param min minimum value
* @param max maximum value
* @param step step size for the TQSlider
*/
void setRange(int min, int max, int step=1);
/**
* Sets the minimum value.
*/
void setMinValue(int min);
/**
* @return the minimum value.
*/
int minValue() const;
/**
* Sets the maximum value.
*/
void setMaxValue(int max);
/**
* @return the maximum value.
*/
int maxValue() const;
/**
* Sets the spacing of tickmarks for the slider.
*
* @param minor Minor tickmark separation.
* @param major Major tickmark separation.
*/
void setSteps(int minor, int major);
void setLabel(const TQString & label);
public slots:
/**
* Sets the value of the control.
*/
void setValue(int);
void spinboxValueChanged(int val);
void sliderValueChanged(int val);
void slotTimeout();
signals:
/**
* Emitted every time the value changes (by calling setValue() or
* by user interaction).
* @param value the new opacity
*/
void valueChanged(int value);
/**
* Emitted every time the value changes (by calling setValue() or
* by user interaction).
* @param value the new opacity
* @param withSlider whether the value was set by dragging the slider
*/
void valueChanged(int value, bool withSlider);
/**
* Emitted after the slider has been hidden, if the value was changed while it was shown.
* @param previous the value before the slider was shown
* @param value the value after the slider was hidden
*/
void finishedChanging(int previous, int value);
private slots:
void slotAboutToShow();
void slotAboutToHide();
private:
void init(int val);
private:
class KisIntSpinboxPrivate;
KisIntSpinboxPrivate *d;
};
#endif