krita

kcurve.h

00001 /* ============================================================
00002  * 
00003  * Copyright 2004-2005 by Gilles Caulier (original work as  digikam curveswidget)
00004  * Copyright 2005 by Casper Boemann (reworked to be generic)
00005  *
00006  * This program is free software; you can redistribute it
00007  * and/or modify it under the terms of the GNU General
00008  * Public License as published by the Free Software Foundation;
00009  * either version 2, or (at your option)
00010  * any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * ============================================================ */
00018 
00019 #ifndef KCURVE_H
00020 #define KCURVE_H
00021 
00022 // Qt includes.
00023 
00024 #include <qwidget.h>
00025 #include <qcolor.h>
00026 #include <qpair.h>
00027 #include <qsortedlist.h>
00028 #include <koffice_export.h>
00029 class KRITAUI_EXPORT KCurve : public QWidget
00030 {
00031 Q_OBJECT
00032 
00033 public:
00034     KCurve(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
00035 
00036     virtual ~KCurve();
00037 
00038     void reset(void);
00039     void setCurveGuide(QColor color);
00040     void setPixmap(QPixmap pix);
00041 
00042 
00043 signals:
00044     
00045     void modified(void);
00046             
00047 protected:
00048 
00049     void keyPressEvent(QKeyEvent *);
00050     void paintEvent(QPaintEvent *);
00051     void mousePressEvent (QMouseEvent * e);
00052     void mouseReleaseEvent ( QMouseEvent * e );
00053     void mouseMoveEvent ( QMouseEvent * e );
00054     void leaveEvent ( QEvent * );
00055     
00056 public:
00057     static double getCurveValue(QPtrList<QPair<double,double> > &curve, double x);
00058     double getCurveValue(double x);
00059     
00060     QPtrList<QPair<double,double> > getCurve();
00061     void setCurve(QPtrList<QPair<double,double> >inlist);
00062 
00063 private:
00064     double m_leftmost;
00065     double m_rightmost;
00066     QPair<double,double> *m_grab_point;
00067     bool m_dragging;
00068     double m_grabOffsetX;
00069     double m_grabOffsetY;
00070     
00071     bool m_readOnlyMode;
00072     bool m_guideVisible;
00073     QColor m_colorGuide;
00074     QPtrList<QPair<double,double> > m_points;
00075     QPixmap *m_pix;
00076 };
00077 
00078 
00079 #endif /* KCURVE_H */
KDE Home | KDE Accessibility Home | Description of Access Keys