Mercurial > hg > octave-lyh
diff src/graphics.cc @ 8560:5cc594679cdc
get display characteristics from system
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 21 Jan 2009 21:43:05 -0500 |
parents | ab82e19002c4 |
children | b4fb0a52b15e |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -40,6 +40,7 @@ #include "cmd-edit.h" #include "defun.h" +#include "display.h" #include "error.h" #include "graphics.h" #include "input.h" @@ -98,6 +99,29 @@ return cmap; } +static double +default_screendepth (void) +{ + return display_info::depth (); +} + +static Matrix +default_screensize (void) +{ + Matrix retval (1, 4, 1.0); + + retval(2) = display_info::width (); + retval(3) = display_info::height (); + + return retval; +} + +static double +default_screenpixelsperinch (void) +{ + return (display_info::x_dpi () + display_info::y_dpi ()) / 2; +} + static Matrix default_colororder (void) { @@ -2013,6 +2037,44 @@ } void +root_figure::properties::update_units (void) +{ + caseless_str xunits = get_units (); + + Matrix ss = default_screensize (); + + double dpi = get_screenpixelsperinch (); + + if (xunits.compare ("inches")) + { + ss(0) = 0; + ss(1) = 0; + ss(2) /= dpi; + ss(3) /= dpi; + } + else if (xunits.compare ("centimeters")) + { + ss(0) = 0; + ss(1) = 0; + ss(2) *= 2.54 / dpi; + ss(3) *= 2.54 / dpi; + } + else if (xunits.compare ("normalized")) + { + ss = Matrix (1, 4, 1.0); + } + else if (xunits.compare ("points")) + { + ss(0) = 0; + ss(1) = 0; + ss(2) *= 72 / dpi; + ss(3) *= 72 / dpi; + } + + set_screensize (ss); +} + +void root_figure::properties::remove_child (const graphics_handle& gh) { gh_manager::pop_figure (gh);