I was wondering if there would be an interest in an easy to use (freeware) GUI engine for ThinBasic ?
Something which Eros could integrate into the ThinBasic engine.
The idea would be to take an early version of my EZGUI engine (1.0 or 2.0), remove anything which would not that useful to the average user and create a free GUI engine which Eros could add to the ThinBasic language. The GUI command set is much easier to use than Dialog style API's and it has its own event engine, rather than have to deal with a Dialog Procedure. It is also extendable so one can still integrate the WIN32 API with it.
The EZGUI 1.0 DLL is only 122 KB in size and the 2.0 DLL is only 186 KB in size.
To see how one would code forms and controls here is a simple example of a form with a Turtle graphic (vector based macro language) control which changes the image each time a button is clicked:
DECLARE SUB FORM1_BUTTON1_Click() ' GLOBAL NoCloseFlag& ' SUB EZ_Main(VerNum&) EZ_Color -1, -1 EZ_Form "FORM1", "", "Your Dialog", 0, 0, 60, 20, "C" END SUB ' SUB EZ_DesignWindow(FormName$) LOCAL D$ SELECT CASE FormName$ CASE "FORM1" EZ_Color-1,-1 EZ_UseFont -1 EZ_UseFont 4 EZ_Button 100, 2, 1.75, 10, 1.5, "Next Image", "T" EZ_Color 0, 30 EZ_Label 102, 2, 4, 10, 1.15, "X Coordinate", "CF" EZ_Label 103, 2, 6, 10, 1.15, "Y Coordinate", "CF" EZ_Label 104, 15.5, .5, 40, 1.15, "Click On Turtle Control to get X/Y Coordinates !", "CF" EZ_Color 9, 17 EZ_UseFont 4 EZ_TurtlePicture 105, 15.5, 1.75, 40, 17, "V1,602,322;U0;F0;", "RS+" CASE ELSE END SELECT END SUB ' SUB EZ_Events(FormName$, CID&, CMsg&, CVal&, Cancel&) EXPORT ' CID& = Control ID or %EZ_Window (0) if Window event ' CMsg& = Control Event Message (Type) ' CVal& = Value: (ie. Scrollbar value) ' Cancel& = is for Closing a Window. Set Cancel& to -1 (True) to stop close LOCAL X&, Y& SELECT CASE FormName$ CASE "FORM1" SELECT CASE CID& CASE %EZ_Window IF CMsg&=%EZ_Close THEN IF NoCloseFlag& THEN Cancel&=1 END IF CASE 100 IF CMsg&=%EZ_Click THEN FORM1_BUTTON1_Click CASE 105 IF CMsg&=%EZ_Click THEN BEEP EZ_GetTurtleXY "FORM1", 105, X&, Y&, 100, 100 EZ_SetText "FORM1", 102, "X ="+STR$(X&) EZ_SetText "FORM1", 103, "Y ="+STR$(Y&) END IF IF CMsg&=%EZ_DClick THEN MSGBOX "You Double Clicked Turtle Control" END IF IF CMsg&=%EZ_CtrlError THEN MSGBOX "Error Processing Turtle Control Text" END IF CASE ELSE END SELECT CASE ELSE END SELECT END SUB ' SUB FORM1_BUTTON1_Click() LOCAL D$, T&, D1$, M$, P2$, A&, D2$ STATIC CT& SELECT CASE CT& CASE 0 ' Draw Lines D$="V1,602,322;" D$=D$+"U0;F0;P3;M10,10;L590,10;P10;W30;M20,40;L580,40;W4;P5;M10,70;L100,90,90,4;" D$=D$+"P6;M220,70;W20;L100,150,120,3;P1;W15;M320,70;L40,90,45,8;" D$=D$+"P3;W12;M500,100;L40,180,60,6;P1;W15;M10,210;L110,310;M110,210;L10,310;" D$=D$+"P9;W50;M200,210;L570,290;P13;L200,250;P14;L400,290;" D$=D$+"P2;W15;M530,200;L45,180,30,12,2;W3;M50,47;P1;L20,45,90,36,1;" CASE 1 ' DRAW CIRCLES D$="V1,602,322;" D$=D$+"U0;P1;F0;B4;W8;M10,10;E300,200,0;H13;M50,50;P2;W3;E300,200;H0;P2;M340,10;B14;W15;E100,100;" D$=D$+"H3;P2;W1;M360,130;B10;E80,120;H0;W5;P1;B3;M10,210;E400,100,4;M450,30;E121,121,7;" D$=D$+"M480,200;E100,100,17;M495,215;E70,70,12;W3;B15;M503,220;E15,15;M543,220;E15,15;" D$=D$+"X1;M530,45;P1;B5;E120,80;P2;B16;E60,40;" CASE 2 ' Draw Rectangles D$="V1,602,322;" D$=D$+"U0;P1;F0;B4;W4;M10,10;R300,200;H13;M50,50;P2;W3;R300,200;H0;P6;M400,10;B3;W15;R100,100,10,10;" D$=D$+"H3;P2;W1;M400,130;B10;R80,120;H0;W2;P1;B15;M10,270;R500,45,100,20;" CASE 3 REM Gradient L TO R D$="V1,602,322;" D$=D$+"P1;C0,0,128;P2;C255,255,255;G1,2,0;" CASE 4 REM Gradient R TO L D$="V1,602,322;" D$=D$+"P1;C0,0,128;P2;C200,200,255;G1,2,1;" CASE 5 REM Gradient T TO B D$="V1,602,322;" D$=D$+"P1;C50,0,0;P2;C255,128,128;G1,2,2;" CASE 6 REM Gradient B TO T D$="V1,602,322;" D$=D$+"P1;C50,0,0;P2;C255,128,128;G1,2,3;" CASE 7 REM Gradient 3D V D$="V1,602,322;" D$=D$+"U0;P0;C0,0,96;P1;F0;" FOR T&=1 TO 10 M$="M"+STR$(T&*50)+",10;" P2$=STR$(T&+4) D1$="G1,"+P2$+",4,30,300;" D$=D$+M$+D1$ NEXT T& D$=D$+"X1;M301,161;G1,15,6,400,80;" CASE 8 REM Gradient 3D H D$="V1,602,322;" D$=D$+"U0;P0;C0,0,96;P1;F0;" FOR T&=0 TO 9 M$="M"+"10,"+STR$((T&*30)+10)+";" P2$=STR$(T&+5) D1$="G1,"+P2$+",6,580,26;" D$=D$+M$+D1$ NEXT T& CASE 9 D$="V1,500,500;U0;F3;P16;W1;B11;M25,25;R450,450;P2;B15;M50,50;E200,375;M350,90;G1,13,4,50,350;" CASE 10 EZ_DisableC "FORM1", 100 NoCloseFlag&=1 ' prevents Closing Form by clicking X button D$="V1,2408,880;U0;F0;" D$=D$+"Z1;O6,10;O1,16;O2,3;O5,1;P5;W50;M240,240;L170,180,30,12,2;" FOR A&=1 TO 100 D2$="A"+STR$(A&)+";"+D$ EZ_SetText "FORM1", 105, D2$ EZ_DoEvents 100 SLEEP(25) NEXT A& D$="V1,400,300;U0;F0;" D$=D$+"X1;Z1;O6,6;M200,150,60,360;P3;B11;E80,60;" FOR A&=1 TO 100 D2$="A"+STR$(A&)+";"+D$ EZ_SetText "FORM1", 105, D2$ EZ_DoEvents 100 SLEEP(25) NEXT A& D$="V1,602,322;U0;F0;" EZ_EnableC "FORM1", 100 CASE ELSE END SELECT CT&=CT&+1 IF CT&>10 THEN CT&=0 EZ_SetText "FORM1", 105, D$ NoCloseFlag&=0 END SUB
The GUI engine only requires three subroutines:
EZ_Main
Where the app starts (must create at least one form here)
EZ_DesignWindow
When EZ_Form is called to create a Form, the engine generates a call to the EZ_DesignWindow routine (passing the forms name in all CAPs) where you then add things like menu items, controls, etc. It is comparable to adding controls in an SDK style window in its WM_CREATE message.
EZ_Events
When EZ_Main finishes, the GUI engine runs its own internal message loop (so app does not need one) waiting for some user input. When an event occurs, it generates a call to the EZ_Events routine passing info about the event. It passes the name of the Form and the Controls ID (forms have an ID of zero) so you know what generated the event. The CMsg& parameter passes a constant value which is the event ID (the GUI engine has a number of built in events). The CVal& parameter is a value the event may pass (ie. a scrollbar passes its new position here) and Cancel& is a return variable where you can pass back a value if the event allows you to cancel the default processing of the event (ie. %EZ_Close for a form can be cancelled).
When an event needs to pass more complex data (only a few events do this) the GUI engine passes a pointer in CVal& instead and there will be a companion command for the event where this value can be pased and multiple values returned back.
No dialog procedures are required.
Forms are defined by a name, rather than a window handle.
Controls are defined by a control ID.
So no global variables are needed to store window handles.
Coordinates are character based (size of system font character) which for 96 DPI is an 8 x 16 pixel unit. Character coordinates are floating point so they can still define down to the pixel accuracy, unlike Dialog units which can not. There are functions for converting between character units and pixels.
FG and BG colors are simply defined by RGB value and then references by index, just like DOS Basic colors. The GUI engine handles all the brush and pen stuff and no need to clean up afterwards. Color indexes 0 to 15 match the DOS Basic colors. Color indexes 16 to 31 are pastel versions of the first 16 colors. This gives a total of 21 predefined colors. You can define more color indexes beyond this though.
Fonts are handled by the GUI engine. They too are defined like colors and then referenced by an index number. Fonts 0 to 5 are predefined to system predefined fonts. After that you can define as many of your own fonts as you like (over 700 can be defined). Again the GUI engine handles the font handles and no need to use them. Simply reference the font by its index
This is the events supported by EZGUI 2.0 runtime engine:
- %EZ_Close
- %EZ_Click
- %EZ_DClick
- %EZ_Focus
- %EZ_NoFocus
- %EZ_Disable
- %EZ_Change
- %EZ_Timer
- %EZ_ToolTip
- %EZ_UnKnown
- %EZ_Command ' used for unknown WM_COMMAND API notification messages
- %EZ_Notify ' used for unknown WM_NOTIFY API notification messages
- %EZ_Redraw
- %EZ_CtrlError
- %EZ_PrintError
- %EZ_AllowEdit
- %EZ_KeyDown
- %EZ_KeyUp
- %EZ_KeyPress
- %EZ_SysKeyDown
- %EZ_SysKeyUp
- %EZ_SysKeyPress
- %EZ_FreeNow
- %EZ_LButtonDown
- %EZ_LButtonUp
- %EZ_LButtonDC
- %EZ_MButtonUp
- %EZ_RButtonUp
- %EZ_SubClass
- %EZ_Drag ' visual design drag engine
- %EZ_Drop ' visual design drag engine
- %EZ_Size
- %EZ_DropFiles
- %EZ_NoDrag
- %EZ_DragItem
- %EZ_Move
- %EZ_Dropping ' visual design drag engine
Hi Chris,
I wouldn't mind giving it shot with Script BASIC using DLLC (FFI) under Windows. I'm pretty happy with IUP and it's cross platform. I'll keep an eye on this thread to see if a DLL gets posted to try.
Thanks for the offer and I'm glad to see you diversifying from being PowerBASIC centric.
John
Bookmarks