2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 #ifdef _USE_WXWIDGETS_
32 //==========================================================================
34 //==========================================================================
35 #include "bbtkInterpreter.h"
36 #include "bbtkWxGUIHtmlBrowser.h"
37 #include "bbtkWxGUIPackageBrowser2.h"
39 //#include "../../src/icons/cc_run.xpm"
40 #include "../../src/icons/cc_exit.xpm"
44 class /*BBTK_EXPORT*/ WxGUIHelp : public wxFrame
45 // public InterpreterUser
48 WxGUIHelp( wxWindow *parent, wxString title, wxSize size );
50 void OnButtonRun(wxCommandEvent& WXUNUSED(event));
51 void OnButtonQuit(wxCommandEvent& WXUNUSED(event));
53 // WxGUIHtmlBrowser* mWxGUIHtmlBrowser;
54 WxGUIPackageBrowser2* mWxGUIPackageBrowser;
55 // wxButton* mwxButtonRun;
56 wxButton* mwxButtonQuit;
58 // bool InterpreterUserHasOwnHtmlPageViewer() { return false; }
59 // void InterpreterUserViewHtmlPage(const std::string&) {}
61 DECLARE_EVENT_TABLE();
70 WxGUIHelp::WxGUIHelp( wxWindow *parent, wxString title, wxSize size )
71 : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size)
74 wxBoxSizer *helpsizer = new wxBoxSizer(wxVERTICAL);
75 // mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
76 // helpsizer->Add (mWxGUIHtmlBrowser,1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5 );
77 mWxGUIPackageBrowser = new WxGUIPackageBrowser2(this);
78 helpsizer->Add (mWxGUIPackageBrowser,1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5 );
80 wxBoxSizer *btnsizer = new wxBoxSizer(wxHORIZONTAL);
82 wxBitmap bmp_run(cc_run_xpm);
83 mwxButtonRun = new wxBitmapButton(this,ID_Button_Run,bmp_run);
84 btnsizer->Add( mwxButtonRun, 0, wxALL, 5 );
86 wxBitmap bmp_quit(cc_exit_xpm);
87 mwxButtonQuit = new wxBitmapButton(this,ID_Button_Quit,bmp_quit);
88 btnsizer->Add( mwxButtonQuit, 0, wxALL, 5 );
90 helpsizer->Add( btnsizer );
92 // Creates and sets the parent window of all bbtk windows
94 wxWindow* top = new wxPanel(this,-1);//,_T("top"));
96 Wx::SetTopWindow(top);
103 // mWxGUIHtmlBrowser->GoHome();
104 mWxGUIPackageBrowser->IncludeAll();
107 WxGUIHelp::~WxGUIHelp() {}
110 void WxGUIHelp::OnButtonRun(wxCommandEvent& WXUNUSED(event))
112 //std::string filename = wx2std(mWxGUIHtmlBrowser->GetCurrentPage());
113 std::string filename = mWxGUIHtmlBrowser->GetCurrentPage();
114 size_t s = filename.length();
116 Interpreter::Pointer I = Interpreter::New();
119 if ((s>3) && (filename[s-1]=='s')
120 && (filename[s-2]=='b')
121 && (filename[s-3]=='b')
122 && (filename[s-4]=='.'))
126 I->InterpretFile(filename);
128 catch (QuitException e)
130 std::cout << "QuitException caught"<<std::endl;
135 mess += std2wx ( e.GetMessage() );
136 wxMessageBox(mess,_T("Error"),wxOK | wxICON_ERROR);
140 wxMessageBox(_T("Undefined error during script execution"),
141 _T("Error"),wxOK | wxICON_ERROR);
147 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);
154 void WxGUIHelp::OnButtonQuit(wxCommandEvent& WXUNUSED(event))
159 //================================================================
160 BEGIN_EVENT_TABLE(WxGUIHelp, wxFrame)
161 // EVT_BUTTON(ID_Button_Run, WxGUIHelp::OnButtonRun )
162 EVT_BUTTON(ID_Button_Quit, WxGUIHelp::OnButtonQuit )
164 //================================================================
168 class myApp : public wxApp
172 int OnExit() { return true; }
175 IMPLEMENT_APP(myApp);
178 bool myApp::OnInit( )
182 //See http://www.wxwindows.org/faqgtk.htm#locale
183 setlocale(LC_NUMERIC, "C");
185 wxInitAllImageHandlers();
187 // WxGUIHelp *I = new WxGUIHelp(0,_T("BBTK help browser"),wxSize(800,600));
189 WxGUIPackageBrowser2Window* I =
190 new WxGUIPackageBrowser2Window(0,_T("bbtk help"),wxSize(1000,800));
199 // How to have a Console and wxWidgets
200 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
201 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
202 // (cout's to the console are visible) and has a wxWidgets GUI,
203 // you need to use the linker option "/subsystem:console" and the following code:
204 int main(int argc, char* argv[])
206 return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
208 #endif // defined(_WIN32)
212 //==========================================================================
214 //==========================================================================
215 int main(int argc, char* argv[])
221 #endif //#ifdef _USE_WXWIDGETS_