changeset 7856:cf672485be43

Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle grid
author Shai Ayal <shaiay@users.sourceforge.net>
date Thu, 06 Mar 2008 06:40:06 +0200
parents f317f14516cb
children 09b1a9c88128
files src/graphics/ChangeLog src/graphics/fltk_backend/fltk_backend.cc
diffstat 2 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/graphics/ChangeLog	Tue Mar 04 15:34:38 2008 +0100
+++ b/src/graphics/ChangeLog	Thu Mar 06 06:40:06 2008 +0200
@@ -1,3 +1,10 @@
+2008-03-06  Shai Ayal  <shaiay@users.sourceforge.net>
+
+	* fltk_backend/fltk_backend.cc (plot_window::handle): Add handling
+	of the 'a' and 'g' keys
+	(plot_window: toggle_grid): New helper function
+	(plot_window): Add new togglegrid button
+
 2008-03-01  Shai Ayal  <shaiay@users.sourceforge.net>
 
 	* fltk_backend/fltk_backend.cc (OpenGL_fltk::draw_overlay,
--- a/src/graphics/fltk_backend/fltk_backend.cc	Tue Mar 04 15:34:38 2008 +0100
+++ b/src/graphics/fltk_backend/fltk_backend.cc	Thu Mar 06 06:40:06 2008 +0200
@@ -178,8 +178,16 @@
 		   "A");
       autoscale->callback (button_callback, static_cast<void*> (this));
 
+      togglegrid = new
+	Fl_Button (status_h, 
+		   _h - status_h, 
+		   status_h,
+		   status_h,
+		   "G");
+      togglegrid->callback (button_callback, static_cast<void*> (this));
+
       help = new
-	Fl_Button (status_h, 
+	Fl_Button (2*status_h, 
 		   _h - status_h, 
 		   status_h,
 		   status_h,
@@ -187,7 +195,7 @@
       help->callback (button_callback, static_cast<void*> (this));
 
       status = new 
-	Fl_Output (2*status_h, 
+	Fl_Output (3*status_h, 
 		   _h - status_h, 
 		   _w > 2*status_h ? _w - status_h : 0, 
 		   status_h, "");
@@ -208,6 +216,7 @@
 
     status->show ();
     autoscale->show ();
+    togglegrid->show ();
 
     resizable (canvas);
     size_range (4*status_h, 2*status_h);
@@ -256,11 +265,13 @@
 
   void button_press (Fl_Widget* widg) {
     if (widg == autoscale) axis_auto ();
+    if (widg == togglegrid) toggle_grid ();
     if (widg == help) fl_message (help_text);
   }
 
   OpenGL_fltk*   canvas;
   Fl_Button*	 autoscale;
+  Fl_Button*	 togglegrid;
   Fl_Button*	 help;
   Fl_Output*     status;
 
@@ -272,6 +283,12 @@
     mark_modified ();
   }
 
+  void toggle_grid () 
+  { 
+    feval ("grid"); 
+    mark_modified ();
+  }
+
   void pixel2pos (int px, int py, double& x, double& y) const {
     graphics_object ax = gh_manager::get_object (fp.get_currentaxes ());
     if (ax && ax.isa ("axes")) 
@@ -355,7 +372,20 @@
 
     switch (event)
       {
-      
+      case FL_KEYDOWN:
+	switch(Fl::event_key ()) 
+	  {
+	  case 'a':
+	  case 'A':
+	    axis_auto ();
+	    break;
+	  case 'g':
+	  case 'G':
+	    toggle_grid ();
+	    break;
+	  }
+	break;
+
       case FL_MOVE:
 	pixel2status (Fl::event_x (), Fl::event_y ());
 	break;