Mercurial > hg > octave-nkf
diff src/graphics/fltk_backend/fltk_backend.cc @ 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 (2008-03-06) |
parents | 4dc3e0ff730a |
children | dfae35ac4fb0 |
line wrap: on
line diff
--- 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<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;