Developer

API Reference

Constraint Types

Brew Release
Brew MP 1.0.2
Description
The constraint container defines a small set of constants that are used to establish points of constraint for determining a widget's size or position. These points of constraint allow an object's size or position to be expressed in terms relative to another object. For example, the layout of an object could be constrained to the placement of other objects using the following vocabulary
   
      - Place the left edge 2 pixels to the right of the right side of the previous object
      - Place the right edge 2 pixels to the left of the right side of the parent object
      - Place the top edge at 50% of the height of the parent object
      - Place the bottom edge 2 pixels above the bottom of the parent object


These types of constraint relationships, in conjunctions with the Constraint and ConstraintElem data types, may be expressed by using the constants listed in the table below
Definition
Definition                 Description
--------------             -------------------------------------------------------
CONSTRAINT_PARENT_BOTTOM:  Indicates that an object is to be positioned relative to the
                           bottom of its parent.  For example, the bottom of a widget
                           could be placed 'x' pixels from the bottom of the parent's
                           bounding rectangle -- effectively anchoring the widget to
                           the bottom of its container.

CONSTRAINT_PARENT_TOP:     Indicates that an object is to be positioned relative to the
                           top of its parent.  For example, the top of a widget could
                           be placed 'x' pixels from the top of the parent's bounding
                           rectangle -- effectively anchoring the widget to the top of
                           its container.

CONSTRAINT_PARENT_LEFT:    Indicates that an object is to be positioned relative to the
                           left side of its parent.  For example, the left side of a
                           widget could be placed 'x' pixels from the left side of the
                           parent's bounding rectangle -- effectively anchoring the widget
                           to the left side of its container.

CONSTRAINT_PARENT_RIGHT:   Indicates that an object is to be positioned relative to the
                           right side of its parent.  For example, the right side of a
                           widget could be placed 'x' pixels from the right side of the
                           parent's bounding rectangle -- effectively anchoring the widget
                           to the right side of its container.

CONSTRAINT_PARENT_WIDTH:   Indicates that an object is to be positioned relative to a
                           percentage of the width of its parent.  For example, the left
                           side of a widget could be placed at a position that is at 50%
                           of the container object's extent -- i.e. the left edge is
                           aligned at the middle of the container.

CONSTRAINT_PARENT_HEIGHT:  Indicates that an object is to be positioned relative to a
                           percentage of the height of its parent.  For example, the bottom
                           of a widget could be placed at a position that is at 33%
                           of the container object's extent -- i.e. the bottom edge is
                           aligned one third of the way down from the top of the container.
                              
CONSTRAINT_PARENT_HCENTER: Indicates that an object is to be positioned relative to horizontal
                           center of the parent. For example, if this constraint is applied
                           to the right edge of a child, then the right edge will be at
                           (container width)/2 pixels from constainers' left edge.

CONSTRAINT_PARENT_VCENTER: Indicates that an object is to be positioned relative to vertical
                           center of the parent. For example, if this constraint is applied
                           to the top edge of a child, then the top edge will be at
                           (container height)/2 pixels from constainers' top edge.
                              
CONSTRAINT_PREV_BOTTOM:    Indicates that an object is to be positioned relative to the
                           bottom edge of the previous visible object in the widget list.
                           For example, the top of a widget could be placed 'x' pixels from
                           the bottom of the widget that was just previously declared.

CONSTRAINT_PREV_TOP:       Indicates that an object is to be positioned relative to the
                           top edge of the previous visible object in the widget list. 
                           For example, the bottom of a widget could be placed 'x' pixels
                           from the top of the widget that was just previously declared.

CONSTRAINT_PREV_LEFT:      Indicates that an object is to be positioned relative to the
                           left edge of the previous visible object in the widget list.
                           For example, the right side of a widget could be placed 'x'
                           pixels from the left side of the widget that was just previously
                           declared.

CONSTRAINT_PREV_RIGHT:     Indicates that an object is to be positioned relative to the
                           right edge of the previous visible object in the widget list.
                           For example, the left side of a widget could be placed 'x'
                           pixels from the right side of the widget that was just previously
                           declared.

WIDGET_CENTER_SIZE_TO_FIT: Indicates that an object is to be positioned relative to the 
                           exact center of the container.  If this constraint is set for either
                           the left or right constraint, the widget will be centered to the 
                           midpoint of the container's width, and the widget will be sized to
                           its preferred width.  The same is true for the top and bottom 
                           constraint except the widget will be centered to the container's
                           height, and the widget will be sized to its preferred height.
                           If this constraint type is chosen for all constraints, the widget
                           will sized to its preferred extent and will be placed in the dead
                           center of the container.  

STF_BOUNDED:               (Size To Fit, Bounded) Indicates that an object is to be positioned 
                           such that it is sized to its preferred extent but bounded by other 
                           constraints. This is a flag used along with another constraint. For
                           example, the left edge might be at 'x' pixel from parent left edge 
                           while the right edge can be positioned such that it is sized to fit
                           the width but bounded by parent right edge. Offset is used to 
                           determine the bounds. For such a case, the right edge constraint 
                           will be STF_BOUNDED | CONSTRAINT_PARENT_RIGHT. This flag should 
                           not be used for both of the parallel edges ( i.e. both left/right 
                           should not have STF_BOUNDED). This flag should be used in conjuction
                           with other relational constraints (parent or prev)

CENTER_STF_BOUNDED:        (Center Size To Fit, Bounded). Indicates that an object is to be 
                           positioned relative to center of the container, sized to fit but
                           bounded by another constraint. This flag is extension to 
                           WIDGET_CENTER_SIZE_TO_FIT flag where the inserted widget can also 
                           be bounded by other constraints. When this flag is set for either
                           the left or right constraint, and if the widget's preferred width
                           is less than the container's width, the behavior is same as 
                           WIDGET_CENTER_SIZE_TO_FIT, however, if the preferred width is more
                           than container's width, then the edge is moved based on the 
                           constraint specified with this flag. Same is true for top and 
                           bottom edges. This flag can be applied to both of the parallel
                           edges at the same time (left/right and top/bottom). This flag 
                           should be used in conjuction with other relational constraints 
                           (parent or prev).

                           
Comment
None
  • Follow