Mercurial > octave-dspies
diff src/graphics.cc @ 12965:22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
* __axis_label__.m: Don't check type of txt argument.
* __go_draw_axes__.m: Handle multi-line string property for
text objects.
* text.m: Likewise.
* gl2ps-renderer.cc (glps_renderer::draw_text): Handle
text::properties string property as octave_value object that can
contain either a char array or cellstr object.
* graphics.cc (axes::properties::update_xlabel_position,
axes::properties::update_ylabel_position,
axes::properties::update_zlabel_position,
axes::properties::get_extent, text::properties::update_text_extent): Likewise.
* graphics.h.in (text_label_property::do_set): Don't forget to set
stored_type when value is a cell.
(text::properties::get_string): Delete custom getter.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Mon, 15 Aug 2011 10:24:09 -0400 |
parents | e77284b6dac6 |
children | d44d7f3c7998 |
line wrap: on
line diff
--- a/src/graphics.cc Mon Aug 15 10:05:28 2011 -0400 +++ b/src/graphics.cc Mon Aug 15 10:24:09 2011 -0400 @@ -4341,7 +4341,7 @@ text::properties& xlabel_props = reinterpret_cast<text::properties&> (gh_manager::get_object (get_xlabel ()).get_properties ()); - bool is_empty = xlabel_props.get_string ().empty (); + bool is_empty = xlabel_props.get_string ().is_empty (); unwind_protect frame; frame.protect_var (updating_xlabel_position); @@ -4432,7 +4432,7 @@ text::properties& ylabel_props = reinterpret_cast<text::properties&> (gh_manager::get_object (get_ylabel ()).get_properties ()); - bool is_empty = ylabel_props.get_string ().empty (); + bool is_empty = ylabel_props.get_string ().is_empty (); unwind_protect frame; frame.protect_var (updating_ylabel_position); @@ -4524,7 +4524,7 @@ (gh_manager::get_object (get_zlabel ()).get_properties ()); bool camAuto = cameraupvectormode_is ("auto"); - bool is_empty = zlabel_props.get_string ().empty (); + bool is_empty = zlabel_props.get_string ().is_empty (); unwind_protect frame; frame.protect_var (updating_zlabel_position); @@ -4896,7 +4896,7 @@ Matrix text_pos = text_props.get_position ().matrix_value (); text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2)); - if (text_props.get_string ().empty ()) + if (text_props.get_string ().is_empty ()) { ext(0) = std::min (ext(0), text_pos(0)); ext(1) = std::min (ext(1), text_pos(1)); @@ -6006,6 +6006,7 @@ text::properties::update_text_extent (void) { #ifdef HAVE_FREETYPE + int halign = 0, valign = 0; if (horizontalalignment_is ("center")) @@ -6021,11 +6022,17 @@ valign = 1; Matrix bbox; + // FIXME: string should be parsed only when modified, for efficiency - renderer.text_to_pixels (get_string (), pixels, bbox, + + octave_value string_prop = get_string (); + + string_vector sv = string_prop.all_strings (); + + renderer.text_to_pixels (sv.join ("\n"), pixels, bbox, halign, valign, get_rotation ()); - set_extent (bbox); + #endif if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") ||