Author Topic: JADE GUI  (Read 8459 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
JADE GUI
« 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


Code: [Select]

#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


Code: [Select]
#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
« Last Edit: November 10, 2013, 12:33:53 AM by John »

kryton9

  • Guest
Re: JADE GUI
« Reply #1 on: November 10, 2013, 12:54:01 AM »
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.

Offline AIR

  • Moderator
  • Posts: 932
  • Coder
Re: JADE GUI
« Reply #2 on: November 10, 2013, 07:45:31 AM »
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.


Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: JADE GUI
« Reply #3 on: November 10, 2013, 10:46:12 AM »
Quote
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++
IUP Mac
« Last Edit: November 10, 2013, 09:48:02 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: JADE GUI
« Reply #4 on: November 10, 2013, 01:32:27 PM »
JADE - wxWidgets - help viewer


Code: [Select]


/* 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.
« Last Edit: November 10, 2013, 01:38:49 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: JADE GUI
« Reply #5 on: November 10, 2013, 09:15:17 PM »
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.


Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: JADE GUI
« Reply #6 on: November 01, 2018, 03:51:09 PM »
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?
« Last Edit: November 01, 2018, 04:16:31 PM by John »

Offline AIR

  • Moderator
  • Posts: 932
  • Coder
Re: JADE GUI
« Reply #7 on: November 01, 2018, 07:50:12 PM »
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...

Quote from: John
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.