CuteLogger
Fast and simple logging solution for Qt based applications
colorwheel.h
1/*
2 * Copyright (c) 2013 Meltytech, LLC
3 * Author: Dan Dennedy <dan@dennedy.org>
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 3 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, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef COLORWHEEL_H
20#define COLORWHEEL_H
21
22#include <QWidget>
23#include <QPainter>
24#include <QResizeEvent>
25
26class ColorWheel : public QWidget
27{
28 Q_OBJECT
29public:
30 explicit ColorWheel(QWidget *parent = 0);
31
32 virtual QSize sizeHint () const;
33 virtual QSize minimumSizeHint () const;
34 QColor color();
35 void setColor(const QColor &color);
36
37signals:
38 void colorChanged(const QColor &color);
39
40public slots:
41 void changeColor(const QColor &color);
42
43protected:
44 void mousePressEvent(QMouseEvent *event);
45 void mouseMoveEvent(QMouseEvent *event);
46 void mouseReleaseEvent(QMouseEvent *event);
47 void resizeEvent(QResizeEvent *event);
48 void paintEvent(QPaintEvent *event);
49
50private:
51 QSize m_initialSize;
52 QImage m_image;
53 bool m_isMouseDown;
54 QPoint m_lastPoint;
55 int m_margin;
56 int m_sliderWidth;
57 QRegion m_wheelRegion;
58 QRegion m_sliderRegion;
59 QColor m_color;
60 bool m_isInWheel;
61 bool m_isInSquare;
62
63 int wheelSize() const;
64 QColor colorForPoint(const QPoint &point);
65 void drawWheel();
66 void drawWheelDot(QPainter &painter);
67 void drawSliderBar(QPainter &painter);
68 void drawSlider();
69};
70
71#endif // COLORWHEEL_H