diff libinterp/corefcn/graphics.in.h @ 18963:a30e1d20fd3c

Freset: properly reset graphics objects (bug #35511) * graphics.in.h (base_graphics_object, graphics_object, root): add new method "get_factory_defaults_list" to retrieve factory defaults as property_list * graphics.in.h (base_graphics_object::reset_default_properties (void)): move definition to graphics.cc * graphics.cc (xreset_default_properties): new function to set a list of prop/val * graphics.cc (base_graphics_object::reset_default_properties): use xreset_default_properties, override with parents' defaults * graphics.cc (root_figure::reset_default_properties, figure::reset_default_properties, uitoolbar::reset_default_properties): same as above but first empty local defaults * graphics.cc (axes_figure::reset_default_properties): same as above but use "propeties.set_defaults" to reset properties to their factory value. * graphics.cc (axes_figure::properties::set_defaults): new "reset" mode, that does the same as "replace" but x/y/zlabels and title are reset instead of being deleting/recreating. * graphics.cc: add %!tests for Freset
author pantxo <pantxo.diribarne@gmail.com>
date Fri, 21 Mar 2014 11:05:28 +0100
parents 52e01aa1fe8b
children
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.in.h	Mon Jul 28 09:28:57 2014 +0200
+++ b/libinterp/corefcn/graphics.in.h	Fri Mar 21 11:05:28 2014 +0100
@@ -2698,6 +2698,12 @@
     return octave_value ();
   }
 
+  virtual property_list get_factory_defaults_list (void) const
+  {
+    error ("base_graphics_object::get_factory_defaults_list: invalid graphics object");
+    return property_list ();
+  }
+
   virtual bool has_readonly_property (const caseless_str& pname) const
   {
     return base_properties::has_readonly_property (pname);
@@ -2829,16 +2835,7 @@
 
   virtual void remove_all_listeners (void);
 
-  virtual void reset_default_properties (void)
-  {
-    if (valid_object ())
-      {
-        std::string msg = (type () + "::reset_default_properties");
-        gripe_not_implemented (msg.c_str ());
-      }
-    else
-      error ("base_graphics_object::default: invalid graphics object");
-  }
+  virtual void reset_default_properties (void);
 
 protected:
   virtual void initialize (const graphics_object& go)
@@ -2976,6 +2973,11 @@
     return rep->get_factory_defaults ();
   }
 
+  property_list get_factory_defaults_list (void) const
+  {
+    return rep->get_factory_defaults_list ();
+  }
+
   bool has_readonly_property (const caseless_str& pname) const
   {
     return rep->has_readonly_property (pname);
@@ -3225,6 +3227,11 @@
     return factory_properties.as_struct ("factory");
   }
 
+  property_list get_factory_defaults_list (void) const
+  {
+    return factory_properties;
+  }
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }