From Clomosy Docs

No edit summary
No edit summary
Line 2: Line 2:
Tags display text. You place a label on a form when you need to define or annotate another component, such as an edit box, or when you want to add text to the form. The standard label component TclLabel is a windowless control. Tags typically display read-only static text that cannot be changed by the application user.<br>
Tags display text. You place a label on a form when you need to define or annotate another component, such as an edit box, or when you want to add text to the form. The standard label component TclLabel is a windowless control. Tags typically display read-only static text that cannot be changed by the application user.<br>


  AddNewLabel(TComponent, xName, xCaption): TclLabel
  AddNewLabel(xOwner:TComponent; xName,xCaption:String): TclLabel


<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.
<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.
Line 10: Line 10:
<span style="color:blue">''xCaption''</span> : You can enter the chart title here.
<span style="color:blue">''xCaption''</span> : You can enter the chart title here.


Let's create a label.<br>


1. Create a new project.<br>


2. You need to define TclLabel 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 TclLabel.<br>
{| class="wikitable" style="border: 2px solid #c3d7e0"
'''var'''
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"|Definition
testLabel : TclLabel;
|-
 
|TclLabel || Label1 : TclLabel; || A variable belonging to the TclLabel class is created.
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.<br>
|-
 
|AddNewLabel || Label1 = MyForm.AddNewLabel(MyForm,'Label1','Test Label Caption'); || A new TclLabel is added to the form.
testLabel:= ''MyForm''.AddNewLabel(MyForm,'testLabel','Test Label Caption');
|-
 
|Width || Label1.Width = 150; ||Allows adjusting the width of the label.
4. If you do not want to define it in the form, you can add it in another component (such as Layout, Panel). Of course, before that, that component must be defined.
|-
<span style="color:blue">testLayout</span> := MyForm.AddNewLayout(MyForm,'testLayout');
|Height || Label1.Height = 50; ||Allows adjusting the height of the label.
testLabel:= MyForm.AddNewLabel(<span style="color:blue">testLayout</span>,'testLabel','Test Label Caption');
|-
 
|Align || Label1.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.
5. While defining the component, you can define it manually by typing. Another method is to write its shortcut. If you type "AddNewLabel" while the shortcut is in the code block, a pop-up menu will appear.<br>
|-
|Margins || Label1.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:TclLabelMargins.png|frameless|200px]]<br><br>
[[File:ShortcutDefinition.png|frameless|400px]]<br><br>
|-
 
|TextSettings || Label1.StyledSettings = ssFamily;<br>Label1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');<br>Label1.TextSettings.Font.Size = 20;<br>Label1.TextSettings.Font.Style = [fsItalic]; //[fsItalic,fsUnderline] || Text formatting is performed in the component. To see the usage, see [https://www.docs.clomosy.com/index.php/Object_Properties#Text_Settings page].
As soon as you click, the following block will come automatically.<br>
|-
 
|Text  || Label1.Text = 'Label's Text'; || It represents the text within the component. The text entered by the user or set by the program is managed through this property.
AddNewLabel(xOwner:TComponent; xName,xCaption:String);
|-
 
|Caption ||Label1.Caption = 'Button Caption'; || It represents the text displayed on the component. The Caption specifies the textual label that the component presents to the user.
6. We gave the variable name while defining the TclLabel 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.
|}
 
7. You give a title to your Label component as the last parameter when defining your project. This title is the text that will appear on the screen when the application is run. You may not want to write this title while defining it.
testLabel:= ''MyForm''.AddNewLabel(MyForm,'testLabel',<nowiki>''</nowiki>);
 
8. Then you can make a definition as follows. Well, an external title can be entered so that it does not appear empty when this project is run. For this, a title can be added with label.Caption assignment.
testLabel.Caption := 'Label Caption';
 
9. Another use of Label is to add text. If we add text to our component by saying label.text, when the project is run, the title does not appear and the value you have written in the text starts to appear.
 
testLabel.Text := 'Label's Text';
For example, take the value written in an TClEdit component and put it in the label and show me this. Below we show you how to do this.
 
testLabel.Text := testEdit.Text;
ShowMessage(testLabel.Text);
 
10. Now let's design our TclLabel component. Let's set the width and height first. For this, you must make the following definitions.
 
  testLabel.Height := 50;
testLabel.Width := 150;
 
