[KLF Backend]
[KLF Tools]
[KLF Home]
KLatexFormula Project
src
klftools
qtcolortriangle.h
Go to the documentation of this file.
1
/*
2
* This file was very slightly modified by Philippe Faist for KLatexFormula. (april 2009)
3
* In order for integration into KLatexFormula, this code is relicensed
4
* to **GPL Version 2.1 or higher** as described in the footnote to the GPL
5
* compatibility table found at
6
* http://www.gnu.org/licenses/gpl-faq.html#compat-matrix-footnote-7
7
*
8
*/
9
10
/****************************************************************************
11
**
12
** This file is part of a Qt Solutions component.
13
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
14
**
15
** Contact: Qt Software Information (qt-info@nokia.com)
16
**
17
** Commercial Usage
18
** Licensees holding valid Qt Commercial licenses may use this file in
19
** accordance with the Qt Solutions Commercial License Agreement provided
20
** with the Software or, alternatively, in accordance with the terms
21
** contained in a written agreement between you and Nokia.
22
**
23
** GNU Lesser General Public License Usage
24
** Alternatively, this file may be used under the terms of the GNU Lesser
25
** General Public License version 2.1 as published by the Free Software
26
** Foundation and appearing in the file LICENSE.LGPL included in the
27
** packaging of this file. Please review the following information to
28
** ensure the GNU Lesser General Public License version 2.1 requirements
29
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
30
**
31
** In addition, as a special exception, Nokia gives you certain
32
** additional rights. These rights are described in the Nokia Qt LGPL
33
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
34
** package.
35
**
36
** GNU General Public License Usage
37
** Alternatively, this file may be used under the terms of the GNU
38
** General Public License version 3.0 as published by the Free Software
39
** Foundation and appearing in the file LICENSE.GPL included in the
40
** packaging of this file. Please review the following information to
41
** ensure the GNU General Public License version 3.0 requirements will be
42
** met: http://www.gnu.org/copyleft/gpl.html.
43
**
44
** Please note Third Party Software included with Qt Solutions may impose
45
** additional restrictions and it is the user's responsibility to ensure
46
** that they have met the licensing requirements of the GPL, LGPL, or Qt
47
** Solutions Commercial license and the relevant license of the Third
48
** Party Software they are using.
49
**
50
** If you are unsure which license is appropriate for your use, please
51
** contact the sales department at qt-sales@nokia.com.
52
**
53
****************************************************************************/
54
55
#ifndef QTCOLORTRIANGLE_H
56
#define QTCOLORTRIANGLE_H
57
#include <QImage>
58
#include <QWidget>
59
60
class
QPointF
;
61
struct
Vertex;
62
63
#if defined(KLF_WS_WIN)
64
# if !defined(QT_QTCOLORTRIANGLE_EXPORT) && !defined(QT_QTCOLORTRIANGLE_IMPORT)
65
# define QT_QTCOLORTRIANGLE_EXPORT
66
# elif defined(QT_QTCOLORTRIANGLE_IMPORT)
67
# if defined(QT_QTCOLORTRIANGLE_EXPORT)
68
# undef QT_QTCOLORTRIANGLE_EXPORT
69
# endif
70
# define QT_QTCOLORTRIANGLE_EXPORT __declspec(dllimport)
71
# elif defined(QT_QTCOLORTRIANGLE_EXPORT)
72
# undef QT_QTCOLORTRIANGLE_EXPORT
73
# define QT_QTCOLORTRIANGLE_EXPORT __declspec(dllexport)
74
# endif
75
#else
76
# define QT_QTCOLORTRIANGLE_EXPORT
77
#endif
78
79
class
QT_QTCOLORTRIANGLE_EXPORT
QtColorTriangle
:
public
QWidget
80
{
81
Q_OBJECT
82
83
Q_PROPERTY(
QColor
color READ color WRITE setColor)
84
85
public
:
86
QtColorTriangle
(QWidget *parent = 0);
87
~
QtColorTriangle
();
88
89
QSize
sizeHint()
const
;
90
int
heightForWidth(
int
w)
const
;
91
92
void
polish();
93
QColor
color()
const
;
94
95
Q_SIGNALS:
96
void
colorChanged(
const
QColor
&col);
97
98
public
Q_SLOTS:
99
void
setColor(
const
QColor
&col);
100
101
protected
:
102
void
paintEvent(
QPaintEvent
*);
103
void
mouseMoveEvent(
QMouseEvent
*);
104
void
mousePressEvent(
QMouseEvent
*);
105
void
mouseReleaseEvent(
QMouseEvent
*);
106
void
keyPressEvent(
QKeyEvent
*e);
107
void
resizeEvent(
QResizeEvent
*);
108
void
drawTrigon(
QImage
*p,
const
QPointF
&a,
const
QPointF
&b,
109
const
QPointF
&c,
const
QColor
&color);
110
111
void
internalSetNewColor(
const
QColor
& color);
112
113
private
:
114
double
radiusAt(
const
QPointF
&pos,
const
QRect
&rect)
const
;
115
double
angleAt(
const
QPointF
&pos,
const
QRect
&rect)
const
;
116
QPointF
movePointToTriangle(
double
x,
double
y,
const
Vertex &a,
117
const
Vertex &b,
const
Vertex &c)
const
;
118
119
QPointF
pointFromColor(
const
QColor
&col)
const
;
120
QColor
colorFromPoint(
const
QPointF
&p)
const
;
121
122
void
genBackground();
123
124
QImage
bg;
125
double
a, b, c;
126
QPointF
pa, pb, pc, pd;
127
128
QColor
curColor;
129
int
curHue;
130
131
bool
mustGenerateBackground;
132
int
penWidth;
133
int
ellipseSize;
134
135
int
outerRadius;
136
QPointF
selectorPos;
137
138
enum
SelectionMode {
139
Idle,
140
SelectingHue,
141
SelectingSatValue
142
} selMode;
143
};
144
145
#endif
QColor
QRect
QSize
QtColorTriangle
The QtColorTriangle class provides a triangular color selection widget.
Definition:
qtcolortriangle.h:79
QPointF
QMouseEvent
QResizeEvent
QPaintEvent
QT_QTCOLORTRIANGLE_EXPORT
#define QT_QTCOLORTRIANGLE_EXPORT
Definition:
qtcolortriangle.h:76
QKeyEvent
QImage
Generated by
doxygen
1.8.17