Mercurial > hg > octave-nkf
comparison libinterp/dldfcn/__init_fltk__.cc @ 17131:ea19ea629a09
Proper placement of the menubar, the toolbar and plot canvas.
* libinterp/dldfcn/__init_fltk__.cc (class plot_window): Properly initialize
the heights and veritcal locations for the canvas, menubar, and statusbar.
Move updating of the canvas from hide_menubar and show_menubar to the draw ()
method. Include the proper positioning of the menubar, toolbar, and plot
canvas in the draw () method.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Thu, 01 Aug 2013 07:43:59 -0400 |
parents | 7a67ab7c4771 |
children | 501420581087 |
comparison
equal
deleted
inserted
replaced
17130:327862500f1c | 17131:ea19ea629a09 |
---|---|
660 class plot_window : public Fl_Window | 660 class plot_window : public Fl_Window |
661 { | 661 { |
662 friend class fltk_uimenu; | 662 friend class fltk_uimenu; |
663 public: | 663 public: |
664 plot_window (int xx, int yy, int ww, int hh, figure::properties& xfp) | 664 plot_window (int xx, int yy, int ww, int hh, figure::properties& xfp) |
665 : Fl_Window (xx, yy, ww, hh, "octave"), window_label (), shift (0), | 665 : Fl_Window (xx, yy - menu_h, ww, hh + menu_h + status_h, "octave"), |
666 ndim (2), fp (xfp), canvas (0), autoscale (0), togglegrid (0), | 666 window_label (), shift (0), ndim (2), fp (xfp), canvas (0), |
667 panzoom (0), rotate (0), help (0), status (0), | 667 autoscale (0), togglegrid (0), panzoom (0), rotate (0), help (0), |
668 ax_obj (), pos_x (0), pos_y (0) | 668 status (0), ax_obj (), pos_x (0), pos_y (0) |
669 { | 669 { |
670 callback (window_close, static_cast<void*> (this)); | 670 callback (window_close, static_cast<void*> (this)); |
671 size_range (4*status_h, 2*status_h); | 671 size_range (4*status_h, 2*status_h); |
672 | 672 |
673 // FIXME: The function below is only available in FLTK >= 1.3 | 673 // FIXME: The function below is only available in FLTK >= 1.3 |
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 | 683 //Fl_Window::resize (xx, yy - menu_h, ww, hh + menu_h + status_h); |
684 canvas = new OpenGL_fltk (0, 0, ww, hh - status_h, number ()); | 684 |
685 // bbox of plot canvas = [xx, yy, ww, hh]; | |
686 // (xx, yy) = UL coordinate relative to UL window. | |
687 | |
688 canvas = new OpenGL_fltk (0, menu_h, ww, hh, number ()); | |
685 | 689 |
686 uimenu = new fltk_uimenu (0, 0, ww, menu_h); | 690 uimenu = new fltk_uimenu (0, 0, ww, menu_h); |
687 uimenu->hide (); | 691 uimenu->hide (); |
688 | 692 |
689 bottom = new Fl_Box (0, hh - status_h, ww, status_h); | 693 // Toolbar is a composite of "bottom", "autoscale", "togglegrid", |
694 // "panzoom", "rotate", "help", and "status". | |
695 | |
696 yy = hh + menu_h; | |
697 bottom = new Fl_Box (0, yy, ww, status_h); | |
690 bottom->box (FL_FLAT_BOX); | 698 bottom->box (FL_FLAT_BOX); |
691 | 699 |
692 ndim = calc_dimensions (gh_manager::get_object (fp.get___myhandle__ ())); | 700 ndim = calc_dimensions (gh_manager::get_object (fp.get___myhandle__ ())); |
693 | 701 |
694 autoscale = new Fl_Button (0, hh - status_h, status_h, status_h, "A"); | 702 autoscale = new Fl_Button (0, yy, status_h, status_h, "A"); |
695 autoscale->callback (button_callback, static_cast<void*> (this)); | 703 autoscale->callback (button_callback, static_cast<void*> (this)); |
696 autoscale->tooltip ("Autoscale"); | 704 autoscale->tooltip ("Autoscale"); |
697 | 705 |
698 togglegrid = new Fl_Button (status_h, hh - status_h, status_h, | 706 togglegrid = new Fl_Button (status_h, yy, status_h, |
699 status_h, "G"); | 707 status_h, "G"); |
700 togglegrid->callback (button_callback, static_cast<void*> (this)); | 708 togglegrid->callback (button_callback, static_cast<void*> (this)); |
701 togglegrid->tooltip ("Toggle Grid"); | 709 togglegrid->tooltip ("Toggle Grid"); |
702 | 710 |
703 panzoom = new Fl_Button (2 * status_h, hh - status_h, status_h, | 711 panzoom = new Fl_Button (2 * status_h, yy, status_h, |
704 status_h, "P"); | 712 status_h, "P"); |
705 panzoom->callback (button_callback, static_cast<void*> (this)); | 713 panzoom->callback (button_callback, static_cast<void*> (this)); |
706 panzoom->tooltip ("Mouse Pan/Zoom"); | 714 panzoom->tooltip ("Mouse Pan/Zoom"); |
707 | 715 |
708 rotate = new Fl_Button (3 * status_h, hh - status_h, status_h, | 716 rotate = new Fl_Button (3 * status_h, yy, status_h, |
709 status_h, "R"); | 717 status_h, "R"); |
710 rotate->callback (button_callback, static_cast<void*> (this)); | 718 rotate->callback (button_callback, static_cast<void*> (this)); |
711 rotate->tooltip ("Mouse Rotate"); | 719 rotate->tooltip ("Mouse Rotate"); |
712 | 720 |
713 if (ndim == 2) | 721 if (ndim == 2) |
714 rotate->deactivate (); | 722 rotate->deactivate (); |
715 | 723 |
716 help = new Fl_Button (4 * status_h, hh - status_h, status_h, | 724 help = new Fl_Button (4 * status_h, yy, status_h, |
717 status_h, "?"); | 725 status_h, "?"); |
718 help->callback (button_callback, static_cast<void*> (this)); | 726 help->callback (button_callback, static_cast<void*> (this)); |
719 help->tooltip ("Help"); | 727 help->tooltip ("Help"); |
720 | 728 |
721 status = new Fl_Output (5 * status_h, hh - status_h, | 729 status = new Fl_Output (5 * status_h, yy, |
722 ww > 2*status_h ? ww - status_h : 0, | 730 ww > 2*status_h ? ww - status_h : 0, |
723 status_h, ""); | 731 status_h, ""); |
724 | 732 |
725 status->textcolor (FL_BLACK); | 733 status->textcolor (FL_BLACK); |
726 status->color (FL_GRAY); | 734 status->color (FL_GRAY); |
797 | 805 |
798 void show_menubar (void) | 806 void show_menubar (void) |
799 { | 807 { |
800 if (!uimenu->is_visible ()) | 808 if (!uimenu->is_visible ()) |
801 { | 809 { |
802 canvas->resize (canvas->x (), | 810 // FIXME - Toolbar and menubar do not update |
803 canvas->y () + menu_h, | |
804 canvas->w (), | |
805 canvas->h () - menu_h); | |
806 uimenu->show (); | 811 uimenu->show (); |
807 mark_modified (); | 812 mark_modified (); |
808 } | 813 } |
809 } | 814 } |
810 | 815 |
811 void hide_menubar (void) | 816 void hide_menubar (void) |
812 { | 817 { |
813 if (uimenu->is_visible ()) | 818 if (uimenu->is_visible ()) |
814 { | 819 { |
815 canvas->resize (canvas->x (), | 820 // FIXME - Toolbar and menubar do not update |
816 canvas->y () - menu_h, | |
817 canvas->w (), | |
818 canvas->h () + menu_h); | |
819 uimenu->hide (); | 821 uimenu->hide (); |
820 mark_modified (); | 822 mark_modified (); |
821 } | 823 } |
822 } | 824 } |
823 | 825 |
1106 { | 1108 { |
1107 if (!fp.is_beingdeleted ()) | 1109 if (!fp.is_beingdeleted ()) |
1108 { | 1110 { |
1109 Matrix pos (1,2,0); | 1111 Matrix pos (1,2,0); |
1110 pos(0) = px; | 1112 pos(0) = px; |
1113 // FIXME - only works if (uimenu->is_visible ()) ? | |
1111 pos(1) = h () - status_h - menu_h - py; | 1114 pos(1) = h () - status_h - menu_h - py; |
1112 fp.set_currentpoint (pos); | 1115 fp.set_currentpoint (pos); |
1113 } | 1116 } |
1114 } | 1117 } |
1115 | 1118 |
1179 { | 1182 { |
1180 Fl_Window::resize (xx, yy, ww, hh); | 1183 Fl_Window::resize (xx, yy, ww, hh); |
1181 | 1184 |
1182 Matrix pos (1,4,0); | 1185 Matrix pos (1,4,0); |
1183 pos(0) = xx; | 1186 pos(0) = xx; |
1184 pos(1) = yy; | 1187 pos(1) = yy + menu_h; |
1185 pos(2) = ww; | 1188 pos(2) = ww; |
1186 pos(3) = hh - status_h - menu_h; | 1189 pos(3) = hh - menu_h - status_h; |
1190 if (! uimenu->is_visible ()) | |
1191 { | |
1192 pos(1) = yy; | |
1193 pos(3) = hh - status_h; | |
1194 } | |
1187 | 1195 |
1188 fp.set_boundingbox (pos, true); | 1196 fp.set_boundingbox (pos, true); |
1189 } | 1197 } |
1190 | 1198 |
1191 void draw (void) | 1199 void draw (void) |
1192 { | 1200 { |
1201 // FIXME - Toolbar and menubar do not update properly | |
1193 Matrix pos = fp.get_boundingbox (true); | 1202 Matrix pos = fp.get_boundingbox (true); |
1194 Fl_Window::resize (pos(0), pos(1), pos(2), pos(3) + status_h + menu_h); | 1203 int canvas_h = pos(3); |
1204 int canvas_w = pos(2); | |
1205 int canvas_y = menu_h; | |
1206 int toolbar_y = menu_h + canvas_h; | |
1207 pos(1) = pos(1) - menu_h; | |
1208 pos(3) = pos(3) + menu_h + status_h; | |
1209 | |
1210 if (! uimenu->is_visible ()) | |
1211 { | |
1212 pos(1) = pos(1) + menu_h; | |
1213 pos(3) = pos(3) - menu_h; | |
1214 toolbar_y = toolbar_y - menu_h; | |
1215 canvas_y = canvas_y - menu_h; | |
1216 } | |
1217 | |
1218 Fl_Window::resize (pos(0), pos(1), pos(2), pos(3)); | |
1219 | |
1220 bottom->resize (0, toolbar_y, status_h, status_h); | |
1221 autoscale->resize (0, toolbar_y, status_h, status_h); | |
1222 togglegrid->resize (status_h, toolbar_y, status_h, status_h); | |
1223 panzoom->resize (2 * status_h, toolbar_y, status_h, status_h); | |
1224 rotate->resize (3 * status_h, toolbar_y, status_h, status_h); | |
1225 help->resize (4 * status_h, toolbar_y, status_h, status_h); | |
1226 status->resize (5 * status_h, toolbar_y, pos(2) - 4 * status_h, status_h); | |
1227 if (canvas->valid ()) | |
1228 canvas->resize (0, canvas_y, canvas_w, canvas_h); | |
1195 | 1229 |
1196 return Fl_Window::draw (); | 1230 return Fl_Window::draw (); |
1197 } | 1231 } |
1198 | 1232 |
1199 int handle (int event) | 1233 int handle (int event) |