[773] | 1 | // |
---|
| 2 | // "$Id: ColorChooser.h 3769 2004-08-07 20:48:36Z spitzak $" |
---|
| 3 | // |
---|
| 4 | // Color chooser header file for the Fast Light Tool Kit (FLTK). |
---|
| 5 | // |
---|
| 6 | // Copyright 1998-2003 by Bill Spitzak and others. |
---|
| 7 | // |
---|
| 8 | // This library is free software; you can redistribute it and/or |
---|
| 9 | // modify it under the terms of the GNU Library General Public |
---|
| 10 | // License as published by the Free Software Foundation; either |
---|
| 11 | // version 2 of the License, or (at your option) any later version. |
---|
| 12 | // |
---|
| 13 | // This library is distributed in the hope that it will be useful, |
---|
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 16 | // Library General Public License for more details. |
---|
| 17 | // |
---|
| 18 | // You should have received a copy of the GNU Library General Public |
---|
| 19 | // License along with this library; if not, write to the Free Software |
---|
| 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
| 21 | // USA. |
---|
| 22 | // |
---|
| 23 | // Please report all bugs and problems to "fltk-bugs@fltk.org". |
---|
| 24 | // |
---|
| 25 | |
---|
| 26 | // The color chooser object and the color chooser popup. The popup |
---|
| 27 | // is just a window containing a single color chooser and some boxes |
---|
| 28 | // to indicate the current and cancelled color. |
---|
| 29 | |
---|
| 30 | #ifndef fltk_ColorChooser_h |
---|
| 31 | #define fltk_ColorChooser_h |
---|
| 32 | |
---|
| 33 | #include <fltk/Group.h> |
---|
| 34 | |
---|
| 35 | namespace fltk { |
---|
| 36 | |
---|
| 37 | class FL_API ccHueBox : public Widget { |
---|
| 38 | int px, py; |
---|
| 39 | protected: |
---|
| 40 | void draw(); |
---|
| 41 | public: |
---|
| 42 | int handle(int); |
---|
| 43 | ccHueBox(int X, int Y, int W, int H) : Widget(X,Y,W,H) { |
---|
| 44 | px = py = 0;} |
---|
| 45 | }; |
---|
| 46 | |
---|
| 47 | class FL_API ccValueBox : public Widget { |
---|
| 48 | int py; |
---|
| 49 | bool is_alpha() const; |
---|
| 50 | protected: |
---|
| 51 | void draw(); |
---|
| 52 | public: |
---|
| 53 | int handle(int); |
---|
| 54 | ccValueBox(int X, int Y, int W, int H) : Widget(X,Y,W,H) { |
---|
| 55 | py = 0;} |
---|
| 56 | }; |
---|
| 57 | |
---|
| 58 | class FL_API ccCellBox : public Widget { |
---|
| 59 | public: |
---|
| 60 | ccCellBox(int X, int Y, int W, int H) : Widget(X,Y,W,H) {} |
---|
| 61 | void draw(); |
---|
| 62 | int handle(int); |
---|
| 63 | }; |
---|
| 64 | |
---|
| 65 | class FL_API ColorChooser : public Group { |
---|
| 66 | friend class ccHueBox; |
---|
| 67 | friend class ccValueBox; |
---|
| 68 | ccHueBox huebox; |
---|
| 69 | ccValueBox valuebox; |
---|
| 70 | ccValueBox alphabox; |
---|
| 71 | ccCellBox cellbox; |
---|
| 72 | float hue_, saturation_, value_; |
---|
| 73 | float r_, g_, b_, a_; |
---|
| 74 | public: |
---|
| 75 | float h() const {return hue_;} |
---|
| 76 | float s() const {return saturation_;} |
---|
| 77 | float v() const {return value_;} |
---|
| 78 | float r() const {return r_;} |
---|
| 79 | float g() const {return g_;} |
---|
| 80 | float b() const {return b_;} |
---|
| 81 | float a() const {return a_;} |
---|
| 82 | Color value() const; |
---|
| 83 | bool value(Color); |
---|
| 84 | bool hsv(float,float,float); |
---|
| 85 | bool rgb(float,float,float); |
---|
| 86 | bool a(float); |
---|
| 87 | void hide_a(); |
---|
| 88 | static void hsv2rgb(float, float, float,float&,float&,float&); |
---|
| 89 | static void rgb2hsv(float, float, float,float&,float&,float&); |
---|
| 90 | ColorChooser(int,int,int,int,const char* = 0); |
---|
| 91 | void layout(); |
---|
| 92 | float setcell(int,float,float,float,float); |
---|
| 93 | float getcell(int,float,float,float,float); |
---|
| 94 | }; |
---|
| 95 | |
---|
| 96 | // Convience functions to pop-up a control panel: |
---|
| 97 | |
---|
| 98 | FL_API bool color_chooser(const char* name, float& r, float& g, float& b); |
---|
| 99 | FL_API bool color_chooser(const char* name, float& r, float& g, float& b, float& a); |
---|
| 100 | FL_API bool color_chooser(const char* name, uchar& r, uchar& g, uchar& b); |
---|
| 101 | FL_API bool color_chooser(const char* name, uchar& r, uchar& g, uchar& b, uchar& a); |
---|
| 102 | FL_API bool color_chooser(const char* name, Color& c); |
---|
| 103 | |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | #endif |
---|
| 107 | |
---|
| 108 | // |
---|
| 109 | // End of "$Id: ColorChooser.h 3769 2004-08-07 20:48:36Z spitzak $". |
---|
| 110 | // |
---|