fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Color_Chooser Class Reference

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

#include <Fl_Color_Chooser.H>

Inheritance diagram for Fl_Color_Chooser:
Collaboration diagram for Fl_Color_Chooser:

List of all members.

Public Member Functions

int mode ()
void mode (int newMode)
double hue () const
double saturation () const
double value () const
double r () const
double g () const
double b () const
int hsv (double H, double S, double V)
int rgb (double R, double G, double B)
 Fl_Color_Chooser (int X, int Y, int W, int H, const char *L=0)

Static Public Member Functions

static void hsv2rgb (double H, double S, double V, double &R, double &G, double &B)
static void rgb2hsv (double R, double G, double B, double &H, double &S, double &V)

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.

fl_color_chooser.jpg

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.

Definition at line 116 of file Fl_Color_Chooser.H.


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,Hposition and size of the widget
[in]Lwidget label, default is no label

Definition at line 474 of file Fl_Color_Chooser.cxx.

References Fl_Widget::box(), Fl_Widget::callback(), Fl_Group::end(), FL_DOWN_FRAME, FL_HELVETICA_BOLD_ITALIC, FL_THIN_UP_BOX, Fl_Menu_::menu(), Fl_Group::resizable(), Fl_Group::resize(), and Fl_Menu_::textfont().


Member Function Documentation

double Fl_Color_Chooser::b ( ) const [inline]

Returns the current blue value. 0 <= b <= 1.

Definition at line 179 of file Fl_Color_Chooser.H.

Referenced by fl_color_chooser().

double Fl_Color_Chooser::g ( ) const [inline]

Returns the current green value. 0 <= g <= 1.

Definition at line 173 of file Fl_Color_Chooser.H.

Referenced by fl_color_chooser().

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,Vcolor components.
Returns:
1 if a new hsv value was set, 0 if the hsv value was the previous one.

Definition at line 175 of file Fl_Color_Chooser.cxx.

References Fl_Widget::damage(), FL_DAMAGE_EXPOSE, FL_DAMAGE_SCROLL, H, hsv2rgb(), ph, and Fl_Widget::set_changed().

Referenced by Flcc_ValueBox::handle(), Flcc_HueBox::handle(), Flcc_ValueBox::handle_key(), and Flcc_HueBox::handle_key().

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,Vcolor components
[out]R,G,Bcolor components

Definition at line 55 of file Fl_Color_Chooser.cxx.

References f, i, and int.

Referenced by Flcc_ValueBox::draw(), and hsv().

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.

Definition at line 149 of file Fl_Color_Chooser.H.

Referenced by Flcc_ValueBox::draw(), Flcc_HueBox::draw(), Flcc_ValueBox::handle(), Flcc_HueBox::handle(), Flcc_ValueBox::handle_key(), and Flcc_HueBox::handle_key().

void Fl_Color_Chooser::mode ( int  newMode)

Set which Fl_Color_Chooser variant is currently active

Parameters:
[in]newModecolor modes are rgb(0), byte(1), hex(2), or hsv(3)

Definition at line 458 of file Fl_Color_Chooser.cxx.

References Fl_Widget::do_callback(), and Fl_Choice::value().

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)

Definition at line 135 of file Fl_Color_Chooser.H.

Referenced by fl_color_chooser(), and Flcc_Value_Input::format().

double Fl_Color_Chooser::r ( ) const [inline]

Returns the current red value. 0 <= r <= 1.

Definition at line 167 of file Fl_Color_Chooser.H.

Referenced by fl_color_chooser().

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,Bcolor components.
Returns:
1 if a new rgb value was set, 0 if the rgb value was the previous one.

Definition at line 147 of file Fl_Color_Chooser.cxx.

References Fl_Widget::damage(), FL_DAMAGE_EXPOSE, FL_DAMAGE_SCROLL, ph, rgb2hsv(), and Fl_Widget::set_changed().

Referenced by fl_color_chooser().

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,Bcolor components
[out]H,S,Vcolor components

Definition at line 81 of file Fl_Color_Chooser.cxx.

Referenced by rgb().

double Fl_Color_Chooser::saturation ( ) const [inline]

Returns the saturation. 0 <= saturation <= 1.

Definition at line 155 of file Fl_Color_Chooser.H.

Referenced by Flcc_ValueBox::draw(), Flcc_HueBox::draw(), Flcc_ValueBox::handle(), Flcc_HueBox::handle(), Flcc_ValueBox::handle_key(), and Flcc_HueBox::handle_key().

double Fl_Color_Chooser::value ( ) const [inline]

Returns the value/brightness. 0 <= value <= 1.

Definition at line 161 of file Fl_Color_Chooser.H.

Referenced by Flcc_ValueBox::draw(), Flcc_ValueBox::handle(), Flcc_HueBox::handle(), Flcc_ValueBox::handle_key(), and Flcc_HueBox::handle_key().


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