diff -r db6478d9c669 src/DLD-FUNCTIONS/fltk_backend.cc --- a/src/DLD-FUNCTIONS/fltk_backend.cc Thu Jul 17 14:25:11 2008 -0400 +++ b/src/DLD-FUNCTIONS/fltk_backend.cc Sat Jul 19 21:01:14 2008 +0200 @@ -723,6 +723,12 @@ public: sz(1) = Fl::h (); return sz; } + + virtual void property_changed (const graphics_handle& h, const std::string& n) { } // do nothing + + virtual void object_created (const graphics_handle&) { } // do nothing + + virtual void object_destroyed (const graphics_handle&) { } // do nothing }; static bool backend_registered = false; diff -r db6478d9c669 src/graphics.cc --- a/src/graphics.cc Thu Jul 17 14:25:11 2008 -0400 +++ b/src/graphics.cc Sat Jul 19 21:01:14 2008 +0200 @@ -457,6 +457,26 @@ make_graphics_object_from_type (const ca } // --------------------------------------------------------------------- + +void +base_property::set (const octave_value& v, bool do_run ) +{ + do_set (v); + + // notify backend + graphics_object go = gh_manager::get_object (parent); + if (go) + { + graphics_backend backend = go.get_backend(); + if (backend) + backend.property_changed (parent, name); + } + + // run listeners + if (do_run && ! error_state) + run_listeners (POSTSET); +} + void base_property::run_listeners (listener_mode mode) @@ -1171,7 +1191,13 @@ gh_manager::do_free (const graphics_hand { p->second.get_properties ().set_beingdeleted (true); p->second.get_properties ().execute_deletefcn (); - + // notify backend + graphics_backend backend = p->second.get_backend (); + if (backend) + backend.object_destroyed (h); + // note - this will be valid only for first explicitly deleted object. + // All his children will have unknown backend then. + handle_map.erase (p); if (h.value () < 0) @@ -1793,6 +1819,12 @@ public: Matrix get_screen_size (void) const { return Matrix (1, 2, 0.0); } + + virtual void property_changed (const graphics_handle& h, const std::string& n) { } // do nothing + + virtual void object_created (const graphics_handle&) { } // do nothing + + virtual void object_destroyed (const graphics_handle&) { } // do nothing }; graphics_backend @@ -3524,6 +3556,10 @@ gh_manager::do_make_graphics_handle (con handle_map[h] = graphics_object (go); if (do_createfcn) go->get_properties ().execute_createfcn (); + // notify backend + graphics_backend backend = go->get_backend (); + if (backend) + backend.object_created (h); } else error ("gh_manager::do_make_graphics_handle: invalid object type `%s'", @@ -3537,8 +3573,14 @@ gh_manager::do_make_figure_handle (doubl { graphics_handle h = val; - handle_map[h] = graphics_object (new figure (h, 0)); - + base_graphics_object* go = new figure (h, 0); + handle_map[h] = graphics_object (go); + + // notify backend + graphics_backend backend = go->get_backend (); + if (backend) + backend.object_created (h); + return h; } diff -r db6478d9c669 src/graphics.h.in --- a/src/graphics.h.in Thu Jul 17 14:25:11 2008 -0400 +++ b/src/graphics.h.in Sat Jul 19 21:01:14 2008 +0200 @@ -372,14 +372,10 @@ public: void set_hidden (bool flag) { hidden = flag; } - void set (const octave_value& v, bool do_run = true) - { - do_set (v); - - if (do_run && ! error_state) - run_listeners (POSTSET); - } - + /// Sets property value, notifies backend. + /// If do_run is \b true, runs associated listeners. + void set (const octave_value& v, bool do_run = true); + virtual octave_value get (void) const { error ("get: invalid property \"%s\"", name.c_str ()); @@ -1351,6 +1347,18 @@ public: virtual void set_figure_position (const graphics_handle&, const Matrix&) const { gripe_invalid ("set_figure_position"); } + /// Called when graphics object using this backend changes it's property. + virtual void property_changed (const graphics_handle&, const std::string&) + { gripe_invalid ("property_changed"); } + + /// Caled when new object using this backend is created. + virtual void object_created (const graphics_handle&) + { gripe_invalid ("object_created"); } + + /// Caled when object using this backend is destroyed. + virtual void object_destroyed (const graphics_handle&) + { gripe_invalid ("object_destroyed"); } + private: std::string name; int count; @@ -1430,7 +1438,21 @@ public: void set_figure_position (const graphics_handle& h, const Matrix& pos) const { rep->set_figure_position (h, pos); } + + /// Notifies backend that object't property has changed. + void property_changed (const graphics_handle& h, const std::string& prop) + { rep->property_changed (h, prop); } + /// Notifies backend that new object was created. + void object_created (const graphics_handle& h) + { rep->object_created (h); } + + /// Notifies backend that object was destroyed. + /// This is called only for explicitly deleted object. Are his children are then + /// deleted implicitly and backend isn't notified. + void object_destroyed (const graphics_handle& h) + { rep->object_destroyed (h); } + OCTINTERP_API static graphics_backend default_backend (void); static void register_backend (const graphics_backend& b)