diff src/DLD-FUNCTIONS/fltk_backend.cc @ 9973:cd8f355157b8

Handle figure visibility in fltk backend
author Shai Ayal <shaiay@users.sourceforge.net>
date Sat, 12 Dec 2009 19:08:40 +0200
parents d64d15e12e6b
children 118158f10628
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/fltk_backend.cc
+++ b/src/DLD-FUNCTIONS/fltk_backend.cc
@@ -269,9 +269,12 @@
 
       // This allows us to have a valid OpenGL context right away.
       canvas->mode (FL_DEPTH | FL_DOUBLE );
-      show ();
-      canvas->show ();
-      canvas->make_current ();
+      if (fp.is_visible ())
+        {
+          show ();
+          canvas->show ();
+          canvas->make_current ();
+        }
     }
     end ();
 
@@ -284,7 +287,8 @@
 
     std::stringstream name;
     name << "octave: figure " << number ();
-    label (name.str ().c_str ());
+    window_label = name.str ();
+    label (window_label.c_str ());
   }
 
   ~plot_window (void)
@@ -316,6 +320,9 @@
   }
 
 private:
+  // window name -- this must exists for the duration of the window's
+  // life
+  std::string window_label;
 
   // Figure properties.
   figure::properties& fp;
@@ -675,6 +682,17 @@
     delete_window (str2idx (idx_str));
   }
 
+  static void toggle_window_visibility (int idx, bool is_visible)
+  {
+    if (instance_ok ())
+      instance->do_toggle_window_visibility (idx, is_visible);
+  }
+
+  static void toggle_window_visibility (std::string idx_str, bool is_visible)
+  {
+    toggle_window_visibility (str2idx (idx_str), is_visible);
+  }
+
   static void mark_modified (int idx)
   {
     if (instance_ok ())
@@ -752,6 +770,20 @@
       }
   }
 
+  void do_toggle_window_visibility (int idx, bool is_visible)
+  {
+    wm_iterator win;
+    if ((win = windows.find (idx)) != windows.end ())
+      {
+        if (is_visible)
+          win->second->show ();
+        else
+          win->second->hide ();
+
+        win->second->redraw ();
+      }
+  }
+
   void do_mark_modified (int idx)
   {
     wm_iterator win;
@@ -911,10 +943,13 @@
 	
 	if (! ov.is_empty ())
 	  {
+            const figure::properties& fp =
+              dynamic_cast<const figure::properties&> (go.get_properties ());
+            
 	    switch (id)
 	      {
 	      case base_properties::VISIBLE:
-		// FIXME -- something to do here.
+                figure_manager::toggle_window_visibility (ov.string_value(), fp.is_visible ());
 		break;
 	      }
 	  }