Author: matt
Date: 2010-10-30 13:16:43 -0700 (Sat, 30 Oct 2010)
New Revision: 7781
Log:
Added interface to set color chooser mode (STR #2407)

Modified:
   branches/branch-1.3/CHANGES
   branches/branch-1.3/FL/Fl_Color_Chooser.H
   branches/branch-1.3/src/Fl_Color_Chooser.cxx
   branches/branch-1.3/test/color_chooser.cxx

Modified: branches/branch-1.3/CHANGES
===================================================================
--- branches/branch-1.3/CHANGES 2010-10-30 20:01:16 UTC (rev 7780)
+++ branches/branch-1.3/CHANGES 2010-10-30 20:16:43 UTC (rev 7781)
@@ -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)

Modified: branches/branch-1.3/FL/Fl_Color_Chooser.H
===================================================================
--- branches/branch-1.3/FL/Fl_Color_Chooser.H   2010-10-30 20:01:16 UTC (rev 
7780)
+++ branches/branch-1.3/FL/Fl_Color_Chooser.H   2010-10-30 20:16:43 UTC (rev 
7781)
@@ -127,9 +127,19 @@
   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 @@
   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
 

Modified: branches/branch-1.3/src/Fl_Color_Chooser.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Color_Chooser.cxx        2010-10-30 20:01:16 UTC 
(rev 7780)
+++ branches/branch-1.3/src/Fl_Color_Chooser.cxx        2010-10-30 20:16:43 UTC 
(rev 7781)
@@ -455,6 +455,13 @@
   c->set_valuators();
 }
 
+void Fl_Color_Chooser::mode(int newMode)
+{
+  choice.value(newMode);
+  choice.do_callback();
+}
+
+
 ////////////////////////////////////////////////////////////////
 
 /**
@@ -561,7 +568,7 @@
   \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 @@
   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 @@
   \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 @@
   }
   return 0;
 }
+
 /** @} */
 //
 // End of "$Id$".

Modified: branches/branch-1.3/test/color_chooser.cxx
===================================================================
--- branches/branch-1.3/test/color_chooser.cxx  2010-10-30 20:01:16 UTC (rev 
7780)
+++ branches/branch-1.3/test/color_chooser.cxx  2010-10-30 20:16:43 UTC (rev 
7781)
@@ -86,7 +86,7 @@
 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;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to