fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("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:
[legend]
Collaboration diagram for Fl_Color_Chooser:
[legend]

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)
 
- Public Member Functions inherited from Fl_Group
int handle (int)
 
void begin ()
 
void end ()
 
int children () const
 
Fl_Widgetchild (int n) const
 
int find (const Fl_Widget *) const
 
int find (const Fl_Widget &o) const
 
Fl_Widget *constarray () const
 
void resize (int, int, int, int)
 
 Fl_Group (int, int, int, int, const char *=0)
 
virtual ~Fl_Group ()
 
void add (Fl_Widget &)
 
void add (Fl_Widget *o)
 
void insert (Fl_Widget &, int i)
 
void insert (Fl_Widget &o, Fl_Widget *before)
 
void remove (int index)
 
void remove (Fl_Widget &)
 
void remove (Fl_Widget *o)
 
void clear ()
 
void resizable (Fl_Widget &o)
 
void resizable (Fl_Widget *o)
 
Fl_Widgetresizable () const
 
void add_resizable (Fl_Widget &o)
 
void init_sizes ()
 
void clip_children (int c)
 
unsigned int clip_children ()
 
virtual Fl_Groupas_group ()
 
void focus (Fl_Widget *W)
 
Fl_Widget *& _ddfdesign_kludge ()
 
void forms_end ()
 
- Public Member Functions inherited from Fl_Widget
virtual ~Fl_Widget ()
 
int is_label_copied () const
 
Fl_Groupparent () const
 
void parent (Fl_Group *p)
 
uchar type () const
 
void type (uchar t)
 
int x () const
 
int y () const
 
int w () const
 
int h () const
 
int damage_resize (int, int, int, int)
 
void position (int X, int Y)
 
void size (int W, int H)
 
Fl_Align align () const
 
void align (Fl_Align alignment)
 
Fl_Boxtype box () const
 
void box (Fl_Boxtype new_box)
 
Fl_Color color () const
 
void color (Fl_Color bg)
 
Fl_Color selection_color () const
 
void selection_color (Fl_Color a)
 
void color (Fl_Color bg, Fl_Color sel)
 
const char * label () const
 
void label (const char *text)
 
void copy_label (const char *new_label)
 
void label (Fl_Labeltype a, const char *b)
 
Fl_Labeltype labeltype () const
 
void labeltype (Fl_Labeltype a)
 
Fl_Color labelcolor () const
 
void labelcolor (Fl_Color c)
 
Fl_Font labelfont () const
 
void labelfont (Fl_Font f)
 
Fl_Fontsize labelsize () const
 
void labelsize (Fl_Fontsize pix)
 
Fl_Imageimage ()
 
const Fl_Imageimage () const
 
void image (Fl_Image *img)
 
void image (Fl_Image &img)
 
Fl_Imagedeimage ()
 
const Fl_Imagedeimage () const
 
void deimage (Fl_Image *img)
 
void deimage (Fl_Image &img)
 
const char * tooltip () const
 
void tooltip (const char *text)
 
void copy_tooltip (const char *text)
 
Fl_Callback_p callback () const
 
void callback (Fl_Callback *cb, void *p)
 
void callback (Fl_Callback *cb)
 
void callback (Fl_Callback0 *cb)
 
void callback (Fl_Callback1 *cb, long p=0)
 
void * user_data () const
 
void user_data (void *v)
 
long argument () const
 
void argument (long v)
 
Fl_When when () const
 
void when (uchar i)
 
unsigned int visible () const
 
int visible_r () const
 
virtual void show ()
 
virtual void hide ()
 
void set_visible ()
 
void clear_visible ()
 
unsigned int active () const
 
int active_r () const
 
void activate ()
 
void deactivate ()
 
unsigned int output () const
 
void set_output ()
 
void clear_output ()
 
unsigned int takesevents () const
 
unsigned int changed () const
 
void set_changed ()
 
void clear_changed ()
 
void clear_active ()
 
void set_active ()
 
int take_focus ()
 
void set_visible_focus ()
 
void clear_visible_focus ()
 
void visible_focus (int v)
 
unsigned int visible_focus ()
 
void do_callback ()
 
void do_callback (Fl_Widget *o, long arg)
 
void do_callback (Fl_Widget *o, void *arg=0)
 
int test_shortcut ()
 
void _set_fullscreen ()
 
void _clear_fullscreen ()
 
int contains (const Fl_Widget *w) const
 
int inside (const Fl_Widget *wgt) const
 
void redraw ()
 
void redraw_label ()
 
