Re: [Q]Finding Screen Resolution in IDL [message #6818 is a reply to message #6803] |
Wed, 28 August 1996 00:00  |
Peter Mason
Messages: 145 Registered: June 1996
|
Senior Member |
|
|
On Wed, 28 Aug 1996, Tim Patterson wrote:
> I have a large IDL widget application that creates a number
> of windows of varying sizes. The problem is that some of
> the machines it runs on have differing screen resolutions
> i.e. 100 dpi vs 75 dpi. If I use a 14 point font, it looks fine
> on the 100dpi screen, but too large on the 75dpi screen
> (the windows are too large and therefore hard to work with
> when there are a number open). But if I use, say, a 10point
> font, the windows look greta on the lower resolution screen, but
> unreadable on the high resolution one.
>
> So, is there a way to test which resolution screen I'm on and
> set the font point-size accordingly (perhaps something using
> the size of the screen in pixels which I can get via IDL).
I'm not sure that you can do this sort of thing reliably. My personal view
is that it's far easier to provide the facility for the user to select the
font of his/her choice.
Here are some ideas anyway...
You can get the screen resolution with DEVICE,GET_SCREEN_SIZ=screen_xy
(size in pixels) and !D.X_PX_CM, !D.Y_PX_CM (screen pixels per cm).
For the character size use !D.X_CH_SIZE and !D.Y_CH_SIZE (pixels wide & high).
Well, this is the idea anyway. I'm not sure how accurate the _PX_CM values
are, and obviously the _CH_SIZE fields are some sort of approximation
when variable-character-width fonts are used. If you have a
representative string of characters handy, you might get a better idea of
width by rendering the string and checking its width, e.g.,
XYOUTS,0,0,char_string,/norm,charsiz=-1,width=string_width,f ont=0
(Then convert the width from "norm" to pixels according to your window
size.)
This all assumes that the widget and device "systems" are using the same
font, and that you can make a rough guess at the sort of overhead
incurred in the widget system (spacing, padding etc). (I think the latter
might be difficult.)
e.g., to set the font (in Windows) to "courier new*10", use
DEVICE,FONT='courier new*10' & WIDGET_CONTROL,DEFAULT_FONT='courier new*10'
Peter Mason
|
|
|