Developer

API Reference

ConstraintElem

Brew Release
Brew MP 1.0.2
See Also
Description
This data type identifies a single constraint element for a widget, which defines how the position of that widget is to be constrained by another object. A ConstraintElem merely defines a reference point for a single aspect of a widget's position -- for example, a reference point for placing the right side of a bitmap widget, or the top edge of a checkbox widget. A single positional relationship will often suffice where an object's preferred extent has statically been defined. However, to truly constrain the dimensions of an object, multiple ConstraintElem are required to specify the location of the object's left, right, top and bottom coordinates, as defined by the Constraint data structure.
The 'type' and 'offset' fields have a binding relationship in which they together define a point of constraint for a target object. For example, a ConstraintElem with 'type' equal to CONSTRAINT_PARENT_BOTTOM and 'offset' equal to -2 would define a coordinate that is two pixels up from the bottom of the object's parent. As part of a Constraint data structure, this relationship might be used to constrain the position of a widget's bottom coordinate.
Members
  • type:    This constant describes either
                    i) The type of positional relationship the constraint element will have
                       against a coordinate of another object (CONSTRAINT_PARENT_BOTTOM,
                       CONSTRAINT_PARENT_TOP, CONSTRAINT_PREV_LEFT, etc).  For example,
                       when 'type' is equal to CONSTRAINT_PARENT_RIGHT, the ConstraintElem
                       defines a constraint point relative to the right side of the widget's
                       parent (generally, the container object).  Or...
                   ii) How the coordinate being described by the ConstraintElem should be
                       sized in relation to the object's own extent, as defined by one of
                       the following constants
                                  
                          WIDGET_SIZE_TO_FIT  - The constraint container will grant an
                                                extent to this object, which is sized to fit
                                                the widget's preferred extent.  For example,
                                                if the ConstraintElem is describing the top
                                                coordinate of an object and 'type' is equal to
                                                WIDGET_SIZE_TO_FIT, the widget will be laid
                                                out in the container with a height equal to the
                                                preferred vertical extent of the widget.
                          WIDGET_KEEP_EXTENT  - The constraint container will grant an
                                                extent to this object, which is exactly the
                                                same size as the widget's extent.  For example,
                                                if the ConstraintElem is describing the left
                                                coordinate of an object and 'type' is equal to
                                                WIDGET_KEEP_EXTENT, the widget will be laid
                                                out in the container with a width equal to the
                                                existing horizontal extent of the widget.
                         Or...
                   iii) Combination of positional relationship and objects own extent.
                        The type can be created by combining one of the positional constraint
                        and a flag which could be STF_BOUNDED or CENTER_STF_BOUNDED. In this 
                        case, if the contained widgets' preferred extent is smaller than the
                        container's extent, then its sized to fit otherwise, its bound to 
                        other constraint defined in the type.
  • offset:  The distance in pixels from a single coordinate of the reference object, as
                defined by the 'type' field.  Positive values mean to the right and down from
                the reference object, and negative values mean to the left and up from the
                reference object.
    
Definition
   typedef struct {
      uint16 type;
      int16 offset;
   } ConstraintElem;
Comment
None
  • Follow