kselect.h Source File (kdeui Library)

| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kselect.h

    00001 /* This file is part of the KDE libraries
    00002     Copyright (C) 1997 Martin Jones (mjones@kde.org)
    00003
    00004     This library is free software; you can redistribute it and/or
    00005     modify it under the terms of the GNU Library General Public
    00006     License as published by the Free Software Foundation; either
    00007     version 2 of the License, or (at your option) any later version.
    00008
    00009     This library is distributed in the hope that it will be useful,
    00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012     Library General Public License for more details.
    00013
    00014     You should have received a copy of the GNU Library General Public License
    00015     along with this library; see the file COPYING.LIB.  If not, write to
    00016     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017     Boston, MA 02111-1307, USA.
    00018 */
    00019 //-----------------------------------------------------------------------------
    00020 // Selector widgets for KDE Color Selector, but probably useful for other
    00021 // stuff also.
    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
    00045 public:
    00050   KXYSelector( QWidget *parent=0, const char *name=0 );
    00054   ~KXYSelector();
    00055
    00060   void setValues( int xPos, int yPos );
    00064   void setRange( int minX, int minY, int maxX, int maxY );
    00065
    00069   int xValue() const {  return xPos; }
    00073   int yValue() const {  return yPos; }
    00074
    00078   QRect contentsRect() const;
    00079
    00080 signals:
    00085   void valueChanged( int x, int y );
    00086
    00087 protected:
    00094   virtual void drawContents( QPainter * );
    00099   virtual void drawCursor( QPainter *p, int xp, int yp );
    00103   virtual void paintEvent( QPaintEvent *e );
    00107   virtual void mousePressEvent( QMouseEvent *e );
    00111   virtual void mouseMoveEvent( QMouseEvent *e );
    00112
    00113 private:
    00114   void setPosition( int xp, int yp );
    00115   int px;
    00116   int py;
    00117   int xPos;
    00118   int yPos;
    00119   int minX;
    00120   int maxX;
    00121   int minY;
    00122   int maxY;
    00123   QPixmap store;
    00124
    00125 protected:
    00126   virtual void virtual_hook( int id, void* data );
    00127 private:
    00128   class KXYSelectorPrivate;
    00129   KXYSelectorPrivate *d;
    00130 };
    00131
    00132
    00142 class KSelector : public QWidget, public QRangeControl
    00143 {
    00144   Q_OBJECT
    00145   Q_PROPERTY( int value READ value WRITE setValue )
    00146   Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
    00147   Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
    00148 public:
    00149
    00153   KSelector( QWidget *parent=0, const char *name=0 );
    00158   KSelector( Orientation o, QWidget *parent = 0L, const char *name = 0L );
    00159   /*
    00160    * Destructs the widget.
    00161    */
    00162   ~KSelector();
    00163
    00167   Orientation orientation() const
    00168   {     return _orientation; }
    00169
    00173   QRect contentsRect() const;
    00174
    00179   void setIndent( bool i )
    00180   {     _indent = i; }
    00184   bool indent() const
    00185   {     return _indent; }
    00186
    00190   void setValue(int value)
    00191   { QRangeControl::setValue(value); }
    00192
    00196   int value() const
    00197   { return QRangeControl::value(); }
    00198
    00202   void setMinValue(int value)
    00203   { QRangeControl::setMinValue(value); }
    00204
    00208   int minValue() const
    00209   { return QRangeControl::minValue(); }
    00210
    00214   void setMaxValue(int value)
    00215   { QRangeControl::setMaxValue(value); }
    00216
    00220   int maxValue() const
    00221   { return QRangeControl::maxValue(); }
    00222
    00223 signals:
    00228   void valueChanged( int value );
    00229
    00230 protected:
    00237   virtual void drawContents( QPainter * );
    00245   virtual void drawArrow( QPainter *painter, bool show, const QPoint &pos );
    00246
    00250   virtual void valueChange();
    00254   virtual void paintEvent( QPaintEvent * );
    00258   virtual void mousePressEvent( QMouseEvent *e );
    00262   virtual void mouseMoveEvent( QMouseEvent *e );
    00263
    00264 private:
    00265   QPoint calcArrowPos( int val );
    00266   void moveArrow( const QPoint &pos );
    00267
    00268   Orientation _orientation;
    00269   bool _indent;
    00270
    00271 protected:
    00272   virtual void virtual_hook( int id, void* data );
    00273 private:
    00274   class KSelectorPrivate;
    00275   KSelectorPrivate *d;
    00276 };
    00277
    00278
    00284 class KGradientSelector : public KSelector
    00285 {
    00286   Q_OBJECT
    00287
    00288   Q_PROPERTY( QColor firstColor READ firstColor WRITE setFirstColor )
    00289   Q_PROPERTY( QColor secondColor READ secondColor WRITE setSecondColor )
    00290   Q_PROPERTY( QString firstText READ firstText WRITE setFirstText )
    00291   Q_PROPERTY( QString secondText READ secondText WRITE setSecondText )
    00292
    00293 public:
    00298   KGradientSelector( QWidget *parent=0, const char *name=0 );
    00303   KGradientSelector( Orientation o, QWidget *parent=0, const char *name=0 );
    00307   ~KGradientSelector();
    00311   void setColors( const QColor &col1, const QColor &col2 )
    00312   {     color1 = col1; color2 = col2; update();}
    00313   void setText( const QString &t1, const QString &t2 )
    00314   {     text1 = t1; text2 = t2; update(); }
    00315
    00319   void setFirstColor( const QColor &col )
    00320   { color1 = col; update(); }
    00321   void setSecondColor( const QColor &col )
    00322   { color2 = col; update(); }
    00323
    00327   void setFirstText( const QString &t )
    00328   { text1 = t; update(); }
    00329   void setSecondText( const QString &t )
    00330   { text2 = t; update(); }
    00331
    00332   const QColor firstColor() const
    00333   { return color1; }
    00334   const QColor secondColor() const
    00335   { return color2; }
    00336
    00337   const QString firstText() const
    00338   { return text1; }
    00339   const QString secondText() const
    00340   { return text2; }
    00341
    00342 protected:
    00346   virtual void drawContents( QPainter * );
    00347
    00351   virtual QSize minimumSize() const
    00352   { return sizeHint(); }
    00353
    00354 private:
    00355   void init();
    00356   QColor color1;
    00357   QColor color2;
    00358   QString text1;
    00359   QString text2;
    00360
    00361 protected:
    00362   virtual void virtual_hook( int id, void* data );
    00363 private:
    00364   class KGradientSelectorPrivate;
    00365   KGradientSelectorPrivate *d;
    00366 };
    00367
    00368
    00369 #endif          // __KSELECT_H__
    00370

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:57:39 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001