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 of 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 (this means 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 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.

Note: With GMA, when the last element on the right of a grid row is defined with SIZEPOLICY=FIXED and its right hand border does not pass over the screen border, GMA will extend its width to reach the border. The last element with a fixed size policy may only grow. It does not shrink to a smaller width than the width defined in the form.

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.
Note: SIZEPOLICY=DYNAMIC is ignored for WEBCOMPONENT fields.

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.

SIZEPOLICY=INITIAL 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.

Note: SIZEPOLICY=INITIAL is ignored for WEBCOMPONENT fields.
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 image displayed and keep that size. If no initial image is displayed (i.e. the image field value is NULL), the form item does not take space in the layout (and also does not adapt the size if an image is displayed later on). 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

N/A: SIZEPOLICY=INITIAL is ignored for WEBCOMPONENT fields.

Example

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

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