<<prev file | next file >>    view single page | view frames    summary: fields | routine    details: routine

ToBeReviewed/STRING/

str_size.pro

The purpose of this function is to return the proper character size to make a specified string a specified width in a window. The width is specified in normalized coordinates. The function is extremely useful for sizing strings and labels in resizeable graphics windows.

topstr_size Graphics, Widget

result = str_size(string[, targetWidth], INITSIZE=INITSIZE, STEP=STEP)

Return value

thisCharSize. This is the size the specified string should be set to if you want to produce output of the specified target width. The value is in standard character size units where 1.0 is the standard character size.

Parameters

string        in required

This is the string that you want to make a specified target size or width.

targetWidth        in optional default: 0.25

This is the target width of the string in normalized coordinates in the current graphics window. The character size of the string (returned as thisCharSize) will be calculated to get the string width as close as possible to the target width.

Keywords

INITSIZE        default: 1.0

This is the initial size of the string. Default is 1.0.

STEP        default: 0.05

This is the amount the string size will change in each step of the interactive process of calculating the string size.

Examples

To make the string "Happy Holidays" take up 30% of the width of the current graphics window, type this: XYOUTS, 0.5, 0.5, ALIGN=0.5, "Happy Holidays", $ CHARSIZE=STR_SIZE("Happy Holidays", 0.3)

Version history

Version

$Id: str_size.pro 157 2006-08-21 09:01:50Z navarro $

History

Written by: David Fanning, 17 DEC 96. Added a scaling factor to take into account the aspect ratio of the window in determing the character size. 28 Oct 97. DWF

Statistics

McCabe cyclic 11
McCabe essential 1
McCabe modular design 1
Produced by IDLdoc 2.0.