Turbo Vision
Feb 16, 2019 13:36:16 GMT 1
Post by Pjot on Feb 16, 2019 13:36:16 GMT 1
All,
Lately I have been searching (again) for some kind of universal GUI which can run on a variety of platforms.
In this search, the good old Turbo Vision library from Borland came up. It seems to have been released under the Public Domain license in 1997. There is a very good port available on Sourceforge.
For fun, I have created a small program which can calculate your BMI (see below). It is just a first attempt to get a basic understanding of the widgets. If you feel adventurous, obtain the latest BaCon beta from the fossil repo, then install the latest Turbo Vision library and it should work.
Preliminary evaluation - advantages:
Lately I have been searching (again) for some kind of universal GUI which can run on a variety of platforms.
In this search, the good old Turbo Vision library from Borland came up. It seems to have been released under the Public Domain license in 1997. There is a very good port available on Sourceforge.
For fun, I have created a small program which can calculate your BMI (see below). It is just a first attempt to get a basic understanding of the widgets. If you feel adventurous, obtain the latest BaCon beta from the fossil repo, then install the latest Turbo Vision library and it should work.
Preliminary evaluation - advantages:
- Nostalgic look and feel which fits perfectly in the BaCon ecology
- Ported to many platforms, some of which are very exotic
- Runs well in graphical mode and also in text mode
- Actively maintained
- Documentation is hard to find
- We're stuck with C++ syntax (yuch!! - but this is a matter of taste)
In any case, it could be interesting to use this toolkit.
BR
Peter
OPTION PARSE FALSE
PRAGMA COMPILER g++
PRAGMA LDFLAGS -lbacon++ -lrhtv
PRAGMA OPTIONS -I/usr/include/rhtvision -Wno-write-strings -Wno-pointer-arith
PRAGMA OPTIONS -DUses_TApplication -DUses_TStatusLine -DUses_TStatusDef -DUses_TStatusItem -DUses_TDeskTop -DUses_TKeys -DUses_MsgBox
PRAGMA OPTIONS -DUses_TEventQueue -DUses_TMenuBar -DUses_TSubMenu -DUses_TDialog -DUses_TButton -DUses_TInputLine -DUses_TLabel
PRAGMA INCLUDE <tv.h>
'----------------------------------------------------------------------------------------------------------------
CONST cmStartBMI = 200
RECORD dialogData
LOCAL weightData[10] TYPE char
LOCAL heightData[10] TYPE char
ENDRECORD
DECLARE bmiData TYPE dialogData_type*
'----------------------------------------------------------------------------------------------------------------
' Within a CLASS put plain C/C++ code
CLASS TVision : public TApplication
public:
TVision() : TProgInit( &TVision::initStatusLine, &TVision::initMenuBar, &TVision::initDeskTop)
{
bmiData = new dialogData_type;
bmiData->heightData[0] = 0;
bmiData->weightData[0] = 0;
}
static TStatusLine *initStatusLine(TRect);
static TMenuBar *initMenuBar(TRect);
virtual void handleEvent(TEvent&);
void newDialog();
ENDCLASS
'----------------------------------------------------------------------------------------------------------------
FUNCTION TVision::initMenuBar(TRect r) TYPE TMenuBar*
r.b.y = r.a.y + 1
RETURN new TMenuBar( r, \
*new TSubMenu( "~F~ile", kbAltF )+ \
*new TMenuItem( "~S~tart", cmStartBMI, kbAltS, hcNoContext, "Alt-S" )+ \
newLine()+ \
*new TMenuItem( "E~x~it", cmQuit, cmQuit, hcNoContext, "Alt-X" ))
ENDFUNCTION
'----------------------------------------------------------------------------------------------------------------
FUNCTION TVision::initStatusLine(TRect r) TYPE TStatusLine*
r.a.y = r.b.y - 1
RETURN new TStatusLine( r, \
*new TStatusDef( 0, 0xFFFF ) + \
*new TStatusItem( "~Alt-X~ Exit", kbAltX, cmQuit ) )
ENDFUNCTION
'----------------------------------------------------------------------------------------------------------------
SUB TVision::newDialog()
LOCAL dlg TYPE TDialog*
LOCAL dflt, widget TYPE TView*
LOCAL resp TYPE short
LOCAL w, h TYPE FLOATING
dlg = new TDialog(TRect(20, 4, 50, 16), "BMI Calculation" )
IF dlg THEN
dlg->insert(new TButton(TRect(2, 9, 14, 11), "~S~how BMI", cmOK, bfDefault))
dlg->insert(new TButton(TRect(18, 9, 28, 11), "~C~ancel", cmCancel, bfNormal))
dflt = new TInputLine(TRect(3, 3, 26, 4), 10)
dlg->insert(dflt)
dlg->insert(new TLabel(TRect(2, 2, 26, 3), "Enter your weight (kg): ", dflt))
widget = new TInputLine(TRect(3, 6, 26, 7), 10)
dlg->insert(widget)
dlg->insert(new TLabel(TRect(2, 5, 26, 6), "Enter your height (cm): ", widget))
dlg->setData(bmiData)
' Set focus to first input dialog
dflt->select()
resp = deskTop->execView(dlg)
IF resp <> cmCancel THEN
dlg->getData(bmiData)
' Calculate
w = VAL(bmiData->weightData)
h = VAL(bmiData->heightData)/100
' This is a message box with arguments like printf
messageBox(mfInformation|mfOKButton, "Your BMI is: %g", w/(h*h))
ENDIF
ENDIF
destroy(dlg)
ENDSUB
'----------------------------------------------------------------------------------------------------------------
SUB TVision::handleEvent(TEvent& event)
TApplication::handleEvent(event)
IF event.what = evCommand THEN
SELECT event.message.command
CASE cmStartBMI
newDialog()
DEFAULT
EXIT SUB
ENDSELECT
clearEvent(event)
ENDIF
ENDSUB
'----------------------------------------------------------------------------------------------------------------
TVision myApp
myApp.run()