changeset 14357:e7c74f56cd03

fltk toolkit requires figure units to be "pixels". Bug # 35430. * graphics.cc (root_figure::properties::get_boundingbox): New function. * graphics.h.in (root_figure::properties::get_boundingbox): New function. * __init__fltk__.cc (class plot_window::draw,redraw,handle): Use get/set boundingbox (units are fixed to pixels) rather than get/set position. Add plot_window::get_figure_postion, which returns figure position in pixels.
author Ben Abbott <bpabbott@mac.com>
date Sat, 11 Feb 2012 21:09:03 -0500
parents c097c22e9294
children adb352685ded
files src/DLD-FUNCTIONS/__init_fltk__.cc src/graphics.cc src/graphics.h.in
diffstat 3 files changed, 34 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/__init_fltk__.cc	Fri Feb 10 18:57:55 2012 -0500
+++ b/src/DLD-FUNCTIONS/__init_fltk__.cc	Sat Feb 11 21:09:03 2012 -0500
@@ -1168,12 +1168,30 @@
     pos(2) = ww;
     pos(3) = hh - status_h - menu_h;
 
-    fp.set_position (pos);
+    graphics_object obj = gh_manager::get_object (0);
+    base_properties& rp = obj.get_properties ();
+    Matrix screen_size = rp.get_boundingbox (true);
+    pos(0)--;
+    pos(1)--;
+    pos(1) = screen_size(3) - pos(1) - pos(3);
+    fp.set_boundingbox (pos, true);
+  }
+
+  Matrix get_figure_position (void)
+  {
+    graphics_object obj = gh_manager::get_object (0);
+    base_properties& rp = obj.get_properties ();
+    Matrix screen_size = rp.get_boundingbox (true);
+    Matrix pos = fp.get_boundingbox (true);
+    pos(1) = screen_size(3) - pos(1) - pos(3);
+    pos(0)++;
+    pos(1)++;
+    return pos;
   }
 
   void draw (void)
   {
-    Matrix pos = fp.get_position ().matrix_value ();
+    Matrix pos = get_figure_position ();
     Fl_Window::resize (pos(0), pos(1), pos(2), pos(3) + status_h + menu_h);
 
     return Fl_Window::draw ();
@@ -1296,7 +1314,7 @@
                       dynamic_cast<axes::properties&> (ax_obj.get_properties ());
 
                     double x0, y0, x1, y1;
-                    Matrix pos = fp.get_position ().matrix_value ();
+                    Matrix pos = get_figure_position ();
                     pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
                     pixel2pos (ax_obj, Fl::event_x (), Fl::event_y (), x1, y1);
 
--- a/src/graphics.cc	Fri Feb 10 18:57:55 2012 -0500
+++ b/src/graphics.cc	Sat Feb 11 21:09:03 2012 -0500
@@ -3043,6 +3043,16 @@
   set_screensize (ss);
 }
 
+Matrix
+root_figure::properties::get_boundingbox (bool internal, const Matrix&) const
+{
+  Matrix screen_size = screen_size_pixels ();
+  Matrix pos = Matrix (1, 4, 0);
+  pos(2) = screen_size(0);
+  pos(3) = screen_size(1);
+  return pos;
+}
+
 /*
 %!test
 %! set (0, "units", "pixels")
--- a/src/graphics.h.in	Fri Feb 10 18:57:55 2012 -0500
+++ b/src/graphics.h.in	Sat Feb 11 21:09:03 2012 -0500
@@ -3154,6 +3154,9 @@
   public:
     void remove_child (const graphics_handle& h);
 
+    Matrix get_boundingbox (bool internal = false,
+                            const Matrix& parent_pix_size = Matrix ()) const;
+
     // See the genprops.awk script for an explanation of the
     // properties declarations.