[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
src/klftools/qtcolortriangle.h
Go to the documentation of this file.
00001 /*
00002  * This file was very slightly modified by Philippe Faist for KLatexFormula. (april 2009)
00003  * In order for integration into KLatexFormula, this code is relicensed
00004  * to **GPL Version 2.1 or higher** as described in the footnote to the GPL
00005  * compatibility table found at
00006  *   http://www.gnu.org/licenses/gpl-faq.html#compat-matrix-footnote-7
00007  *
00008  */
00009 
00010 /****************************************************************************
00011 **
00012 ** This file is part of a Qt Solutions component.
00013 ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
00014 ** 
00015 ** Contact:  Qt Software Information (qt-info@nokia.com)
00016 ** 
00017 ** Commercial Usage  
00018 ** Licensees holding valid Qt Commercial licenses may use this file in
00019 ** accordance with the Qt Solutions Commercial License Agreement provided
00020 ** with the Software or, alternatively, in accordance with the terms
00021 ** contained in a written agreement between you and Nokia.
00022 ** 
00023 ** GNU Lesser General Public License Usage
00024 ** Alternatively, this file may be used under the terms of the GNU Lesser
00025 ** General Public License version 2.1 as published by the Free Software
00026 ** Foundation and appearing in the file LICENSE.LGPL included in the
00027 ** packaging of this file.  Please review the following information to
00028 ** ensure the GNU Lesser General Public License version 2.1 requirements
00029 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00030 ** 
00031 ** In addition, as a special exception, Nokia gives you certain
00032 ** additional rights. These rights are described in the Nokia Qt LGPL
00033 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
00034 ** package.
00035 ** 
00036 ** GNU General Public License Usage 
00037 ** Alternatively, this file may be used under the terms of the GNU
00038 ** General Public License version 3.0 as published by the Free Software
00039 ** Foundation and appearing in the file LICENSE.GPL included in the
00040 ** packaging of this file.  Please review the following information to
00041 ** ensure the GNU General Public License version 3.0 requirements will be
00042 ** met: http://www.gnu.org/copyleft/gpl.html.
00043 ** 
00044 ** Please note Third Party Software included with Qt Solutions may impose
00045 ** additional restrictions and it is the user's responsibility to ensure
00046 ** that they have met the licensing requirements of the GPL, LGPL, or Qt
00047 ** Solutions Commercial license and the relevant license of the Third
00048 ** Party Software they are using.
00049 ** 
00050 ** If you are unsure which license is appropriate for your use, please
00051 ** contact the sales department at qt-sales@nokia.com.
00052 ** 
00053 ****************************************************************************/
00054 
00055 #ifndef QTCOLORTRIANGLE_H
00056 #define QTCOLORTRIANGLE_H
00057 #include <QImage>
00058 #include <QWidget>
00059 
00060 class QPointF;
00061 struct Vertex;
00062 
00063 #if defined(KLF_WS_WIN)
00064 #  if !defined(QT_QTCOLORTRIANGLE_EXPORT) && !defined(QT_QTCOLORTRIANGLE_IMPORT)
00065 #    define QT_QTCOLORTRIANGLE_EXPORT
00066 #  elif defined(QT_QTCOLORTRIANGLE_IMPORT)
00067 #    if defined(QT_QTCOLORTRIANGLE_EXPORT)
00068 #      undef QT_QTCOLORTRIANGLE_EXPORT
00069 #    endif
00070 #    define QT_QTCOLORTRIANGLE_EXPORT __declspec(dllimport)
00071 #  elif defined(QT_QTCOLORTRIANGLE_EXPORT)
00072 #    undef QT_QTCOLORTRIANGLE_EXPORT
00073 #    define QT_QTCOLORTRIANGLE_EXPORT __declspec(dllexport)
00074 #  endif
00075 #else
00076 #  define QT_QTCOLORTRIANGLE_EXPORT
00077 #endif
00078 
00079 class QT_QTCOLORTRIANGLE_EXPORT QtColorTriangle : public QWidget
00080 {
00081     Q_OBJECT
00082 
00083     Q_PROPERTY(QColor color READ color WRITE setColor)
00084 
00085 public:
00086     QtColorTriangle(QWidget *parent = 0);
00087     ~QtColorTriangle();
00088 
00089     QSize sizeHint() const;
00090     int heightForWidth(int w) const;
00091 
00092     void polish();
00093     QColor color() const;
00094 
00095 Q_SIGNALS:
00096     void colorChanged(const QColor &col);
00097 
00098 public Q_SLOTS:
00099     void setColor(const QColor &col);
00100 
00101 protected:
00102     void paintEvent(QPaintEvent *);
00103     void mouseMoveEvent(QMouseEvent *);
00104     void mousePressEvent(QMouseEvent *);
00105     void mouseReleaseEvent(QMouseEvent *);
00106     void keyPressEvent(QKeyEvent *e);
00107     void resizeEvent(QResizeEvent *);
00108     void drawTrigon(QImage *p, const QPointF &a, const QPointF &b,
00109                     const QPointF &c, const QColor &color);
00110 
00111   void internalSetNewColor(const QColor& color);
00112 
00113 private:
00114     double radiusAt(const QPointF &pos, const QRect &rect) const;
00115     double angleAt(const QPointF &pos, const QRect &rect) const;
00116     QPointF movePointToTriangle(double x, double y, const Vertex &a,
00117                                     const Vertex &b, const Vertex &c) const;
00118 
00119     QPointF pointFromColor(const QColor &col) const;
00120     QColor colorFromPoint(const QPointF &p) const;
00121 
00122     void genBackground();
00123 
00124     QImage bg;
00125     double a, b, c;
00126     QPointF pa, pb, pc, pd;
00127 
00128     QColor curColor;
00129     int curHue;
00130 
00131     bool mustGenerateBackground;
00132     int penWidth;
00133     int ellipseSize;
00134 
00135     int outerRadius;
00136     QPointF selectorPos;
00137 
00138     enum SelectionMode {
00139         Idle,
00140         SelectingHue,
00141         SelectingSatValue
00142     } selMode;
00143 };
00144 
00145 #endif

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net