# HG changeset patch # User Michael Goffioul # Date 1289771505 0 # Node ID 830b940e7ff4b0d8343ffab9edad82c339311c73 # Parent 6cd1e62b6616efee11a4e5ade26e711418e4f04c Turn xget_ancestor into regular API diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2010-11-14 Michael Goffioul + + * graphics.h.in (graphics_object::get_ancestor): New method. + * graphics.cc (graphics_object::get_ancestor): Likewise. + (convert_text_position, convert_cdata): Use it. + (xget_ancestor): Remove obsolete function. + * DLD_FUNCTIONS/fltk_backend.cc (plot_window::uimenu_update, + fltk_backend::update): Replace xget_ancestor with + graphics_objects::get_ancestor. + 2010-11-13 John W. Eaton * graphics.h.in (figure::properties::filename): Make writable. diff --git a/src/DLD-FUNCTIONS/fltk_backend.cc b/src/DLD-FUNCTIONS/fltk_backend.cc --- a/src/DLD-FUNCTIONS/fltk_backend.cc +++ b/src/DLD-FUNCTIONS/fltk_backend.cc @@ -85,9 +85,6 @@ left double click - autoscale\n\ "; -graphics_object xget_ancestor (const graphics_object& go_arg, - const std::string& type); - class OpenGL_fltk : public Fl_Gl_Window { public: @@ -790,7 +787,7 @@ uimenu::properties& uimenup = dynamic_cast (uimenu_obj.get_properties ()); std::string fltk_label = uimenup.get_fltk_label(); - graphics_object fig = xget_ancestor(uimenu_obj,"figure"); + graphics_object fig = uimenu_obj.get_ancestor("figure"); figure::properties& figp = dynamic_cast (fig.get_properties ()); @@ -1825,7 +1822,7 @@ if (id == uimenu::properties::ID_LABEL) uimenu_set_fltk_label (go); - graphics_object fig = xget_ancestor(go,"figure"); + graphics_object fig = go.get_ancestor("figure"); figure_manager::uimenu_update(fig.get_handle (), go.get_handle (), id); } } diff --git a/src/graphics.cc b/src/graphics.cc --- a/src/graphics.cc +++ b/src/graphics.cc @@ -55,8 +55,6 @@ // forward declarations static octave_value xget (const graphics_handle& h, const caseless_str& name); -graphics_object xget_ancestor (const graphics_object& go_arg, - const std::string& type); static void gripe_set_invalid (const std::string& pname) @@ -460,7 +458,7 @@ const caseless_str& to_units) { graphics_object go = gh_manager::get_object (props.get___myhandle__ ()); - graphics_object ax = xget_ancestor (go, "axes"); + graphics_object ax = go.get_ancestor ("axes"); Matrix retval (1, pos.numel (), 0); @@ -541,26 +539,6 @@ return convert_position (sz, obj.get ("units").string_value (), "pixels", sz.extract_n (0, 2, 1, 2)).extract_n (0, 2, 1, 2); } -graphics_object -xget_ancestor (const graphics_object& go_arg, const std::string& type) -{ - graphics_object go = go_arg; - - do - { - if (go.valid_object ()) - { - if (go.isa (type)) - return go; - else - go = gh_manager::get_object (go.get_parent ()); - } - else - return graphics_object (); - } - while (true); -} - static void convert_cdata_2 (bool is_scaled, double clim_0, double clim_1, const double *cmapv, double x, octave_idx_type lda, @@ -615,7 +593,7 @@ Matrix clim (1, 2, 0.0); graphics_object go = gh_manager::get_object (props.get___myhandle__ ()); - graphics_object fig = xget_ancestor (go, "figure"); + graphics_object fig = go.get_ancestor ("figure"); if (fig.valid_object ()) { @@ -627,7 +605,7 @@ if (is_scaled) { - graphics_object ax = xget_ancestor (go, "axes"); + graphics_object ax = go.get_ancestor ("axes"); if (ax.valid_object ()) { @@ -2555,6 +2533,20 @@ return retval; } +graphics_object +graphics_object::get_ancestor (const std::string& type) const +{ + if (valid_object ()) + { + if (isa (type)) + return *this; + else + return gh_manager::get_object (get_parent ()).get_ancestor (type); + } + else + return graphics_object (); +} + // --------------------------------------------------------------------- #include "graphics-props.cc" diff --git a/src/graphics.h.in b/src/graphics.h.in --- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -2496,6 +2496,8 @@ graphics_handle get_handle (void) const { return rep->get_handle (); } + graphics_object get_ancestor (const std::string& type) const; + void remove_child (const graphics_handle& h) { rep->remove_child (h); } void adopt (const graphics_handle& h) { rep->adopt (h); }