The layout of windows and panels will be done at runtime (that is when you run the Delphi program). That is because that is the first time the size of the components is known. The whole layout will be done by one Delphi unit: LayoutUnit.pas.
LayoutUnit.pas consist of three routines:
function MinWidth(WinControl: TWinControl): Integer;
TWinControl
(= TPanel
or TForm
).
function MinHeight(WinControl: TWinControl): Integer;
TWinControl
(= TPanel
or TForm
).
procedure LayoutWinControl(WinControl: TWinControl): Integer;
LayoutWinControl
for each panel. Only for the main panel you
have to call this procedure. By the way you do not have to call this
procedure yourself, because it is automatically called in the constructor of the window.
LayoutUnit.pas makes use of the Tag values of the components. So it illegal to use the Tag values in your own project. The most significant nibble (= 4 bits) are used only for panels and forms and can have the following values:
The plug tags window and panel can have three types of layout:
A window of panel with the borderlayout is split into five regions: top, bottom, left, right and center. Each of these regions can contain exactly one child element.
The top region is on the top of the window or panel element. Each element in the top region will use the full width of the window or panel. The height of an element in the top region is the height it minimal needs.
The bottom region is on the bottom of the window or panel element. Each element in the bottom region will use the full width of the window or panel. The height of an element in the bottom region is the height it minimal needs.
The left region is at the left of the window or panel element. Each element in the left region will use the full height of the window or panel, except the space that is used by the bottom and top regions. The width of an element in the left region is the width it minimal needs.
The right region is at the right of the window or panel element. Each element in the right region will use the full height of the window or panel, except the space that is used by the bottom and top regions. The width of an element in the right region is the width it minimal needs.
The center region is in the center of the window and panel element. Each element in the center region will initial use the height and width it minimal needs. When the window or panel is resized it will use the space left by the other regions of the window or panel.
The horizontal layout places the elements next to each other on a horizontal line. The center of the elements in it are vertical aligned. There are three possible aligns of the horizontal layout:
The elements are placed in a left to right manner. This means that the first element is placed left. The second element is place at the right of the first element. et cetera.
The elements are placed in the center. In a left to right manner. This means that the first element is placed in the center. The second element is placed right to the first element and the elements are centered. et cetera.
The elements are placed in a right to left manner. This means that the first element is placed right. The second element is place at the left of the first element. et cetera.
The vertical layout places the elements above each other on a vertical line. The center of the elements in it are horizontal aligned. There are three possible aligns of the vertical layout:
The elements are placed in a top to bottom manner. This means that the first element is placed at the top. The second element is place under the first element. et cetera.
The elements are placed in the center. In a top to bottom manner. This means that the first element is placed in the center. The second element is placed under the first element and the elements are centered. et cetera.
The elements are placed in a bottom to top manner. This means that the first element is placed at the bottom. The second element is placed above the first element. et cetera.