From Clomosy Docs

Revision as of 14:37, 22 August 2024 by ClomosyManager (talk | contribs)

CheckBox represents a TclCheckBox style checkbox that can be open (selected) or closed (cleared). The CheckBox component gives you a choice. Select the box to turn the option on or clear the box to turn the option off.

AddNewCheckBox(TComponent, xName, xCaption): TclCheckBox

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

xCaption : You can add a title.

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

TextSettings CheckBox1.StyledSettings = ssFamily;

CheckBox1.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');

CheckBox1.TextSettings.Font.Size = 20;

CheckBox1.TextSettings.Font.Style = [fsItalic]; //[fsItalic,fsUnderline]
Text formatting is performed in the component. To see the usage, see page.
Text CheckBox1.Text = 'CheckBox'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.
isChecked CheckBox1.isChecked = True; Assign the value True or False to the Checked property to change the checkBox's visual state. As soon as it is correct, it will come selected.

Example 1:

TRObject Syntax
 var
   MyForm:TclForm;
   testButton : TclButton;
   testLabel : TclLabel;
   testCheckBox,testCheckBox2 : TClCheckBox;
 
 void ButtonClicked;
 {
   testCheckBox.isChecked = not testCheckBox.isChecked;
   testCheckBox2.isChecked = not testCheckBox2.isChecked;
 }
 
 {
   MyForm = TclForm.Create(Self);
   testButton= MyForm.AddNewButton(MyForm,'testButton','Click');
   testButton.TextSettings.Font.Size=50;
   testButton.Align = alCenter;
   testButton.Height = 50;
   testButton.Width = 100;
   
   testLabel = MyForm.AddNewLabel(MyForm,'testLabel','Your hobbies?');
   testLabel.StyledSettings = ssFamily;
   testLabel.TextSettings.Font.Size=25;
   testLabel.TextSettings.FontColor = clAlphaColor.clHexToColor('#4a08ff');
   testLabel.Align = alMostTop;
   testLabel.Height = 30;
   
   testCheckBox = MyForm.AddNewCheckBox(MyForm,'testCheckBox','Reading book');
   testCheckBox.StyledSettings = ssFamily;
   testCheckBox.TextSettings.Font.Size=15;
   testCheckBox.TextSettings.FontColor = clAlphaColor.clHexToColor('#272643');
   testCheckBox.Align = alTop;
   testCheckBox.Height = 30;
   
   testCheckBox2 = MyForm.AddNewCheckBox(MyForm,'testCheckBox2','Watching movie');
   testCheckBox2.StyledSettings = ssFamily;
   testCheckBox2.TextSettings.Font.Size=15;
   testCheckBox2.TextSettings.FontColor = clAlphaColor.clHexToColor('#272643');
   testCheckBox2.Align = alTop;
   testCheckBox2.Height = 30;
   
   MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
   
   MyForm.Run;
 }
Base Syntax
 var
   MyForm:TclForm;
   testButton : TclButton;
   testLabel : TclLabel;
   testCheckBox,testCheckBox2 : TClCheckBox;
 
 procedure ButtonClicked;
 begin
   testCheckBox.isChecked := not testCheckBox.isChecked;
   testCheckBox2.isChecked := not testCheckBox2.isChecked;
 end;
 
 begin
   MyForm := TclForm.Create(Self);
   testButton:= MyForm.AddNewButton(MyForm,'testButton','Click');
   testButton.TextSettings.Font.Size:=50;
   testButton.Align := alCenter;
   testButton.Height := 50;
   testButton.Width := 100;
   
   testLabel := MyForm.AddNewLabel(MyForm,'testLabel','Your hobbies?');
   testLabel.StyledSettings := ssFamily;
   testLabel.TextSettings.Font.Size:=25;
   testLabel.TextSettings.FontColor := clAlphaColor.clHexToColor('#4a08ff');
   testLabel.Align := alMostTop;
   testLabel.Height := 30;
   
   testCheckBox := MyForm.AddNewCheckBox(MyForm,'testCheckBox','Reading book');
   testCheckBox.StyledSettings := ssFamily;
   testCheckBox.TextSettings.Font.Size:=15;
   testCheckBox.TextSettings.FontColor := clAlphaColor.clHexToColor('#272643');
   testCheckBox.Align := alTop;
   testCheckBox.Height := 30;
   
   testCheckBox2 := MyForm.AddNewCheckBox(MyForm,'testCheckBox2','Watching movie');
   testCheckBox2.StyledSettings := ssFamily;
   testCheckBox2.TextSettings.Font.Size:=15;
   testCheckBox2.TextSettings.FontColor := clAlphaColor.clHexToColor('#272643');
   testCheckBox2.Align := alTop;
   testCheckBox2.Height := 30;
   
   MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
   
   MyForm.Run;
 end;


