comparison libinterp/dldfcn/__init_fltk__.cc @ 18968:0257a936dc4a

Fix FLTK redraw and event issue * __init_fltk__.cc: Move axis auto code in own function (again). Fix event issue where windowbuttondownfcn was called before set_currentpoint and execute event only if it's defined. * __add_default_menu__.m: Add drawnow () for grid and axis callback
author Andreas Weber <andy.weber.aw@gmail.com>
date Tue, 29 Jul 2014 21:13:03 +0200
parents b2db129c664d
children f84361735a40
comparison
equal deleted inserted replaced
18967:69658bd9952b 18968:0257a936dc4a
944 } 944 }
945 945
946 void button_press (Fl_Widget* widg, void*) 946 void button_press (Fl_Widget* widg, void*)
947 { 947 {
948 if (widg == autoscale) 948 if (widg == autoscale)
949 { 949 axis_auto ();
950 set_on_ax_obj ("xlimmode", "auto");
951 set_on_ax_obj ("ylimmode", "auto");
952 set_on_ax_obj ("zlimmode", "auto");
953 mark_modified ();
954 }
955 else if (widg == togglegrid) 950 else if (widg == togglegrid)
956 toggle_grid (); 951 toggle_grid ();
957 else if (widg == panzoom) 952 else if (widg == panzoom)
958 set_on_ax_obj ("pan", "on"); 953 set_on_ax_obj ("pan", "on");
959 else if (widg == rotate) 954 else if (widg == rotate)
993 Fl_Box* resize_dummy; 988 Fl_Box* resize_dummy;
994 graphics_object ax_obj; 989 graphics_object ax_obj;
995 int pos_x; 990 int pos_x;
996 int pos_y; 991 int pos_y;
997 992
993
994 void axis_auto (void)
995 {
996 octave_value_list args;
997 if (fp.get_currentaxes ().ok ())
998 {
999 args(0) = fp.get_currentaxes ().as_octave_value ();
1000 args(1) = "auto";
1001 feval ("axis", args);
1002 mark_modified ();
1003 }
1004 }
1005
998 void toggle_grid (void) 1006 void toggle_grid (void)
999 { 1007 {
1000 octave_value_list args; 1008 octave_value_list args;
1001 if (fp.get_currentaxes ().ok ()) 1009 if (fp.get_currentaxes ().ok ())
1002 args(0) = fp.get_currentaxes ().as_octave_value (); 1010 args(0) = fp.get_currentaxes ().as_octave_value ();
1196 int handle (int event) 1204 int handle (int event)
1197 { 1205 {
1198 if (event == FL_FOCUS) 1206 if (event == FL_FOCUS)
1199 return 1; 1207 return 1;
1200 1208
1201 Fl_Window::handle (event);
1202 graphics_handle gh; 1209 graphics_handle gh;
1203 1210
1204 if (!fp.is_beingdeleted ()) 1211 if (!fp.is_beingdeleted ())
1205 { 1212 {
1206 //std::cout << "plot_window::handle event = " << fl_eventnames[event] << std::endl; 1213 //std::cout << "plot_window::handle event = " << fl_eventnames[event] << std::endl;
1222 } 1229 }
1223 switch (key) 1230 switch (key)
1224 { 1231 {
1225 case 'a': 1232 case 'a':
1226 case 'A': 1233 case 'A':
1227 set_on_ax_obj ("xlimmode", "auto"); 1234 axis_auto ();
1228 set_on_ax_obj ("ylimmode", "auto");
1229 set_on_ax_obj ("zlimmode", "auto");
1230 mark_modified ();
1231 return 1; 1235 return 1;
1232 1236
1233 case 'g': 1237 case 'g':
1234 case 'G': 1238 case 'G':
1235 toggle_grid (); 1239 toggle_grid ();
1276 Fl::event_y () - menu_dy ()), 1280 Fl::event_y () - menu_dy ()),
1277 Fl::event_x (), Fl::event_y () - menu_dy ()); 1281 Fl::event_x (), Fl::event_y () - menu_dy ());
1278 return 1; 1282 return 1;
1279 1283
1280 case FL_PUSH: 1284 case FL_PUSH:
1281 fp.execute_windowbuttondownfcn (Fl::event_button());
1282
1283 pos_x = Fl::event_x (); 1285 pos_x = Fl::event_x ();
1284 pos_y = Fl::event_y () - menu_dy (); 1286 pos_y = Fl::event_y () - menu_dy ();
1285 1287
1286 set_currentpoint (pos_x, pos_y); 1288 set_currentpoint (pos_x, pos_y);
1289
1290 if (fp.get_windowbuttonupfcn ().is_defined ())
1291 fp.execute_windowbuttondownfcn (Fl::event_button());
1287 1292
1288 gh = pixel2axes_or_ca (pos_x, pos_y); 1293 gh = pixel2axes_or_ca (pos_x, pos_y);
1289 1294
1290 if (gh.ok ()) 1295 if (gh.ok ())
1291 { 1296 {