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
00041 class KXYSelector :
public QWidget
00042 {
00043 Q_OBJECT
00044 Q_PROPERTY(
int xValue READ xValue WRITE
setXValue )
00045 Q_PROPERTY(
int yValue READ yValue WRITE
setYValue )
00046
00047
public:
00052
KXYSelector(
QWidget *parent=0,
const char *name=0 );
00056
~KXYSelector();
00057
00064
void setValues(
int xPos,
int yPos );
00065
00070
void setXValue(
int xPos );
00071
00076
void setYValue(
int yPos );
00077
00081
void setRange(
int minX,
int minY,
int maxX,
int maxY );
00082
00086 int xValue()
const {
return xPos; }
00090 int yValue()
const {
return yPos; }
00091
00095
QRect contentsRect() const;
00096
00097 signals:
00102
void valueChanged(
int x,
int y );
00103
00104 protected:
00111 virtual
void drawContents(
QPainter * );
00116 virtual
void drawCursor( QPainter *p,
int xp,
int yp );
00117
00118 virtual
void paintEvent(
QPaintEvent *e );
00119 virtual
void mousePressEvent(
QMouseEvent *e );
00120 virtual
void mouseMoveEvent(
QMouseEvent *e );
00121 virtual
void wheelEvent(
QWheelEvent * );
00122
00126
void valuesFromPosition(
int x,
int y,
int& xVal,
int& yVal ) const;
00127
00128 private:
00129
void setPosition(
int xp,
int yp );
00130
int px;
00131
int py;
00132
int xPos;
00133
int yPos;
00134
int minX;
00135
int maxX;
00136
int minY;
00137
int maxY;
00138
QPixmap store;
00139
00140 protected:
00141 virtual
void virtual_hook(
int id,
void* data );
00142 private:
00143 class KXYSelectorPrivate;
00144 KXYSelectorPrivate *d;
00145 };
00146
00147
00157 class
KSelector : public
QWidget, public
QRangeControl
00158 {
00159 Q_OBJECT
00160 Q_PROPERTY(
int value READ value WRITE setValue )
00161 Q_PROPERTY(
int minValue READ minValue WRITE setMinValue )
00162 Q_PROPERTY(
int maxValue READ maxValue WRITE setMaxValue )
00163
public:
00164
00168
KSelector( QWidget *parent=0,
const char *name=0 );
00173
KSelector( Orientation o, QWidget *parent = 0L,
const char *name = 0L );
00174
00175
00176
00177 ~
KSelector();
00178
00182 Orientation orientation()
const
00183
{
return _orientation; }
00184
00188
QRect contentsRect() const;
00189
00194 void setIndent(
bool i )
00195 { _indent = i; }
00199 bool indent()
const
00200
{
return _indent; }
00201
00205 void setValue(
int value)
00206 { QRangeControl::setValue(value); }
00207
00211 int value()
const
00212
{
return QRangeControl::value(); }
00213
00217 void setMinValue(
int value)
00218 { QRangeControl::setMinValue(value); }
00219
00223 int minValue()
const
00224
{
return QRangeControl::minValue(); }
00225
00229 void setMaxValue(
int value)
00230 { QRangeControl::setMaxValue(value); }
00231
00235 int maxValue()
const
00236
{
return QRangeControl::maxValue(); }
00237
00238 signals:
00243
void valueChanged(
int value );
00244
00245
protected:
00252
virtual void drawContents( QPainter * );
00260
virtual void drawArrow( QPainter *painter,
bool show,
const QPoint &pos );
00261
00262
virtual void valueChange();
00263
virtual void paintEvent(
QPaintEvent * );
00264
virtual void mousePressEvent(
QMouseEvent *e );
00265
virtual void mouseMoveEvent(
QMouseEvent *e );
00266
virtual void wheelEvent( QWheelEvent * );
00267
00268
private:
00269
QPoint calcArrowPos(
int val );
00270
void moveArrow(
const QPoint &pos );
00271
00272 Orientation _orientation;
00273
bool _indent;
00274
00275
protected:
00276
virtual void virtual_hook(
int id,
void* data );
00277
private:
00278
class KSelectorPrivate;
00279 KSelectorPrivate *d;
00280 };
00281
00282
00291 class KGradientSelector :
public KSelector
00292 {
00293 Q_OBJECT
00294
00295 Q_PROPERTY(
QColor firstColor READ firstColor WRITE setFirstColor )
00296 Q_PROPERTY(
QColor secondColor READ secondColor WRITE setSecondColor )
00297 Q_PROPERTY(
QString firstText READ firstText WRITE setFirstText )
00298 Q_PROPERTY(
QString secondText READ secondText WRITE setSecondText )
00299
00300
public:
00305
KGradientSelector(
QWidget *parent=0,
const char *name=0 );
00310
KGradientSelector( Orientation o,
QWidget *parent=0,
const char *name=0 );
00314 ~
KGradientSelector();
00318 void setColors(
const QColor &col1,
const QColor &col2 )
00319 { color1 = col1; color2 = col2; update();}
00320
void setText(
const QString &t1,
const QString &t2 )
00321 { text1 = t1; text2 = t2; update(); }
00322
00326 void setFirstColor(
const QColor &col )
00327 { color1 = col; update(); }
00328
void setSecondColor(
const QColor &col )
00329 { color2 = col; update(); }
00330
00334 void setFirstText(
const QString &t )
00335 { text1 = t; update(); }
00336
void setSecondText(
const QString &t )
00337 { text2 = t; update(); }
00338
00339
const QColor firstColor()
const
00340
{
return color1; }
00341
const QColor secondColor()
const
00342
{
return color2; }
00343
00344
const QString firstText()
const
00345
{
return text1; }
00346
const QString secondText()
const
00347
{
return text2; }
00348
00349
protected:
00350
00351
virtual void drawContents(
QPainter * );
00352
virtual QSize minimumSize()
const
00353
{
return sizeHint(); }
00354
00355
private:
00356
void init();
00357
QColor color1;
00358
QColor color2;
00359
QString text1;
00360
QString text2;
00361
00362
protected:
00363
virtual void virtual_hook(
int id,
void* data );
00364
private:
00365
class KGradientSelectorPrivate;
00366 KGradientSelectorPrivate *d;
00367 };
00368
00369
00370
#endif // __KSELECT_H__
00371