comparison libinterp/corefcn/graphics.in.h @ 18579:8d5cb159fbc7

Add methods to determine if a graphic property is read-only (bug #41629). * genprops.awk: add *::properties::has_readonly_property and *::properties::readonly_property_names. * genprops.awk: modify base_properties::set to report early when a property is read-only. * graphics.in.h: add *::has_readonly_property methods to all graphics objects.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 18 Feb 2014 16:55:08 +0100
parents ec9b35e60f95
children cd83730e5e38
comparison
equal deleted inserted replaced
18578:875f4510d6dc 18579:8d5cb159fbc7
2702 { 2702 {
2703 error ("base_graphics_object::get_factory_defaults: invalid graphics object"); 2703 error ("base_graphics_object::get_factory_defaults: invalid graphics object");
2704 return octave_value (); 2704 return octave_value ();
2705 } 2705 }
2706 2706
2707 virtual bool has_readonly_property (const caseless_str& pname) const
2708 {
2709 return base_properties::has_readonly_property (pname);
2710 }
2711
2707 virtual std::string values_as_string (void); 2712 virtual std::string values_as_string (void);
2708 2713
2709 virtual std::string value_as_string (const std::string& prop); 2714 virtual std::string value_as_string (const std::string& prop);
2710 2715
2711 virtual octave_scalar_map values_as_struct (void); 2716 virtual octave_scalar_map values_as_struct (void);
2973 octave_value get_defaults (void) const { return rep->get_defaults (); } 2978 octave_value get_defaults (void) const { return rep->get_defaults (); }
2974 2979
2975 octave_value get_factory_defaults (void) const 2980 octave_value get_factory_defaults (void) const
2976 { 2981 {
2977 return rep->get_factory_defaults (); 2982 return rep->get_factory_defaults ();
2983 }
2984
2985 bool has_readonly_property (const caseless_str& pname) const
2986 {
2987 return rep->has_readonly_property (pname);
2978 } 2988 }
2979 2989
2980 std::string values_as_string (void) { return rep->values_as_string (); } 2990 std::string values_as_string (void) { return rep->values_as_string (); }
2981 2991
2982 std::string value_as_string (const std::string& prop) 2992 std::string value_as_string (const std::string& prop)
3235 const base_properties& get_properties (void) const { return xproperties; } 3245 const base_properties& get_properties (void) const { return xproperties; }
3236 3246
3237 bool valid_object (void) const { return true; } 3247 bool valid_object (void) const { return true; }
3238 3248
3239 void reset_default_properties (void); 3249 void reset_default_properties (void);
3250
3251 bool has_readonly_property (const caseless_str& pname) const
3252 {
3253 bool retval = xproperties.has_readonly_property (pname);
3254 if (! retval)
3255 retval = base_properties::has_readonly_property (pname);
3256 return retval;
3257 }
3240 3258
3241 private: 3259 private:
3242 property_list default_properties; 3260 property_list default_properties;
3243 3261
3244 static property_list factory_properties; 3262 static property_list factory_properties;
3459 const base_properties& get_properties (void) const { return xproperties; } 3477 const base_properties& get_properties (void) const { return xproperties; }
3460 3478
3461 bool valid_object (void) const { return true; } 3479 bool valid_object (void) const { return true; }
3462 3480
3463 void reset_default_properties (void); 3481 void reset_default_properties (void);
3482
3483 bool has_readonly_property (const caseless_str& pname) const
3484 {
3485 bool retval = xproperties.has_readonly_property (pname);
3486 if (! retval)
3487 retval = base_properties::has_readonly_property (pname);
3488 return retval;
3489 }
3464 3490
3465 private: 3491 private:
3466 property_list default_properties; 3492 property_list default_properties;
3467 }; 3493 };
3468 3494
4181 4207
4182 bool valid_object (void) const { return true; } 4208 bool valid_object (void) const { return true; }
4183 4209
4184 void reset_default_properties (void); 4210 void reset_default_properties (void);
4185 4211
4212 bool has_readonly_property (const caseless_str& pname) const
4213 {
4214 bool retval = xproperties.has_readonly_property (pname);
4215 if (! retval)
4216 retval = base_properties::has_readonly_property (pname);
4217 return retval;
4218 }
4219
4186 protected: 4220 protected:
4187 void initialize (const graphics_object& go); 4221 void initialize (const graphics_object& go);
4188 4222
4189 private: 4223 private:
4190 property_list default_properties; 4224 property_list default_properties;
4261 base_properties& get_properties (void) { return xproperties; } 4295 base_properties& get_properties (void) { return xproperties; }
4262 4296
4263 const base_properties& get_properties (void) const { return xproperties; } 4297 const base_properties& get_properties (void) const { return xproperties; }
4264 4298
4265 bool valid_object (void) const { return true; } 4299 bool valid_object (void) const { return true; }
4300
4301 bool has_readonly_property (const caseless_str& pname) const
4302 {
4303 bool retval = xproperties.has_readonly_property (pname);
4304 if (! retval)
4305 retval = base_properties::has_readonly_property (pname);
4306 return retval;
4307 }
4266 }; 4308 };
4267 4309
4268 // --------------------------------------------------------------------- 4310 // ---------------------------------------------------------------------
4269 4311
4270 class OCTINTERP_API text : public base_graphics_object 4312 class OCTINTERP_API text : public base_graphics_object
4426 base_properties& get_properties (void) { return xproperties; } 4468 base_properties& get_properties (void) { return xproperties; }
4427 4469
4428 const base_properties& get_properties (void) const { return xproperties; } 4470 const base_properties& get_properties (void) const { return xproperties; }
4429 4471
4430 bool valid_object (void) const { return true; } 4472 bool valid_object (void) const { return true; }
4473
4474 bool has_readonly_property (const caseless_str& pname) const
4475 {
4476 bool retval = xproperties.has_readonly_property (pname);
4477 if (! retval)
4478 retval = base_properties::has_readonly_property (pname);
4479 return retval;
4480 }
4431 }; 4481 };
4432 4482
4433 // --------------------------------------------------------------------- 4483 // ---------------------------------------------------------------------
4434 4484
4435 class OCTINTERP_API image : public base_graphics_object 4485 class OCTINTERP_API image : public base_graphics_object
4573 base_properties& get_properties (void) { return xproperties; } 4623 base_properties& get_properties (void) { return xproperties; }
4574 4624
4575 const base_properties& get_properties (void) const { return xproperties; } 4625 const base_properties& get_properties (void) const { return xproperties; }
4576 4626
4577 bool valid_object (void) const { return true; } 4627 bool valid_object (void) const { return true; }
4628
4629 bool has_readonly_property (const caseless_str& pname) const
4630 {
4631 bool retval = xproperties.has_readonly_property (pname);
4632 if (! retval)
4633 retval = base_properties::has_readonly_property (pname);
4634 return retval;
4635 }
4578 }; 4636 };
4579 4637
4580 // --------------------------------------------------------------------- 4638 // ---------------------------------------------------------------------
4581 4639
4582 class OCTINTERP_API patch : public base_graphics_object 4640 class OCTINTERP_API patch : public base_graphics_object
4697 base_properties& get_properties (void) { return xproperties; } 4755 base_properties& get_properties (void) { return xproperties; }
4698 4756
4699 const base_properties& get_properties (void) const { return xproperties; } 4757 const base_properties& get_properties (void) const { return xproperties; }
4700 4758
4701 bool valid_object (void) const { return true; } 4759 bool valid_object (void) const { return true; }
4760
4761 bool has_readonly_property (const caseless_str& pname) const
4762 {
4763 bool retval = xproperties.has_readonly_property (pname);
4764 if (! retval)
4765 retval = base_properties::has_readonly_property (pname);
4766 return retval;
4767 }
4702 }; 4768 };
4703 4769
4704 // --------------------------------------------------------------------- 4770 // ---------------------------------------------------------------------
4705 4771
4706 class OCTINTERP_API surface : public base_graphics_object 4772 class OCTINTERP_API surface : public base_graphics_object
4852 base_properties& get_properties (void) { return xproperties; } 4918 base_properties& get_properties (void) { return xproperties; }
4853 4919
4854 const base_properties& get_properties (void) const { return xproperties; } 4920 const base_properties& get_properties (void) const { return xproperties; }
4855 4921
4856 bool valid_object (void) const { return true; } 4922 bool valid_object (void) const { return true; }
4923
4924 bool has_readonly_property (const caseless_str& pname) const
4925 {
4926 bool retval = xproperties.has_readonly_property (pname);
4927 if (! retval)
4928 retval = base_properties::has_readonly_property (pname);
4929 return retval;
4930 }
4857 }; 4931 };
4858 4932
4859 // --------------------------------------------------------------------- 4933 // ---------------------------------------------------------------------
4860 4934
4861 class OCTINTERP_API hggroup : public base_graphics_object 4935 class OCTINTERP_API hggroup : public base_graphics_object
4929 5003
4930 void update_axis_limits (const std::string& axis_type); 5004 void update_axis_limits (const std::string& axis_type);
4931 5005
4932 void update_axis_limits (const std::string& axis_type, 5006 void update_axis_limits (const std::string& axis_type,
4933 const graphics_handle& h); 5007 const graphics_handle& h);
5008
5009 bool has_readonly_property (const caseless_str& pname) const
5010 {
5011 bool retval = xproperties.has_readonly_property (pname);
5012 if (! retval)
5013 retval = base_properties::has_readonly_property (pname);
5014 return retval;
5015 }
4934 5016
4935 }; 5017 };
4936 5018
4937 // --------------------------------------------------------------------- 5019 // ---------------------------------------------------------------------
4938 5020
4991 5073
4992 const base_properties& get_properties (void) const { return xproperties; } 5074 const base_properties& get_properties (void) const { return xproperties; }
4993 5075
4994 bool valid_object (void) const { return true; } 5076 bool valid_object (void) const { return true; }
4995 5077
5078 bool has_readonly_property (const caseless_str& pname) const
5079 {
5080 bool retval = xproperties.has_readonly_property (pname);
5081 if (! retval)
5082 retval = base_properties::has_readonly_property (pname);
5083 return retval;
5084 }
5085
4996 }; 5086 };
4997 5087
4998 // --------------------------------------------------------------------- 5088 // ---------------------------------------------------------------------
4999 5089
5000 class OCTINTERP_API uicontextmenu : public base_graphics_object 5090 class OCTINTERP_API uicontextmenu : public base_graphics_object
5037 base_properties& get_properties (void) { return xproperties; } 5127 base_properties& get_properties (void) { return xproperties; }
5038 5128
5039 const base_properties& get_properties (void) const { return xproperties; } 5129 const base_properties& get_properties (void) const { return xproperties; }
5040 5130
5041 bool valid_object (void) const { return true; } 5131 bool valid_object (void) const { return true; }
5132
5133 bool has_readonly_property (const caseless_str& pname) const
5134 {
5135 bool retval = xproperties.has_readonly_property (pname);
5136 if (! retval)
5137 retval = base_properties::has_readonly_property (pname);
5138 return retval;
5139 }
5042 5140
5043 }; 5141 };
5044 5142
5045 // --------------------------------------------------------------------- 5143 // ---------------------------------------------------------------------
5046 5144
5130 base_properties& get_properties (void) { return xproperties; } 5228 base_properties& get_properties (void) { return xproperties; }
5131 5229
5132 const base_properties& get_properties (void) const { return xproperties; } 5230 const base_properties& get_properties (void) const { return xproperties; }
5133 5231
5134 bool valid_object (void) const { return true; } 5232 bool valid_object (void) const { return true; }
5233
5234 bool has_readonly_property (const caseless_str& pname) const
5235 {
5236 bool retval = xproperties.has_readonly_property (pname);
5237 if (! retval)
5238 retval = base_properties::has_readonly_property (pname);
5239 return retval;
5240 }
5135 }; 5241 };
5136 5242
5137 // --------------------------------------------------------------------- 5243 // ---------------------------------------------------------------------
5138 5244
5139 class OCTINTERP_API uipanel : public base_graphics_object 5245 class OCTINTERP_API uipanel : public base_graphics_object
5197 base_properties& get_properties (void) { return xproperties; } 5303 base_properties& get_properties (void) { return xproperties; }
5198 5304
5199 const base_properties& get_properties (void) const { return xproperties; } 5305 const base_properties& get_properties (void) const { return xproperties; }
5200 5306
5201 bool valid_object (void) const { return true; } 5307 bool valid_object (void) const { return true; }
5308
5309 bool has_readonly_property (const caseless_str& pname) const
5310 {
5311 bool retval = xproperties.has_readonly_property (pname);
5312 if (! retval)
5313 retval = base_properties::has_readonly_property (pname);
5314 return retval;
5315 }
5202 }; 5316 };
5203 5317
5204 // --------------------------------------------------------------------- 5318 // ---------------------------------------------------------------------
5205 5319
5206 class OCTINTERP_API uitoolbar : public base_graphics_object 5320 class OCTINTERP_API uitoolbar : public base_graphics_object
5283 const base_properties& get_properties (void) const { return xproperties; } 5397 const base_properties& get_properties (void) const { return xproperties; }
5284 5398
5285 bool valid_object (void) const { return true; } 5399 bool valid_object (void) const { return true; }
5286 5400
5287 void reset_default_properties (void); 5401 void reset_default_properties (void);
5402
5403 bool has_readonly_property (const caseless_str& pname) const
5404 {
5405 bool retval = xproperties.has_readonly_property (pname);
5406 if (! retval)
5407 retval = base_properties::has_readonly_property (pname);
5408 return retval;
5409 }
5288 5410
5289 private: 5411 private:
5290 property_list default_properties; 5412 property_list default_properties;
5291 }; 5413 };
5292 5414
5335 base_properties& get_properties (void) { return xproperties; } 5457 base_properties& get_properties (void) { return xproperties; }
5336 5458
5337 const base_properties& get_properties (void) const { return xproperties; } 5459 const base_properties& get_properties (void) const { return xproperties; }
5338 5460
5339 bool valid_object (void) const { return true; } 5461 bool valid_object (void) const { return true; }
5462
5463 bool has_readonly_property (const caseless_str& pname) const
5464 {
5465 bool retval = xproperties.has_readonly_property (pname);
5466 if (! retval)
5467 retval = base_properties::has_readonly_property (pname);
5468 return retval;
5469 }
5340 5470
5341 }; 5471 };
5342 5472
5343 // --------------------------------------------------------------------- 5473 // ---------------------------------------------------------------------
5344 5474
5389 5519
5390 const base_properties& get_properties (void) const { return xproperties; } 5520 const base_properties& get_properties (void) const { return xproperties; }
5391 5521
5392 bool valid_object (void) const { return true; } 5522 bool valid_object (void) const { return true; }
5393 5523
5524 bool has_readonly_property (const caseless_str& pname) const
5525 {
5526 bool retval = xproperties.has_readonly_property (pname);
5527 if (! retval)
5528 retval = base_properties::has_readonly_property (pname);
5529 return retval;
5530 }
5531
5394 }; 5532 };
5395 5533
5396 // --------------------------------------------------------------------- 5534 // ---------------------------------------------------------------------
5397 5535
5398 octave_value 5536 octave_value