NTK 1.3.0
Fl_Color_Chooser.H
Go to the documentation of this file.
1//
2// "$Id: Fl_Color_Chooser.H 7981 2010-12-08 23:53:04Z greg.ercolano $"
3//
4// Color chooser header file for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2010 by Bill Spitzak and others.
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Library General Public
10// License as published by the Free Software Foundation; either
11// version 2 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Library General Public License for more details.
17//
18// You should have received a copy of the GNU Library General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21// USA.
22//
23// Please report all bugs and problems on the following page:
24//
25// http://www.fltk.org/str.php
26//
27
31// The color chooser object and the color chooser popup. The popup
32// is just a window containing a single color chooser and some boxes
33// to indicate the current and cancelled color.
34
35#ifndef Fl_Color_Chooser_H
36#define Fl_Color_Chooser_H
37
38#include <FL/Fl_Group.H>
39#include <FL/Fl_Box.H>
40#include <FL/Fl_Return_Button.H>
41#include <FL/Fl_Choice.H>
42#include <FL/Fl_Value_Input.H>
43
44#ifndef FL_DOXYGEN
45
47class FL_EXPORT Flcc_HueBox : public Fl_Widget {
48 int px, py;
49protected:
50 void draw();
51 int handle_key(int);
52public:
53 int handle(int);
54 Flcc_HueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) {
55 px = py = 0;}
56};
57
59class FL_EXPORT Flcc_ValueBox : public Fl_Widget {
60 int py;
61protected:
62 void draw();
63 int handle_key(int);
64public:
65 int handle(int);
66 Flcc_ValueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) {
67 py = 0;}
68};
69
71class FL_EXPORT Flcc_Value_Input : public Fl_Value_Input {
72public:
73 int format(char*);
74 Flcc_Value_Input(int X, int Y, int W, int H) : Fl_Value_Input(X,Y,W,H) {}
75};
76
77#endif // !FL_DOXYGEN
78
116class FL_EXPORT Fl_Color_Chooser : public Fl_Group {
117 Flcc_HueBox huebox;
118 Flcc_ValueBox valuebox;
119 Fl_Choice choice;
120 Flcc_Value_Input rvalue;
121 Flcc_Value_Input gvalue;
122 Flcc_Value_Input bvalue;
123 Fl_Box resize_box;
124 double hue_, saturation_, value_;
125 double r_, g_, b_;
126 void set_valuators();
127 static void rgb_cb(Fl_Widget*, void*);
128 static void mode_cb(Fl_Widget*, void*);
129public:
130
135 int mode() {return choice.value();}
136
141 void mode(int newMode);
142
149 double hue() const {return hue_;}
150
155 double saturation() const {return saturation_;}
156
161 double value() const {return value_;}
162
167 double r() const {return r_;}
168
173 double g() const {return g_;}
174
179 double b() const {return b_;}
180
181 int hsv(double H, double S, double V);
182
183 int rgb(double R, double G, double B);
184
185 static void hsv2rgb(double H, double S, double V, double& R, double& G, double& B);
186
187 static void rgb2hsv(double R, double G, double B, double& H, double& S, double& V);
188
189 Fl_Color_Chooser(int X, int Y, int W, int H, const char *L = 0);
190};
191
192FL_EXPORT int fl_color_chooser(const char* name, double& r, double& g, double& b, int m=-1);
193FL_EXPORT int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b, int m=-1);
194
195#endif
196
197//
198// End of "$Id: Fl_Color_Chooser.H 7981 2010-12-08 23:53:04Z greg.ercolano $".
199//
This widget simply draws its box, and possibly it's label.
Definition: Fl_Box.H:43
A button that is used to pop up a menu.
Definition: Fl_Choice.H:85
int value() const
Gets the index of the last item chosen by the user.
Definition: Fl_Choice.H:97
The Fl_Color_Chooser widget provides a standard RGB color chooser.
Definition: Fl_Color_Chooser.H:116
double hue() const
Returns the current hue.
Definition: Fl_Color_Chooser.H:149
double value() const
Returns the value/brightness.
Definition: Fl_Color_Chooser.H:161
double g() const
Returns the current green value.
Definition: Fl_Color_Chooser.H:173
double b() const
Returns the current blue value.
Definition: Fl_Color_Chooser.H:179
double r() const
Returns the current red value.
Definition: Fl_Color_Chooser.H:167
int mode()
Returns which Fl_Color_Chooser variant is currently active.
Definition: Fl_Color_Chooser.H:135
double saturation() const
Returns the saturation.
Definition: Fl_Color_Chooser.H:155
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:45
The Fl_Value_Input widget displays a numeric value.
Definition: Fl_Value_Input.H:65
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:111
virtual void draw()=0
Draws the widget.
virtual int handle(int event)
Handles the specified event.
Definition: Fl_Widget.cxx:106
unsigned char uchar
unsigned char
Definition: fl_types.h:39
int fl_color_chooser(const char *name, double &r, double &g, double &b, int cmode)
Pops up a window to let the user pick an arbitrary RGB color.
Definition: Fl_Color_Chooser.cxx:574