diff src/graphics.h.in @ 13816:7ee18dc46bbb

new and improved non-integer figure handles * waitbar.m: Pass NaN and "integerhandle" property to __go_figure__. * __init_fltk__.cc (OpenGL_fltk::renumber, plot_window::renumber, figure_manager::renumber_figure, figure_manager::do_renumber_figure): New functions. (figure_manager::hnd2idx): Don't declare double arg as const. Include figure number in error message. (fltk_graphics_toolkit::update): Handle ID_INTEGERHANDLE. * graphics.h.in, graphics.cc (gh_manager::do_get_handle): Rename from gh_manager::get_handle. (gh_manager::get_handle): New static function. (gh_manager::renumber_figure): New static function. (gh_manager::do_renumber_figure): New function. (figure::properties::set_integerhandle): New function. (figure::properties::integerhandle): Tag property declaration with S. (F__go_figure__): Intercept and handle integerhandle property here. * graphics.h.in (children_property::renumber): New function. (base_properties::init_integerhandle): New virtual function. (figure::properties::init_integerhandle): New function. (base_properties::renumber_child, base_properties::renumber_parent): New functions.
author John W. Eaton <jwe@octave.org>
date Fri, 04 Nov 2011 06:25:13 -0400
parents e6c1308568c3
children 87f78c11d725
line wrap: on
line diff
--- a/src/graphics.h.in
+++ b/src/graphics.h.in
@@ -1711,6 +1711,21 @@
       do_delete_children (clear);
     }
 
+  void renumber (graphics_handle old_gh, graphics_handle new_gh)
+    {
+      for (children_list_iterator p = children_list.begin ();
+           p != children_list.end (); p++)
+        {
+          if (*p == old_gh)
+            {
+              *p = new_gh.value ();
+              return;
+            }
+        }
+
+      error ("children_list::renumber: child not found!");
+    }
+
 private:
   typedef std::list<double>::iterator children_list_iterator;
   typedef std::list<double>::const_iterator const_children_list_iterator;
@@ -2273,6 +2288,11 @@
 
   void override_defaults (base_graphics_object& obj);
 
+  virtual void init_integerhandle (const octave_value&)
+    {
+      panic_impossible ();
+    }
+
   // Look through DEFAULTS for properties with given CLASS_NAME, and
   // apply them to the current object with set (virtual method).
 
@@ -2377,6 +2397,16 @@
       children.delete_children (clear);
     }
 
+  void renumber_child (graphics_handle old_gh, graphics_handle new_gh)
+    {
+      children.renumber (old_gh, new_gh);
+    }
+
+  void renumber_parent (graphics_handle new_gh)
+    {
+      parent = new_gh;
+    }
+
   static property_list::pval_map_type factory_defaults (void);
 
   // FIXME -- these functions should be generated automatically by the
@@ -3075,6 +3105,11 @@
   class OCTINTERP_API properties : public base_properties
   {
   public:
+    void init_integerhandle (const octave_value& val)
+      {
+        integerhandle = val;
+      }
+
     void remove_child (const graphics_handle& h);
 
     void set_visible (const octave_value& val);
@@ -3153,7 +3188,7 @@
       bool_property dockcontrols , "off"
       bool_property doublebuffer , "on"
       string_property filename , ""
-      bool_property integerhandle , "on"
+      bool_property integerhandle S , "on"
       bool_property inverthardcopy , "off"
       callback_property keypressfcn , Matrix ()
       callback_property keyreleasefcn , Matrix ()
@@ -5147,12 +5182,25 @@
     return retval;
   }
 
+  static graphics_handle get_handle (bool integer_figure_handle)
+  {
+    return instance_ok ()
+      ? instance->do_get_handle (integer_figure_handle) : graphics_handle ();
+  }
+
   static void free (const graphics_handle& h)
   {
     if (instance_ok ())
       instance->do_free (h);
   }
 
+  static void renumber_figure (const graphics_handle& old_gh,
+                               const graphics_handle& new_gh)
+  {
+    if (instance_ok ())
+      instance->do_renumber_figure (old_gh, new_gh);
+  }
+
   static graphics_handle lookup (double val)
   {
     return instance_ok () ? instance->do_lookup (val) : graphics_handle ();
@@ -5386,10 +5434,13 @@
   // A flag telling whether event processing must be constantly on.
   int event_processing;
 
-  graphics_handle get_handle (bool integer_figure_handle);
+  graphics_handle do_get_handle (bool integer_figure_handle);
 
   void do_free (const graphics_handle& h);
 
+  void do_renumber_figure (const graphics_handle& old_gh,
+                           const graphics_handle& new_gh);
+
   graphics_handle do_lookup (double val)
   {
     iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val));