source: NonGTP/glut/FLTK/include/fltk/ColorChooser.h @ 814

Revision 814, 3.2 KB checked in by gumbau, 18 years ago (diff)

Glut initial import used by Geometry modules

Line 
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
35namespace fltk {
36
37class FL_API ccHueBox : public Widget {
38  int px, py;
39protected:
40  void draw();
41public:
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
47class FL_API ccValueBox : public Widget {
48  int py;
49  bool is_alpha() const;
50protected:
51  void draw();
52public:
53  int handle(int);
54  ccValueBox(int X, int Y, int W, int H) : Widget(X,Y,W,H) {
55  py = 0;}
56};
57
58class FL_API ccCellBox : public Widget {
59public:
60  ccCellBox(int X, int Y, int W, int H) : Widget(X,Y,W,H) {}
61  void draw();
62  int handle(int);
63};
64
65class 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_;
74public:
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
98FL_API bool color_chooser(const char* name, float& r, float& g, float& b);
99FL_API bool color_chooser(const char* name, float& r, float& g, float& b, float& a);
100FL_API bool color_chooser(const char* name, uchar& r, uchar& g, uchar& b);
101FL_API bool color_chooser(const char* name, uchar& r, uchar& g, uchar& b, uchar& a);
102FL_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//
Note: See TracBrowser for help on using the repository browser.