Mercurial > hg > octave-avbm
changeset 6761:813172f035de
[project @ 2007-06-27 15:08:05 by jwe]
author | jwe |
---|---|
date | Wed, 27 Jun 2007 15:08:06 +0000 |
parents | 301885c9d265 |
children | 721953d49b19 |
files | src/ChangeLog src/graphics.cc src/graphics.h |
diffstat | 3 files changed, 32 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2007-06-27 Kai Habel <kai.habel@gmx.de> + + * 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 <dbateman@free.fr> * 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 <kai.habel@gmx.de> +2007-06-15 Kai Habel <kai.habel@gmx.de> * graphics.cc (Fget, Fset): Handle vectors of handles.
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -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;
--- a/src/graphics.h +++ b/src/graphics.h @@ -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); };