summaryrefslogtreecommitdiffstats
path: root/kcoloredit/texteditselection.h
blob: 55e41e413bf402387f73c795aa037e0f7023d717 (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
/***************************************************************************
                          texteditselection.h  -  description
                             -------------------
    begin                : Wed Jul 12 2000
    copyright            : (C) 2000 by Artur Rataj
    email                : art@zeus.polsl.gliwice.pl
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 TEXTEDITSELECTION_H
#define TEXTEDITSELECTION_H

#include <tqwidget.h>
#include <tqlineedit.h>
#include <tqlayout.h>

#include "color.h"

/** Color selection widget using line edit. Either HSV or RGB components
  * can be set.
  * @author Artur Rataj
  */
class TextEditSelection : public TQWidget  {
   Q_OBJECT
  TQ_OBJECT

public:
	/** Constructs the widget */
	TextEditSelection(TQWidget *parent=0, const char *name=0);
	~TextEditSelection();
	
signals:
	/** A signal that a color value has changed by edition */
	void valueChanged(Color*);

public slots:
	/** sets a color */
	void slotSetValue(Color* color);
	
protected:
	/** Adds a component line edit */
	void addComponent(const int index, TQLineEdit* lineEdit, const int maxValue, const TQString& labelString,
		const int row, const int column, TQGridLayout* layout);
	/** sets RGB string in rgbStringLineEdit */
	void setRgbString(const int red, const int green, const int blue);
		
protected slots:
	/** Called if one of HSV components has changed. In that case, RGB components are
	 *  also changed to match the HSV ones
	 */
	void slotHsvComponentChanged();
	/** Called if one of RGB components has changed. In that case, HSV components are
	 *  also changed to match the RGB ones
	 */
	void slotRgbComponentChanged();
	/** Called if the RGB string has changed. In that case, RGB and HSV components are
	 *  also changed to match the RGB string
	 */
	void slotRgbStringChanged();

protected:
	/** Indexes of components */
	enum { H_INDEX = 0,
	       S_INDEX = 1,
	       V_INDEX = 2,
	       R_INDEX = 3,
	       G_INDEX = 4,
	       B_INDEX = 5,
	/** A total number of components */
	       COMPONENTS_NUM = 6 };
	
	/** Line edit widgets table */
	TQLineEdit* lineEditTable[COMPONENTS_NUM];
	/** RGB hex string line edit widgets table */
	TQLineEdit* rgbStringLineEdit;
	/** The selected color */
	Color color;	
	/** A flag that components are matched */
	bool inChangingComponents;
};

#endif