AllBASIC Forum
BASIC Developer & Support Resources => Translators => JADE => Topic started by: John on November 10, 2013, 12:31:25 AM
-
AIR has created a couple examples of using JADE with Qt and FLTK GUI tool kits.
JADE - Qt4 Tiny Times
(http://files.allbasic.info/JADE/qt4tt.png)
#include "../../jade.h"
#include "ui_tinytimes.h"
/* Needed for Center() Method */
#include <QStyle>
#include <QDesktopWidget>
class TT: public QMainWindow {
Q_OBJECT //REQUIRED!
public:
CONSTRUCTOR TT();
void Center();
private:
Ui::MainWindow ui;
private slots:
void BuildTable(QAbstractButton *button);
};
#include "tinytimes.moc" //REQUIRED!
CONSTRUCTOR TT::TT() :QMainWindow() DO
ui.setupUi(this);
ENDCONSTRUCTOR
SUB TT::Center() DO
this->setGeometry(QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,this->size(),qApp->desktop()->availableGeometry()));
ENDSUB
SUB TT::BuildTable(QAbstractButton *button) DO
DIM AS INT I;
DIM AS QString buf;
ui.listWidget->clear();
FOR (I = 1 TO I<11 STEP I++) DO
buf = QString("%1 %2 %3 %4 %5").arg(button->text()).arg(" X ").arg(QString::number(I)).arg(" = ").arg(QString::number(I*button->text().toInt()));
ui.listWidget->addItem(new QListWidgetItem(buf));
END
ENDSUB
MAIN
DIM AS QApplication app(argc, argv);
DIM AS TT PTR TinyTimes = new TT;
TinyTimes->Center();
TinyTimes->show();
RETURN app.exec();
ENDMAIN
JADE - FLTK GUI example
(http://files.allbasic.info/JADE/fltk.png)
#include "../jade.h"
#include "fltk.inc"
MAIN
DIM AS INT top = 40;
DIM AS WINDOW PTR win;
DIM AS INPUT PTR txtSource, PTR txtDest;
DIM AS BUTTON PTR btnSource, PTR btnDest;
win = new WINDOW(690,486,"FLTK Demo");
win->position((Fl::w() - win->w())/2, (Fl::h() - win->h())/2);
txtSource = new INPUT(20,top,540,26);
btnSource = new BUTTON(580,top,90,26,"Source");
txtDest = new INPUT(20,top+40,540,26);
btnDest = new BUTTON(580, top+40,90,26,"Dest");
win->show();
RETURN Fl::run();
ENDMAIN
-
AIR is a steam powered programming locomotive, wow! Can't keep up with how he is flying along. I tell you this project is going places with his tremendous energy and clear coding!
Thanks for the screenshots John and updates.
-
I'm going to do one more, using wxWidgets. The recurring theme, as far as GUI Toolkits I'm testing go, is that they're cross-platform.
@John: Try your hand at an IUP demo when you get a chance. Since IUP on Mac requires X11, I won't be doing one. Still, I think it would be useful to see that.
A.
-
IUP is a multi-platform toolkit for building graphical user interfaces. It offers APIs in three basic languages: C, Lua and LED.
I was planning to convert some of the IUP example with C BASIC but that seems on hold at the moment until Charles has time to move that project forward. I'm working on a ScriptBasic extension module interface to the CERN CINT API. (all platforms) This will expand SB's abilities to dynamic JIT compiling of C source among other features the CINT interface offers.
Update
IUP C++ (http://www.tecgraf.puc-rio.br/iup/en/guide.html#cpp)
IUP Mac (https://github.com/phasis68/iup_mac)
-
JADE - wxWidgets - help viewer
(http://files.allbasic.info/JADE/wxhelp.png)
/* This is how Im creating a MAC application bundle while testing
Uncomment this if compiling under MacOS
$onexit "rm -rf $FILE$.app && mkdir -p $FILE$.app/Contents/MacOS && cp $FILE$ $FILE$.app/Contents/MacOS && open $FILE$.app"
*/
#include "jade.h"
#include <wx/wx.h>
#include <wx/image.h>
#include <wx/wxhtml.h>
#include <wx/fs_zip.h>
#include <wx/log.h>
#include <wx/filedlg.h>
class MyApp: public wxApp {
// override base class virtuals
// ----------------------------
public:
virtual bool OnInit();
virtual int OnExit();
/* Sub that Responds to idle event */
void OnIdle(wxIdleEvent& event);
private:
bool m_exitIfNoMainWindow;
wxHtmlHelpController* help;
wxFileName fName;
DECLARE_EVENT_TABLE()
};
/* Connect to idle event */
BEGIN_EVENT_TABLE(MyApp, wxApp)
EVT_IDLE(MyApp::OnIdle)
END_EVENT_TABLE()
/* Implement the Application Object */
IMPLEMENT_APP(MyApp)
/* Initialize Application */
FUNCTION BOOL MyApp::OnInit() DO
INT i;
/* Used as Exit status flag */
m_exitIfNoMainWindow = FALSE;
/* Assign the name of the HelpFile to the wxFileName object */
fName.Assign( wxT("book.htb") );
/* Dont exit immediately when app window is closed */
#ifdef __APPLE__
SetExitOnFrameDelete(false);
#endif
/* Initialize all available image handlers */
wxInitAllImageHandlers();
/* Enable virtual Zip FileSystem */
wxFileSystem::AddHandler(new wxZipFSHandler);
/* Set the Application Name (NOT SHOWN ON TITLEBAR!) */
SetAppName( wxT("Help Viewer") );
/* Initialize the HelpController Object */
help = new wxHtmlHelpController(wxHF_DEFAULT_STYLE|wxHF_OPEN_FILES);
/* Add the HelpFile to the HelpController */
help->AddBook(fName);
/* Show the HelpFile */
help->DisplayContents();
/* Set the Help windows as topmost */
SetTopWindow( help->GetFrame() );
/* Set the exit flag to true */
m_exitIfNoMainWindow = TRUE;
RETURN TRUE;
ENDFUNCTION
/* Idle Event */
SUB MyApp::OnIdle(wxIdleEvent &event) DO
/* Exit if Window is closed */
IF (m_exitIfNoMainWindow AND NOT GetTopWindow()) THEN
ExitMainLoop();
ENDIF
/* Sort of like DoEvents */
event.Skip();
event.RequestMore();
ENDSUB
/* Called when Application Exits */
FUNCTION INT MyApp::OnExit() DO
/* Delete the HelpController Object */
delete help;
RETURN 0;
ENDFUNCTION
I can appreciate the irony of this example.
-
I seemed to be the only one posting screen shots for JADE GUI.
I've only seen a Pong from AIR and Kent and that was only by request.
-
AIR,
I know this thread is pretty old but I would like to see a JADE and IUP connection. I'm thinking that breaking up the JADE.inc into core and extension modules may be a better way to go.
Can you do a SB LIKE / JOKER function(s) in JADE?
-
AIR,
I know this thread is pretty old but I would like to see a JADE and IUP connection. I'm thinking that breaking up the JADE.inc into core and extension modules may be a better way to go.
Give it a shot; I don't use IUP (no macOS support) so I wouldn't be able to implement it...
Can you do a SB LIKE / JOKER function(s) in JADE?
If you look at match.c in the SB source, you'll see that this is not a trivial thing to implement from scratch. There's a lot of parsing going on in that module.
AIR.