diff options
| -rw-r--r-- | CHANGES | 1 | ||||
| -rw-r--r-- | FL/Fl_Color_Chooser.H | 18 | ||||
| -rw-r--r-- | src/Fl_Color_Chooser.cxx | 15 | ||||
| -rw-r--r-- | test/color_chooser.cxx | 2 |
4 files changed, 28 insertions, 8 deletions
@@ -1,5 +1,6 @@ CHANGES IN FLTK 1.3.0 + - Added interface to set color chooser mode (STR #2407) - Fixed compile errors when HAVE_LIBJPEG was not defined (STR #2382) - Fixed special handling for ISO back-tab keycode (STR #2369) diff --git a/FL/Fl_Color_Chooser.H b/FL/Fl_Color_Chooser.H index 131c10d9b..f840f7aad 100644 --- a/FL/Fl_Color_Chooser.H +++ b/FL/Fl_Color_Chooser.H @@ -127,9 +127,19 @@ class FL_EXPORT Fl_Color_Chooser : public Fl_Group { static void rgb_cb(Fl_Widget*, void*); static void mode_cb(Fl_Widget*, void*); public: - /** Returns which Fl_Color_Chooser variant is currently active */ + + /** + Returns which Fl_Color_Chooser variant is currently active + \return color modes are rgb(0), byte(1), hex(2), or hsv(3) + */ int mode() {return choice.value();} - + + /** + Set which Fl_Color_Chooser variant is currently active + \param[in] newMode color modes are rgb(0), byte(1), hex(2), or hsv(3) + */ + void mode(int newMode); + /** Returns the current hue. 0 <= hue < 6. Zero is red, one is yellow, two is green, etc. @@ -179,8 +189,8 @@ public: Fl_Color_Chooser(int X, int Y, int W, int H, const char *L = 0); }; -FL_EXPORT int fl_color_chooser(const char* name, double& r, double& g, double& b); -FL_EXPORT int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b); +FL_EXPORT int fl_color_chooser(const char* name, double& r, double& g, double& b, int m=-1); +FL_EXPORT int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b, int m=-1); #endif diff --git a/src/Fl_Color_Chooser.cxx b/src/Fl_Color_Chooser.cxx index 3b379a55f..576618382 100644 --- a/src/Fl_Color_Chooser.cxx +++ b/src/Fl_Color_Chooser.cxx @@ -455,6 +455,13 @@ void Fl_Color_Chooser::mode_cb(Fl_Widget* o, void*) { c->set_valuators(); } +void Fl_Color_Chooser::mode(int newMode) +{ + choice.value(newMode); + choice.do_callback(); +} + + //////////////////////////////////////////////////////////////// /** @@ -561,7 +568,7 @@ static void cc_cancel_cb (Fl_Widget *o, void *p) { \retval 0 if user cancels the dialog \relates Fl_Color_Chooser */ -int fl_color_chooser(const char* name, double& r, double& g, double& b) { +int fl_color_chooser(const char* name, double& r, double& g, double& b, int m) { int ret = 0; Fl_Window window(215,200,name); window.callback(cc_cancel_cb,&ret); @@ -578,6 +585,7 @@ int fl_color_chooser(const char* name, double& r, double& g, double& b) { window.resizable(chooser); chooser.rgb(r,g,b); chooser.callback(chooser_cb, &ok_color); + if (m!=-1) chooser.mode(m); window.end(); window.set_modal(); window.hotspot(window); @@ -601,11 +609,11 @@ int fl_color_chooser(const char* name, double& r, double& g, double& b) { \retval 0 if user cancels the dialog \relates Fl_Color_Chooser */ -int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b) { +int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b, int m) { double dr = r/255.0; double dg = g/255.0; double db = b/255.0; - if (fl_color_chooser(name,dr,dg,db)) { + if (fl_color_chooser(name,dr,dg,db,m)) { r = uchar(255*dr+.5); g = uchar(255*dg+.5); b = uchar(255*db+.5); @@ -613,6 +621,7 @@ int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b) { } return 0; } + /** @} */ // // End of "$Id$". diff --git a/test/color_chooser.cxx b/test/color_chooser.cxx index e737dcfec..212b08f5f 100644 --- a/test/color_chooser.cxx +++ b/test/color_chooser.cxx @@ -86,7 +86,7 @@ void cb1(Fl_Widget *, void *v) { void cb2(Fl_Widget *, void *v) { uchar r,g,b; Fl::get_color(c,r,g,b); - if (!fl_color_chooser("New color:",r,g,b)) return; + if (!fl_color_chooser("New color:",r,g,b,3)) return; c = fullcolor_cell; Fl::set_color(fullcolor_cell,r,g,b); Fl_Box* bx = (Fl_Box*)v; |
