summaryrefslogtreecommitdiffstats
path: root/kcoloredit/gradientselection.h
blob: cd47355b4c583e19534035c6000db0d9a88c6862 (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
/***************************************************************************
                          gradientselection.h  -  description
                             -------------------
    begin                : Wed Jul 12 2000
    copyright            : (C) 2000 by Artur Rataj
    email                : [email protected]
 ***************************************************************************/

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

#ifndef GRADIENTSELECTION_H
#define GRADIENTSELECTION_H

#include <tqwidget.h>
#include <tqcheckbox.h>
#include <tqpushbutton.h>
#include <tqbuttongroup.h>

#include "kxycolorselector.h"
#include "kzcolorselector.h"
#include "color.h"

/** A widget for selecting colors from gradients
  * @author Artur Rataj
  */
class GradientSelection : public TQWidget  {
   Q_OBJECT
  

public:
	/** Constructs the widget */
	GradientSelection(TQWidget *parent=0, const char *name=0);
	~GradientSelection();
	/** Enables or disables the color synchronize button */
	void enableSynchronizeColorButton(bool enable);

signals:
	/** A signal that a color value has changed by edition */
	void valueChanged(Color*);
	/** Synchronizes the widget color */
	void synchronizeColor();

public slots:
	/** Sets a color */
	void slotSetValue(Color* color);
	/** Whether to ignore the set value slot. Default is false. */
	void slotIgnoreSetValue(bool ignore);

protected:
	/** Components indices. If the gradient selector shows one of them,
	 *  the two components selector should be in a mode indicated by a value
	 *  of the appropriate index
	 */
	enum { H_COMPONENT = KXYColorSelector::TYPE_VS,
	       S_COMPONENT = KXYColorSelector::TYPE_HV,
	       V_COMPONENT = KXYColorSelector::TYPE_HS };
	
	/** Variable global component checkbox */
	TQCheckBox* variableCheckBox;
	/** Synchronize color button */
	TQPushButton* synchronizeColorButton;
	/** HSV buttons button group widget */
	TQButtonGroup hsvButtons;
	/** The two components selector */
	KXYColorSelector* xyColorSelector;
	/** The gradient selector */
	KZColorSelector* zColorSelector;
	/** Whether the two component color selector global component is variable */
	bool variableGlobalComponent;
	/** Whether to ignore the set value slot */
	bool ignoreSetValue;
	/** The selected color */
	Color color;
	/** The selected color H component */
	int hComponent;
	/** The selected color S component */
	int sComponent;
	/** The selected color V component */
	int vComponent;
	/** The gradient selector component index */
	int	zColorSelectorComponentIndex;
	/** Updates two component selector colors */
	void updateXyColorSelector(const bool modeChanged);
	/** Updates gradient selector colors */
	void updateZColorSelector();
	
protected slots:
	/** Sets color selection mode */
	void slotSetColorSelectionMode(int mode);
	/** Sets if the two component selector has a variable global component */
	void slotSetVariableGlobalComponent(bool variable);
	/** Notifies that the two component color selector pointer position changed */
	void slotXyColorSelectorPosChanged(int x, int y);
	/** Notifies that the gradient color selector pointer position changed */
	void slotZColorSelectorPosChanged(int y);
	/** sends synchronizeColor signal */
	void slotSynchronizeColor();
};

#endif