FLTK
Fl_Color_Chooser.H
Go to the documentation of this file.
1 //
2 // Color chooser header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2019 by Bill Spitzak and others.
5 //
6 // This library is free software. Distribution and use rights are outlined in
7 // the file "COPYING" which should have been included with this file. If this
8 // file is missing or damaged, see the license at:
9 //
10 // https://www.fltk.org/COPYING.php
11 //
12 // Please see the following page on how to report bugs and issues:
13 //
14 // https://www.fltk.org/bugs.php
15 //
16 
20 // The color chooser object and the color chooser popup. The popup
21 // is just a window containing a single color chooser and some boxes
22 // to indicate the current and cancelled color.
23 
24 #ifndef Fl_Color_Chooser_H
25 #define Fl_Color_Chooser_H
26 
27 #include <FL/Fl_Group.H>
28 #include <FL/Fl_Box.H>
29 #include <FL/Fl_Return_Button.H>
30 #include <FL/Fl_Choice.H>
31 #include <FL/Fl_Value_Input.H>
32 
33 #ifndef FL_DOXYGEN
34 
36 class FL_EXPORT Flcc_HueBox : public Fl_Widget {
37  int px, py;
38 protected:
39  void draw();
40  int handle_key(int);
41 public:
42  int handle(int);
43  Flcc_HueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) {
44  px = py = 0;}
45 };
46 
48 class FL_EXPORT Flcc_ValueBox : public Fl_Widget {
49  int py;
50 protected:
51  void draw();
52  int handle_key(int);
53 public:
54  int handle(int);
55  Flcc_ValueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) {
56  py = 0;}
57 };
58 
60 class FL_EXPORT Flcc_Value_Input : public Fl_Value_Input {
61 public:
62  int format(char*);
63  Flcc_Value_Input(int X, int Y, int W, int H) : Fl_Value_Input(X,Y,W,H) {}
64 };
65 
66 #endif // !FL_DOXYGEN
67 
109 class FL_EXPORT Fl_Color_Chooser : public Fl_Group {
110  Flcc_HueBox huebox;
111  Flcc_ValueBox valuebox;
112  Fl_Choice choice;
113  Flcc_Value_Input rvalue;
114  Flcc_Value_Input gvalue;
115  Flcc_Value_Input bvalue;
116  Fl_Box resize_box;
117  double hue_, saturation_, value_;
118  double r_, g_, b_;
119  void set_valuators();
120  static void rgb_cb(Fl_Widget*, void*);
121  static void mode_cb(Fl_Widget*, void*);
122 public:
123 
124  int handle(int e);
125 
130  int mode() {return choice.value();}
131 
136  void mode(int newMode);
137 
144  double hue() const {return hue_;}
145 
150  double saturation() const {return saturation_;}
151 
156  double value() const {return value_;}
157 
162  double r() const {return r_;}
163 
168  double g() const {return g_;}
169 
174  double b() const {return b_;}
175 
176  int hsv(double H, double S, double V);
177 
178  int rgb(double R, double G, double B);
179 
180  static void hsv2rgb(double H, double S, double V, double& R, double& G, double& B);
181 
182  static void rgb2hsv(double R, double G, double B, double& H, double& S, double& V);
183 
184  Fl_Color_Chooser(int X, int Y, int W, int H, const char *L = 0);
185 };
186 
187 FL_EXPORT int fl_color_chooser(const char* name, double& r, double& g, double& b, int m=-1);
188 FL_EXPORT int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b, int m=-1);
189 
190 #endif
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
int value() const
Gets the index of the last item chosen by the user.
Definition: Fl_Choice.H:115
The Fl_Value_Input widget displays a numeric value.
Definition: Fl_Value_Input.H:55
virtual int handle(int event)
Handles the specified event.
Definition: Fl_Widget.cxx:102
The Fl_Color_Chooser widget provides a standard RGB color chooser.
Definition: Fl_Color_Chooser.H:109
virtual void draw()=0
Draws the widget.
double saturation() const
Returns the saturation.
Definition: Fl_Color_Chooser.H:150
double b() const
Returns the current blue value.
Definition: Fl_Color_Chooser.H:174
This widget simply draws its box, and possibly its label.
Definition: Fl_Box.H:32
double r() const
Returns the current red value.
Definition: Fl_Color_Chooser.H:162
virtual int format(char *)
Uses internal rules to format the fields numerical value into the character array pointed to by the p...
Definition: Fl_Valuator.cxx:168
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:42
int handle(int)
Handles the specified event.
Definition: Fl_Group.cxx:144
int mode()
Returns which Fl_Color_Chooser variant is currently active.
Definition: Fl_Color_Chooser.H:130
double value() const
Returns the value/brightness.
Definition: Fl_Color_Chooser.H:156
double hue() const
Returns the current hue.
Definition: Fl_Color_Chooser.H:144
A button that is used to pop up a menu.
Definition: Fl_Choice.H:103
double g() const
Returns the current green value.
Definition: Fl_Color_Chooser.H:168
unsigned char uchar
unsigned char
Definition: fl_types.h:28