# HG changeset patch # User John W. Eaton # Date 1265273788 18000 # Node ID 8c583af2cf645d53cbe326c617866e32960f894d # Parent e58c1711d752cf59697c9861c4d425a94d575bc1 validate text object children of axes objects diff -r e58c1711d752 -r 8c583af2cf64 src/ChangeLog --- a/src/ChangeLog Thu Feb 04 03:55:41 2010 -0500 +++ b/src/ChangeLog Thu Feb 04 03:56:28 2010 -0500 @@ -1,3 +1,10 @@ +2010-02-04 John W. Eaton + + * graphics.h.in (gh_manager::lookup (const octave_value&)): + New function. + * graphics.cc (axes::properties::set_text_child): Validate value. + Allow value to be character string or handle of text object. + 2010-02-04 John W. Eaton * Makefile.am (OCTAVE_LIBS): Include all liboctave library diff -r e58c1711d752 -r 8c583af2cf64 src/graphics.cc --- a/src/graphics.cc Thu Feb 04 03:55:41 2010 -0500 +++ b/src/graphics.cc Thu Feb 04 03:56:28 2010 -0500 @@ -2664,7 +2664,28 @@ const std::string& who, const octave_value& v) { - graphics_handle val = ::reparent (v, "set", who, __myhandle__, false); + graphics_handle val; + + if (v.is_string ()) + { + val = gh_manager::make_graphics_handle ("text", __myhandle__, false); + + xset (val, "string", v); + } + else + { + graphics_object go = gh_manager::get_object (gh_manager::lookup (v)); + + if (go.isa ("text")) + val = ::reparent (v, "set", who, __myhandle__, false); + else + { + std::string cname = v.class_name (); + + error ("set: expecting text graphics object or character string for %s property, found %s", + who.c_str (), cname.c_str ()); + } + } if (! error_state) { diff -r e58c1711d752 -r 8c583af2cf64 src/graphics.h.in --- a/src/graphics.h.in Thu Feb 04 03:55:41 2010 -0500 +++ b/src/graphics.h.in Thu Feb 04 03:56:28 2010 -0500 @@ -3871,6 +3871,12 @@ return instance_ok () ? instance->do_lookup (val) : graphics_handle (); } + static graphics_handle lookup (const octave_value& val) + { + return val.is_real_scalar () + ? lookup (val.double_value ()) : graphics_handle (); + } + static graphics_object get_object (const graphics_handle& h) { return instance_ok () ? instance->do_get_object (h) : graphics_object ();