comparison libinterp/dldfcn/__init_fltk__.cc @ 17213:4407606d0939

FLTK toolkit: Simplify conditionals for uimenu presence. * libinterp/dldfcn/__init_fltk__.cc: Introduce menu_dy() to unify the "if (uimenu->is_visible ())" blocks. Correctly determine the figure's currentpoint. Correct zoom box and resulting ylim.
author Ben Abbott <bpabbott@mac.com>
date Sat, 10 Aug 2013 12:37:12 -0400
parents d23fcc227fa9
children bc924baa2c4e
comparison
equal deleted inserted replaced
17212:9336d0e1d1ec 17213:4407606d0939
678 // windows. Otherwise, the class is just "FLTK" 678 // windows. Otherwise, the class is just "FLTK"
679 //default_xclass ("Octave"); 679 //default_xclass ("Octave");
680 680
681 begin (); 681 begin ();
682 { 682 {
683 //Fl_Window::resize (xx, yy - menu_h, ww, hh + menu_h + status_h);
684
685 // bbox of plot canvas = [xx, yy, ww, hh]; 683 // bbox of plot canvas = [xx, yy, ww, hh];
686 // (xx, yy) = UL coordinate relative to UL window. 684 // (xx, yy) = UL coordinate relative to UL window.
687 685
688 canvas = new OpenGL_fltk (0, menu_h, ww, hh, number ()); 686 canvas = new OpenGL_fltk (0, menu_h, ww, hh, number ());
689 687
1108 { 1106 {
1109 if (!fp.is_beingdeleted ()) 1107 if (!fp.is_beingdeleted ())
1110 { 1108 {
1111 Matrix pos (1,2,0); 1109 Matrix pos (1,2,0);
1112 pos(0) = px; 1110 pos(0) = px;
1113 pos(1) = h () - menu_h - py; 1111 pos(1) = h () - (py + status_h + menu_dy ());
1114 if (! uimenu->is_visible ())
1115 pos(1) = pos(1) + menu_h;
1116 fp.set_currentpoint (pos); 1112 fp.set_currentpoint (pos);
1117 graphics_object robj = gh_manager::get_object (fp.get_parent ()); 1113 graphics_object robj = gh_manager::get_object (fp.get_parent ());
1118 root_figure::properties& rp = 1114 root_figure::properties& rp =
1119 dynamic_cast<root_figure::properties&> (robj.get_properties ()); 1115 dynamic_cast<root_figure::properties&> (robj.get_properties ());
1120 rp.set_currentfigure (fp.get___myhandle__ ().value ()); 1116 rp.set_currentfigure (fp.get___myhandle__ ().value ());
1127 { 1123 {
1128 axes::properties& ap = 1124 axes::properties& ap =
1129 dynamic_cast<axes::properties&> (ax.get_properties ()); 1125 dynamic_cast<axes::properties&> (ax.get_properties ());
1130 1126
1131 double xx, yy; 1127 double xx, yy;
1132 if (uimenu->is_visible ())
1133 py = py - menu_h;
1134 pixel2pos (ax, px, py, xx, yy); 1128 pixel2pos (ax, px, py, xx, yy);
1135 1129
1136 Matrix pos (2,3,0); 1130 Matrix pos (2,3,0);
1137 pos(0,0) = xx; 1131 pos(0,0) = xx;
1138 pos(1,0) = yy; 1132 pos(1,0) = yy;
1141 1135
1142 ap.set_currentpoint (pos); 1136 ap.set_currentpoint (pos);
1143 fp.set_currentaxes (ap.get___myhandle__ ().value ()); 1137 fp.set_currentaxes (ap.get___myhandle__ ().value ());
1144 } 1138 }
1145 } 1139 }
1140
1141 int menu_dy ()
1142 {
1143 if (uimenu->is_visible ())
1144 return menu_h;
1145 else
1146 return 0;
1147 }
1146 1148
1147 int key2shift (int key) 1149 int key2shift (int key)
1148 { 1150 {
1149 if (key == FL_Shift_L || key == FL_Shift_R) 1151 if (key == FL_Shift_L || key == FL_Shift_R)
1150 return FL_SHIFT; 1152 return FL_SHIFT;
1190 { 1192 {
1191 Fl_Window::resize (xx, yy, ww, hh); 1193 Fl_Window::resize (xx, yy, ww, hh);
1192 1194
1193 Matrix pos (1,4,0); 1195 Matrix pos (1,4,0);
1194 pos(0) = xx; 1196 pos(0) = xx;
1195 pos(1) = yy + menu_h; 1197 pos(1) = yy + menu_dy ();
1196 pos(2) = ww; 1198 pos(2) = ww;
1197 pos(3) = hh - menu_h - status_h; 1199 pos(3) = hh - menu_dy () - status_h;
1198 if (! uimenu->is_visible ())
1199 {
1200 pos(1) = yy;
1201 pos(3) = hh - status_h;
1202 }
1203 1200
1204 fp.set_boundingbox (pos, true); 1201 fp.set_boundingbox (pos, true);
1205 } 1202 }
1206 1203
1207 void draw (void) 1204 void draw (void)
1208 { 1205 {
1209 // FIXME - Toolbar and menubar do not update properly 1206 // FIXME - Toolbar and menubar do not update properly
1210 Matrix pos = fp.get_boundingbox (true); 1207 Matrix pos = fp.get_boundingbox (true);
1211 int canvas_h = pos(3); 1208 int canvas_h = pos(3);
1212 int canvas_w = pos(2); 1209 int canvas_w = pos(2);
1213 int canvas_y = menu_h; 1210 int canvas_y = menu_dy ();
1214 int toolbar_y = menu_h + canvas_h; 1211 int toolbar_y = menu_dy () + canvas_h;
1215 pos(1) = pos(1) - menu_h; 1212 pos(1) = pos(1) - menu_dy ();
1216 pos(3) = pos(3) + menu_h + status_h; 1213 pos(3) = pos(3) + menu_dy () + status_h;
1217
1218 if (! uimenu->is_visible ())
1219 {
1220 pos(1) = pos(1) + menu_h;
1221 pos(3) = pos(3) - menu_h;
1222 toolbar_y = toolbar_y - menu_h;
1223 canvas_y = canvas_y - menu_h;
1224 }
1225 1214
1226 Fl_Window::resize (pos(0), pos(1), pos(2), pos(3)); 1215 Fl_Window::resize (pos(0), pos(1), pos(2), pos(3));
1227 1216
1228 bottom->resize (0, toolbar_y, status_h, status_h); 1217 bottom->resize (0, toolbar_y, status_h, status_h);
1229 autoscale->resize (0, toolbar_y, status_h, status_h); 1218 autoscale->resize (0, toolbar_y, status_h, status_h);
1308 } 1297 }
1309 } 1298 }
1310 break; 1299 break;
1311 1300
1312 case FL_MOVE: 1301 case FL_MOVE:
1313 pixel2status (pixel2axes_or_ca (Fl::event_x (), Fl::event_y ()), 1302 pixel2status (pixel2axes_or_ca (Fl::event_x (), Fl::event_y () - menu_dy ()),
1314 Fl::event_x (), Fl::event_y ()); 1303 Fl::event_x (), Fl::event_y () - menu_dy ());
1315 break; 1304 break;
1316 1305
1317 case FL_PUSH: 1306 case FL_PUSH:
1318 pos_x = Fl::event_x (); 1307 pos_x = Fl::event_x ();
1319 pos_y = Fl::event_y (); 1308 pos_y = Fl::event_y () - menu_dy ();
1320 1309
1321 set_currentpoint (Fl::event_x (), Fl::event_y ()); 1310 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
1322 1311
1323 gh = pixel2axes_or_ca (pos_x, pos_y); 1312 gh = pixel2axes_or_ca (pos_x, pos_y);
1324 1313
1325 if (gh.ok ()) 1314 if (gh.ok ())
1326 { 1315 {
1336 break; 1325 break;
1337 1326
1338 case FL_DRAG: 1327 case FL_DRAG:
1339 if (fp.get_windowbuttonmotionfcn ().is_defined ()) 1328 if (fp.get_windowbuttonmotionfcn ().is_defined ())
1340 { 1329 {
1341 set_currentpoint (Fl::event_x (), Fl::event_y ()); 1330 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
1342 fp.execute_windowbuttonmotionfcn (); 1331 fp.execute_windowbuttonmotionfcn ();
1343 } 1332 }
1344 1333
1345 if (Fl::event_button () == 1) 1334 if (Fl::event_button () == 1)
1346 { 1335 {
1347 if (ax_obj && ax_obj.isa ("axes")) 1336 if (ax_obj && ax_obj.isa ("axes"))
1348 { 1337 {
1349 if (gui_mode == pan_zoom) 1338 if (gui_mode == pan_zoom)
1350 pixel2status (ax_obj, pos_x, pos_y, 1339 pixel2status (ax_obj, pos_x, pos_y,
1351 Fl::event_x (), Fl::event_y ()); 1340 Fl::event_x (), Fl::event_y () - menu_dy ());
1352 else 1341 else
1353 view2status (ax_obj); 1342 view2status (ax_obj);
1354 axes::properties& ap = 1343 axes::properties& ap =
1355 dynamic_cast<axes::properties&> (ax_obj.get_properties ()); 1344 dynamic_cast<axes::properties&> (ax_obj.get_properties ());
1356 1345
1357 double x0, y0, x1, y1; 1346 double x0, y0, x1, y1;
1358 Matrix pos = fp.get_boundingbox (true); 1347 Matrix pos = fp.get_boundingbox (true);
1359 pixel2pos (ax_obj, pos_x, pos_y, x0, y0); 1348 pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
1360 pixel2pos (ax_obj, Fl::event_x (), Fl::event_y (), x1, y1); 1349 pixel2pos (ax_obj, Fl::event_x (), Fl::event_y () - menu_dy (), x1, y1);
1361 1350
1362 if (gui_mode == pan_zoom) 1351 if (gui_mode == pan_zoom)
1363 ap.translate_view (x0, x1, y0, y1); 1352 ap.translate_view (x0, x1, y0, y1);
1364 else if (gui_mode == rotate_zoom) 1353 else if (gui_mode == rotate_zoom)
1365 { 1354 {
1366 double daz, del; 1355 double daz, del;
1367 daz = (Fl::event_x () - pos_x) / pos(2) * 360; 1356 daz = (Fl::event_x () - pos_x) / pos(2) * 360;
1368 del = (Fl::event_y () - pos_y) / pos(3) * 360; 1357 del = (Fl::event_y () - menu_dy () - pos_y) / pos(3) * 360;
1369 ap.rotate_view (del, daz); 1358 ap.rotate_view (del, daz);
1370 } 1359 }
1371 1360
1372 pos_x = Fl::event_x (); 1361 pos_x = Fl::event_x ();
1373 pos_y = Fl::event_y (); 1362 pos_y = Fl::event_y () - menu_dy ();
1374 mark_modified (); 1363 mark_modified ();
1375 } 1364 }
1376 return 1; 1365 return 1;
1377 } 1366 }
1378 else if (Fl::event_button () == 3) 1367 else if (Fl::event_button () == 3)
1379 { 1368 {
1380 pixel2status (ax_obj, pos_x, pos_y, 1369 pixel2status (ax_obj, pos_x, pos_y,
1381 Fl::event_x (), Fl::event_y ()); 1370 Fl::event_x (), Fl::event_y () - menu_dy ());
1382 Matrix zoom_box (1,4,0); 1371 Matrix zoom_box (1,4,0);
1383 zoom_box (0) = pos_x; 1372 zoom_box (0) = pos_x;
1384 zoom_box (1) = pos_y; 1373 zoom_box (1) = pos_y;
1385 zoom_box (2) = Fl::event_x (); 1374 zoom_box (2) = Fl::event_x ();
1386 zoom_box (3) = Fl::event_y (); 1375 zoom_box (3) = Fl::event_y () - menu_dy ();
1387 canvas->set_zoom_box (zoom_box); 1376 canvas->set_zoom_box (zoom_box);
1388 canvas->zoom (true); 1377 canvas->zoom (true);
1389 canvas->redraw (); 1378 canvas->redraw ();
1390 } 1379 }
1391 1380
1393 1382
1394 case FL_MOUSEWHEEL: 1383 case FL_MOUSEWHEEL:
1395 { 1384 {
1396 graphics_object ax = 1385 graphics_object ax =
1397 gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (), 1386 gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (),
1398 Fl::event_y ())); 1387 Fl::event_y () - menu_dy ()));
1399 if (ax && ax.isa ("axes")) 1388 if (ax && ax.isa ("axes"))
1400 { 1389 {
1401 axes::properties& ap = 1390 axes::properties& ap =
1402 dynamic_cast<axes::properties&> (ax.get_properties ()); 1391 dynamic_cast<axes::properties&> (ax.get_properties ());
1403 1392
1405 const double factor = 1394 const double factor =
1406 (Fl::event_dy () > 0) ? 1.0 + wheel_zoom_speed : 1.0 - wheel_zoom_speed; 1395 (Fl::event_dy () > 0) ? 1.0 + wheel_zoom_speed : 1.0 - wheel_zoom_speed;
1407 1396
1408 // Get the point we're zooming about. 1397 // Get the point we're zooming about.
1409 double x1, y1; 1398 double x1, y1;
1410 pixel2pos (ax, Fl::event_x (), Fl::event_y (), x1, y1); 1399 pixel2pos (ax, Fl::event_x (), Fl::event_y () - menu_dy (), x1, y1);
1411 1400
1412 ap.zoom_about_point (x1, y1, factor, false); 1401 ap.zoom_about_point (x1, y1, factor, false);
1413 mark_modified (); 1402 mark_modified ();
1414 } 1403 }
1415 } 1404 }
1416 return 1; 1405 return 1;
1417 1406
1418 case FL_RELEASE: 1407 case FL_RELEASE:
1419 if (fp.get_windowbuttonupfcn ().is_defined ()) 1408 if (fp.get_windowbuttonupfcn ().is_defined ())
1420 { 1409 {
1421 set_currentpoint (Fl::event_x (), Fl::event_y ()); 1410 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
1422 fp.execute_windowbuttonupfcn (); 1411 fp.execute_windowbuttonupfcn ();
1423 } 1412 }
1424 1413
1425 if (Fl::event_button () == 1) 1414 if (Fl::event_button () == 1)
1426 { 1415 {
1448 { 1437 {
1449 axes::properties& ap = 1438 axes::properties& ap =
1450 dynamic_cast<axes::properties&> (ax_obj.get_properties ()); 1439 dynamic_cast<axes::properties&> (ax_obj.get_properties ());
1451 pixel2pos (ax_obj, pos_x, pos_y, x0, y0); 1440 pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
1452 int pos_x1 = Fl::event_x (); 1441 int pos_x1 = Fl::event_x ();
1453 int pos_y1 = Fl::event_y (); 1442 int pos_y1 = Fl::event_y () - menu_dy ();
1454 pixel2pos (ax_obj, pos_x1, pos_y1, x1, y1); 1443 pixel2pos (ax_obj, pos_x1, pos_y1, x1, y1);
1455 Matrix xl (1,2,0); 1444 Matrix xl (1,2,0);
1456 Matrix yl (1,2,0); 1445 Matrix yl (1,2,0);
1457 int dx = abs (pos_x - pos_x1); 1446 int dx = abs (pos_x - pos_x1);
1458 int dy = abs (pos_y - pos_y1); 1447 int dy = abs (pos_y - pos_y1);