FLTK 1.3.0
|
00001 // 00002 // "$Id: Fl_Color_Chooser.H 7981 2010-12-08 23:53:04Z greg.ercolano $" 00003 // 00004 // Color chooser header file for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00031 // The color chooser object and the color chooser popup. The popup 00032 // is just a window containing a single color chooser and some boxes 00033 // to indicate the current and cancelled color. 00034 00035 #ifndef Fl_Color_Chooser_H 00036 #define Fl_Color_Chooser_H 00037 00038 #include <FL/Fl_Group.H> 00039 #include <FL/Fl_Box.H> 00040 #include <FL/Fl_Return_Button.H> 00041 #include <FL/Fl_Choice.H> 00042 #include <FL/Fl_Value_Input.H> 00043 00044 #ifndef FL_DOXYGEN 00045 00047 class FL_EXPORT Flcc_HueBox : public Fl_Widget { 00048 int px, py; 00049 protected: 00050 void draw(); 00051 int handle_key(int); 00052 public: 00053 int handle(int); 00054 Flcc_HueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) { 00055 px = py = 0;} 00056 }; 00057 00059 class FL_EXPORT Flcc_ValueBox : public Fl_Widget { 00060 int py; 00061 protected: 00062 void draw(); 00063 int handle_key(int); 00064 public: 00065 int handle(int); 00066 Flcc_ValueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) { 00067 py = 0;} 00068 }; 00069 00071 class FL_EXPORT Flcc_Value_Input : public Fl_Value_Input { 00072 public: 00073 int format(char*); 00074 Flcc_Value_Input(int X, int Y, int W, int H) : Fl_Value_Input(X,Y,W,H) {} 00075 }; 00076 00077 #endif // !FL_DOXYGEN 00078 00116 class FL_EXPORT Fl_Color_Chooser : public Fl_Group { 00117 Flcc_HueBox huebox; 00118 Flcc_ValueBox valuebox; 00119 Fl_Choice choice; 00120 Flcc_Value_Input rvalue; 00121 Flcc_Value_Input gvalue; 00122 Flcc_Value_Input bvalue; 00123 Fl_Box resize_box; 00124 double hue_, saturation_, value_; 00125 double r_, g_, b_; 00126 void set_valuators(); 00127 static void rgb_cb(Fl_Widget*, void*); 00128 static void mode_cb(Fl_Widget*, void*); 00129 public: 00130 00135 int mode() {return choice.value();} 00136 00141 void mode(int newMode); 00142 00149 double hue() const {return hue_;} 00150 00155 double saturation() const {return saturation_;} 00156 00161 double value() const {return value_;} 00162 00167 double r() const {return r_;} 00168 00173 double g() const {return g_;} 00174 00179 double b() const {return b_;} 00180 00181 int hsv(double H, double S, double V); 00182 00183 int rgb(double R, double G, double B); 00184 00185 static void hsv2rgb(double H, double S, double V, double& R, double& G, double& B); 00186 00187 static void rgb2hsv(double R, double G, double B, double& H, double& S, double& V); 00188 00189 Fl_Color_Chooser(int X, int Y, int W, int H, const char *L = 0); 00190 }; 00191 00192 FL_EXPORT int fl_color_chooser(const char* name, double& r, double& g, double& b, int m=-1); 00193 FL_EXPORT int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b, int m=-1); 00194 00195 #endif 00196 00197 // 00198 // End of "$Id: Fl_Color_Chooser.H 7981 2010-12-08 23:53:04Z greg.ercolano $". 00199 //