comparison 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
comparison
equal deleted inserted replaced
18962:d4b69559a0f7 18963:a30e1d20fd3c
2696 { 2696 {
2697 error ("base_graphics_object::get_factory_defaults: invalid graphics object"); 2697 error ("base_graphics_object::get_factory_defaults: invalid graphics object");
2698 return octave_value (); 2698 return octave_value ();
2699 } 2699 }
2700 2700
2701 virtual property_list get_factory_defaults_list (void) const
2702 {
2703 error ("base_graphics_object::get_factory_defaults_list: invalid graphics object");
2704 return property_list ();
2705 }
2706
2701 virtual bool has_readonly_property (const caseless_str& pname) const 2707 virtual bool has_readonly_property (const caseless_str& pname) const
2702 { 2708 {
2703 return base_properties::has_readonly_property (pname); 2709 return base_properties::has_readonly_property (pname);
2704 } 2710 }
2705 2711
2827 get_properties ().delete_listener (nm, v, mode); 2833 get_properties ().delete_listener (nm, v, mode);
2828 } 2834 }
2829 2835
2830 virtual void remove_all_listeners (void); 2836 virtual void remove_all_listeners (void);
2831 2837
2832 virtual void reset_default_properties (void) 2838 virtual void reset_default_properties (void);
2833 {
2834 if (valid_object ())
2835 {
2836 std::string msg = (type () + "::reset_default_properties");
2837 gripe_not_implemented (msg.c_str ());
2838 }
2839 else
2840 error ("base_graphics_object::default: invalid graphics object");
2841 }
2842 2839
2843 protected: 2840 protected:
2844 virtual void initialize (const graphics_object& go) 2841 virtual void initialize (const graphics_object& go)
2845 { 2842 {
2846 if (! toolkit_flag) 2843 if (! toolkit_flag)
2972 octave_value get_defaults (void) const { return rep->get_defaults (); } 2969 octave_value get_defaults (void) const { return rep->get_defaults (); }
2973 2970
2974 octave_value get_factory_defaults (void) const 2971 octave_value get_factory_defaults (void) const
2975 { 2972 {
2976 return rep->get_factory_defaults (); 2973 return rep->get_factory_defaults ();
2974 }
2975
2976 property_list get_factory_defaults_list (void) const
2977 {
2978 return rep->get_factory_defaults_list ();
2977 } 2979 }
2978 2980
2979 bool has_readonly_property (const caseless_str& pname) const 2981 bool has_readonly_property (const caseless_str& pname) const
2980 { 2982 {
2981 return rep->has_readonly_property (pname); 2983 return rep->has_readonly_property (pname);
3221 } 3223 }
3222 3224
3223 octave_value get_factory_defaults (void) const 3225 octave_value get_factory_defaults (void) const
3224 { 3226 {
3225 return factory_properties.as_struct ("factory"); 3227 return factory_properties.as_struct ("factory");
3228 }
3229
3230 property_list get_factory_defaults_list (void) const
3231 {
3232 return factory_properties;
3226 } 3233 }
3227 3234
3228 base_properties& get_properties (void) { return xproperties; } 3235 base_properties& get_properties (void) { return xproperties; }
3229 3236
3230 const base_properties& get_properties (void) const { return xproperties; } 3237 const base_properties& get_properties (void) const { return xproperties; }