chalk

kcurve.h
1/* ============================================================
2 *
3 * Copyright 2004-2005 by Gilles Caulier (original work as digikam curveswidget)
4 * Copyright 2005 by Casper Boemann (reworked to be generic)
5 *
6 * This program is free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General
8 * Public License as published by the Free Software Foundation;
9 * either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * ============================================================ */
18
19#ifndef KCURVE_H
20#define KCURVE_H
21
22// TQt includes.
23
24#include <tqwidget.h>
25#include <tqcolor.h>
26#include <tqpair.h>
27#include <tqsortedlist.h>
28#include <koffice_export.h>
29class KRITAUI_EXPORT KCurve : public TQWidget
30{
31TQ_OBJECT
32
33
34public:
35 KCurve(TQWidget *parent = 0, const char *name = 0, WFlags f = 0);
36
37 virtual ~KCurve();
38
39 void reset(void);
40 void setCurveGuide(TQColor color);
41 void setPixmap(TQPixmap pix);
42
43
44signals:
45
46 void modified(void);
47
48protected:
49
50 void keyPressEvent(TQKeyEvent *);
51 void paintEvent(TQPaintEvent *);
52 void mousePressEvent (TQMouseEvent * e);
53 void mouseReleaseEvent ( TQMouseEvent * e );
54 void mouseMoveEvent ( TQMouseEvent * e );
55 void leaveEvent ( TQEvent * );
56
57public:
58 static double getCurveValue(TQPtrList<TQPair<double,double> > &curve, double x);
59 double getCurveValue(double x);
60
61 TQPtrList<TQPair<double,double> > getCurve();
62 void setCurve(TQPtrList<TQPair<double,double> >inlist);
63
64private:
65 double m_leftmost;
66 double m_rightmost;
67 TQPair<double,double> *m_grab_point;
68 bool m_dragging;
69 double m_grabOffsetX;
70 double m_grabOffsetY;
71
72 bool m_readOnlyMode;
73 bool m_guideVisible;
74 TQColor m_colorGuide;
75 TQPtrList<TQPair<double,double> > m_points;
76 TQPixmap *m_pix;
77};
78
79
80#endif /* KCURVE_H */