Consultor Eletrônico



Kbase 13715: Proportional Fonts in Progress Version 7 GUI
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Proportional Fonts in Progress Version 7 GUI

The FORMAT qualifier is used to allocate space for the value of given
widget. Thus, using a FIXED SIZE font for a widget will result in
"correct" visualization, i.e. the entire widget can be viewed when
the widget's font is also a fixed-size font of the same point size.
However, using a PROPORTIONAL font will cause Progress to estimate
the viewport of the widget, based on an average value for the selected
font. If a given widget has a CONSTANT value, the default viewport
can be changed by the code shown below.

EXAMPLE:
In the PROGRESS.INI file:
FONT 1 is defined as SYSTEM FONT, FONT 3 as Courier New, 8 pts
Default font is also defined as Courier New, 8 pts

DEFINE VAR c AS CHAR NO-UNDO.
DEFINE VAR wh AS WIDGET-HANDLE.
DEFINE FRAME f WITH SIZE 80 BY 10.
c = FILL("1234567890", 6) + "x".

CREATE TEXT wh ASSIGN
FRAME = frame f:handle
FONT = 1
FORMAT = "x(" + STRING(LENGTH(c)) + ")"
SCREEN-VALUE = c
VISIBLE = yes.

WAIT-FOR " " OF CURRENT-WINDOW.

Running the attached code will only display part of the string
(around 53 characters), because the viewport is calculated on a
average font value. The FONT-TABLE:GET-TEXT-WIDTH-PIXELS method
can be used to changed this default value:

DEFINE VAR c AS CHAR NO-UNDO.
DEFINE VAR wh AS WIDGET-HANDLE.
DEFINE FRAME f WITH SIZE 80 BY 10.
c = FILL("1234567890", 6) + "x".

CREATE TEXT wh ASSIGN
FRAME = frame f:handle
FONT = 1
FORMAT = "x(" + STRING(LENGTH(c)) + ")"
WIDTH-PIXELS = FONT-TABLE:GET-TEXT-WIDTH-PIXELS(c, 1)
SCREEN-VALUE = c
VISIBLE = yes.

WAIT-FOR " " OF CURRENT-WINDOW.

and Progress will display the entire string. If FONT or SCREEN-VALUE
changes, we need to change the widget with the following statement:
wh:WIDTH-PIXELS = FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
wh:SCREEN-VALUE, wh:FONT).
to resize the width of the widget.

Progress Software Technical Support Note # 13715