NAME

hwGUI - properties common to GUI elements

INHERITS FROM

None

PROPERTIES

PosX 1I X position of the element
PosY 1I Y position of the element
Width 1I Width of the element
Height 1I Height of the element
Align 1I Set of flags describing how position / size are to be interpreted

DEFAULTS

None

DESCRIPTION

GUI elements in HoverWare share a comon set of positioning rules to make it easier to properly lay out user interfaces. All elements are placed relative to their parent container - either an hwRowCol or hwLayout object, or the window if there is no enclosing layout object. By default, PosX, PosY, Width, and Height are pixel coordinates of the upper left corner of the object relative to the upper left corner of its parent. However, this behavior may be changed including one or more of the following flags in the Align property:

HW_GUI_REL_RIGHT The PosX describes a position the given distance to the left of the right edge of the parent
HW_GUI_REL_BOT The PosY describes a position the given distance to the bottom edge of the parent
HW_GUI_REL_WIDTH The Width should be subtracted from the parent's width to derive the size
HW_GUI_REL_HEIGHT The Height should be subtracted from the parent's height to describe the size
HW_GUI_FRACTIONAL All units (PosX, PosY, Width, and Height) are to be interpreted as the numerator of a fraction whose denominator is 1000, and the resulting fraction used to calculate a value which is a fraction of the parent's width (for PosX and Width) or height (for PosY and Height)
HW_GUI_CENTER PosX and PosY position the center of the widget.

Note that all of these properties are overriden if the parent container is an hwRowCol object.

For objects which contain a text label, by default, the label is centered horizontally and vertically inside the object's bounding rectangle. This behavior may be altered by including one or more of the following flags in the Align property:

HW_GUI_LABEL_LEFT The label should be left-aligned in the bounding box
HW_GUI_LABEL_RIGHT The label should be right-aligned in the bounding box
HW_GUI_LABEL_TOP The label should be positioned starting at the top of the bounding box
HW_GUI_LABEL_BOTTOM The label should be positioned ending at the bottom of the bounding box

C EXAMPLE

    hwObject buttonOK, buttonCancel;

    /* Create the buttons in the bottom right corner of the window: */
    buttonOK = hwButton->create( hwButton );
    buttonOK->modify( buttonOK, hwStrLabel, HW_TYPE_STRING, "OK" );
    HW_MODIFY_3F( buttonOK, hwStrBackgroundColor, 0.5, 0.5, 0.5 );
    HW_MODIFY_1I( buttonOK, hwStrPosX, 280 );
    HW_MODIFY_1I( buttonOK, hwStrPosY, 50);
    HW_MODIFY_1I( buttonOK, hwStrWidth, 120 );
    HW_MODIFY_1I( buttonOK, hwStrHeight, 40);
    HW_MOIDFY_1I( buttonOK, hwStrAlign, (HW_GUI_REL_RIGHT | HW_GUI_REL_BOT) );

    buttonCancel = hwButton->create( hwButton );
    buttonCancel->modify( buttonCancel, hwStrLabel, HW_TYPE_STRING, "Cancel" );
    HW_MODIFY_3F( buttonCancel, hwStrBackgroundColor, 0.5, 0.5, 0.5 );
    HW_MODIFY_1I( buttonCancel, hwStrPosX, 140 );
    HW_MODIFY_1I( buttonCancel, hwStrPosY, 50);
    HW_MODIFY_1I( buttonCancel, hwStrWidth, 120 );
    HW_MODIFY_1I( buttonCancel, hwStrHeight, 40);
    HW_MOIDFY_1I( buttonCancel, hwStrAlign, (HW_GUI_REL_RIGHT | HW_GUI_REL_BOT) );

    while( 1 ) {
        buttonOK->draw( buttonOK );
        buttonCancel->draw( buttonCancel );
        disp->update( disp, HW_UPDATE_ALL );
    }

OBJECT FILE EXAMPLE

    hwButton buttonOK {
        PosX = 280      PosY = 50
        Width = 120     Height = 40
        Align = (HW_GUI_REL_RIGHT + HW_GUI_REL_BOT)
        BackgroundColor = {.5, .5, .5 }
        Label = "OK"
    }
    hwButton buttonCancel {
        PosX = 140      PosY = 50
        Width = 120     Height = 40
        Align = (HW_GUI_REL_RIGHT + HW_GUI_REL_BOT)
        BackgroundColor = {.5, .5, .5 }
        Label = "Cancel"
    }

SEE ALSO

hw, hwButton, hwLabel, hwToggle, hwRowCol, hwLayout