uchar damage () const
 
void clear_damage (uchar c=0)
 
void damage (uchar c)
 
void damage (uchar c, int x, int y, int w, int h)
 
void draw_label (int, int, int, int, Fl_Align) const
 
void measure_label (int &ww, int &hh) const
 
Fl_Windowwindow () const
 
Fl_Windowtop_window () const
 
Fl_Windowtop_window_offset (int &xoff, int &yoff) const
 
virtual Fl_Windowas_window ()
 
virtual class Fl_Gl_Windowas_gl_window ()
 
int use_accents_menu ()
 
Fl_Color color2 () const
 
void color2 (unsigned a)
 

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)
 
- Static Public Member Functions inherited from Fl_Group
static Fl_Groupcurrent ()
 
static void current (Fl_Group *g)
 
- Static Public Member Functions inherited from Fl_Widget
static void default_callback (Fl_Widget *cb, void *d)
 
static unsigned int label_shortcut (const char *t)
 
static int test_shortcut (const char *, const bool require_alt=false)
 

Private Member Functions

void set_valuators ()
 

Static Private Member Functions

static void rgb_cb (Fl_Widget *, void *)
 
static void mode_cb (Fl_Widget *, void *)
 

Private Attributes

Flcc_HueBox huebox
 
Flcc_ValueBox valuebox
 
Fl_Choice choice
 
Flcc_Value_Input rvalue
 
Flcc_Value_Input gvalue
 
Flcc_Value_Input bvalue
 
Fl_Box resize_box
 
double hue_
 
double saturation_
 
double value_
 
double r_
 
double g_
 
double b_
 

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. More...
 
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. More...
 

Additional Inherited Members

- Protected Types inherited from Fl_Widget
enum  {
  INACTIVE = 1<<0, INVISIBLE = 1<<1, OUTPUT = 1<<2, NOBORDER = 1<<3,
  FORCE_POSITION = 1<<4, NON_MODAL = 1<<5, SHORTCUT_LABEL = 1<<6, CHANGED = 1<<7,
  OVERRIDE = 1<<8, VISIBLE_FOCUS = 1<<9, COPIED_LABEL = 1<<10, CLIP_CHILDREN = 1<<11,
  MENU_WINDOW = 1<<12, TOOLTIP_WINDOW = 1<<13, MODAL = 1<<14, NO_OVERLAY = 1<<15,
  GROUP_RELATIVE = 1<<16, COPIED_TOOLTIP = 1<<17, FULLSCREEN = 1<<18, MAC_USE_ACCENTS_MENU = 1<<19,
  USERFLAG3 = 1<<29, USERFLAG2 = 1<<30, USERFLAG1 = 1<<31
}
 
- Protected Member Functions inherited from Fl_Group
void draw ()
 
void draw_child (Fl_Widget &widget) const
 
void draw_children ()
 
void draw_outside_label (const Fl_Widget &widget) const
 
void update_child (Fl_Widget &widget) const
 
int * sizes ()
 
- Protected Member Functions inherited from Fl_Widget
 Fl_Widget (int x, int y, int w, int h, const char *label=0L)
 
void x (int v)
 
void y (int v)
 
void w (int v)
 
void h (int v)
 
unsigned int flags () const
 
void set_flag (unsigned int c)
 
void clear_flag (unsigned int c)
 
void draw_box () const
 
void draw_box (Fl_Boxtype t, Fl_Color c) const
 
void draw_box (Fl_Boxtype t, int x, int y, int w, int h, Fl_Color c) const
 
void draw_backdrop () const
 
void draw_focus ()
 
void draw_focus (Fl_Boxtype t, int x, int y, int w, int h) const
 
void draw_label () const
 
void draw_label (int, int, int, int) const
 

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.

Definition at line 107 of file Fl_Color_Chooser.H.

Constructor & Destructor Documentation

◆ 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. 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 465 of file Fl_Color_Chooser.cxx.

References b_, Fl_Widget::box(), bvalue, Fl_Widget::callback(), choice, Fl_Group::end(), FL_DOWN_FRAME, FL_HELVETICA_BOLD_ITALIC, FL_THIN_UP_BOX, g_, gvalue, H, hue_, huebox, Fl_Menu_::menu(), mode_cb(), mode_menu, r_, Fl_Group::resizable(), Fl_Group::resize(), resize_box, rgb_cb(), rvalue, saturation_, set_valuators(), Fl_Menu_::textfont(), value_, valuebox, and Y.

Member Function Documentation

◆ b()

