Simba/Includes/ezForm.simba
By @Obscurity;
Last Updated: 2015-10-26
Click the thumbnails for full-size
Introduction
eZForm is a tool for easily creating and manipulating forms for your Simba scripts. These forms can run simultaneously with your scripts, allowing you to update variables, options, and more on the fly! You can even add images from a URL with a single line of code!
Simba Code:program eZTutorial;
{$i ezForm.simba}
var
myForm:eZForm;
myButton,
myMemo:eZElement;
procedure pButtonHandler();native;
begin
myForm.height(135);
myMemo.height(80).multiple(true).text('Now I''m multi-line...');
myButton.disabled(true).offsetTop(95);
end;
begin
myForm.create('Tutorial');
myMemo:=myForm.addMemo('I''m single-line...','s8','',[10,10],[230,20],nil);
myButton:=myForm.addButton('Multi-line','b s08','',[10,35],[230,30],pButtonHandler);
myForm.show();
repeat wait(1);until false;
end.
Simba Code:program eZTutorial;
{$i ezForm.simba}
var
myForm:eZForm;
myCheckbox:eZElement;
procedure pCheckboxHandler();native;
begin
myForm.find().isnt(myCheckbox).disabled(myCheckbox.checked());
end;
begin
myForm.create('Tutorial');
myCheckbox:=myForm.addCheckbox('Disable components','i s8','hCheckbox',[10,10],pCheckboxHandler);
myForm.addMemo('','s08','',[10,30],[230,20],nil);
myForm.addButton('Button','b s08','',[10,55],[230,30],nil);
myForm.show();
repeat wait(1);until false;
end.
Simba Code:program eZTutorial;
{$i ezForm.simba}
var
myForm:eZForm;
myButton,
myListbox:eZElement;
procedure pButtonHandler();native;
begin
myListbox.prop('cols',2);
myButton.prop('disabled',true);
end;
begin
myForm.create('Tutorial');
myListbox:=myForm.addListbox(['First','Second','Third','Fourth','Fifth','Sixth','Seventh','Eighth','Nineth','Tenth'],'s8','',[10,10],[230,100],nil);
myButton:=myForm.addButton('Two Columns','b s08','',[10,115],[230,30],pButtonHandler);
myForm.show();
repeat wait(1);until false;
end.
Simba Code:program eZTutorial;
{$i ezForm.simba}
var
myForm:eZForm;
begin
myForm.create('Tutorial');
myForm.addGroupbox('Tooltip','b s10','',[10,10],[230,50]);
myForm.addLabel('Hover over me. I have a tooltip!','s8','',[20,35]).title('This is a tooltip!');
myForm.show();
repeat wait(1);until false;
end.
Simba Code:program eZTutorial;
{$i ezForm.simba}
var
myForm:eZForm;
procedure pButtonHandler();native;
begin
myForm.find('#hMemo')[0].text('');
end;
procedure pMemoHandler();native;
var
Memo_Color,
Memo_Length:integer;
Memo_Value:string;
begin
Memo_Value:=myForm.find('#hMemo')[0].val();
Memo_Length:=length(Memo_Value);
Memo_Color:=round(Memo_Length/12*255);
myForm.find('#hLabel')[0].color(Memo_Color).text('Characters: '+toStr(Memo_Length)+'/12');
myForm.find('#hButton')[0].disabled(Memo_Length=0)
end;
begin
myForm.create('Tutorial');
myForm.addLabel('Characters: 0/12','i s08','hLabel',[10,10]);
myForm.addMemo('','s8','hMemo',[10,30],[230,20],pMemoHandler).maxLength(12);
myForm.addButton('Clear','b s08','hButton',[10,55],[230,30],pButtonHandler).disabled(true);
myForm.show();
repeat wait(1);until false;
end.
Simba Code:program eZTutorial;
{$i ezForm.simba}
var
myForm:eZForm;
myImage:eZElement;
procedure pButtonHandler(vSender:tObject);native;
begin
case myImage.src() of
'http://puu.sh/kYXD8/e9dde9e433':myImage.src('http://puu.sh/kYXCm/2631effd0c');
'http://puu.sh/kYXCm/2631effd0c':myImage.src('http://puu.sh/kYXD8/e9dde9e433');
end;
end;
begin
myForm.create('Tutorial');
myImage:=myForm.addImage('http://puu.sh/kYXCm/2631effd0c','',[10,10],[230,230],nil);
myForm.addButton('Invert','b s08','hInverted',[10,260],[230,30],pButtonHandler);
myForm.show();
repeat wait(1);until false;
end.
Simba Code:program eZTutorial;
{$i ezForm.simba}
var
myForm:eZForm;
myCombobox,
myText:eZElement;
procedure pButtonHandler();native;
begin
myText.text('You submitted: '+myCombobox.val());
end;
begin
myForm.create('Tutorial');
myCombobox:=myForm.addCombobox(['First','Second','Third','Fourth','Fifth'],'s8','',[10,10],230,nil).readOnly(true);
myForm.addButton('Submit','b s08','',[10,40],[230,30],pButtonHandler);
myText:=myForm.addLabel('You submitted: ','s08','',[10,80]);
myForm.show();
repeat wait(1);until false;
end.
Simba Code:program eZTutorial;
{$i eZForm.simba}
var
myForm:ezForm;
procedure eButtonHandler(vSender:tObject);native;
var
_Sender:eZElement;
begin
_Sender:=vSender.toElement();
if _Sender.equals('#addButton') then
myForm.find('#progressBar')[0].val('+10')
else if _Sender.equals('#subtractButton') then
myForm.find('#progressBar')[0].val('-10')
else if _Sender.equals('#setButton') then
myForm.find('#progressBar')[0].val(+50);
end;
begin
myForm.create('Tutorial');
myForm.addProgressbar(90,'progressBar',[10,10],[230,20]);
myForm.addButton('Add 10','b s8','addButton',[10,40],[115,30],eButtonHandler);
myForm.addButton('Subtract 10','b s8','subtractButton',[125,40],[115,30],eButtonHandler);
myForm.addButton('Set as 50','b s8','setButton',[10,70],[230,30],eButtonHandler);
myForm.show();
repeat wait(1);until false;
end.
Simba Code:program new;
{$i ezForm.simba}
var
myForm:eZForm;
begin
myForm.create('Tutorial');
myForm.addLabel('Username','c8421504 i s08','',[10,10]);
myForm.addMemo('eZForm','','',[10,30],[230,20],nil).prop('maxlength',12);
myForm.addLabel('Password','c8421504 i s08','',[10,60]);
myForm.addMemo('Rocks my socks!','','',[10,80],[230,20],nil).prop('maxlength',20).prop('password',true);
myForm.show();
repeat wait(1);until false;
end.
Simba Code:program eZTutorial;
{$i ezForm.simba}
var
myForm:eZForm;
begin
myForm.create('Tutorial');
myForm.addTab(['Memo','Picture','Button'],'s8','tabList',[10,10],[230,120],nil).select(1);
myForm.addMemo('Memo','c8421504 i s08','',[10,10],[200,70],nil).parent('#tabList0');
myForm.addImage('http://puu.sh/ldbMk/00ed57d427.png','',[10,10],[200,70],nil).parent('#tabList1');
myForm.addButton('Button','b s08','',[10,10],[200,70],nil).parent('#tabList2');
myForm.show();
repeat wait(1);until false;
end.
Download eZForm.simba from Github and place it into your Includes folder.
Download ProSocks.dll from Github and place it into your Plugins folder.
Read the quick guide to using eZForm found here.