Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_Color_Chooser.h

00001 /*
00002  * $Id: Fl_Color_Chooser.h,v 1.10 2003/03/30 06:16:46 parshin Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Mikko Lahteenmaki
00016  * Email  : mikko@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
00019  *
00020  */
00021 
00022 // The color chooser object and the color chooser popup.  The popup
00023 // is just a window containing a single color chooser and some boxes
00024 // to indicate the current and cancelled color.
00025 
00026 #ifndef _FL_COLOR_CHOOSER_H_
00027 #define _FL_COLOR_CHOOSER_H_
00028 
00029 #include "Fl_Group.h"
00030 #include "Fl_Box.h"
00031 #include "Fl_Return_Button.h"
00032 #include "Fl_Choice.h"
00033 #include "Fl_Value_Input.h"
00034 
00035 class FL_API Flcc_HueBox : public Fl_Widget {
00036 public:
00037     Flcc_HueBox(int X, int Y, int W, int H);
00038     virtual ~Flcc_HueBox();
00039 
00040     virtual void layout();
00041     virtual void draw();
00042     virtual int handle(int);
00043 
00044 private:
00045     void generate();
00046     Fl_Image *bg;
00047     int px, py;
00048 };
00049 
00050 class FL_API Flcc_ValueBox : public Fl_Widget {
00051 public:
00052     Flcc_ValueBox(int X, int Y, int W, int H);
00053     ~Flcc_ValueBox();
00054 
00055     virtual void layout();
00056     virtual void draw();
00057     virtual int handle(int);
00058 private:
00059     void generate();
00060     Fl_Image *bg;
00061     int py;
00062 };
00063 
00064 class FL_API Flcc_Value_Input : public Fl_Value_Input {
00065 public:
00066     Flcc_Value_Input(int X, int Y, int W, int H) : Fl_Value_Input(X,Y,W,H) { }
00067     int format(char*);
00068 };
00069 
00071 class FL_API Fl_Color_Chooser : public Fl_Group {
00072 public:
00073     static Fl_Named_Style* default_style;
00074 
00076     Fl_Color_Chooser(int,int,int,int,const char* l= 0);
00077 
00079     Fl_Color_Chooser(const char* l = 0,int layout_size=30,Fl_Align layout_al=FL_ALIGN_TOP,int label_w=100);
00080 
00081     Fl_Color value() const;
00082     void value(Fl_Color);
00083 
00084     int mode() { return choice.value(); }
00085     float hue() const {return hue_;}
00086     float saturation() const {return saturation_;}
00087     float v() const {return value_;}
00088     float r() const {return r_;}
00089     float g() const {return g_;}
00090     float b() const {return b_;}
00091     int hsv(float,float,float);
00092     int rgb(float,float,float);
00093 
00094     static void hsv2rgb(float, float, float,float&,float&,float&);
00095     static void rgb2hsv(float, float, float,float&,float&,float&);
00096 
00097     void draw();
00098 
00099 private:
00100     Flcc_HueBox huebox;
00101     Flcc_ValueBox valuebox;
00102     Fl_Group nrgroup; // no resize group
00103     Fl_Choice choice;
00104     Flcc_Value_Input rvalue;
00105     Flcc_Value_Input gvalue;
00106     Flcc_Value_Input bvalue;
00107     float hue_, saturation_, value_;
00108     float r_, g_, b_;
00109 
00110     void set_valuators();
00111     void ctor_init(int X, int Y, int W, int H);
00112 
00113     static void rgb_cb(Fl_Widget*, Fl_Color_Chooser*);
00114     static void mode_cb(Fl_Widget*, Fl_Color_Chooser*);
00115 };
00116 
00117 FL_API int fl_color_chooser(const char*name, float& r,float& g,float& b);
00118 FL_API int fl_color_chooser(const char*name, uchar& r, uchar& g, uchar& b);
00119 FL_API int fl_color_chooser(const char*name, Fl_Color& c);
00120 
00121 #endif

Generated on Thu Jul 31 15:33:43 2003 for eFLTK by doxygen1.2.15