Mercurial > hg > octave-lyh
changeset 13799:760e4e88dba3
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.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 03 Nov 2011 04:33:25 -0400 |
parents | 718f78b01de1 |
children | 5acb5c25e4ae |
files | src/DLD-FUNCTIONS/__init_fltk__.cc src/graphics.cc src/graphics.h.in |
diffstat | 3 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/__init_fltk__.cc +++ b/src/DLD-FUNCTIONS/__init_fltk__.cc @@ -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);
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -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);
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -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