From Clomosy Docs

(Created page with "TclLoyout is a container for other graphic object. Use TclLayout to edit multiple chart controls under the same parent. For example, you wanted to put 2 components (label, button) in a single line on the page you want to design. In such cases, you can position these 2 components in a single Layout. AddNewLayout(TComponent, xName) <span style="color:blue">''TComponent''</span> : The variable name of the defined component is written. Here you should write the component...")
 
No edit summary
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
TclLoyout is a container for other graphic object. Use TclLayout to edit multiple chart controls under the same parent. For example, you wanted to put 2 components (label, button) in a single line on the page you want to design. In such cases, you can position these 2 components in a single Layout.
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function AddNewLayout(AComponent: TCLComponent; xName: string): TclLayout;
</div>
<span style="color:blue"><b>AComponent</b></span> : Specifies the parent of the object to be defined.<br>


AddNewLayout(TComponent, xName)
<span style="color:blue"><b>xName</b></span> : The name of the defined layout should be written.<br>


<span style="color:blue">''TComponent''</span> : The variable name of the defined component is written. Here you should write the component variable name of whatever your component will be in.
It is used to arrange other components on the form. Simply put, it is used to organize buttons, labels, and other visual elements in a specific layout on a form. This layout automatically adjusts the size and position of the components, making the form appear more organized and aesthetically pleasing. TclLayout is particularly useful when creating dynamic user interfaces and adapting to different screen sizes.<br>


<span style="color:blue">''xName''</span> : The name of the defined layout should be written.
The features and usage are provided in the table below.<br>


Let's create a layout.<br>
<div class="table-responsive">
1. Create a new project.<br>
{| class="wikitable" style="border: 2px solid #c3d7e0"
! style="background-color: #c3d7e0"| Feature  !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition
|-
|TclLayout || Layout1 : TclLayout; || A variable belonging to the TclLayout class is created.
|-
|AddNewLayout || Layout1 = Form1.AddNewLayout(Form1,'Layout1'); || A new TclLayout is added to the form.
|-
|AutoResize ||Layout1.AutoResize = clVertical; || Enables automatic resizing of a component based on its content. This feature allows resizing horizontally (clHorizontal) or vertically (clVertical) and can be adjusted as needed.
|-
|Width || Layout1.Width = 150; ||Allows adjusting the width of the layout.
|-
|Height || Layout1.Height = 50; ||Allows adjusting the height of the layout.
|-
|Align  || Layout1.Align = alTop; ||With the Align parameter, you can specify where you want our component to be aligned in the form. This parameter has multiple positioning properties. See the [[Object_Properties#Align | page]] to learn about these features.
|-
|Margins || Layout1.Margins.Left = 50; // Right, Top, Bottom ||With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.<br>[[File:PanelAppearance.png|frameless|200px]]<br><br>
|}
</div>


2. You need to define TclLayout on the form. To do this, you should add under the var parameter on the ide as follows. It is the name of your variable you typed at the beginning. You should define this as you want and add it as TclLayout.<br>
<b>Example</b><br>
<pre>
Var 
  MyForm:TclForm;
  Panel1 : TclPanel;
  Layout1 : TclLayout;
  Edit1 : TclEdit;
{
  MyForm=TclForm.Create(self);
   
  Panel1=MyForm.AddNewPanel(MyForm,'Panel1');
  Panel1.Align=ALTop;
  Panel1.Height=100;
   
  Layout1 = MyForm.AddNewLayout(Panel1,'Layout1');
  Layout1.Align=ALCenter;
  Layout1.Height = 50;
 
  Edit1 = MyForm.AddNewEdit(Layout1,'Edit1','Write something...');
  Edit1.Align=aLLeft;
  Edit1.Width = 150;
   
  MyForm.Run;
}
</pre>


'''var'''
<b>Output:</b><br>
testLayout : TclLayout;
[[File:Layout.png|frameless|450px]]<br>


3. Add the TclLabel to the form. For this, you must add the begin end block and add it inside the form after the form is defined. By saying MyForm.AddNewLabel, we actually add to the form we have defined. Here, you need to add your form definition as whatever you wrote it.
<h2> See Also </h2>
* [[Components]]
* [[Object Properties]]
* [[AddNewEvent]]
{{#seo:|title=TclLayout Using in Clomosy - Clomosy Docs}}
{{#seo:|description=Discover TclLayout in Clomosy, a component used to organize buttons, labels, and visuals, ensuring dynamic and responsive user interface design.}}

Latest revision as of 13:23, 20 February 2025

AComponent : Specifies the parent of the object to be defined.

xName : The name of the defined layout should be written.

It is used to arrange other components on the form. Simply put, it is used to organize buttons, labels, and other visual elements in a specific layout on a form. This layout automatically adjusts the size and position of the components, making the form appear more organized and aesthetically pleasing. TclLayout is particularly useful when creating dynamic user interfaces and adapting to different screen sizes.

The features and usage are provided in the table below.

Feature Use of Definition
TclLayout Layout1 : TclLayout; A variable belonging to the TclLayout class is created.
AddNewLayout Layout1 = Form1.AddNewLayout(Form1,'Layout1'); A new TclLayout is added to the form.
AutoResize Layout1.AutoResize = clVertical; Enables automatic resizing of a component based on its content. This feature allows resizing horizontally (clHorizontal) or vertically (clVertical) and can be adjusted as needed.
Width Layout1.Width = 150; Allows adjusting the width of the layout.
Height Layout1.Height = 50; Allows adjusting the height of the layout.
Align Layout1.Align = alTop; With the Align parameter, you can specify where you want our component to be aligned in the form. This parameter has multiple positioning properties. See the page to learn about these features.
Margins Layout1.Margins.Left = 50; // Right, Top, Bottom With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
PanelAppearance.png

Example

 Var   
   MyForm:TclForm;
   Panel1 : TclPanel;
   Layout1 : TclLayout;
   Edit1 : TclEdit;
 
 {
 
   MyForm=TclForm.Create(self);
    
   Panel1=MyForm.AddNewPanel(MyForm,'Panel1');
   Panel1.Align=ALTop;
   Panel1.Height=100;
    
   Layout1 = MyForm.AddNewLayout(Panel1,'Layout1');
   Layout1.Align=ALCenter;
   Layout1.Height = 50;
   
   Edit1 = MyForm.AddNewEdit(Layout1,'Edit1','Write something...');
   Edit1.Align=aLLeft;
   Edit1.Width = 150;
    
   MyForm.Run;
 
 }

Output:
Layout.png

See Also