Unit LOPanel |
*****************************************************} { } { Delphi Visual Component Library } { } { Copyright (c) 1996 Anna B. Sotnichenko } { } { TLayoutPanel - panel that can } { layout its children } { } {
Classes |
TChildMetrics - TConstraint}
the layout metrics represent four equations.
TConstraint -
constraints can have up to three input variables
the method for solving the constraint is represented as an ordered linear
combination of the inputs and the constant with the constant expressed last
TLayoutPanel -
Functions |
AboveConstraint - RightOfConstraint} {--------------------------------------- AboveConstraint
AbsoluteConstraint - PercentOfConstraint} {--------------------------------------- AbsoluteConstraint } { setting an edge to a fixed value
AssignConstraint - SetConstraint} {--------------------------------------- AssignConstraint } { Assign one constraint to anoter one
AssignLayoutMetrics - WriteConstraint } {--------------------------------------- AssignLayoutMetrics } { Assign values to the fields of TLayoutMetrics
BelowConstraint - AboveConstraint} {--------------------------------------- BelowConstraint
Flush - SetMeasurementUnits} {--------------------------------------- Flush } { Destroy all items in the list if
they are proved to be Objects
InitLayoutMetrics - AssignLayoutMetrics} {--------------------------------------- InitLayoutMetrics } { Initialize layout metrtics
LeftOfConstraint - SetConstraint}
these four procedures can be used to position your window with
respective to a sibling window.
PercentOfConstraint - SameAsConstraint} {--------------------------------------- PercentOfConstraint
ReadConstraint - AbsoluteConstraint} {--------------------------------------- ReadConstraint } { read constraint from stream
RightOfConstraint - LeftOfConstraint} {--------------------------------------- RightOfConstraint
SameAsConstraint - BelowConstraint} { these two work on the same edge, e.
SetConstraint - TLayoutPanel
Common functions } {--------------------------------------- SetConstraint } { Setting arbitrary edge constraints
SetMeasurementUnits - InitLayoutMetrics} {--------------------------------------- SetMeasurementUnits
WriteConstraint - ReadConstraint } {--------------------------------------- WriteConstraint } { write constraint from stream
Types |
PLayoutConstraint
PLayoutMetrics
PVariable
TEdge
TEdgeVariables
TLayoutConstraint
TLayoutMetrics
TMeasurementUnits
TRelationship
TVariable
TWhichConstraint
Constants |
Format10
lmLeftOf
lmParent
lmRightOf
ParentNum
Variables |
Functions |
Common functions } {--------------------------------------- SetConstraint } { Setting arbitrary edge constraints
Types |
PLayoutConstraint = ^TLayoutConstraint
PLayoutMetrics = ^TLayoutMetricsTVariable
PVariable = ^TVariable
TEdge = (lmLeft, lmTop, lmRight, lmBottom, lmCenter, lmWidth, lmHeight);Relative control has no layout metrics } { Edge and size - had to merge them into one type
TEdgeVariables = array [0..3] of TVariable;
TLayoutConstraint = recordrecord TLayoutConstraint ------ ----------------- layout constraints are specified as a relationship between an edge/size of one window and an edge/size of one of the window's siblings or parent it is acceptable for a control to have one of its sizes depend on the size of the opposite dimension (e.g. width is twice height) distances can be specified in either pixels or layout units a layout unit is defined by dividing the font "em" quad into 8 vertical and 8 horizontal segments. we get the font by self-sending WM_GETFONT (we use the system font if WM_GETFONT returns 0) "lmAbove", "lmBelow', "lmLeftOf", and "lmRightOf" are only used with edge constraints. they place the window 1 pixel to the indicated side(i.e. adjacent to the other window) and then adjust it by "Margin"(e.g. above window "A" by 6) NOTE: "Margin" is either added to ("lmAbove" and "lmLeftOf") or subtracted from("lmBelow" and "lmRightOf") depending on the relationship "lmSameAs" can be used with either edges or sizes, and it doesn't offset by 1 pixel like the above four relationships did. it also uses "Value" (e.g. same width as window "A" plus 10) NOTE: "Value" is always *added*. use a negative number if you want the effect to be subtractive
RelWin : TControl;
MyEdge : TEdge;
Units : TMeasurementUnits;
OtherEdge : TEdge;
end;
TLayoutMetrics = recordTLayoutConstraint} { record TLayoutMetrics ----- -------------- when specifying the layout metrics for a window you specify four layout constraints
X : TLayoutConstraint;
Y : TLayoutConstraint;
Width : TLayoutConstraint;
Height : TLayoutConstraint;
MinW : integer;
MaxW : integer;
MinH : integer;
MaxH : integer;
end;
TMeasurementUnits = (lmPixels, lmLayoutUnits);Unit identifier
TRelationship = (lmAsIs, lmPercentOf, lmAbove, lmBelow, lmSameAs, lmAbsolute);Relationship between controls
TVariable = recordVariable represents control's Left, Top, Right or Bottom edge
Value : integer;
DeterminedBy : TConstraint;
Resolved : Boolean;
end;
TWhichConstraint = (XConstraint, YConstraint, WidthConstraint, HeightConstraint);TChildMetrics} class TLayoutPanel ----- ------------- when specifying the layout metrics for a window, there are several options: e.g. in the horizontal direction, Two Edge Constraints in X and Width 1. left edge and right edge 2. center edge and right edge 3. left edge and center edge Edge Constraint and Size constraint in X and Width 4. left edge and size 5. right edge and size 6. center edge and size the same holds true in the vertical direction for Y and Height it is also possible to specify "lmAsIs" in which case we use the windows current value specifying "lmAbsolute" means that we will use whatever is in data member "Value" we just name the fields "X" and "Width" and "Y" and "Height", although its okay to place a right or center edge constraint in the "Width" field and its also okay to place a right edge constraint in the "X" field (i.e. option #3) however, it's NOT okay to place a width constraint in the "X" or "Height" fields or a height constraint in the "Y" or "Width" fields.
Constants |
Variables |