From Clomosy Docs

No edit summary
No edit summary
Line 64: Line 64:
     MyForm:=TclForm.Create(self);
     MyForm:=TclForm.Create(self);
      
      
     Panel1:=MyForm.AddNewPanel(MyForm,'Panel1',<nowiki>''</nowiki>);
     Panel1:=MyForm.AddNewPanel(MyForm,'Panel1');
     Panel1.Align:=ALTop;
     Panel1.Align:=ALTop;
     Panel1.Height:=100;
     Panel1.Height:=100;
Line 91: Line 91:
     MyForm=TclForm.Create(self);
     MyForm=TclForm.Create(self);
      
      
     Panel1=MyForm.AddNewPanel(MyForm,'Panel1','');
     Panel1=MyForm.AddNewPanel(MyForm,'Panel1');
     Panel1.Align=ALTop;
     Panel1.Align=ALTop;
     Panel1.Height=100;
     Panel1.Height=100;

Revision as of 14:06, 28 May 2024

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)

TComponent : The variable name of the defined component is written. Here you should write the component variable name of whatever your component will be in.

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

Let's create a layout.
1. Create a new project.

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.

var
testLayout : TclLayout;

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.

testLayout := MyForm.AddNewLayout(MyForm,'testLayout');

4. While defining the component, you can define it manually by typing. Another method is to write its shortcut. If you type "AddNewLayout" while the shortcut is in the code block, a pop-up menu will appear.

frameles

As soon as you click, the following block will come automatically.

AddNewLayout(xOwner:TComponent; xName:String);

5. We gave the variable name while defining the TclLayout in var. Now when you add this in begin end you should use this variable name in all definitions. Your code will throw an error when you write these variable names incorrectly.

6. Now let's design our TclLayout component. Let's set the width and height first. For this, you must make the following definitions.

testLayout.Height := 50;
testLayout.Width := 150;

7. 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. We're going to call it the top part here. So we have to write "AlTop".

testLayout.Align := alTop;

8. With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.

testLayout.Margins.Left:= 50;
testLayout.Margins.Right:= 10; 
testLayout.Margins.Top:= 50;
testLayout.Margins.Bottom:= 10;

Appearance:

PanelAppearance.png

9. If we want to add click feature to your component, you can use the following procedure. 'BtnOnClick' is a procedure name. For more information about the AddNewEvent component, see the page.

MyForm.AddNewEvent(testLayout,tbeOnClick,'BtnOnClick');

10. To tell you the truth, you have created a simple application that does nothing yet. Let's save and start using our project. You can save in one of two ways:
Click the save icon (the button in the upper right corner) or press Ctrl + S to save the project and see what you've done on the platforms now.

Example:

Base Syntax
 Var   
   MyForm:TclForm;
   Panel1 : TclPanel;
   Layout1 : TclLayout;
   Edit1 : TclEdit;
 
 begin
 
   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;
 
 end;
TRObject Syntax
 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