Index: src/genprops.awk =================================================================== RCS file: /cvs/octave/src/genprops.awk,v retrieving revision 1.10 diff -c -r1.10 genprops.awk *** src/genprops.awk 12 Jan 2008 08:21:57 -0000 1.10 --- src/genprops.awk 13 Jan 2008 21:00:25 -0000 *************** *** 176,185 **** function emit_get_callback (i) { ! printf (" void execute_%s (void)", name[i]); if (emit_get[i] == "definition") ! printf (" { %s.execute (); }\n", name[i]); else printf (";\n"); --- 176,185 ---- function emit_get_callback (i) { ! printf (" void execute_%s (const octave_value& data = octave_value ()) const", name[i]); if (emit_get[i] == "definition") ! printf (" { %s.execute (data); }\n", name[i]); else printf (";\n"); Index: src/graphics.cc =================================================================== RCS file: /cvs/octave/src/graphics.cc,v retrieving revision 1.69 diff -c -r1.69 graphics.cc *** src/graphics.cc 13 Jan 2008 06:46:39 -0000 1.69 --- src/graphics.cc 13 Jan 2008 21:00:30 -0000 *************** *** 137,142 **** --- 137,197 ---- return retval; } + // NOTE: "cb" is passed by value, because "function_value" method + // is non-const; passing "cb" by const-reference is not + // possible + + static void + execute_callback (octave_value cb, const graphics_handle& h, + const octave_value& data) + { + octave_value_list args; + octave_function *fcn = 0; + + args(0) = h.as_octave_value (); + args(1) = data; + + BEGIN_INTERRUPT_WITH_EXCEPTIONS; + + if (cb.is_function_handle ()) + fcn = cb.function_value (); + else if (cb.is_string ()) + { + std::string s = cb.string_value (); + octave_value f = symbol_table::find_function (s); + int status; + + if (f.is_defined ()) + fcn = f.function_value (); + else + { + eval_string (s, false, status); + return; + } + } + else if (cb.is_cell () && cb.length () > 0 + && (cb.rows () == 1 || cb.columns () == 1) + && cb.cell_value ()(0).is_function_handle ()) + { + Cell c = cb.cell_value (); + + fcn = c(0).function_value (); + if (! error_state) + { + for (int i = 0; i < c.length () ; i++) + args(2+i) = c(i); + } + } + else + error ("trying to execute non-executable object (class = %s)", + cb.class_name ()); + + if (! error_state) + feval (fcn, args); + + END_INTERRUPT_WITH_EXCEPTIONS; + } + // --------------------------------------------------------------------- radio_values::radio_values (const std::string& opt_string) *************** *** 335,350 **** } bool ! callback_property::validate (const octave_value&) const { ! // FIXME: implement this ! return true; } void ! callback_property::execute (void) { ! // FIXME: define correct signature and implement this } // --------------------------------------------------------------------- --- 390,423 ---- } bool ! callback_property::validate (const octave_value& v) const { ! // case 1: function handle ! // case 2: cell array with first element being a function handle ! // case 3: string corresponding to known function name ! // case 4: evaluatable string ! // case 5: empty matrix ! ! if (v.is_function_handle ()) ! return true; ! else if (v.is_string ()) ! // complete validation will be done at execution-time ! return true; ! else if (v.is_cell () && v.length () > 0 ! && (v.rows() == 1 || v.columns () == 1) ! && v.cell_value ()(0).is_function_handle ()) ! return true; ! else if (v.is_empty ()) ! return true; ! ! return false; } void ! callback_property::execute (const octave_value& data) const { ! if (callback.is_defined () && ! callback.is_empty ()) ! execute_callback (callback, get_parent (), data); } // --------------------------------------------------------------------- *************** *** 606,611 **** --- 679,686 ---- if (p != handle_map.end ()) { + p->second.get_properties ().execute_deletefcn (); + handle_map.erase (p); if (h.value () < 0) *************** *** 2065,2073 **** graphics_object parent_obj = gh_manager::get_object (parent_h); ! parent_obj.remove_child (h); gh_manager::free (h); } else error ("delete: invalid graphics object (= %g)", val); --- 2140,2152 ---- graphics_object parent_obj = gh_manager::get_object (parent_h); ! // NOTE: free the handle before removing it from its parent's ! // children, such that the object's state is correct when ! // the deletefcn callback is executed gh_manager::free (h); + + parent_obj.remove_child (h); } else error ("delete: invalid graphics object (= %g)", val); Index: src/graphics.h.in =================================================================== RCS file: /cvs/octave/src/graphics.h.in,v retrieving revision 1.32 diff -c -r1.32 graphics.h.in *** src/graphics.h.in 13 Jan 2008 06:46:39 -0000 1.32 --- src/graphics.h.in 13 Jan 2008 21:00:31 -0000 *************** *** 796,802 **** get_name ().c_str ()); } ! OCTINTERP_API void execute (void); callback_property& operator = (const octave_value& val) { --- 796,802 ---- get_name ().c_str ()); } ! OCTINTERP_API void execute (const octave_value& data = octave_value ()) const; callback_property& operator = (const octave_value& val) { *************** *** 967,983 **** parent ("parent", mh, p), children (), busyaction ("parent", mh, "{queue}|cancel"), ! buttondownfcn ("buttondownfcn", mh, octave_value ()), clipping ("clipping", mh, true), ! createfcn ("createfcn" , mh, octave_value ()), ! deletefcn ("deletefcn", mh, octave_value ()), handlevisibility ("handlevisibility", mh, "{on}|callback|off"), hittest ("hittest", mh, true), interruptible ("interruptible", mh, true), selected ("selected", mh, false), selectionhighlight ("selectionhighlight", mh, true), uicontextmenu ("uicontextmenu", mh, graphics_handle ()), ! userdata ("userdata", mh, octave_value ()), visible ("visible", mh, true) { } --- 967,983 ---- parent ("parent", mh, p), children (), busyaction ("parent", mh, "{queue}|cancel"), ! buttondownfcn ("buttondownfcn", mh, Matrix ()), clipping ("clipping", mh, true), ! createfcn ("createfcn" , mh, Matrix ()), ! deletefcn ("deletefcn", mh, Matrix ()), handlevisibility ("handlevisibility", mh, "{on}|callback|off"), hittest ("hittest", mh, true), interruptible ("interruptible", mh, true), selected ("selected", mh, false), selectionhighlight ("selectionhighlight", mh, true), uicontextmenu ("uicontextmenu", mh, graphics_handle ()), ! userdata ("userdata", mh, Matrix ()), visible ("visible", mh, true) { } *************** *** 1025,1032 **** --- 1025,1038 ---- std::string get_clipping (void) const { return clipping.current_value (); } + void execute_createfcn (const octave_value& data = octave_value ()) const + { createfcn.execute (data); } + octave_value get_createfcn (void) const { return createfcn.get (); } + void execute_deletefcn (const octave_value& data = octave_value ()) const + { deletefcn.execute (data); } + octave_value get_deletefcn (void) const { return deletefcn.get (); } std::string get_handlevisibility (void) const { return handlevisibility.current_value (); }