# HG changeset patch # User Ben Abbott # Date 1329012543 18000 # Node ID e7c74f56cd03e4e92179c442bf0ab6ea8cbb8b45 # Parent c097c22e9294e1323d5e7f73c7fe08bab1012f22 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. diff --git a/src/DLD-FUNCTIONS/__init_fltk__.cc b/src/DLD-FUNCTIONS/__init_fltk__.cc --- a/src/DLD-FUNCTIONS/__init_fltk__.cc +++ b/src/DLD-FUNCTIONS/__init_fltk__.cc @@ -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 (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); diff --git a/src/graphics.cc b/src/graphics.cc --- a/src/graphics.cc +++ b/src/graphics.cc @@ -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") diff --git a/src/graphics.h.in b/src/graphics.h.in --- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -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.