changeset 14448:7a49519913e3

Add custom inline set_postion method for text objects which accepts [1x2] and [1x3] vectors. * graphics.h.in (text::properties::set_position): Add custom inline definition for text position property.
author Ben Abbott <bpabbott@mac.com>
date Sat, 10 Mar 2012 17:53:31 -0500
parents c97416a0f657
children 8cdfd3cabea3
files src/graphics.h.in
diffstat 1 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/graphics.h.in
+++ b/src/graphics.h.in
@@ -4235,13 +4235,38 @@
   public:
     double get_fontsize_points (double box_pix_height = 0) const;
 
+    void set_position (const octave_value& val)
+    {
+      if (! error_state)
+        {
+          octave_value new_val (val);
+    
+          if (new_val.numel () == 2)
+            {
+              dim_vector dv (1, 3);
+    
+              new_val = new_val.resize (dv, true);
+            }
+
+          if (position.set (new_val, false))
+            {
+              set_positionmode ("manual");
+              update_position ();
+              position.run_listeners (POSTSET);
+              mark_modified ();
+            }
+          else
+            set_positionmode ("manual");
+        }
+    }
+
     // See the genprops.awk script for an explanation of the
     // properties declarations.
 
     BEGIN_PROPERTIES (text)
       text_label_property string u , ""
       radio_property units u , "{data}|pixels|normalized|inches|centimeters|points"
-      array_property position mu , Matrix (1, 3, 0.0)
+      array_property position smu , Matrix (1, 3, 0.0)
       double_property rotation mu , 0
       radio_property horizontalalignment mu , "{left}|center|right"
       color_property color u , color_values (0, 0, 0)
@@ -4287,7 +4312,6 @@
   protected:
     void init (void)
       {
-        position.add_constraint (dim_vector (1, 2));
         position.add_constraint (dim_vector (1, 3));
         cached_units = get_units ();
         update_font ();