Output:
CheckBox.png

Example 2:
Here is an example similar to the first one. It only involves the clicking of a checkbox component.

TRObject Syntax
 var
   Form1:TclForm;
   Label1 : TclLabel;
   CheckBox1,CheckBox2 : TClCheckBox;
 
 void CheckBoxClicked;
 var
   senderCheckBox:TClCheckBox;
 {
   senderCheckBox = TClCheckBox(Form1.Clsender);
   if senderCheckBox.clTagInt == 1 //CheckBox1 kontrol
     CheckBox2.isChecked =  senderCheckBox.isChecked 
   else if senderCheckBox.clTagInt == 2 //CheckBox1 kontrol
     CheckBox1.isChecked = senderCheckBox.isChecked
 }
 
 {
   Form1 = TclForm.Create(Self);
   
   Label1 = Form1.AddNewLabel(Form1,'Label1','Your hobbies?');
   Label1.StyledSettings = ssFamily;
   Label1.TextSettings.Font.Size=25;
   Label1.TextSettings.FontColor = clAlphaColor.clHexToColor('#4a08ff');
   Label1.Align = alMostTop;
   Label1.Height = 30;
   
   CheckBox1 = Form1.AddNewCheckBox(Form1,'CheckBox1','Reading book');
   CheckBox1.StyledSettings = ssFamily;
   CheckBox1.TextSettings.Font.Size=15;
   CheckBox1.TextSettings.FontColor = clAlphaColor.clHexToColor('#272643');
   CheckBox1.Align = alTop;
   CheckBox1.Height = 30;
   CheckBox1.clTagInt = 1;
   
   CheckBox2 = Form1.AddNewCheckBox(Form1,'CheckBox2','Watching movie');
   CheckBox2.StyledSettings = ssFamily;
   CheckBox2.TextSettings.Font.Size=15;
   CheckBox2.TextSettings.FontColor = clAlphaColor.clHexToColor('#272643');
   CheckBox2.Align = alTop;
   CheckBox2.Height = 30;
   CheckBox2.clTagInt = 2;
   Form1.AddNewEvent(CheckBox2,tbeOnClick,'CheckBoxClicked');
   Form1.AddNewEvent(CheckBox1,tbeOnClick,'CheckBoxClicked');
   
   Form1.Run;
 }


Base Syntax
 var
   Form1:TclForm;
   Label1 : TclLabel;
   CheckBox1,CheckBox2 : TClCheckBox;
 
 procedure CheckBoxClicked;
 var
   senderCheckBox:TClCheckBox;
 begin
   senderCheckBox := TClCheckBox(Form1.Clsender);
   if senderCheckBox.clTagInt = 1  then//CheckBox1 kontrol
     CheckBox2.isChecked :=  senderCheckBox.isChecked 
   else if senderCheckBox.clTagInt = 2 then//CheckBox1 kontrol
     CheckBox1.isChecked := senderCheckBox.isChecked
 end;
 
 begin
   Form1 := TclForm.Create(Self);
   
   Label1 := Form1.AddNewLabel(Form1,'Label1','Your hobbies?');
   Label1.StyledSettings := ssFamily;
   Label1.TextSettings.Font.Size:=25;
   Label1.TextSettings.FontColor := clAlphaColor.clHexToColor('#4a08ff');
   Label1.Align := alMostTop;
   Label1.Height := 30;
   
   CheckBox1 := Form1.AddNewCheckBox(Form1,'CheckBox1','Reading book');
   CheckBox1.StyledSettings := ssFamily;
   CheckBox1.TextSettings.Font.Size:=15;
   CheckBox1.TextSettings.FontColor := clAlphaColor.clHexToColor('#272643');
   CheckBox1.Align := alTop;
   CheckBox1.Height := 30;
   CheckBox1.clTagInt := 1;
   
   CheckBox2 := Form1.AddNewCheckBox(Form1,'CheckBox2','Watching movie');
   CheckBox2.StyledSettings := ssFamily;
   CheckBox2.TextSettings.Font.Size:=15;
   CheckBox2.TextSettings.FontColor := clAlphaColor.clHexToColor('#272643');
   CheckBox2.Align := alTop;
   CheckBox2.Height := 30;
   CheckBox2.clTagInt := 2;
   Form1.AddNewEvent(CheckBox2,tbeOnClick,'CheckBoxClicked');
   Form1.AddNewEvent(CheckBox1,tbeOnClick,'CheckBoxClicked');
   
   Form1.Run;
 end;


See Also