FLTK 1.4.5: Fl_Color_Chooser.H Source File

FLTK 1.4.5

Loading...
Searching...
No Matches
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
19
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
36class FL_EXPORT Flcc_HueBox : public Fl_Widget {
37 int px, py;
38protected:
39 void draw() FL_OVERRIDE;
40 int handle_key(int);
41public:
42 int handle(int) FL_OVERRIDE;
43 Flcc_HueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) {
44 px = py = 0;}
45};
46
48class FL_EXPORT Flcc_ValueBox : public Fl_Widget {
49 int py;
50protected:
51 void draw() FL_OVERRIDE;
52 int handle_key(int);
53public:
54 int handle(int) FL_OVERRIDE;
55 Flcc_ValueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) {
56 py = 0;}
57};
58
60class FL_EXPORT Flcc_Value_Input : public Fl_Value_Input {
61public:
62 int format(char*) FL_OVERRIDE;
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
70
112 class FL_EXPORT Fl_Color_Chooser : public Fl_Group {
113 Flcc_HueBox huebox;
114 Flcc_ValueBox valuebox;
115 Fl_Choice choice;
116 Flcc_Value_Input rvalue;
117 Flcc_Value_Input gvalue;
118 Flcc_Value_Input bvalue;
119 Fl_Box resize_box;
120 double hue_, saturation_, value_;
121 double r_, g_, b_;
122 void set_valuators();
123 static void rgb_cb(Fl_Widget*, void*);
124 static void mode_cb(Fl_Widget*, void*);
125public:
126
127 int handle(int e) FL_OVERRIDE;
128
133 int mode() {return choice.value();}
134
139 void mode(int newMode);
140
147 double hue() const {return hue_;}
148
153 double saturation() const {return saturation_;}
154
159 double value() const {return value_;}
160
165 double r() const {return r_;}
166
171 double g() const {return g_;}
172
177 double b() const {return b_;}
178
179 int hsv(double H, double S, double V);
180
181 int rgb(double R, double G, double B);
182
183 static void hsv2rgb(double H, double S, double V, double& R, double& G, double& B);
184
185 static void rgb2hsv(double R, double G, double B, double& H, double& S, double& V);
186
187 Fl_Color_Chooser(int X, int Y, int W, int H, const char *L = 0);
188};
189
190FL_EXPORT int fl_color_chooser(const char* name, double& r, double& g, double& b, int m=-1);
191FL_EXPORT int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b, int m=-1);
192
193#endif
Fl_Box.H
Fl_Box widget.
Fl_Group.H
Fl_Group and Fl_End classes.
Fl_Box
This widget simply draws its box, and possibly its label.
Definition Fl_Box.H:34
Fl_Choice
A button that is used to pop up a menu.
Definition Fl_Choice.H:104
Fl_Color_Chooser::hue
double hue() const
Returns the current hue.
Definition Fl_Color_Chooser.H:147
Fl_Color_Chooser::value
double value() const
Returns the value/brightness.
Definition Fl_Color_Chooser.H:159
Fl_Color_Chooser::g
double g() const
Returns the current green value.
Definition Fl_Color_Chooser.H:171
Fl_Color_Chooser::b
double b() const
Returns the current blue value.
Definition Fl_Color_Chooser.H:177
Fl_Color_Chooser::Fl_Color_Chooser
Fl_Color_Chooser(int X, int Y, int W, int H, const char *L=0)
Creates a new Fl_Color_Chooser widget using the given position, size, and label string.
Definition Fl_Color_Chooser.cxx:551
Fl_Color_Chooser::r
double r() const
Returns the current red value.
Definition Fl_Color_Chooser.H:165
Fl_Color_Chooser::handle
int handle(int e) FL_OVERRIDE
Handles all events received by this widget.
Definition Fl_Color_Chooser.cxx:512
Fl_Color_Chooser::mode
int mode()
Returns which Fl_Color_Chooser variant is currently active.
Definition Fl_Color_Chooser.H:133
Fl_Color_Chooser::saturation
double saturation() const
Returns the saturation.
Definition Fl_Color_Chooser.H:153
Fl_Value_Input
The Fl_Value_Input widget displays a numeric value.
Definition Fl_Value_Input.H:56
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:112
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
uchar
unsigned char uchar
unsigned char
Definition fl_types.h:30