00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#ifndef __KSELECT_H__
00024
#define __KSELECT_H__
00025
00026
#include <qwidget.h>
00027
#include <qrangecontrol.h>
00028
#include <qpixmap.h>
00029
00030
#include <kdelibs_export.h>
00031
00043 class KDEUI_EXPORT KXYSelector :
public QWidget
00044 {
00045 Q_OBJECT
00046 Q_PROPERTY(
int xValue READ xValue WRITE setXValue )
00047 Q_PROPERTY(
int yValue READ yValue WRITE setYValue )
00048
00049
public:
00054 KXYSelector(
QWidget *parent=0,
const char *name=0 );
00058 ~KXYSelector();
00059
00066
void setValues(
int xPos,
int yPos );
00067
00072
void setXValue(
int xPos );
00073
00078
void setYValue(
int yPos );
00079
00083
void setRange(
int minX,
int minY,
int maxX,
int maxY );
00084
00088 int xValue()
const {
return xPos; }
00092 int yValue()
const {
return yPos; }
00093
00097
QRect contentsRect() const;
00098
00099 signals:
00104
void valueChanged(
int x,
int y );
00105
00106 protected:
00113 virtual
void drawContents(
QPainter * );
00118 virtual
void drawCursor( QPainter *p,
int xp,
int yp );
00119
00120 virtual
void paintEvent(
QPaintEvent *e );
00121 virtual
void mousePressEvent(
QMouseEvent *e );
00122 virtual
void mouseMoveEvent(
QMouseEvent *e );
00123 virtual
void wheelEvent(
QWheelEvent * );
00124
00128
void valuesFromPosition(
int x,
int y,
int& xVal,
int& yVal ) const;
00129
00130 private:
00131
void setPosition(
int xp,
int yp );
00132
int px;
00133
int py;
00134
int xPos;
00135
int yPos;
00136
int minX;
00137
int maxX;
00138
int minY;
00139
int maxY;
00140
QPixmap store;
00141
00142 protected:
00143 virtual
void virtual_hook(
int id,
void* data );
00144 private:
00145 class KXYSelectorPrivate;
00146 KXYSelectorPrivate *d;
00147 };
00148
00149
00159 class KDEUI_EXPORT
KSelector : public
QWidget, public
QRangeControl
00160 {
00161 Q_OBJECT
00162 Q_PROPERTY(
int value READ value WRITE setValue )
00163 Q_PROPERTY(
int minValue READ minValue WRITE setMinValue )
00164 Q_PROPERTY(
int maxValue READ maxValue WRITE setMaxValue )
00165
public:
00166
00170
KSelector( QWidget *parent=0,
const char *name=0 );
00175
KSelector( Orientation o, QWidget *parent = 0L,
const char *name = 0L );
00176
00177
00178
00179 ~
KSelector();
00180
00184 Orientation orientation()
const
00185
{
return _orientation; }
00186
00190
QRect contentsRect() const;
00191
00196 void setIndent(
bool i )
00197 { _indent = i; }
00201 bool indent()
const
00202
{
return _indent; }
00203
00207 void setValue(
int value)
00208 { QRangeControl::setValue(value); }
00209
00213 int value()
const
00214
{
return QRangeControl::value(); }
00215
00219 void setMinValue(
int value)
00220 { QRangeControl::setMinValue(value); }
00221
00225 int minValue()
const
00226
{
return QRangeControl::minValue(); }
00227
00231 void setMaxValue(
int value)
00232 { QRangeControl::setMaxValue(value); }
00233
00237 int maxValue()
const
00238
{
return QRangeControl::maxValue(); }
00239
00240 signals:
00245
void valueChanged(
int value );
00246
00247
protected:
00254
virtual void drawContents( QPainter * );
00262
virtual void drawArrow( QPainter *painter,
bool show,
const QPoint &pos );
00263
00264
virtual void valueChange();
00265
virtual void paintEvent(
QPaintEvent * );
00266
virtual void mousePressEvent(
QMouseEvent *e );
00267
virtual void mouseMoveEvent(
QMouseEvent *e );
00268
virtual void wheelEvent( QWheelEvent * );
00269
00270
private:
00271
QPoint calcArrowPos(
int val );
00272
void moveArrow(
const QPoint &pos );
00273
00274 Orientation _orientation;
00275
bool _indent;
00276
00277
protected:
00278
virtual void virtual_hook(
int id,
void* data );
00279
private:
00280
class KSelectorPrivate;
00281 KSelectorPrivate *d;
00282 };
00283
00284
00293 class KDEUI_EXPORT KGradientSelector :
public KSelector
00294 {
00295 Q_OBJECT
00296
00297 Q_PROPERTY(
QColor firstColor READ firstColor WRITE setFirstColor )
00298 Q_PROPERTY(
QColor secondColor READ secondColor WRITE setSecondColor )
00299 Q_PROPERTY(
QString firstText READ firstText WRITE setFirstText )
00300 Q_PROPERTY(
QString secondText READ secondText WRITE setSecondText )
00301
00302
public:
00307 KGradientSelector(
QWidget *parent=0,
const char *name=0 );
00312 KGradientSelector( Orientation o,
QWidget *parent=0,
const char *name=0 );
00316 ~KGradientSelector();
00320 void setColors(
const QColor &col1,
const QColor &col2 )
00321 { color1 = col1; color2 = col2; update();}
00322
void setText(
const QString &t1,
const QString &t2 )
00323 { text1 = t1; text2 = t2; update(); }
00324
00328 void setFirstColor(
const QColor &col )
00329 { color1 = col; update(); }
00330
void setSecondColor(
const QColor &col )
00331 { color2 = col; update(); }
00332
00336 void setFirstText(
const QString &t )
00337 { text1 = t; update(); }
00338
void setSecondText(
const QString &t )
00339 { text2 = t; update(); }
00340
00341
const QColor firstColor()
const
00342
{
return color1; }
00343
const QColor secondColor()
const
00344
{
return color2; }
00345
00346
const QString firstText()
const
00347
{
return text1; }
00348
const QString secondText()
const
00349
{
return text2; }
00350
00351
protected:
00352
00353
virtual void drawContents(
QPainter * );
00354
virtual QSize minimumSize()
const
00355
{
return sizeHint(); }
00356
00357
private:
00358
void init();
00359
QColor color1;
00360
QColor color2;
00361
QString text1;
00362
QString text2;
00363
00364
protected:
00365
virtual void virtual_hook(
int id,
void* data );
00366
private:
00367
class KGradientSelectorPrivate;
00368 KGradientSelectorPrivate *d;
00369 };
00370
00371
00372
#endif // __KSELECT_H__
00373