5 //==========================================================================
7 //==========================================================================
8 #include "bbtkInterpreter.h"
9 #include "bbtkWxGUIHtmlBrowser.h"
10 #include "bbtkWxGUIPackageBrowser2.h"
12 //#include "../../src/icons/cc_run.xpm"
13 #include "../../src/icons/cc_exit.xpm"
17 class /*BBTK_EXPORT*/ WxGUIHelp : public wxFrame
18 // public InterpreterUser
21 WxGUIHelp( wxWindow *parent, wxString title, wxSize size );
23 void OnButtonRun(wxCommandEvent& WXUNUSED(event));
24 void OnButtonQuit(wxCommandEvent& WXUNUSED(event));
26 // WxGUIHtmlBrowser* mWxGUIHtmlBrowser;
27 WxGUIPackageBrowser2* mWxGUIPackageBrowser;
28 // wxButton* mwxButtonRun;
29 wxButton* mwxButtonQuit;
31 // bool InterpreterUserHasOwnHtmlPageViewer() { return false; }
32 // void InterpreterUserViewHtmlPage(const std::string&) {}
34 DECLARE_EVENT_TABLE();
43 WxGUIHelp::WxGUIHelp( wxWindow *parent, wxString title, wxSize size )
44 : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size)
47 wxBoxSizer *helpsizer = new wxBoxSizer(wxVERTICAL);
48 // mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
49 // helpsizer->Add (mWxGUIHtmlBrowser,1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5 );
50 mWxGUIPackageBrowser = new WxGUIPackageBrowser2(this);
51 helpsizer->Add (mWxGUIPackageBrowser,1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5 );
53 wxBoxSizer *btnsizer = new wxBoxSizer(wxHORIZONTAL);
55 wxBitmap bmp_run(cc_run_xpm);
56 mwxButtonRun = new wxBitmapButton(this,ID_Button_Run,bmp_run);
57 btnsizer->Add( mwxButtonRun, 0, wxALL, 5 );
59 wxBitmap bmp_quit(cc_exit_xpm);
60 mwxButtonQuit = new wxBitmapButton(this,ID_Button_Quit,bmp_quit);
61 btnsizer->Add( mwxButtonQuit, 0, wxALL, 5 );
63 helpsizer->Add( btnsizer );
65 // Creates and sets the parent window of all bbtk windows
67 wxWindow* top = new wxPanel(this,-1);//,_T("top"));
69 Wx::SetTopWindow(top);
76 // mWxGUIHtmlBrowser->GoHome();
77 mWxGUIPackageBrowser->IncludeAll();
80 WxGUIHelp::~WxGUIHelp() {}
83 void WxGUIHelp::OnButtonRun(wxCommandEvent& WXUNUSED(event))
85 //std::string filename = wx2std(mWxGUIHtmlBrowser->GetCurrentPage());
86 std::string filename = mWxGUIHtmlBrowser->GetCurrentPage();
87 size_t s = filename.length();
89 Interpreter::Pointer I = Interpreter::New();
92 if ((s>3) && (filename[s-1]=='s')
93 && (filename[s-2]=='b')
94 && (filename[s-3]=='b')
95 && (filename[s-4]=='.'))
99 I->InterpretFile(filename);
101 catch (QuitException e)
103 std::cout << "QuitException caught"<<std::endl;
108 mess += std2wx ( e.GetMessage() );
109 wxMessageBox(mess,_T("Error"),wxOK | wxICON_ERROR);
113 wxMessageBox(_T("Undefined error during script execution"),
114 _T("Error"),wxOK | wxICON_ERROR);
120 wxMessageBox(_T("You can only execute .bbs script files (click on [source] in the field 'To use it' of a box) !"),_T("Warning"),wxOK | wxICON_ERROR);
127 void WxGUIHelp::OnButtonQuit(wxCommandEvent& WXUNUSED(event))
132 //================================================================
133 BEGIN_EVENT_TABLE(WxGUIHelp, wxFrame)
134 // EVT_BUTTON(ID_Button_Run, WxGUIHelp::OnButtonRun )
135 EVT_BUTTON(ID_Button_Quit, WxGUIHelp::OnButtonQuit )
137 //================================================================
141 class myApp : public wxApp
145 int OnExit() { return true; }
148 IMPLEMENT_APP(myApp);
151 bool myApp::OnInit( )
155 //See http://www.wxwindows.org/faqgtk.htm#locale
156 setlocale(LC_NUMERIC, "C");
158 wxInitAllImageHandlers();
160 // WxGUIHelp *I = new WxGUIHelp(0,_T("BBTK help browser"),wxSize(800,600));
162 WxGUIPackageBrowser2Window* I =
163 new WxGUIPackageBrowser2Window(0,_T("bbtk help"),wxSize(1000,800));
172 // How to have a Console and wxWidgets
173 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
174 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
175 // (cout's to the console are visible) and has a wxWidgets GUI,
176 // you need to use the linker option "/subsystem:console" and the following code:
177 int main(int argc, char* argv[])
179 return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
181 #endif // defined(_WIN32)
185 //==========================================================================
187 //==========================================================================
188 int main(int argc, char* argv[])
194 #endif //#ifdef _USE_WXWIDGETS_