# HG changeset patch # User John W. Eaton # Date 1320309205 14400 # Node ID 760e4e88dba3bdc9f3736f168b23d5a0c1cfe192 # Parent 718f78b01de17b46076709ae89b0fff225674192 convert units for figure positions * graphics.h.in, graphics.cc (convert_position, screen_size_pixels): Now extern. * __init_fltk__.cc (figure_manager::do_new_window): Convert specified position to pixels. diff -r 718f78b01de1 -r 760e4e88dba3 src/DLD-FUNCTIONS/__init_fltk__.cc --- a/src/DLD-FUNCTIONS/__init_fltk__.cc Thu Nov 03 01:30:54 2011 -0400 +++ b/src/DLD-FUNCTIONS/__init_fltk__.cc Thu Nov 03 04:33:25 2011 -0400 @@ -1574,6 +1574,10 @@ { Matrix pos = fp.get_position ().matrix_value (); + Matrix screen_size = screen_size_pixels (); + + pos = convert_position (pos, fp.get_units (), "pixels", screen_size); + int x = pos(0); int y = pos(1); int w = pos(2); diff -r 718f78b01de1 -r 760e4e88dba3 src/graphics.cc --- a/src/graphics.cc Thu Nov 03 01:30:54 2011 -0400 +++ b/src/graphics.cc Thu Nov 03 04:33:25 2011 -0400 @@ -411,10 +411,9 @@ return new_font_size; } -static Matrix +Matrix convert_position (const Matrix& pos, const caseless_str& from_units, - const caseless_str& to_units, - const Matrix& parent_dim = Matrix (1, 2, 0.0)) + const caseless_str& to_units, const Matrix& parent_dim) { Matrix retval (1, pos.numel ()); double res = 0; @@ -636,7 +635,7 @@ } // This function always returns the screensize in pixels -static Matrix +Matrix screen_size_pixels (void) { graphics_object obj = gh_manager::get_object (0); diff -r 718f78b01de1 -r 760e4e88dba3 src/graphics.h.in --- a/src/graphics.h.in Thu Nov 03 01:30:54 2011 -0400 +++ b/src/graphics.h.in Thu Nov 03 04:33:25 2011 -0400 @@ -5486,4 +5486,11 @@ // This function is NOT equivalent to the scripting language function gca. OCTINTERP_API graphics_handle gca (void); +extern OCTINTERP_API Matrix +convert_position (const Matrix& pos, const caseless_str& from_units, + const caseless_str& to_units, + const Matrix& parent_dim = Matrix (1, 2, 0.0)); + +extern OCTINTERP_API Matrix screen_size_pixels (void); + #endif