Mercurial > hg > octave-lojdl
changeset 10265:8c583af2cf64
validate text object children of axes objects
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 04 Feb 2010 03:56:28 -0500 |
parents | e58c1711d752 |
children | 82db36545def |
files | src/ChangeLog src/graphics.cc src/graphics.h.in |
diffstat | 3 files changed, 35 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-02-04 John W. Eaton <jwe@octave.org> + + * 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 <jwe@octave.org> * Makefile.am (OCTAVE_LIBS): Include all liboctave library
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -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) {
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -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 ();