XmConvertUnits(3X) — Subroutines
OSF
NAME
XmConvertUnits — a function that converts a value in one unit type to another unit type.
SYNOPSIS
#include <Xm/Xm.h> int XmConvertUnits (widget, orientation, from_unit_type, from_value, to_unit_type)
Widgetwidget;
intorientation;
intfrom_unit_type;
intfrom_value;
intto_unit_type;
DESCRIPTION
XmConvertUnits converts the value and returns it as the return value from the function.
widgetSpecifies the widget for which the data is to be converted
orientationSpecifies whether the converter uses the horizontal or vertical screen resolution when performing the conversions. orientation can have values of XmHORIZONTAL or XmVERTICAL.
from_unit_typeSpecifies the current unit type of the supplied value
from_valueSpecifies the value to be converted
to_unit_typeConverts the value to the unit type specified
The parameters from_unit_type and to_unit_type can have the following values:
•XmPIXELS — all values provided to the widget are treated as normal pixel values. This is the default for the resource.
•Xm100TH_MILLIMETERS — all values provided to the widget are treated as 1/100 millimeter.
•Xm1000TH_INCHES — all values provided to the widget are treated as 1/1000 inch.
•Xm100TH_POINTS — all values provided to the widget are treated as 1/100 point. A point is a unit typically used in text processing applications and is defined as 1/72 inch.
•Xm100TH_FONT_UNITS — all values provided to the widget are treated as 1/100 of a font unit. The value to be used for the font unit is determined in one of three ways:
•The application can use XmSetFontUnits to specify the font unit values.
•If the application has not called XmSetFontUnits, the font units can be derived from a font. The user specifies this font by using the font resource in a defaults file or on the command line, or by using the standard command line options −fn and −font.
•If the application has not called XmSetFontUnits and the user has not specified a font resource, the horizontal and vertical font units default to 10.
A horizontal font unit is derived from a font as follows:
•If the font has an AVERAGE_WIDTH property, the horizontal font unit is the AVERAGE_WIDTH property divided by 10.
•If the font has no AVERAGE_WIDTH property but has a QUAD_WIDTH property, the horizontal font unit is the QUAD_WIDTH property.
•If the font has no AVERAGE_WIDTH or QUAD_WIDTH property, the horizontal font unit is the sum of the font struct’s min_bounds.width and max_bounds.width divided by 2.3.
A vertical font unit is derived from a font as follows:
•If the font has a PIXEL_SIZE property, the vertical font unit is the PIXEL_SIZE property divided by 1.8.
•If the font has no PIXEL_SIZE property but has POINT_SIZE and RESOLUTION_Y properties, the vertical font unit is the product of the POINT_SIZE and RESOLUTION_Y properties divided by 1400.
•If the font has no PIXEL_SIZE, POINT_SIZE, or RESOLUTION_Y properties, the vertical font unit is the sum of the font struct’s max_bounds.ascent and max_bounds.descent divided by 2.2.
RETURN VALUE
Returns the converted value. If a NULL widget, incorrect orientation, or incorrect unit_type is supplied as parameter data, 0 is returned.