From Clomosy Docs
function AddNewFlowLayout(AComponent: TCLComponent; xName: string): TclFlowLayout;
AComponent : Specifies the parent of the object to be defined.
xName : The name of the defined FlowLayout should be written.
It is used to arrange components on the form in a sequential flow. Simply put, it automatically places buttons, labels, and other visual elements in a row or column, and moves them to the next line or column when space runs out.
This layout ensures that the interface elements are organized neatly, maintaining proper spacing and order even when the container is resized. TCLFlowLayout is particularly useful when creating dynamic user interfaces with variable numbers of controls or when the layout needs to adapt fluidly to different screen sizes.
The features and usage are provided in the table below.
| Feature | Use of | Definition |
|---|---|---|
| TclFlowLayout | FlowLayout1 : TclFlowLayout; | A variable belonging to the TclFlowLayout class is created. |
| AddNewFlowLayout | FlowLayout1 = Form1.AddNewFlowLayout(Form1,'FlowLayout1'); | A new TclFlowLayout is added to the form. |
| Align | FlowLayout1.Align = alTop; | Specifies how the FlowLayout is aligned within its parent container. Multiple alignment options are available. See the page for more details. |
| FlowDirectionText | FlowLayout1.FlowDirectionText = 'RightToLeft'; | Determines the direction in which child controls flow: LeftToRight or RightToLeft (aliases: LTR/RTL). |
| JustifyText | FlowLayout1.JustifyText = 'Justify'; | Specifies the horizontal alignment of controls within each line: Left, Right, Center, or Justify (aliases: L/R/C, Full/Justified). |
| JustifyLastLineText | FlowLayout1.JustifyLastLineText = 'Center'; | Specifies the alignment of controls in the last line: Left, Right, Center, or Justify. |
| HorizontalGap | FlowLayout1.HorizontalGap = 7; | Sets the horizontal spacing (gap) between controls. |
| VerticalGap | FlowLayout1.VerticalGap = 5; | Sets the vertical spacing (gap) between lines of controls. |
| Margins | FlowLayout1.Margins.Left = 50; // Right, Top, Bottom | Allows setting margins around the FlowLayout container. |
Example
var
MyForm:TclForm;
FlowLayout:TclFlowLayout;
testButton:TCLButton;
I:Integer;
{
MyForm=TclForm.Create(self);
FlowLayout = MyForm.AddNewFlowLayout(MyForm,'FlowLayout');
FlowLayout.Align = alClient;
FlowLayout.JustifyText='Justify';// Left, Right, Center, or Justify (aliases: L/R/C, Full/Justified)
FlowLayout.JustifyLastLineText='center';// Left, Right, Center, or Justify (aliases: L/R/C, Full/Justified)
FlowLayout.FlowDirectionText='RightToLeft';//LeftToRight or RightToLeft (aliases: LTR/RTL)
FlowLayout.HorizontalGap = 7;
FlowLayout.VerticalGap = 5;
for (I = 0 to 10) {
testButton = MyForm.AddNewButton(FlowLayout,'testButton'+IntToStr(I),'Button'+IntToStr(I));
}
MyForm.Run;
}
Output:
See Also
