# HG changeset patch # User Shai Ayal # Date 1204778406 -7200 # Node ID cf672485be432ab544325067200a64551980db6b # Parent f317f14516cbedbe26d85bd9cfe1ed0b7285edaa Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle grid diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,10 @@ +2008-03-06 Shai Ayal + + * 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 * fltk_backend/fltk_backend.cc (OpenGL_fltk::draw_overlay, diff --git a/src/graphics/fltk_backend/fltk_backend.cc b/src/graphics/fltk_backend/fltk_backend.cc --- a/src/graphics/fltk_backend/fltk_backend.cc +++ b/src/graphics/fltk_backend/fltk_backend.cc @@ -178,8 +178,16 @@ "A"); autoscale->callback (button_callback, static_cast (this)); + togglegrid = new + Fl_Button (status_h, + _h - status_h, + status_h, + status_h, + "G"); + togglegrid->callback (button_callback, static_cast (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 (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;