1 /***************************************************************************
2 * Copyright (C) 2005 by Jorge Cuadrado *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef GRADIENTSELECTOR_H
22 #define GRADIENTSELECTOR_H
24 #include <QAbstractSlider>
29 #include <QMouseEvent>
30 #include <QWheelEvent>
31 #include <QPaintEvent>
33 #include <QLinearGradient>
34 #include <QPainterPath>
42 * @short Esta clase provee de una simple interfaz grafica para generar "GradientStops".
44 * @author Jorge Cuadrado <kuadrosx@gmail.com>
46 class GradientSelector
: public QAbstractSlider
56 * Constructor por defecto.
59 GradientSelector( QWidget
*parent
=0 );
69 * Pone un GradienStops, para ser editado.
72 void setStops(const QGradientStops
&);
73 QRect
contentsRect() const;
74 void setValue(int value
);
81 * Pone el numero maximo de flechas, que definen el "GradienStops".
84 void setMaxArrows(int value
);
89 * Devuelve el "GradienStops" actual.
92 QGradientStops
gradientStops() const;
98 * Crea el "GradienStops" actual apartir de las flechas acutales.
101 void createGradient();
106 * Cambia el color de la flecha actualmente seleccionada.
109 void setCurrentColor(const QColor
& color
);
112 void newValue( int value
);
113 void gradientChanged( const QGradientStops
& );
117 void addArrow(QPoint position
, QColor color
);
118 virtual void valueChange( int value
);
121 virtual void drawContents( QPainter
* );
122 virtual void paintEvent( QPaintEvent
* );
123 virtual void mousePressEvent( QMouseEvent
*e
);
124 virtual void mouseMoveEvent( QMouseEvent
*e
);
125 virtual void wheelEvent( QWheelEvent
* );
127 virtual QSize
minimumSize() const;
129 virtual void resizeEvent ( QResizeEvent
* event
);
130 virtual QSize
sizeHint() const;
134 QPoint
calcArrowPos( int val
);
135 void moveArrow( const QPoint
&pos
);
136 double valueToGradient(int _value
) const;