# HG changeset patch # User jwe # Date 1182956886 0 # Node ID 813172f035de3c3eec2d7af5222927d75f8d64a9 # Parent 301885c9d265ffb66323897dd17c0bc05166036c [project @ 2007-06-27 15:08:05 by jwe] diff -r 301885c9d265 -r 813172f035de src/ChangeLog --- a/src/ChangeLog Wed Jun 27 02:27:51 2007 +0000 +++ b/src/ChangeLog Wed Jun 27 15:08:06 2007 +0000 @@ -1,3 +1,10 @@ +2007-06-27 Kai Habel + + * graphics.h (color_values::color_values): Arg is now std:string + instead of char. Call str2rgb, not c2rgb. + * graphics.h, graphics.cc: (color_values::str2rgb): Rename from + c2rgb. Handle long color names, not just single char abbreviations. + 2007-06-27 David Bateman * src/load-save.cc (Fsave): Ensure header is written for non @@ -37,7 +44,7 @@ New macros. Use them to declare individual properties and define accessor methods for each property in the property classes. -2007-06-15 Kai Habel +2007-06-15 Kai Habel * graphics.cc (Fget, Fset): Handle vectors of handles. diff -r 301885c9d265 -r 813172f035de src/graphics.cc --- a/src/graphics.cc Wed Jun 27 02:27:51 2007 +0000 +++ b/src/graphics.cc Wed Jun 27 15:08:06 2007 +0000 @@ -96,47 +96,30 @@ } bool -color_values::c2rgb (char c) +color_values::str2rgb (std::string str) { double tmp_rgb[3] = {0, 0, 0}; bool retval = true; - - switch(c) - { - case 'k': - break; - - case 'r': - tmp_rgb[0] = 1; - break; - - case 'g': - tmp_rgb[1] = 1; - break; - - case 'b': - tmp_rgb[2] = 1; - break; + unsigned int len = str.length(); - case 'c': - tmp_rgb[1] = tmp_rgb[2] = 1; - break; - - case 'm': - tmp_rgb[0] = tmp_rgb[2] = 1; - break; - - case 'y': - tmp_rgb[0] = tmp_rgb[1] = 1; - break; - - case 'w': - tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1; - break; - - default: - retval = false; - } + if (str.compare(0, len, "blue", 0, len) == 0) + tmp_rgb[2] = 1; + else if (str.compare(0, len, "black", 0, len) == 0 || str.compare(0, len, "w", 0, len) == 0) + tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; + else if (str.compare(0, len, "red", 0, len) == 0) + tmp_rgb[0] = 1; + else if (str.compare(0, len, "green", 0, len) == 0) + tmp_rgb[1] = 1; + else if (str.compare(0, len, "yellow", 0, len) == 0) + tmp_rgb[0] = tmp_rgb[1] = 1; + else if (str.compare(0, len, "magenta", 0, len) == 0) + tmp_rgb[0] = tmp_rgb[2] = 1; + else if (str.compare(0, len, "cyan", 0, len) == 0) + tmp_rgb[1] = tmp_rgb[2] = 1; + else if (str.compare(0, len, "white", 0, len) == 0) + tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1; + else + retval = false; if (retval) { @@ -147,7 +130,6 @@ return retval; } - color_property::color_property (const octave_value& val) : radio_val (), current_val () { @@ -159,7 +141,7 @@ if (! s.empty ()) { - color_values col (s[0]); + color_values col (s); if (! error_state) { color_val = col; diff -r 301885c9d265 -r 813172f035de src/graphics.h --- a/src/graphics.h Wed Jun 27 02:27:51 2007 +0000 +++ b/src/graphics.h Wed Jun 27 15:08:06 2007 +0000 @@ -144,9 +144,9 @@ validate (); } - color_values (const char c) + color_values (std::string str) { - if (! c2rgb (c)) + if (! str2rgb (str)) error ("invalid color specification"); } @@ -187,7 +187,7 @@ private: double xrgb[3]; - bool c2rgb (char c); + bool str2rgb (std::string str); };