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 widget size (width and height), or the widget width only of form items, based on the content, or definition of the form field or form item.

Note: For most form items types like LABEL, CHECKBOX, or COMBOBOX, the SIZEPOLICY attribute applies only to the width of the widget. For form items such as IMAGE, the attribute applies to the width and height. However, for example, the height of a (vertical) RADIOGROUP is defined by the number of ITEMS, and only the width can be controlled with the SIZEPOLICY attribute.

The SIZEPOLICY attribute applies to AUI tree leaf elements of a form (it does not apply to containers such as TABLE or GRID): SIZEPOLICY can be used with form items having content with variable size such as IMAGE, LABEL (for localization) and with form items where the definition impacts the widget size, like the width of labels in ITEMS of a COMBOBOX.

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 the SIZEPOLICY attribute.

Note: In TABLE or TREE containers, SIZEPOLICY applies only to COMBOBOX, CHECKBOX and RADIOGROUP (this concerns the size policy specified by the user, or the default (INITIAL)). In such list views, for widgets like LABEL, the size policy is implicitly fixed, and the column width is defined by the form layout.

When the SIZEPOLICY is not specified, it defaults to INITIAL. The behavior then depends on the type of form item. For more details, see Table 1.

SIZEPOLICY = FIXED

When SIZEPOLICY is FIXED, the form element's size (or its width only) is 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, for form items supporting the STRETCH attribute, 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 form element's size (or its width only) of the element grows and shrinks to adapt to the size of the content (like the width of a LABEL text), or to adapt to the widget definition (like the picture size for an IMAGE), during the lifetime of the application.

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

Note: Exceptions regarding SIZEPOLICY=DYNAMIC:
  1. 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.
  2. With WEBCOMPONENT fields, SIZEPOLICY=DYNAMIC is ignored.
  3. With TEXTEDIT fields, SIZEPOLICY=DYNAMIC is only supported by GMA and GMI mobile front-ends.

SIZEPOLICY = INITIAL

When SIZEPOLICY is INITIAL, the first time the element appears on the screen, its size (or its width only) is computed from the initial content (like the text of a LABEL) or the widget definition (like the labels in ITEMS of COMBOBOX). Once the widget displays, its size is frozen.

However, for form items supporting the STRETCH attribute, if the STRETCH attribute is set to X, Y or BOTH, the form element can still stretch when the parent window size changes.

Note: SIZEPOLICY=INITIAL is ignored for WEBCOMPONENT fields.

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 may need to be increased, based on the size of items 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).
CHECKBOX The width defined in the form is a minimum width. If the checkbox label (TEXT) is larger as the minimum width, this defines the initial size of the widget. Then, the checkbox size remains fixed for the life time of the form.
COMBOBOX The width defined in the form is a minimum width. If a label of combobox ITEMS is larger than the minimum width, 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 The width defined in the form is a minimum width. If the length of the initial field value (or the length of the TEXT attribute for static labels) is larger as the minimum width, this defines the initial size of the widget. Then, the label keeps the same size for the life time of the form. 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.
RADIOGROUP For vertical radiogroups: The height of the widget is defined by the number of ITEMS. The width defined in the form is a minimum width. If a label of radiogroup ITEMS is larger than the minimum width, the width grows in order for the radiogroup to fully display the largest item. Then, the radiogroup size remains fixed for the life time of the form.
TEXTEDIT N/A: SIZEPOLICY=INITIAL is not supported for TEXTEDIT fields.
WEBCOMPONENT

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

Example

IMAGE img1 = FORMONLY.main_image,
    SIZEPOLICY=DYNAMIC;

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

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