include("wincontrolworks") include('create_makefile') func doStart gvar(BLK_BODY, BLK_PRIV, BLK_SLOT, BLK_MTD, CUR_CLASS, BLK_INIT, BLK_LOC, BLK_INC, BLK_SIG, BLK_IDS, BLK_EVTB, BLK_TMRS, BLK_OBJS, BLK_OBJS_RULES, NEED_COMMA, NEED_COMMA_T) fvar(main) BLK_BODY = 'block.body' BLK_INC = 'block.include' BLK_IDS = 'block.ids' BLK_TMRS = 'block.timers' BLK_EVTB = 'block.evtab' BLK_PRIV = 'block.priv' BLK_SLOT = 'block.slot' BLK_MTD = 'block.mtd' BLK_INIT = 'block.init' BLK_LOC = 'block.local' BLK_OBJS = 'block.objects.decls' BLK_OBJS_RULES = 'block.objects.rules' main = 'minimal.cpp' NEED_COMMA = 0 NEED_COMMA_T = 0 block.reg(BLK_BODY) block.reg(BLK_INC) block.reg(BLK_IDS) block.reg(BLK_EVTB) block.reg(BLK_PRIV) block.reg(BLK_SLOT) block.reg(BLK_MTD) block.reg(BLK_INIT) block.reg(BLK_TMRS) block.reg(BLK_OBJS) block.reg(BLK_OBJS_RULES) block.reg(main) CUR_CLASS = 'MyFrame' block.select(BLK_BODY) event(onCreate) sys.initall() block.select(main) println('// ============================================================================') println('// declarations') println('// ============================================================================') println('// ----------------------------------------------------------------------------') println('// headers') println('// ----------------------------------------------------------------------------') println(' ') println('#include "wx/wxprec.h"') println(' ') println('// for all others, include the necessary headers (this file is usually all you') println('// need because it includes almost all "standard" wxWidgets headers)') println('#ifndef WX_PRECOMP') println('#include "wx/wx.h"') println('#endif') println(' ') block.copyhere(BLK_INC) println(' ') println('// ----------------------------------------------------------------------------') println('// resources') println('// ----------------------------------------------------------------------------') println(' ') println('// the application icon (under Windows and OS/2 it is in resources and even') println('// though we could still include the XPM here it would be unused)') println('#if !defined(__WXMSW__) && !defined(__WXPM__)') println('#include "../sample.xpm"') println('#endif') println('') println('class MyApp : public wxApp') println('{') println('public:') println(' // override base class virtuals') println(' // ----------------------------') println('') println(' // this one is called on application startup and is a good place for the app') println(' // initialization (doing it here and not in the ctor allows to have an error') println(' // return: if OnInit() returns false, the application terminates') println(' virtual bool OnInit();') println('};') println(' ') println('// Define a new frame type: this is going to be our main frame') println('class MyFrame : public wxFrame') println('{') println('public:') println(' // ctor(s)') println(' MyFrame(const wxString& title);') println(' ') println(' // event handlers (these functions should _not_ be virtual)') block.inclvl() block.copyhere(BLK_SLOT) block.declvl() println(' ') println('private:') println(' // any class wishing to process wxWidgets events must use this macro') println(' DECLARE_EVENT_TABLE()') block.inclvl() block.copyhere(BLK_PRIV) block.declvl() println('};') println('// ----------------------------------------------------------------------------') println('// constants') println('// ----------------------------------------------------------------------------') println('// IDs for the controls and the menu commands') println('enum') println('{') block.inclvl() block.copyhere(BLK_IDS) block.declvl() println(' ') println('};') println(' ') println('// IDs for the timers') println('enum') println('{') block.inclvl() block.copyhere(BLK_TMRS) block.declvl() println(' ') println('};') println(' ') println('// ----------------------------------------------------------------------------') println('// event tables and other macros for wxWidgets') println('// ----------------------------------------------------------------------------') println(' ') println('// the event tables connect the wxWidgets events with the functions (event') println('// handlers) which process them. It can be also done at run-time, but for the') println('// simple menu events like this the static method is much simpler.') println(' ') println('BEGIN_EVENT_TABLE(MyFrame, wxFrame)') block.inclvl() block.copyhere(BLK_EVTB) block.declvl() println('END_EVENT_TABLE()') println(' ') println('// Create a new application object: this macro will allow wxWidgets to create') println('// the application object during program execution (it is better than using a') println('// static object for many reasons) and also implements the accessor function') println('// wxGetApp() which will return the reference of the right type (i.e. MyApp and') println('// not wxApp)') println('IMPLEMENT_APP(MyApp)') println(' ') println('// ============================================================================') println('// implementation') println('// ============================================================================') println(' ') println('// ----------------------------------------------------------------------------') println('// the application class') println('// ----------------------------------------------------------------------------') println(' ') println('// "Main program" equivalent: the program execution "starts" here') println('bool MyApp::OnInit()') println('{') println(' // call the base class initialization method, currently it only parses a') println(' // few common command-line options but it could be do more in the future') println(' if ( !wxApp::OnInit() )') println(' return false;') println(' ') println(' // create the main application window') println(' MyFrame *frame = new MyFrame(',Caption,');') println(' ') println(' // and show it (the frames, unlike simple controls, are not shown when') println(' // created initially)') println('frame->Show(true);') println(' ') println(' // success: wxApp::OnRun() will be called which will enter the main message') println(' // loop and the application will run. If we returned false here, the') println(' // application would exit immediately.') println(' return true;') println('}') println(' ') println('// ----------------------------------------------------------------------------') println('// main frame') println('// ----------------------------------------------------------------------------') println(' ') println('// frame constructor') println('MyFrame::MyFrame(const wxString& title)') println(': wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(', Width, ', ', Height, '))') println('{') println(' // set the frame icon') println(' SetIcon(wxICON(sample));') if(isndef(Opacity)) println(' SetTransparent(', Opacity, ');') end println(' ') block.inclvl() block.copyhere(BLK_LOC) block.copyhere(BLK_BODY) block.copyhere(BLK_INIT) block.declvl() println('}') println('') block.copyhere(BLK_MTD) block.delete(BLK_PRIV) block.delete(BLK_BODY) block.delete(BLK_SLOT) block.delete(BLK_MTD) block.delete(BLK_INIT) block.delete(BLK_LOC) block.delete(BLK_INC) block.delete(BLK_IDS) block.delete(BLK_EVTB) block.delete(BLK_TMRS) var(mk, prjName) mk = block.reggen() block.select(mk) prjName = lng.project_name() createMakefile() main = sys.codedir() + 'makefile.' block.save(main) //cgt.res_add_file(main) block.delete(mk) block.delete(BLK_OBJS) block.delete(BLK_OBJS_RULES) end func doClose() println('Close(true);') end func doCaption(_data) println('SetTitle(', e_str(_data), ');') end