KDEUI
kselector.h
Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 //----------------------------------------------------------------------------- 00020 // Selector widgets for KDE Color Selector, but probably useful for other 00021 // stuff also. 00022 00023 #ifndef KSELECTOR_H 00024 #define KSELECTOR_H 00025 00026 #include <kdeui_export.h> 00027 00028 #include <QtGui/QAbstractSlider> 00029 #include <QtGui/QGradient> 00030 #include <QtGui/QWidget> 00031 00041 class KDEUI_EXPORT KSelector : public QAbstractSlider 00042 { 00043 Q_OBJECT 00044 Q_PROPERTY( int value READ value WRITE setValue ) 00045 Q_PROPERTY( int minValue READ minimum WRITE setMinimum ) 00046 Q_PROPERTY( int maxValue READ maximum WRITE setMaximum ) 00047 Q_PROPERTY( bool indent READ indent WRITE setIndent ) 00048 Q_PROPERTY( Qt::ArrowType arrowDirection READ arrowDirection WRITE setArrowDirection ) 00049 public: 00050 00054 explicit KSelector( QWidget *parent=0 ); 00059 explicit KSelector( Qt::Orientation o, QWidget *parent = 0 ); 00060 /* 00061 * Destructs the widget. 00062 */ 00063 ~KSelector(); 00064 00068 QRect contentsRect() const; 00069 00074 void setIndent( bool i ); 00075 00079 bool indent() const; 00080 00084 void setArrowDirection( Qt::ArrowType direction ); 00085 00089 Qt::ArrowType arrowDirection() const; 00090 00091 protected: 00098 virtual void drawContents( QPainter * ); 00103 virtual void drawArrow( QPainter *painter, const QPoint &pos ); 00104 00105 virtual void paintEvent( QPaintEvent * ); 00106 virtual void mousePressEvent( QMouseEvent *e ); 00107 virtual void mouseMoveEvent( QMouseEvent *e ); 00108 virtual void mouseReleaseEvent( QMouseEvent *e ); 00109 virtual void wheelEvent( QWheelEvent * ); 00110 00111 private: 00112 QPoint calcArrowPos( int val ); 00113 void moveArrow( const QPoint &pos ); 00114 00115 private: 00116 class Private; 00117 friend class Private; 00118 Private * const d; 00119 00120 Q_DISABLE_COPY(KSelector) 00121 }; 00122 00123 00132 class KDEUI_EXPORT KGradientSelector : public KSelector 00133 { 00134 Q_OBJECT 00135 00136 Q_PROPERTY( QColor firstColor READ firstColor WRITE setFirstColor ) 00137 Q_PROPERTY( QColor secondColor READ secondColor WRITE setSecondColor ) 00138 Q_PROPERTY( QString firstText READ firstText WRITE setFirstText ) 00139 Q_PROPERTY( QString secondText READ secondText WRITE setSecondText ) 00140 00141 public: 00146 explicit KGradientSelector( QWidget *parent=0 ); 00151 explicit KGradientSelector( Qt::Orientation o, QWidget *parent=0 ); 00155 ~KGradientSelector(); 00156 00162 void setStops(const QGradientStops &stops); 00163 00168 QGradientStops stops() const; 00169 00173 void setColors( const QColor &col1, const QColor &col2 ); 00174 void setText( const QString &t1, const QString &t2 ); 00175 00179 void setFirstColor( const QColor &col ); 00180 void setSecondColor( const QColor &col ); 00181 00185 void setFirstText( const QString &t ); 00186 void setSecondText( const QString &t ); 00187 00188 QColor firstColor() const; 00189 QColor secondColor() const; 00190 00191 QString firstText() const; 00192 QString secondText() const; 00193 00194 protected: 00195 00196 virtual void drawContents( QPainter * ); 00197 virtual QSize minimumSize() const; 00198 00199 private: 00200 class KGradientSelectorPrivate; 00201 friend class KGradientSelectorPrivate; 00202 KGradientSelectorPrivate * const d; 00203 00204 Q_DISABLE_COPY(KGradientSelector) 00205 }; 00206 00207 #endif // KSELECTOR_H
KDE 4.6 API Reference