comparison libinterp/dldfcn/__init_fltk__.cc @ 18985:f84361735a40

maint: Use Octave coding conventions for some recent patches. * __init_fltk__.cc: Wrap long lines to 80 characters. Use space between function name and opening '(' when calling function. * __go_draw_axes__.m: Wrap long lines to 80 characters. Use space between function name and opening '(' when calling function.
author Rik <rik@octave.org>
date Tue, 05 Aug 2014 09:15:01 -0700
parents 0257a936dc4a
children
comparison
equal deleted inserted replaced
18982:04dc55bf71e8 18985:f84361735a40
666 status (0), resize_dummy (0), ax_obj (), pos_x (0), pos_y (0) 666 status (0), resize_dummy (0), ax_obj (), pos_x (0), pos_y (0)
667 { 667 {
668 callback (window_close, static_cast<void*> (this)); 668 callback (window_close, static_cast<void*> (this));
669 669
670 // The size of the resize_dummy box also determines the minimum window size 670 // The size of the resize_dummy box also determines the minimum window size
671 resize_dummy = new Fl_Box(5 * status_h + 1, menu_h + 1, ww - 5 * status_h - 1, hh); 671 resize_dummy = new Fl_Box (5 * status_h + 1, menu_h + 1,
672 // read on http://fltk.org/articles.php?L415+I0+T+M1000+P1 how resizable works 672 ww - 5 * status_h - 1, hh);
673 // See http://fltk.org/articles.php?L415+I0+T+M1000+P1
674 // for how resizable works
673 resizable (resize_dummy); 675 resizable (resize_dummy);
674 676
675 // FIXME: The function below is only available in FLTK >= 1.3 677 // FIXME: The function below is only available in FLTK >= 1.3
676 // At some point support for FLTK 1.1 will be dropped in Octave. 678 // At some point support for FLTK 1.1 will be dropped in Octave.
677 // At that point this function should be uncommented. 679 // At that point this function should be uncommented.
682 684
683 uimenu = new fltk_uimenu (0, 0, ww, menu_h); 685 uimenu = new fltk_uimenu (0, 0, ww, menu_h);
684 canvas = new OpenGL_fltk (0, menu_h, ww, hh, number ()); 686 canvas = new OpenGL_fltk (0, menu_h, ww, hh, number ());
685 687
686 // The bottom toolbar is a composite of "autoscale", "togglegrid", 688 // The bottom toolbar is a composite of "autoscale", "togglegrid",
687 // "panzoom", "rotate", "help", and "status". Only "status" should be resized. 689 // "panzoom", "rotate", "help", and "status".
690 // Only "status" should be resized.
688 691
689 int toolbar_y = menu_h + hh + 1; 692 int toolbar_y = menu_h + hh + 1;
690 status = new Fl_Output (5 * status_h + 1, toolbar_y, ww - 5 * status_h - 1, status_h, ""); 693 status = new Fl_Output (5 * status_h + 1, toolbar_y,
694 ww - 5 * status_h - 1, status_h, "");
691 695
692 status->textcolor (FL_BLACK); 696 status->textcolor (FL_BLACK);
693 status->color (FL_GRAY); 697 status->color (FL_GRAY);
694 status->textfont (FL_COURIER); 698 status->textfont (FL_COURIER);
695 status->textsize (10); 699 status->textsize (10);
868 // showing the menubar. All other resizing is done by fltk. 872 // showing the menubar. All other resizing is done by fltk.
869 873
870 void update_toolbar_position () 874 void update_toolbar_position ()
871 { 875 {
872 int old_canvas_h = canvas->h (); 876 int old_canvas_h = canvas->h ();
873 size(w (), old_canvas_h + menu_dy () + status_h + 2); 877 size (w (), old_canvas_h + menu_dy () + status_h + 2);
874 canvas->resize (0, menu_dy (), w (), old_canvas_h); 878 canvas->resize (0, menu_dy (), w (), old_canvas_h);
875 879
876 int toolbar_y = canvas->h () + menu_dy () + 1; 880 int toolbar_y = canvas->h () + menu_dy () + 1;
877 autoscale->position (0, toolbar_y); 881 autoscale->position (0, toolbar_y);
878 togglegrid->position (status_h, toolbar_y); 882 togglegrid->position (status_h, toolbar_y);
879 panzoom->position (2 * status_h, toolbar_y); 883 panzoom->position (2 * status_h, toolbar_y);
880 rotate->position (3 * status_h, toolbar_y); 884 rotate->position (3 * status_h, toolbar_y);
881 help->position (4 * status_h, toolbar_y); 885 help->position (4 * status_h, toolbar_y);
882 status->resize (5 * status_h + 1, toolbar_y, w () - 5 * status_h - 1, status_h); 886 status->resize (5 * status_h + 1, toolbar_y,
883 887 w () - 5 * status_h - 1, status_h);
884 init_sizes(); 888
889 init_sizes ();
885 redraw (); 890 redraw ();
886 } 891 }
887 892
888 // Called from figure::properties::ID_POSITION 893 // Called from figure::properties::ID_POSITION
889 // (someone has requested a position change with set(h, "position", [...])) 894 // (someone has requested a position change with set (h, "position", [...]))
890 // ww and hh refers to the canvas size, not the plot_window size. 895 // ww and hh refers to the canvas size, not the plot_window size.
891 896
892 void update_position (int xx, int yy, int ww, int hh) 897 void update_position (int xx, int yy, int ww, int hh)
893 { 898 {
894 Fl_Window::resize (xx, yy + menu_dy (), ww, hh + menu_dy () + status_h + 2); 899 Fl_Window::resize (xx, yy + menu_dy (), ww, hh + menu_dy () + status_h + 2);
960 void set_on_ax_obj (const std::string& name, const std::string& value) 965 void set_on_ax_obj (const std::string& name, const std::string& value)
961 { 966 {
962 // ax_obj is the last clicked axes object 967 // ax_obj is the last clicked axes object
963 if (ax_obj && ax_obj.isa ("axes")) 968 if (ax_obj && ax_obj.isa ("axes"))
964 { 969 {
965 axes::properties& ap = dynamic_cast<axes::properties&>(ax_obj.get_properties ()); 970 axes::properties& ap =
971 dynamic_cast<axes::properties&>(ax_obj.get_properties ());
966 ap.set (name, value); 972 ap.set (name, value);
967 } 973 }
968 else // no axes object clicked so far, take currentaxes 974 else // no axes object clicked so far, take currentaxes
969 { 975 {
970 graphics_handle gh = fp.get_currentaxes (); 976 graphics_handle gh = fp.get_currentaxes ();
971 if (gh.ok ()) 977 if (gh.ok ())
972 { 978 {
973 graphics_object go = gh_manager::get_object (gh); 979 graphics_object go = gh_manager::get_object (gh);
974 axes::properties& ap = dynamic_cast<axes::properties&>(go.get_properties ()); 980 axes::properties& ap =
981 dynamic_cast<axes::properties&>(go.get_properties ());
975 ap.set (name, value); 982 ap.set (name, value);
976 } 983 }
977 } 984 }
978 } 985 }
979 986
1286 pos_y = Fl::event_y () - menu_dy (); 1293 pos_y = Fl::event_y () - menu_dy ();
1287 1294
1288 set_currentpoint (pos_x, pos_y); 1295 set_currentpoint (pos_x, pos_y);
1289 1296
1290 if (fp.get_windowbuttonupfcn ().is_defined ()) 1297 if (fp.get_windowbuttonupfcn ().is_defined ())
1291 fp.execute_windowbuttondownfcn (Fl::event_button()); 1298 fp.execute_windowbuttondownfcn (Fl::event_button ());
1292 1299
1293 gh = pixel2axes_or_ca (pos_x, pos_y); 1300 gh = pixel2axes_or_ca (pos_x, pos_y);
1294 1301
1295 if (gh.ok ()) 1302 if (gh.ok ())
1296 { 1303 {
1325 axes::properties& ap = 1332 axes::properties& ap =
1326 dynamic_cast<axes::properties&> 1333 dynamic_cast<axes::properties&>
1327 (ax_obj.get_properties ()); 1334 (ax_obj.get_properties ());
1328 1335
1329 // Don't pan or rotate legend 1336 // Don't pan or rotate legend
1330 if (ap.get_tag().compare ("legend") < 0) 1337 if (ap.get_tag ().compare ("legend") < 0)
1331 { 1338 {
1332 if (ap.rotate3d_is ("on")) 1339 if (ap.rotate3d_is ("on"))
1333 view2status (ax_obj); 1340 view2status (ax_obj);
1334 else 1341 else
1335 pixel2status (ax_obj, pos_x, pos_y, 1342 pixel2status (ax_obj, pos_x, pos_y,
1359 } 1366 }
1360 } 1367 }
1361 else 1368 else
1362 { // move the position of the legend 1369 { // move the position of the legend
1363 Matrix pos = ap.get_position ().matrix_value (); 1370 Matrix pos = ap.get_position ().matrix_value ();
1364 pos(0) += double (Fl::event_x () - pos_x) / canvas->w(); 1371 pos(0) += double (Fl::event_x () - pos_x)
1365 pos(1) -= double (Fl::event_y () - menu_dy () - pos_y) / canvas->h(); 1372 / canvas->w ();
1373 pos(1) -= double (Fl::event_y () - menu_dy () - pos_y)
1374 / canvas->h ();
1366 ap.set_position (pos); 1375 ap.set_position (pos);
1367 } 1376 }
1368 1377
1369 pos_x = Fl::event_x (); 1378 pos_x = Fl::event_x ();
1370 pos_y = Fl::event_y () - menu_dy (); 1379 pos_y = Fl::event_y () - menu_dy ();
1398 if (ax && ax.isa ("axes")) 1407 if (ax && ax.isa ("axes"))
1399 { 1408 {
1400 axes::properties& ap = 1409 axes::properties& ap =
1401 dynamic_cast<axes::properties&> (ax.get_properties ()); 1410 dynamic_cast<axes::properties&> (ax.get_properties ());
1402 1411
1403 // Parameter controlling how fast we zoom when using the scrool wheel. 1412 // Control how fast to zoom when using scroll wheel.
1404 double Vwheel_zoom_speed = ap.get_mouse_wheel_zoom (); 1413 double Vwheel_zoom_speed = ap.get_mouse_wheel_zoom ();
1405 1414
1406 // Determine if we're zooming in or out. 1415 // Determine if we're zooming in or out.
1407 const double factor = 1416 const double factor =
1408 (Fl::event_dy () > 0) ? 1 / (1.0 - Vwheel_zoom_speed) 1417 (Fl::event_dy () > 0) ? 1 / (1.0 - Vwheel_zoom_speed)
1424 { 1433 {
1425 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ()); 1434 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
1426 fp.execute_windowbuttonupfcn (); 1435 fp.execute_windowbuttonupfcn ();
1427 } 1436 }
1428 1437
1429 if ((Fl::event_button () == 1) && Fl::event_clicks ()) //double click 1438 if ((Fl::event_button () == 1) && Fl::event_clicks ())
1430 { 1439 {
1440 // Double click
1431 set_on_ax_obj ("xlimmode", "auto"); 1441 set_on_ax_obj ("xlimmode", "auto");
1432 set_on_ax_obj ("ylimmode", "auto"); 1442 set_on_ax_obj ("ylimmode", "auto");
1433 set_on_ax_obj ("zlimmode", "auto"); 1443 set_on_ax_obj ("zlimmode", "auto");
1434 return 1; 1444 return 1;
1435 } 1445 }
1619 1629
1620 static void toggle_menubar_visibility (const std::string& fig_idx_str, 1630 static void toggle_menubar_visibility (const std::string& fig_idx_str,
1621 bool menubar_is_figure) 1631 bool menubar_is_figure)
1622 { 1632 {
1623 if (instance_ok ()) 1633 if (instance_ok ())
1624 instance->do_toggle_menubar_visibility (str2idx (fig_idx_str), menubar_is_figure); 1634 instance->do_toggle_menubar_visibility (str2idx (fig_idx_str),
1635 menubar_is_figure);
1625 } 1636 }
1626 1637
1627 private: 1638 private:
1628 1639
1629 static figure_manager *instance; 1640 static figure_manager *instance;