View Full Version : thinBasic Visual Designer Code Generator
ErosOlmi
02-05-2012, 00:54
Ok, some vaporware to show in thinBasic world.
It is some time I'm working on next thinBasic version 1.9.
I've already added many new features to the language, many new options to SDK engine regarding Module Classes, and now I've started to work to a very rough visual designer.
I've used a quite old piece of code from PB forum public released by "JULES MARCHILDON" (I will add merit in executable when it will released) changing and adapting it to work under all latest Windows Versions including Windows 8.
So far I've added few controls, control property dialog, form properties, tab order dialog, possibility to save forms in binary format in order to be able to save and re-open when needed.
At the end, the visual designer directly produces thinBasic source code ready to be pasted into a thinBasic script and be executed.
I've intention to release Visual Designer as PowerBasic source code so everyone will be able to participate in development.
The idea is to finish beta version able to work as simple thinBasic code generator but later I will try to add events to forms and controls in order to add thinBasic source code directly into designer and produce real applications and not just skeleton of scrips.
Anyway, a video is worth 1000 words.
http://www.youtube.com/watch?v=pyE8N2Ew890
ErosOlmi
02-05-2012, 07:14
That is not automatic.
What is best is usually a programmer by programmer decision and is valid only for that programmer.
So, the most there will be on the table the better for thinBasic programmers.
Petr Schreiber
02-05-2012, 09:32
Eros,
this looks really great, it would be big help in form intensive applications. The controls are intuitive, I like it very much!
My mind is already full of wild ideas:
Visual designer itself
add support for RESIZE of controls (anchors)
use Begin ControlID/End ControlID blocks in generated code for equates
add option to generate code for dialog, which is not in TBMain (code for secondary dialog, for example to be placed to other thinBASIC Unit)
add help label to the form, where you pick the styles - beginners are usually not familiar with Win32 styles
something to think about - preserve style definition using Win32 styles, or go the route of "general" styles implemented via Win32 behind the curtains?
define the format of forms in XML -> possible use by modules, see below
Module related to visual designer - classic conservative approach
ability to save/load the forms from XML(or other format) to script.
So something like hDlg = Module_CreateForm( sPathToFile )
The benefit is that the code does get simpler, without 100 lines of dialog definition
the equates could be then defined from module via thinBASIC_AddEquate without need to be explicitly named in code
Module related to visual designer - OOP style
As ThinBASIC modules in 1.9.0.0 will have great power, I think it would be possible to design standalone module, allowing to handle forms via OOPish syntax. Imagine:
DIM myForm AS TBForm = new TBForm("Form1.bin") ' -- Constructor loads the form definition from file
myForm.ShowModal( EventProcedure ) ' -- Classic method call, passes callback function name as parameter, invokable internally using thinBasic_FunctionSimpleCall_ByPtr
...
myForm.Edit1.Text = "Hello" ' -- Now this is a bit more complex, but not that much - each control has its equate stored in the definition file, so via the approach which is used for method chains in Betas, when I find symbol, which is not method, I look if it is not name of the control (based on loaded data), and then behave accordingly
Petr
ErosOlmi
02-05-2012, 11:23
eh eh Petr,
I know your mind is always travelling fast and in different directions at the same time. And ... I LIKE IT :dance1:
At the moment all is very rough:
Visual Designer Power Basic code is quite copy/paste mode from different sources. I need to better organize, "modularize" and beautify it before I can release it
form can be saved but actually only in binary format. I will sure convert it into XML format
thinBasic generated code is quite bad but the beauty is that it can be "modulated" in the sense we can add different "code generators" dynamically.
In any way next generated code will be much better
I still need to add all main controls. After that I will add thinBasic special controls
I definitely want to add possibility to add events (in form and controls) and add thinBasic source code to events directly into Visual Designer
I will also add possibility to execute thinBasic code directly from Visual Editor without the need to copy/past code into thinAir. Anyway all possibilities will be available.
So, a lot to work on but seems exciting looking at the possibilities.
Very soon I will release PowerBasic Visual Designer source code into thinBasic SVN server
Ciao
Eros
Eros,
The preview looked good. I came to the forum today to read some older threads about making Dialogs and Forms. So it was nice to see what you have planned for thinBasic's future.
Lance
Looks really nice Eros! Such a good language needed a good form designer and your plans for the future sound really great!
Hello:
This is my first post. I am a retired tech writer who enjoys programming games and things for my grandson and I have just discovered thinBASIC (GREAT!!). I have been playing around with thinFORM and have discovered that thinFORM draws its control to a fixed height that exceeds the size of the NetBook screen.Looking at the code it looke like 668 pixels and the netbook is only 576 pixels high.
I can look at the thinFORM code and it looks like an easy fix is to have all of the buttons at the bottom of the control appear on another floating control. (as in older versions of GIMP with multiple g=floating controls and palettes).
Would that be a reasonable approach to fixing the problem?
Thanks
Terry Ward
taward@elp.rr.com
ErosOlmi
08-05-2012, 06:31
Hello Terry and welcome to thinBasic community forum.
The new Visual Designer we are talking in this thread is something that still has to be released.
This thread is just a preview (we are under vaporware forum :) ) of what I'm working on and was shown in order to let thinBasic user know about it and get some feedback/suggestions/impressions.
thinForm, instead, was a user project developed directly in thinBasic and is available as source code. You can change it in order to adapt to your needs.
Ciao
Eros
i never tried the visual designer (in the Tools menu) before, but now i have tried it and it is realy something good and makes the life easier.
there is only one note, i choose font size for the textbox and the button to be "Arial Black", 12 but albeit reflected on the form during the design it does not reflected in the code, the code generated by the vd is:
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'thinAir Visual Designer
'------------------------------------------------------------------------------
' Project: Visual Designer generated code
' File: Your file name
' Created: On 06-25-2017 at 15:08:47
'------------------------------------------------------------------------------
'---Needed thinBasic modules
Uses "UI"
'---Controls IDs---
Begin ControlID
%IDC_BUTTON_1
%IDC_EDIT_1
End ControlID
'------------------------------------------------------------------------------
' Main thinBasic function
'------------------------------------------------------------------------------
Function TBMain() As Long
MainWindow_Create(%HWND_DESKTOP)
End Function
'------------------------------------------------------------------------------
' Create main Window
'------------------------------------------------------------------------------
Function MainWindow_Create(ByVal hParent As Long) As Long
Local hDlg As Long
Local hFont As Long
Local lStyle As Long
Local lStyleEx As Long
lStyle = _
%WS_DLGFRAME | _
%WS_CAPTION | _
%WS_SYSMENU | _
%WS_OVERLAPPEDWINDOW | _
%WS_CLIPCHILDREN | _
%WS_CLIPSIBLINGS | _
%DS_CENTER
lStyleEx = 0
Dialog New Pixels, hParent, "Form1", -1, -1, 476, 230, lStyle, lStyleEx, To hDlg
hFont = Font_Create("MS Sans Serif", 8)
Dialog Send hDlg, %WM_SETFONT, hFont, 0
Control Add Button, hDlg, %IDC_BUTTON_1, "Run", 16, 24, 88, 72, %WS_CHILD Or %WS_CLIPSIBLINGS Or %WS_TABSTOP Or %WS_VISIBLE Or %BS_PUSHBUTTON, 0
Control Add Textbox, hDlg, %IDC_EDIT_1, "Edit1", 184, 32, 256, 184, %WS_CHILD Or %WS_CLIPSIBLINGS Or %WS_TABSTOP Or %WS_VISIBLE Or %WS_VSCROLL Or %ES_AUTOVSCROLL Or %ES_MULTILINE Or %ES_WANTRETURN, %WS_EX_CLIENTEDGE Or %WS_EX_LEFT
Dialog Show Modal hDlg, Call MainWindow_Proc
Win_DeleteObject hFont
End Function
'------------------------------------------------------------------------------
' Main WIndow CallBack handler
'------------------------------------------------------------------------------
CallBack Function MainWindow_Proc() As Long
Local pNMHDR As NMHDR Ptr
Local PageNo As Long
Local hFontTab As Long
Select Case (CBMSG)
Case %WM_INITDIALOG
Case %WM_COMMAND
Select Case LOWRD(CBWPARAM)
Case %IDOK
Case %IDCANCEL
End Select
Case %WM_NOTIFY
Case %WM_DESTROY
End Select
End Function
in any case this is trivial issue relative to benifits of this vd
so i have added
hFont = Font_Create("Arial Black", 12)
Dialog Send hDlg, %WM_SETFONT, hFont, 0
and
Control Send hDlg, %IDC_BUTTON_1, %WM_SETFONT, hFont, 0
Control Send hDlg, %IDC_EDIT_1, %WM_SETFONT, hFont, 0
'------------------------------------------------------------------------------
'thinAir Visual Designer
'------------------------------------------------------------------------------
' Project: Visual Designer generated code
' File: Your file name
' Created: On 06-25-2017 at 14:45:20
'------------------------------------------------------------------------------
'---Needed thinBasic modules
Uses "UI"
'---Controls IDs---
Begin ControlID
%IDC_BUTTON_1
%IDC_EDIT_1
End ControlID
'------------------------------------------------------------------------------
' Main thinBasic function
'------------------------------------------------------------------------------
Function TBMain() As Long
MainWindow_Create(%HWND_DESKTOP)
End Function
'------------------------------------------------------------------------------
' Create main Window
'------------------------------------------------------------------------------
Function MainWindow_Create(ByVal hParent As Long) As Long
Global hDlg As Long
Local hFont As Long
Local lStyle As Long
Local lStyleEx As Long
lStyle = _
%WS_DLGFRAME | _
%WS_CAPTION | _
%WS_SYSMENU | _
%WS_OVERLAPPEDWINDOW | _
%WS_CLIPCHILDREN | _
%WS_CLIPSIBLINGS | _
%DS_CENTER
lStyleEx = 0
Dialog New Pixels, hParent, "Form1", -1, -1, 476, 230, lStyle, lStyleEx, To hDlg
'hFont = Font_Create("MS Sans Serif", 8)
hFont = Font_Create("Arial Black", 12)
Dialog Send hDlg, %WM_SETFONT, hFont, 0
Control Add Button, hDlg, %IDC_BUTTON_1, "Run", 16, 24, 88, 72, %WS_CHILD Or %WS_CLIPSIBLINGS Or %WS_TABSTOP Or %WS_VISIBLE Or %BS_PUSHBUTTON, 0
Control Add Textbox, hDlg, %IDC_EDIT_1, "Edit1", 184, 32, 256, 184, %WS_CHILD Or %WS_CLIPSIBLINGS Or %WS_TABSTOP Or %WS_VISIBLE Or %WS_VSCROLL Or %ES_AUTOVSCROLL Or %ES_MULTILINE Or %ES_WANTRETURN, %WS_EX_CLIENTEDGE Or %WS_EX_LEFT
Control Send hDlg, %IDC_BUTTON_1, %WM_SETFONT, hFont, 0
Control Send hDlg, %IDC_EDIT_1, %WM_SETFONT, hFont, 0
Dialog Show Modal hDlg, Call MainWindow_Proc
Win_DeleteObject hFont
End Function
'------------------------------------------------------------------------------
' Main WIndow CallBack handler
'------------------------------------------------------------------------------
CallBack Function MainWindow_Proc() As Long
Local pNMHDR As NMHDR Ptr
Local PageNo As Long
Local hFontTab As Long
Select Case (CBMSG)
Case %WM_INITDIALOG
Case %WM_COMMAND
Select Case CBCTL
Case %IDC_BUTTON_1
Control Append Text hDlg, %IDC_EDIT_1, $CRLF & "big font size "
End Select
Select Case LOWRD(CBWPARAM)
Case %IDOK
Case %IDCANCEL
End Select
Case %WM_NOTIFY
Case %WM_DESTROY
End Select
End Function
in any case this is trivial issue relative to benifits of this vd
I think VD needs some improvements also. Assume that you create a simple gui today and get the code. You, then added some more functionalities to that gui and thus made an application with that code and bundled it and sent to friend. Next day he calls you and told that he needs some extra features in that app. Some trivial changes. You agreed and changed the work you have done in VD. VD then creates the code again but how would you include in your app ? You need to manually search for changes in new code( which VD creates now) copy the newly created lines only to your existing code. Is this a problem. So i think VD can read existing thinbasic code and it shouldn't change the existing code you have added.
I think VD needs some improvements also. Assume that you have create a simple gui today and get the code. You, then added some more functionalities to that gui and thus made an application with that code and bundled it and sent to your friend. Next day he calls you and told that he needs some extra features in that app. Some trivial changes. You agreed and changed the work you have done in VD. VD then creates the code again but how would you include in your app ? You need to manually search for changes in new code( which VD creates now) copy the newly created lines only to your existing code. Is this a problem. So i think VD can read existing thinbasic code and it shouldn't change the existing code you have added.
Note: Support for unicode in VD is another feature.
in the old time in the days of visual basic 6 it has the best VD and the easiest . it was a usual practice for me when needing to solve simple tasks , to draw a button quickly and a small text box, then double clicking on the button and add as an example:
for i=1 to 1000
t=t+i
next i
Text1.text = t
and run it without saving it to get 500500 in the text box
now i have noticed that Rapid-Q (like vb6) is a compiler, (i though before it is like VB6 (not a real compiler) it has a VD, there is a new version here http://rapidq.phatcode.net/download/ last update 9/27/2016)
since its size is 25 MB then certainly it has something . i will try it later
EDIT: they say: The program is made up of byte-code with its own interpreter attached. so why they say in another page it is compiler !!
Hi primo,
Rapidq is a nice tool. Actually, i am searching for some good visual designers to club in my favorite scripting languages i.e AutoIt and thinBasic.
What i am planning is to make a translator program which translates the code from visual designer into my favorite scripting languages.
I have experimented with ResEdit. But it is not supporting unicode. Except that, it is a nice VD to work with. you can easily translate the code to your desired languages. Do you know anything like ResEdit ? If so, please suggest.
kcvinu, there was something here http://www.thinbasic.com/community/showthread.php?12017-thinBASIC-IUP
but it was deleted.
https://en.wikipedia.org/wiki/IUP_(software)
Eros refered to The Phoenix Visual Form Designer http://www.thinbasic.com/community/showthread.php?8235-IDE-Phoenix
albeit it is commercial but they have a demo version for powerbasic .
i don't know about ResEdit, they said it is for apple mac https://en.wikipedia.org/wiki/ResEdit
Petr Schreiber
23-07-2017, 09:28
Hi,
in my opinion, the direction which could avoid the issue that was mentioned - regenerating code affects changes already made - would be saving the dialog in some data file, totally separate from code.
This way, you could:
- re edit the layout anytime
- in script, you would just use something like DIALOG NEW FROMFILE "Dialog.xml"
What do you think about it?
Petr
Hi Petr,
DIALOG NEW FROMFILE "Dialog.xml" will be a great idea, i don't see FROMFILE keyword but in the LL_FROMFILE only
so this is like loading GUI_EmptyScript.xml template
but isn't this like #INCLUDE "Dialog.tbasic" what is the benifits of using xml files , i never used xml files in any project, will read something about it.
Petr Schreiber
24-07-2017, 07:04
Primo,
mentioning XML was just example - it does not have to be XML, could be JSON or other general purpose structured storage format.
The benefit would be separation of GUI design from code which controls it.
There is no FROMFILE option for DIALOG NEW now, but I thought it could be good for future development.
Petr
DirectuX
24-11-2018, 11:17
The benefit would be separation of GUI design from code which controls it.
There is no FROMFILE option for DIALOG NEW now, but I thought it could be good for future development.
I share these ideas, currently I've put all GUI related code in an include. Callback functions contain just calls to other functions.
mentioning XML was just example - it does not have to be XML, could be JSON or other general purpose structured storage format.
XML is great for machines, thinBasic code is human-readable. How do you conceive the usage flexibility that exist currently with thinbasic ?