00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __OSELECT_H__
00024 #define __OSELECT_H__
00025
00026 #include <qwidget.h>
00027 #include <qrangecontrol.h>
00028 #include <qpixmap.h>
00029
00030
00031 namespace Opie {
00032 namespace Ui {
00044 class OXYSelector : public QWidget
00045 {
00046 Q_OBJECT
00047
00048 public:
00053 OXYSelector( QWidget *parent=0, const char *name=0 );
00057 ~OXYSelector();
00058
00063 void setValues( int xPos, int yPos );
00067 void setRange( int minX, int minY, int maxX, int maxY );
00068
00072 int xValue() const { return xPos; }
00076 int yValue() const { return yPos; }
00077
00081 QRect contentsRect() const;
00082
00083 signals:
00088 void valueChanged( int x, int y );
00089
00090 protected:
00097 virtual void drawContents( QPainter * );
00102 virtual void drawCursor( QPainter *p, int xp, int yp );
00106 virtual void paintEvent( QPaintEvent *e );
00110 virtual void mousePressEvent( QMouseEvent *e );
00114 virtual void mouseMoveEvent( QMouseEvent *e );
00118 virtual void wheelEvent( QWheelEvent * );
00122 void valuesFromPosition( int x, int y, int& xVal, int& yVal ) const;
00123
00124 private:
00125 void setPosition( int xp, int yp );
00126 int px;
00127 int py;
00128 int xPos;
00129 int yPos;
00130 int minX;
00131 int maxX;
00132 int minY;
00133 int maxY;
00134 QPixmap store;
00135
00136 private:
00137 class OXYSelectorPrivate;
00138 OXYSelectorPrivate *d;
00139 };
00140
00141
00151 class OSelector : public QWidget, public QRangeControl
00152 {
00153 Q_OBJECT
00154 Q_PROPERTY( int value READ value WRITE setValue )
00155 Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
00156 Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
00157 public:
00158
00162 OSelector( QWidget *parent=0, const char *name=0 );
00167 OSelector( Orientation o, QWidget *parent = 0L, const char *name = 0L );
00168
00169
00170
00171 ~OSelector();
00172
00176 Orientation orientation() const
00177 { return _orientation; }
00178
00182 QRect contentsRect() const;
00183
00188 void setIndent( bool i )
00189 { _indent = i; }
00193 bool indent() const
00194 { return _indent; }
00195
00199 void setValue(int value)
00200 { QRangeControl::setValue(value); }
00201
00205 int value() const
00206 { return QRangeControl::value(); }
00207
00211 #if ( QT_VERSION >= 0x030000 )
00212 void setMinValue(int value) { QRangeControl::setMinValue(value); }
00213 #else
00214 void setMinValue(int value) { QRangeControl::setRange(value,QRangeControl::maxValue()); }
00215 #endif
00216
00220 int minValue() const
00221 { return QRangeControl::minValue(); }
00222
00226 #if ( QT_VERSION >= 0x030000 )
00227 void setMaxValue(int value) { QRangeControl::setMaxValue(value); }
00228 #else
00229 void setMaxValue(int value) { QRangeControl::setRange(QRangeControl::minValue(),value); }
00230 #endif
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
00265 virtual void valueChange();
00269 virtual void paintEvent( QPaintEvent * );
00273 virtual void mousePressEvent( QMouseEvent *e );
00277 virtual void mouseMoveEvent( QMouseEvent *e );
00281 virtual void wheelEvent( QWheelEvent * );
00282
00283 private:
00284 QPoint calcArrowPos( int val );
00285 void moveArrow( const QPoint &pos );
00286
00287 Orientation _orientation;
00288 bool _indent;
00289
00290 private:
00291 class OSelectorPrivate;
00292 OSelectorPrivate *d;
00293 };
00294
00295
00301 class OGradientSelector : public OSelector
00302 {
00303 Q_OBJECT
00304
00305 Q_PROPERTY( QColor firstColor READ firstColor WRITE setFirstColor )
00306 Q_PROPERTY( QColor secondColor READ secondColor WRITE setSecondColor )
00307 Q_PROPERTY( QString firstText READ firstText WRITE setFirstText )
00308 Q_PROPERTY( QString secondText READ secondText WRITE setSecondText )
00309
00310 public:
00315 OGradientSelector( QWidget *parent=0, const char *name=0 );
00320 OGradientSelector( Orientation o, QWidget *parent=0, const char *name=0 );
00324 ~OGradientSelector();
00328 void setColors( const QColor &col1, const QColor &col2 )
00329 { color1 = col1; color2 = col2; update();}
00330 void setText( const QString &t1, const QString &t2 )
00331 { text1 = t1; text2 = t2; update(); }
00332
00336 void setFirstColor( const QColor &col )
00337 { color1 = col; update(); }
00338 void setSecondColor( const QColor &col )
00339 { color2 = col; update(); }
00340
00344 void setFirstText( const QString &t )
00345 { text1 = t; update(); }
00346 void setSecondText( const QString &t )
00347 { text2 = t; update(); }
00348
00349 const QColor firstColor() const
00350 { return color1; }
00351 const QColor secondColor() const
00352 { return color2; }
00353
00354 const QString firstText() const
00355 { return text1; }
00356 const QString secondText() const
00357 { return text2; }
00358
00359 protected:
00363 virtual void drawContents( QPainter * );
00364
00368 virtual QSize minimumSize() const
00369 { return sizeHint(); }
00370
00371 private:
00372 void init();
00373 QColor color1;
00374 QColor color2;
00375 QString text1;
00376 QString text2;
00377
00378 private:
00379 class OGradientSelectorPrivate;
00380 OGradientSelectorPrivate *d;
00381 };
00382
00392 class OHSSelector : public OXYSelector
00393 {
00394 Q_OBJECT
00395
00396 public:
00400 OHSSelector( QWidget *parent=0, const char *name=0 );
00401
00402 protected:
00407 virtual void drawPalette( QPixmap *pixmap );
00411 virtual void resizeEvent( QResizeEvent * );
00417 virtual void drawContents( QPainter *painter );
00418
00419 private:
00420 void updateContents();
00421 QPixmap pixmap;
00422
00423 private:
00424 class OHSSelectorPrivate;
00425 OHSSelectorPrivate *d;
00426 };
00427
00428
00429 class OValueSelectorPrivate;
00437 class OValueSelector : public OSelector
00438 {
00439 Q_OBJECT
00440
00441 public:
00445 OValueSelector( QWidget *parent=0, const char *name=0 );
00449 OValueSelector( Orientation o, QWidget *parent = 0, const char *name = 0 );
00450
00451 int hue() const
00452 { return _hue; }
00453 void setHue( int h )
00454 { _hue = h; }
00455 int saturation() const
00456 { return _sat; }
00457 void setSaturation( int s )
00458 { _sat = s; }
00459
00460 void updateContents();
00461 protected:
00466 virtual void drawPalette( QPixmap *pixmap );
00470 virtual void resizeEvent( QResizeEvent * );
00476 virtual void drawContents( QPainter *painter );
00477
00478 private:
00479 int _hue;
00480 int _sat;
00481 QPixmap pixmap;
00482
00483 private:
00484 class OValueSelectorPrivate;
00485 OValueSelectorPrivate *d;
00486 };
00487
00488
00489 class OColor : public QColor
00490 {
00491 public:
00492 OColor();
00493 OColor( const OColor &col);
00494 OColor( const QColor &col);
00495
00496 OColor& operator=( const OColor& col);
00497
00498 bool operator==( const OColor& col) const;
00499
00500 void setHsv(int _h, int _s, int _v);
00501 void setRgb(int _r, int _g, int _b);
00502
00503 void rgb(int *_r, int *_g, int *_b) const;
00504 void hsv(int *_h, int *_s, int *_v) const;
00505 protected:
00506 int h;
00507 int s;
00508 int v;
00509 int r;
00510 int g;
00511 int b;
00512
00513 private:
00514 class OColorPrivate;
00515 OColorPrivate *d;
00516 };
00517
00518 }
00519 }
00520
00521
00522 #endif // __OSELECT_H__
00523