FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Related Functions
Fl_Color_Chooser Class Reference
Common Dialogs classes and functions

The Fl_Color_Chooser widget provides a standard RGB color chooser. More...

`#include <Fl_Color_Chooser.H>`

Inheritance diagram for Fl_Color_Chooser:

List of all members.

## Public Member Functions
double | b () const
| Returns the current blue value.
| 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.
double | g () const
| Returns the current green value.
int | hsv (double H, double S, double V)
| Set the hsv values.
double | hue () const
| Returns the current hue.
int | mode ()
| Returns which Fl_Color_Chooser variant is currently active.
void | mode (int newMode)
| Set which Fl_Color_Chooser variant is currently active.
double | r () const
| Returns the current red value.
int | rgb (double R, double G, double B)
| Sets the current rgb color values.
double | saturation () const
| Returns the saturation.
double | value () const
| Returns the value/brightness.
## Static Public Member Functions
static void | hsv2rgb (double H, double S, double V, double &R, double &G, double &B)
| This static method converts HSV colors to RGB colorspace.
static void | rgb2hsv (double R, double G, double B, double &H, double &S, double &V)
| This static method converts RGB colors to HSV colorspace.
## Related Functions
(Note that these are not member functions.)
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.
int | fl_color_chooser (const char *name, uchar &r, uchar &g, uchar &b, int cmode)
| Pops up a window to let the user pick an arbitrary RGB color.

## Detailed Description

The Fl_Color_Chooser widget provides a standard RGB color chooser.

You can place any number of the widgets into a panel of your own design. The diagram shows the widget as part of a color chooser dialog created by the fl_color_chooser() function. The Fl_Color_Chooser widget contains the hue box, value slider, and rgb input fields from the above diagram (it does not have the color chips or the Cancel or OK buttons). The callback is done every time the user changes the rgb value. It is not done if they move the hue control in a way that produces the same rgb value, such as when saturation or value is zero.

The fl_color_chooser() function pops up a window to let the user pick an arbitrary RGB color. They can pick the hue and saturation in the "hue box" on the left (hold down CTRL to just change the saturation), and the brightness using the vertical slider. Or they can type the 8-bit numbers into the RGB Fl_Value_Input fields, or drag the mouse across them to adjust them. The pull-down menu lets the user set the input fields to show RGB, HSV, or 8-bit RGB (0 to 255).

fl_color_chooser() returns non-zero if the user picks ok, and updates the RGB values. If the user picks cancel or closes the window this returns zero and leaves RGB unchanged.

If you use the color chooser on an 8-bit screen, it will allocate all the available colors, leaving you no space to exactly represent the color the user picks! You can however use fl_rectf() to fill a region with a simulated color using dithering.

## Constructor & Destructor Documentation

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.

The recommended dimensions are 200x95. The color is initialized to black.

Parameters:

  [in] | X,Y,W,H | position and size of the widget
  [in] | L | widget label, default is no label

## Member Function Documentation

double Fl_Color_Chooser::b | ( |  | ) | const`[inline]`

Returns the current blue value.

0 <= b <= 1.

double Fl_Color_Chooser::g | ( |  | ) | const`[inline]`

Returns the current green value.

0 <= g <= 1.

int Fl_Color_Chooser::hsv | ( | double | H,
|  | double | S,
|  | double | V
| ) |  |

Set the hsv values.

The passed values are clamped (or for hue, modulus 6 is used) to get legal values. Does not do the callback.

Parameters:

  [in] | H,S,V | color components.

Returns:
  1 if a new hsv value was set, 0 if the hsv value was the previous one.

void Fl_Color_Chooser::hsv2rgb | ( | double | H,
|  | double | S,
|  | double | V,
|  | double & | R,
|  | double & | G,
|  | double & | B
| ) |  | `[static]`

This static method converts HSV colors to RGB colorspace.

Parameters:

  [in] | H,S,V | color components
  [out] | R,G,B | color components

double Fl_Color_Chooser::hue | ( |  | ) | const`[inline]`

Returns the current hue.

0 <= hue < 6. Zero is red, one is yellow, two is green, etc. This value is convenient for the internal calculations - some other systems consider hue to run from zero to one, or from 0 to 360.

int Fl_Color_Chooser::mode | ( |  | ) | `[inline]`

Returns which Fl_Color_Chooser variant is currently active.

Returns:
  color modes are rgb(0), byte(1), hex(2), or hsv(3)

void Fl_Color_Chooser::mode | ( | int | newMode | ) |

Set which Fl_Color_Chooser variant is currently active.

Parameters:

  [in] | newMode | color modes are rgb(0), byte(1), hex(2), or hsv(3)

double Fl_Color_Chooser::r | ( |  | ) | const`[inline]`

Returns the current red value.

0 <= r <= 1.

int Fl_Color_Chooser::rgb | ( | double | R,
|  | double | G,
|  | double | B
| ) |  |

Sets the current rgb color values.

Does not do the callback. Does not clamp (but out of range values will produce psychedelic effects in the hue selector).

Parameters:

  [in] | R,G,B | color components.

Returns:
  1 if a new rgb value was set, 0 if the rgb value was the previous one.

void Fl_Color_Chooser::rgb2hsv | ( | double | R,
|  | double | G,
|  | double | B,
|  | double & | H,
|  | double & | S,
|  | double & | V
| ) |  | `[static]`

This static method converts RGB colors to HSV colorspace.

Parameters:

  [in] | R,G,B | color components
  [out] | H,S,V | color components

double Fl_Color_Chooser::saturation | ( |  | ) | const`[inline]`

Returns the saturation.

0 <= saturation <= 1.

double Fl_Color_Chooser::value | ( |  | ) | const`[inline]`

Returns the value/brightness.

0 <= value <= 1.

The documentation for this class was generated from the following files:

- Fl_Color_Chooser.H
- Fl_Color_Chooser.cxx