- Save/load palettes properly
[dashstudio.git] / src / components / colorpalette / private / gradientselector.h
blob391894f6d3b13334064138a1f8fb9fab57ffac14
1 /***************************************************************************
2 * Copyright (C) 2005 by Jorge Cuadrado *
3 * kuadrosx@gmail.com *
4 * *
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. *
9 * *
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. *
14 * *
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>
25 #include <QColor>
26 #include <QImage>
27 #include <QPixmap>
28 #include <QPainter>
29 #include <QMouseEvent>
30 #include <QWheelEvent>
31 #include <QPaintEvent>
32 #include <QPoint>
33 #include <QLinearGradient>
34 #include <QPainterPath>
36 #include <QList>
38 /**
39 * @if english
40 * @short translate me
41 * @elseif spanish
42 * @short Esta clase provee de una simple interfaz grafica para generar "GradientStops".
43 * @endif
44 * @author Jorge Cuadrado <kuadrosx@gmail.com>
46 class GradientSelector : public QAbstractSlider
48 Q_OBJECT;
50 public:
52 /**
53 * @if english
54 * Translate
55 * @elseif spanish
56 * Constructor por defecto.
57 * @endif
59 GradientSelector( QWidget *parent=0 );
61 /**
62 * Destructor
64 ~GradientSelector();
65 /**
66 * @if english
67 * Translate
68 * @elseif spanish
69 * Pone un GradienStops, para ser editado.
70 * @endif
72 void setStops(const QGradientStops &);
73 QRect contentsRect() const;
74 void setValue(int value);
75 int value() const;
77 /**
78 * @if english
79 * Translate
80 * @elseif spanish
81 * Pone el numero maximo de flechas, que definen el "GradienStops".
82 * @endif
84 void setMaxArrows(int value);
85 /**
86 * @if english
87 * Translate
88 * @elseif spanish
89 * Devuelve el "GradienStops" actual.
90 * @endif
92 QGradientStops gradientStops() const;
94 /**
95 * @if english
96 * Translate
97 * @elseif spanish
98 * Crea el "GradienStops" actual apartir de las flechas acutales.
99 * @endif
101 void createGradient();
103 * @if english
104 * Translate
105 * @elseif spanish
106 * Cambia el color de la flecha actualmente seleccionada.
107 * @endif
109 void setCurrentColor(const QColor& color);
111 signals:
112 void newValue( int value );
113 void gradientChanged( const QGradientStops& );
114 void arrowAdded();
116 public slots:
117 void addArrow(QPoint position, QColor color);
118 virtual void valueChange( int value);
120 protected:
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;
133 private:
134 QPoint calcArrowPos( int val );
135 void moveArrow( const QPoint &pos );
136 double valueToGradient(int _value) const;
138 private:
139 struct Private;
140 Private *d;
143 #endif