# HG changeset patch # User John W. Eaton # Date 1219771407 14400 # Node ID ca39c21fa4b88701efcc11599d75212734b8c4c6 # Parent 7670cd2966873e73061a3855aeeb37e28d4c106d [mq]: generic_octave_to_backend_nofitication diff -r 7670cd296687 -r ca39c21fa4b8 src/ChangeLog --- a/src/ChangeLog Tue Aug 26 18:05:35 2008 +0200 +++ b/src/ChangeLog Tue Aug 26 13:23:27 2008 -0400 @@ -1,3 +1,16 @@ +2008-08-26 Maciek Gajewski + + * graphics.h.in (base_property::set): Remove inline implementation. + (base_graphics_backend::property_changed, + base_graphics_backend::object_created, + base_graphics_backend::object_destroyed): New method. + (graphics_backend::property_changed, graphics_backend::object_created, + graphics_backend::object_destroyed): Likewise. + * graphics.cc (base_property::set): Moved from header file. + (gh_manager::do_free): Add backend notification. + (gh_manager::do_make_graphics_handle): Likewise. + (gh_manager::do_make_figure_handle): Likewise. + 2008-08-25 Thomas L. Scofield * DLD-FUNCTIONS/__magick_read__.cc: Untabify. diff -r 7670cd296687 -r ca39c21fa4b8 src/graphics.cc --- a/src/graphics.cc Tue Aug 26 18:05:35 2008 +0200 +++ b/src/graphics.cc Tue Aug 26 13:23:27 2008 -0400 @@ -459,6 +459,26 @@ // --------------------------------------------------------------------- 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) { const octave_value_list& l = listeners[mode]; @@ -1172,6 +1192,13 @@ 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) @@ -3524,6 +3551,11 @@ 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 +3569,14 @@ { 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 7670cd296687 -r ca39c21fa4b8 src/graphics.h.in --- a/src/graphics.h.in Tue Aug 26 18:05:35 2008 +0200 +++ b/src/graphics.h.in Tue Aug 26 13:23:27 2008 -0400 @@ -372,14 +372,10 @@ 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 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 @@ 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"); } + + // Called when new object using this backend is created. + virtual void object_created (const graphics_handle&) + { gripe_invalid ("object_created"); } + + // Called 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 @@ 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. Children are + // 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)