PDA

View Full Version : thinBasic 1.10.5 UI is becoming more easier and more clean (I hope)



ErosOlmi
30-11-2017, 00:45
Another new set of features you will get in next thinBasic 1.10.5 is the ability to specify shorter sentences for creating windows and controls and later, when it's the right time, specify the missing information using a simple <object>.<property> notation. This is possible using the new "Name" option that will allow to give a name to Windows and Controls and use that name to reference to specific windows or controls without the need to know windows handle and control IDs

Of course remaining 100% compatible with previous notation.
No need to change anything in your scripts if you do not want.

A script example and a bundled exe can show you how.


uses "ui"


begin ControlID
%lbl
%txt
%btnClose
%stBar
%listbox
%progressbar
end ControlID


'---Create Window and controls using new shot notations
'---All the rest of properties can be defined later during window events
DIALOG New Pixels, Name frmMain, 0, "Window to demonstrate Named Controls"
control add label , name lbl , frmMain.Handle, %lbl , "This is a label"
control add textbox , name txt , frmMain.Handle, %txt , "This is a textbox"
control add Button , name btnClose , frmMain.Handle, %btnClose , "Close"
Control Add Statusbar , name stBar , frmMain.Handle, %stBar , ""


DIALOG SHOW MODAL frmMain.Handle




'--------------------------------------------
callBack function frmMain_OnCallback() As Long
'--------------------------------------------


end Function


'--------------------------------------------
callBack function frmMain_OnInit() As Long
'--------------------------------------------


long dW, dH


'---Define window style
frmMain.Style = %WS_DLGFRAME | %DS_CENTER | %WS_CAPTION | %WS_SYSMENU | %WS_OVERLAPPEDWINDOW


'---Get desktop size
DESKTOP GET SIZE TO dW, dH

'---Set Window client size
frmMain.cw = 800
frmMain.ch = 600


'---Set window minimum size
frmMain.MinSize = 640, 480

'---Center window
frmMain.x = (dW - frmMain.cw)/ 2
frmMain.y = (dH - frmMain.ch)/ 2


end Function


'--------------------------------------------
callBack function frmMain_OnSize() As Long
'--------------------------------------------


'---Set controls locations and size
lbl.x = 5: lbl.y = 5: lbl.w = 200: lbl.h = 20
txt.x = 5: txt.y = 25: txt.w = 200: txt.h = 25


btnClose.x = frmMain.cw - 110
btnClose.y = frmMain.ch - 50 - stBar.h
btnClose.w = 100
btnClose.h = 40


end function


'--------------------------------------------
callback function btnClose_OnClick()
'--------------------------------------------


frmMain.End

end Function

Petr Schreiber
30-11-2017, 21:31
I consider this to be the jump to the right direction - it makes the creation of dialogs and controls simple.
With less code more done while it does not compromise the clarity and meaning.

My wish is to get rid of those evil DIALOG and CONTROL commands.

If we look at:


control add label , name lbl , frmMain.Handle, %lbl , "This is a label"


...BASICally, the %lbl is redunant and the same could be done in a way similar to:


add label "lbl", "This is a label" to frmMain

(handle known to frmMain, no need for ctrlId, which could be autogenerated internally)

...or maybe more standard:


lbl = new Label("This is a label")
frmMain.addControl(lbl)



Petr

kcvinu
01-12-2017, 17:08
Hi Eros,
Great changes !. Please consider function syntax like this;
FunctionName(Param1, Param2....,ParamN)
Here is an example of window creation;

Window_Handle = CreateWindow(Location=(x,y), Size=(x,y), Title="String", WindowStyles=(List_Of_Styles))

And here is one for control creation;


Control_Handle = CreateButton(Parent=Window_Handle, Location=(x,y), Size=(x,y), Text="String", ButtonStyles=(List_Of_Styles))
Control_Handle = CreateLabel(Parent = Window_Handle, Location=(x,y), Size=(x,y), Text="String", LabelStyles=(List_Of_Styles))
Control_Handle = CreateTextBox(Parent = Window_Handle, Location=(x,y), Size=(x,y), Text="String", TextBoxlStyles=(List_Of_Styles))

And bind events like this;

BindEvent(Control_Handle, EventName = TB_EVENT_MOUSE_HOVER, CallBackFunction = "NameOfFunction")

looks like python style. But its an easy one.

primo
02-12-2017, 20:00
i agree with Petr:
add label "lbl", "This is a label" to frmMain
we will never forget this syntax, or may be :
add label "lbl", w,h, x,y, "This is a label", to frmMain

so it is a kind of a wrapper to the complex syntax, which will stay available (as i understand from Eros reply somewhere) .