sizePolicy

The sizePolicy property is a sizing directive to display form elements.

This property defines how the front-ends will compute the size of some form elements in grids. The sizePolicy applies only to leaf elements, not to containers. The default value of sizePolicy is initial.

The sizePolicy property is ignored for the widgets used in Table and Tree columns, because in tables, the size policy is implicitly defined by the cell as fixed (i.e. the size of the column in the form layout).

When the sizePolicy is fixed, the form elements size is exactly the one defined in 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.

When sizePolicy is dynamic, the size of the element grows and shrinks according to the width of the wider during the life time 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. With sizePolicy=DYNAMIC, Buttons, Labels, CheckBoxes, Images, and RadioGroups can shrink and grow all the time, while ComboBoxes can only grow.

When sizePolicy is initial, the size is computed the first time the element appears on the screen. Once the widget is displayed, its size is frozen. This is typically used when the size of the element must be fixed but is not known at design time (for instance, when populating a ComboBox item list from a database table). This option 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. Keep in mind that after the firs the display, the element size will be frozen:

  • Buttons: The size defined in the form is a minimum size. If the text is bigger, the size grows (width and height).
  • ComboBoxes: The width defined in the form is a minimum width. If one of the items in the value list is bigger, the size grows in order for the combobox to display the largest item fully.
  • Labels, CheckBoxes, and RadioGroups can shrink or grow. The size defined in the form is ignored. The fields are sized according to the element text.
  • Images can shrink and grow according to the picture displayed. Images can use the stretch property, so that the size of the widget can be dependant from the parent container, overriding the sizePolicy property. If the width and height properties have to be used, the sizePolicy property must be set to FIXED.
  • Other items such as Edit or widget without items like ProgressBar are not sensitive to the sizePolicy property.

The sizePolicy property is supported for web component fields, however as the content and behavior is defined by the front-end, this property may have no effect. See the front-end web-component specific documentation for more details.

For additional information, see the SIZEPOLICY attribute topic in the Genero Business Development Language User Guide.