kselect.h
/* This file is part of the KDE libraries
Copyright (C) 1997 Martin Jones (mjones@kde.org)
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.
*/
//-----------------------------------------------------------------------------
// Selector widgets for KDE Color Selector, but probably useful for other
// stuff also.
#ifndef __KSELECT_H__
#define __KSELECT_H__
#include <qwidget.h>
#include <qrangecontrol.h>
#include <qpixmap.h>
#include <kdelibs_export.h>
class KDEUI_EXPORT KXYSelector : public QWidget
{
Q_OBJECT
Q_PROPERTY( int xValue READ xValue WRITE setXValue )
Q_PROPERTY( int yValue READ yValue WRITE setYValue )
public:
KXYSelector( QWidget *parent=0, const char *name=0 );
~KXYSelector();
void setValues( int xPos, int yPos );
void setXValue( int xPos );
void setYValue( int yPos );
void setRange( int minX, int minY, int maxX, int maxY );
int xValue() const { return xPos; }
int yValue() const { return yPos; }
QRect contentsRect() const;
signals:
void valueChanged( int x, int y );
protected:
virtual void drawContents( QPainter * );
virtual void drawCursor( QPainter *p, int xp, int yp );
virtual void paintEvent( QPaintEvent *e );
virtual void mousePressEvent( QMouseEvent *e );
virtual void mouseMoveEvent( QMouseEvent *e );
virtual void wheelEvent( QWheelEvent * );
void valuesFromPosition( int x, int y, int& xVal, int& yVal ) const;
private:
void setPosition( int xp, int yp );
int px;
int py;
int xPos;
int yPos;
int minX;
int maxX;
int minY;
int maxY;
QPixmap store;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KXYSelectorPrivate;
KXYSelectorPrivate *d;
};
class KDEUI_EXPORT KSelector : public QWidget, public QRangeControl
{
Q_OBJECT
Q_PROPERTY( int value READ value WRITE setValue )
Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
public:
KSelector( QWidget *parent=0, const char *name=0 );
KSelector( Orientation o, QWidget *parent = 0L, const char *name = 0L );
/*
* Destructs the widget.
*/
~KSelector();
Orientation orientation() const
{ return _orientation; }
QRect contentsRect() const;
void setIndent( bool i )
{ _indent = i; }
bool indent() const
{ return _indent; }
void setValue(int value)
{ QRangeControl::setValue(value); }
int value() const
{ return QRangeControl::value(); }
void setMinValue(int value)
{ QRangeControl::setMinValue(value); }
int minValue() const
{ return QRangeControl::minValue(); }
void setMaxValue(int value)
{ QRangeControl::setMaxValue(value); }
int maxValue() const
{ return QRangeControl::maxValue(); }
signals:
void valueChanged( int value );
protected:
virtual void drawContents( QPainter * );
virtual void drawArrow( QPainter *painter, bool show, const QPoint &pos );
virtual void valueChange();
virtual void paintEvent( QPaintEvent * );
virtual void mousePressEvent( QMouseEvent *e );
virtual void mouseMoveEvent( QMouseEvent *e );
virtual void wheelEvent( QWheelEvent * );
private:
QPoint calcArrowPos( int val );
void moveArrow( const QPoint &pos );
Orientation _orientation;
bool _indent;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KSelectorPrivate;
KSelectorPrivate *d;
};
class KDEUI_EXPORT KGradientSelector : public KSelector
{
Q_OBJECT
Q_PROPERTY( QColor firstColor READ firstColor WRITE setFirstColor )
Q_PROPERTY( QColor secondColor READ secondColor WRITE setSecondColor )
Q_PROPERTY( QString firstText READ firstText WRITE setFirstText )
Q_PROPERTY( QString secondText READ secondText WRITE setSecondText )
public:
KGradientSelector( QWidget *parent=0, const char *name=0 );
KGradientSelector( Orientation o, QWidget *parent=0, const char *name=0 );
~KGradientSelector();
void setColors( const QColor &col1, const QColor &col2 )
{ color1 = col1; color2 = col2; update();}
void setText( const QString &t1, const QString &t2 )
{ text1 = t1; text2 = t2; update(); }
void setFirstColor( const QColor &col )
{ color1 = col; update(); }
void setSecondColor( const QColor &col )
{ color2 = col; update(); }
void setFirstText( const QString &t )
{ text1 = t; update(); }
void setSecondText( const QString &t )
{ text2 = t; update(); }
const QColor firstColor() const
{ return color1; }
const QColor secondColor() const
{ return color2; }
const QString firstText() const
{ return text1; }
const QString secondText() const
{ return text2; }
protected:
virtual void drawContents( QPainter * );
virtual QSize minimumSize() const
{ return sizeHint(); }
private:
void init();
QColor color1;
QColor color2;
QString text1;
QString text2;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KGradientSelectorPrivate;
KGradientSelectorPrivate *d;
};
#endif // __KSELECT_H__
KXYSelector::yValue
int yValue() const
Definition: kselect.h:92
KSelector::setValue
void setValue(int value)
Sets the value.
Definition: kselect.h:207
KSelector::orientation
Orientation orientation() const
Definition: kselect.h:184
KSelector::indent
bool indent() const
Definition: kselect.h:201
KGradientSelector
The KGradientSelector widget allows the user to choose from a one-dimensional range of colors which i...
Definition: kselect.h:293
KSelector::setMaxValue
void setMaxValue(int value)
Sets the max value.
Definition: kselect.h:231
KSelector::setIndent
void setIndent(bool i)
Sets the indent option of the widget to i.
Definition: kselect.h:196
KSelector::maxValue
int maxValue() const
Definition: kselect.h:237
KSelector::drawContents
virtual void drawContents(QPainter *)
Override this function to draw the contents of the control.
Definition: kselect.cpp:367
KGradientSelector::setFirstText
void setFirstText(const QString &t)
Set each description on its own.
Definition: kselect.h:336
KSelector::value
int value() const
Definition: kselect.h:213
KSelector::minValue
int minValue() const
Definition: kselect.h:225
KXYSelector::xValue
int xValue() const
Definition: kselect.h:88
KXYSelector
KXYSelector is the base class for other widgets which provides the ability to choose from a two-dimen...
Definition: kselect.h:43
KSelector::setMinValue
void setMinValue(int value)
Sets the min value.
Definition: kselect.h:219
KGradientSelector::setFirstColor
void setFirstColor(const QColor &col)
Set each color on its own.
Definition: kselect.h:328
KGradientSelector::setColors
void setColors(const QColor &col1, const QColor &col2)
Sets the two colors which span the gradient.
Definition: kselect.h:320
KSelector
KSelector is the base class for other widgets which provides the ability to choose from a one-dimensi...
Definition: kselect.h:159

KDE Home | KDE Accessibility Home | Description of Access Keys