double Fl_Color_Chooser::b ( ) const
inline

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

Definition at line 170 of file Fl_Color_Chooser.H.

Referenced by chooser_cb(), and fl_color_chooser().

◆ g()

double Fl_Color_Chooser::g ( ) const
inline

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

Definition at line 164 of file Fl_Color_Chooser.H.

Referenced by chooser_cb(), and fl_color_chooser().

◆ hsv()

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 166 of file Fl_Color_Chooser.cxx.

References b_, Fl_Widget::damage(), FL_DAMAGE_EXPOSE, FL_DAMAGE_SCROLL, g_, H, hsv2rgb(), hue_, huebox, ph, r_, saturation_, Fl_Widget::set_changed(), set_valuators(), V, value_, and valuebox.

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

◆ hsv2rgb()

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 46 of file Fl_Color_Chooser.cxx.

References f, H, and V.

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

◆ hue()

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 140 of file Fl_Color_Chooser.H.

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

◆ mode() [1/2]

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 126 of file Fl_Color_Chooser.H.

References Fl_Choice::value().

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

◆ mode() [2/2]

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 449 of file Fl_Color_Chooser.cxx.

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

◆ mode_cb()

void Fl_Color_Chooser::mode_cb ( Fl_Widget o,
void *   
)
staticprivate

◆ r()

double Fl_Color_Chooser::r ( ) const
inline

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

Definition at line 158 of file Fl_Color_Chooser.H.

Referenced by chooser_cb(), and fl_color_chooser().

◆ rgb()

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 138 of file Fl_Color_Chooser.cxx.

References b_, Fl_Widget::damage(), FL_DAMAGE_EXPOSE, FL_DAMAGE_SCROLL, g_, hue_, huebox, ph, r_, rgb2hsv(), saturation_, Fl_Widget::set_changed(), set_valuators(), value_, and valuebox.

Referenced by fl_color_chooser(), and rgb_cb().

◆ rgb2hsv()

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 72 of file Fl_Color_Chooser.cxx.

References H, and V.

Referenced by rgb().

◆ rgb_cb()

void Fl_Color_Chooser::rgb_cb ( Fl_Widget o,
void *   
)
staticprivate

◆ saturation()

double Fl_Color_Chooser::saturation ( ) const
inline

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

Definition at line 146 of file Fl_Color_Chooser.H.

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

◆ set_valuators()

void Fl_Color_Chooser::set_valuators ( )
private

◆ value()

double Fl_Color_Chooser::value ( ) const
inline

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

Definition at line 152 of file Fl_Color_Chooser.H.

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

Member Data Documentation

◆ b_

double Fl_Color_Chooser::b_
private

Definition at line 116 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), hsv(), rgb(), and set_valuators().

◆ bvalue

Flcc_Value_Input Fl_Color_Chooser::bvalue
private

Definition at line 113 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), mode_cb(), rgb_cb(), and set_valuators().

◆ choice

Fl_Choice Fl_Color_Chooser::choice
private

Definition at line 110 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), and mode().

◆ g_

double Fl_Color_Chooser::g_
private

Definition at line 116 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), hsv(), rgb(), and set_valuators().

◆ gvalue

Flcc_Value_Input Fl_Color_Chooser::gvalue
private

Definition at line 112 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), mode_cb(), rgb_cb(), and set_valuators().

◆ hue_

double Fl_Color_Chooser::hue_
private

Definition at line 115 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), hsv(), rgb(), and set_valuators().

◆ huebox

Flcc_HueBox Fl_Color_Chooser::huebox
private

Definition at line 108 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), hsv(), and rgb().

◆ r_

double Fl_Color_Chooser::r_
private

Definition at line 116 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), hsv(), rgb(), and set_valuators().

◆ resize_box

Fl_Box Fl_Color_Chooser::resize_box
private

Definition at line 114 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser().

◆ rvalue

Flcc_Value_Input Fl_Color_Chooser::rvalue
private

Definition at line 111 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), mode_cb(), rgb_cb(), and set_valuators().

◆ saturation_

double Fl_Color_Chooser::saturation_
private

Definition at line 115 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), hsv(), rgb(), and set_valuators().

◆ value_

double Fl_Color_Chooser::value_
private

Definition at line 115 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), hsv(), rgb(), and set_valuators().

◆ valuebox

Flcc_ValueBox Fl_Color_Chooser::valuebox
private

Definition at line 109 of file Fl_Color_Chooser.H.

Referenced by Fl_Color_Chooser(), hsv(), and rgb().


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