diff src/graphics.cc @ 7844:3d60445d3638

Add new double_radio_property class for alpha values.
author Michael Goffioul <michael.goffioul@gmail.com>
date Tue, 26 Feb 2008 22:06:47 +0100
parents d3dcfdfdc434
children 40b16e04172a
line wrap: on
line diff
--- a/src/graphics.cc	Mon Feb 25 21:50:37 2008 +0200
+++ b/src/graphics.cc	Tue Feb 26 22:06:47 2008 +0100
@@ -581,6 +581,32 @@
            get_name ().c_str ());
 }
 
+void
+double_radio_property::set (const octave_value& val)
+{
+  if (val.is_string ())
+    {
+      std::string s = val.string_value ();
+
+      if (! s.empty () && radio_val.contains (s))
+	{
+	  current_val = s;
+	  current_type = radio_t;
+	}
+      else
+	error ("invalid value for double_radio property \"%s\"",
+	       get_name ().c_str ());
+    }
+  else if (val.is_scalar_type () && val.is_real_type ())
+    {
+      dval = val.double_value ();
+      current_type = double_t;
+    }
+  else 
+    error ("invalid value for double_radio property \"%s\"",
+	   get_name ().c_str ());
+}
+
 bool
 array_property::validate (const octave_value& v)
 {