SIZEPOLICY attribute

The SIZEPOLICY attribute is a sizing directive based on the content of a form item.

Syntax

SIZEPOLICY = { INITIAL | FIXED | DYNAMIC }

Usage

The SIZEPOLICY attribute defines how front-ends compute the size of some form elements, based on the content of the form field or form item.

The SIZEPOLICY applies only to leaf elements of the layout. It does not apply to containers. It applies to form elements whose content can be resized, typically IMAGE, COMBOBOX, WEBCOMPONENT. Elements allowing user input such as EDIT, or elements where the size does not depend on the value content such as PROGRESSBAR, SLIDER do not use this attribute.

Note: The SIZEPOLICY attribute is ignored for columns used in TABLE or TREE containers: In list views, the size policy is implicitly defined by the cell (i.e., the size of the column in the form layout). The SIZEPOLICY attribute is also implicitly fixed for fields inside SCROLLGRID and GRID containers that are controlled by a list dialog, such as a DISPLAY ARRAY. With a list dialog, each row can have a different value, which would imply a different widget size for each row; this is not supported.

When the SIZEPOLICY is not specified, the default behavior depends on the type of the form item. See Table 1.

SIZEPOLICY = FIXED

When SIZEPOLICY is FIXED, the form element's size is exactly the size defined in the layout of the form specification file.

The size of the element is computed from the width and height in the form grid and the font used on the front-end side.

The element keeps the size, even if the content is modified. However, if the STRETCH attribute is set to X, Y or BOTH, the form element can still stretch when the parent window size changes.

SIZEPOLICY = DYNAMIC

When SIZEPOLICY is DYNAMIC, the size of the element grows and shrinks depending on the width of the content, during the lifetime of the application.

This can be used for COMBOBOX or RADIOGROUP fields, when the size of the widget must fit exactly to its content, which can vary during the program execution.

Note: With SIZEPOLICY=DYNAMIC, some element such as BUTTON, LABEL, IMAGE and RADIOGROUP can shrink and grow all the time, while COMBOBOX elements can only grow.

SIZEPOLICY = INITIAL

When SIZEPOLICY is INITIAL, the size is computed from the initial content, the first time the element appears on the screen. Once the widget displays, its size is frozen. However, if the STRETCH attribute is set to X, Y or BOTH, the form element can still stretch when the parent window size changes.

This is typically used when the size of the element must be fixed, but is not known at design time. For example, when populating a COMBOBOX item list from a database table, the size of the COMBOBOX depends on the size of the labels in the drop-down list.

This size policy mode is also useful when the text of labels is unknown at design time because of internationalization.

With SIZEPOLICY=INITIAL, the behavior differs depending on the form element type.

Table 1. Behavior of SIZEPOLICY=INITIAL, based on form item type
Form item Behavior with SIZEPOLICY=INITIAL
BUTTON The size defined in the form is a minimum size. If the initial button text is bigger, the size grows (width and height).
COMBOBOX The width defined in the form is a minimum width. If one of the combobox items in the value list is bigger, the size grows in order for the combobox to fully display the largest item. Then the combobox size remains fixed for the life time of the form.
LABEL, CHECKBOX, RADIOGROUP These form items adapt to the initial element text(s), then they keep the same size. The size defined in the form is ignored.
IMAGE Image form items adapt their size to the initial picture displayed. Images can use the STRETCH attribute, so that the widget size is dependent on the parent container, overriding the SIZEPOLICY attribute. If the WIDTH and HEIGHT attributes must be used, the SIZEPOLICY attribute must be set to FIXED.
WEBCOMPONENT

The web component is scaled to the right size, after the first web page is loaded. It stays at that size, except if the STRETCH attribute is used, and the parent container size changes.

Keep in mind that after the first display, the element size will be frozen.

Example

COMBOBOX f001 = customer.city,
    ITEMS=((1,"Paris"),(2,"Madrid"), (3,"London")),
    SIZEPOLICY=DYNAMIC;

WEBCOMPONENT wc1 = FORMONLY.chart,
    COMPONENTTYPE="chart",
    SIZEPOLICY=FIXED,
    STRETCH=BOTH;