summaryrefslogtreecommitdiffstats
path: root/karbon/widgets/vcolorslider.h
blob: c7467e454b6d55d802c27a527c6eb4186b053c6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* This file is part of the KDE project
   Made by Tomislav Lukman (tomislav.lukman@ck.tel.hr)
   Copyright (C) 2002, The Karbon Developers

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

/* vcolorslider.h */
#ifndef VCOLORSLIDER_H
#define VCOLORSLIDER_H

#include <tqwidget.h>

class TQLabel;
class KIntSpinBox;
class KGradientSelector;

/**
 * This is the color slider widget that is used to select color or color components.
 * It combines a label, a gradient selector and a spinbox.
 */
class VColorSlider : public TQWidget
{
	Q_OBJECT
  
public:
	/**
	 * Constructs a new color slider.
	 *
	 * @param parent the parent widget
	 * @param name the slider's name
	 */
	VColorSlider( TQWidget* parent = 0L, const char* name = 0L );

	/**
	 * Constructs a new color slider.
	 *
	 * @param label the label text
	 * @param col1 the left color
	 * @param col2 the right color
	 * @param min the minimum value
	 * @param max the maximum value
	 * @param value the actual value
	 * @param parent the parent widget
	 * @param name the slider's name
	 */
	VColorSlider( const TQString& label, const TQColor& col1, const TQColor& col2,
		int min, int max, int value, TQWidget* parent = 0L, const char* name = 0L );
	
	/** Destroys the color slider */
	~VColorSlider();
	
	/** 
	 * Reflects if the slider is still being dragged while the color changes 
	 *
	 * @return true if slider is still dragged, else false
	 */
	bool isDragging() { return m_isDragging; }
public slots:
	
	/**
	 * Sets the description of the slider 
	 *
	 * @param label the new label text
	 */
	virtual void setLabel( const TQString& label );
	
	/**
	* Sets the colors for the slider.
	*
	* @param color1 the new left color
	* @param color2 the new right color
	*/
	virtual void setColors( const TQColor& color1, const TQColor& color2 );
	
	/**
	 * Sets the value of the spinbox (and the value of the vcolorslider).
	 *
	 * @param value the new value
	 */
	virtual void setValue( int value );

	/**
	 * Sets the minimum value of the spinbox and slider.
	 *
	 * @param value the new minimum value
	 */
	virtual void setMinValue( int value );
	
	/**
	 * Sets the maximum value of the spinbox and slider.
	 *
	 * @param value the new maximum value
	 */
	virtual void setMaxValue( int value );
	
	/**
	 * Retrieves the actual value of the spinbox and slider.
	 *
	 * @return the actual value
	 */
	int value();

private:
	void init();
 	bool eventFilter( TQObject *obj, TQEvent *ev );
	TQLabel* m_label;
	KIntSpinBox* m_spinBox;
	KGradientSelector* m_gradientSelect;
	bool m_isDragging;
	int m_minValue;
	int m_maxValue;

signals:
	/** 
	* Is emitted whenever the slider or spinbox value has changed.
	* Use @ref isDragging to know if the slider is still being dragged.
	*
	* @param value the actual value
	*/
	void valueChanged( int value );

private slots:
	void updateFrom_spinBox( int );
	void updateFrom_gradientSelect( int );
};

#endif