11. 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 [https://www.docs.clomosy.com/index.php/Object_Properties#Align page] to learn about these features. We're going to call it the top part here. So we have to write "AlTop".
testLabel.Align := alTop;
 
12. With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
 
testLabel.Margins.Left:= 50;
testLabel.Margins.Right:= 10;
testLabel.Margins.Top:= 50;
testLabel.Margins.Bottom:= 10;
 
[[File:TclLabelMargins.png|frameless|500px]]<br><bR>
 
13. You may want to change the appearance of the text in the tag. We will use the TextSettings parameter for this.In order to use this parameter, you have to make the following definition. Otherwise your commands will not work.<br>
testLabel.StyledSettings := ssFamily;
To adjust the text size;<br>
testLabel.TextSettings.Font.Size := 20;
To set the text color;<br>
testLabel.TextSettings.FontColor := clAlphaColor.clHexToColor('#8a067c');
 
14. 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:<br>
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:'''<br>
'''Example:'''<br>
:'''Base Syntax'''
'''var'''
MyForm:TclForm;
testLabel : TclLabel;<br>
'''begin'''<br>
MyForm := TclForm.Create(Self);
testLabel:= MyForm.AddNewLabel(MyForm,'testLabel','Test Label Caption');
testLabel.StyledSettings := ssFamily;
testLabel.TextSettings.Font.Size:=20;
testLabel.Align := alCenter;
testLabel.Margins.Left:= 50;
testLabel.Margins.Top:= 10;
testLabel.Height := 50;
testLabel.Width := 150;<br>
MyForm.Run;<br>
'''end;'''


:'''TRObject Syntax'''
:'''TRObject Syntax'''
Line 117: Line 56:
   }
   }


:'''Base Syntax'''
'''var'''
MyForm:TclForm;
testLabel : TclLabel;<br>
'''begin'''<br>
MyForm := TclForm.Create(Self);
testLabel:= MyForm.AddNewLabel(MyForm,'testLabel','Test Label Caption');
testLabel.StyledSettings := ssFamily;
testLabel.TextSettings.Font.Size:=20;
testLabel.Align := alCenter;
testLabel.Margins.Left:= 50;
testLabel.Margins.Top:= 10;
testLabel.Height := 50;
testLabel.Width := 150;<br>
MyForm.Run;<br>
'''end;'''


'''Output:'''<br>
'''Output:'''<br>

Revision as of 14:59, 22 August 2024

The TclLabel component is used to output a user-modifiable text (it can of course also be modified by a program). Tags display text. You place a label on a form when you need to define or annotate another component, such as an edit box, or when you want to add text to the form. The standard label component TclLabel is a windowless control. Tags typically display read-only static text that cannot be changed by the application user.

AddNewLabel(xOwner:TComponent; xName,xCaption:String): TclLabel

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 label should be written.

xCaption : You can enter the chart title here.


Feature Use of Definition
TclLabel Label1 : TclLabel; A variable belonging to the TclLabel class is created.
AddNewLabel Label1 = MyForm.AddNewLabel(MyForm,'Label1','Test Label Caption'); A new TclLabel is added to the form.
Width Label1.Width = 150; Allows adjusting the width of the label.
Height Label1.Height = 50; Allows adjusting the height of the label.
Align Label1.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 Label1.Margins.Left = 50; // Right, Top, Bottom With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
TclLabelMargins.png

TextSettings Label1.StyledSettings = ssFamily;
Label1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
Label1.TextSettings.Font.Size = 20;
Label1.TextSettings.Font.Style = [fsItalic]; //[fsItalic,fsUnderline]
Text formatting is performed in the component. To see the usage, see page.
Text Label1.Text = 'Label's Text'; It represents the text within the component. The text entered by the user or set by the program is managed through this property.
Caption Label1.Caption = 'Button Caption'; It represents the text displayed on the component. The Caption specifies the textual label that the component presents to the user.


Example:

TRObject Syntax
 var
   MyForm:TclForm;
   testLabel : TclLabel;
 
 {
   MyForm = TclForm.Create(Self);
   testLabel= MyForm.AddNewLabel(MyForm,'testLabel','Test Label Caption');
   testLabel.StyledSettings = ssFamily;
   testLabel.TextSettings.Font.Size=20;
   testLabel.Align = alCenter;
   testLabel.Margins.Left= 50;
   testLabel.Margins.Top= 10; 
   testLabel.Height = 50;
   testLabel.Width = 150;
   
   MyForm.Run;
 }
Base Syntax
var
MyForm:TclForm;
testLabel : TclLabel;
begin
MyForm := TclForm.Create(Self); testLabel:= MyForm.AddNewLabel(MyForm,'testLabel','Test Label Caption'); testLabel.StyledSettings := ssFamily; testLabel.TextSettings.Font.Size:=20; testLabel.Align := alCenter; testLabel.Margins.Left:= 50; testLabel.Margins.Top:= 10; testLabel.Height := 50; testLabel.Width := 150;
MyForm.Run;
end;

Output:
Label.png

See Also