lib

koColorSlider.h
1/* This file is part of the KDE project
2 Copyright (c) 1999 Matthias Elter (me@kde.org)
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef __ko_ColorSlider_h__
21#define __ko_ColorSlider_h__
22
23#include <tqframe.h>
24#include <tqpoint.h>
25#include <tqimage.h>
26#include <tqwidget.h>
27#include <kpixmap.h>
28#include <koffice_export.h>
29class SliderWidget;
30
31class KOPAINTER_EXPORT KoColorFrame : public TQFrame
32{
33 TQ_OBJECT
34
35public:
36 KoColorFrame(TQWidget *parent = 0L);
37
38 const TQColor colorAt(const TQPoint &p);
39
40protected:
41 void drawContents(TQPainter *p);
42 void mousePressEvent(TQMouseEvent *e);
43 void mouseMoveEvent(TQMouseEvent *e);
44 void mouseReleaseEvent(TQMouseEvent *e);
45
46public slots:
47 void slotSetColor1(const TQColor &c);
48 void slotSetColor2(const TQColor &c);
49
50signals:
51 void clicked(const TQPoint &p);
52 void colorSelected(const TQColor &c);
53
54protected:
55 TQColor mC1;
56 TQColor mC2;
57 KPixmap mPixmap;
58 TQImage mImage;
59 bool mColorChanged;
60 bool mPixChanged;
61 bool mDragging;
62};
63
64class KOPAINTER_EXPORT KoSliderWidget : public TQWidget
65{
66 TQ_OBJECT
67
68public:
69 KoSliderWidget(TQWidget *parent = 0L);
70
71protected:
72 void mousePressEvent(TQMouseEvent *e);
73 void mouseReleaseEvent(TQMouseEvent *e);
74 void mouseMoveEvent(TQMouseEvent *e);
75 void paintEvent(TQPaintEvent *);
76
77signals:
78 void positionChanged(int);
79
80protected:
81 bool mDragging;
82 TQPoint mPos;
83};
84
85class KOPAINTER_EXPORT KoColorSlider : public TQWidget
86{
87 TQ_OBJECT
88
89public:
90 KoColorSlider(TQWidget *parent = 0L);
91 virtual ~KoColorSlider();
92
93 int minValue();
94 int maxValue();
95
96protected:
97 void resizeEvent(TQResizeEvent *);
98 void mousePressEvent(TQMouseEvent *);
99
100public slots:
101 void slotSetColor1(const TQColor &c);
102 void slotSetColor2(const TQColor &c);
103
104 void slotSetValue(int value);
105 void slotSetRange(int min, int max);
106
107protected slots:
108 void slotSliderMoved(int x);
109 void slotFrameClicked(const TQPoint &p);
110
111signals:
112 void colorSelected(const TQColor &c);
113 void valueChanged(int value);
114
115protected:
116 KoSliderWidget *mSlider;
117 KoColorFrame *mColorFrame;
118 int mMin, mMax;
119 int mValue;
120};
121
122#endif