#include <bbtkWxGUIConsole.h>
Public Member Functions | |
WxGUIConsole (wxWindow *parent, wxString title, wxSize size) | |
~WxGUIConsole () | |
Interpreter::Pointer | GetInterpreter () const |
Returns the Interpreter used (const). | |
void | SetInputs (const std::map< std::string, std::string > &m) |
void | SetNoExecMode (bool b) |
void | SetDialogMode (Interpreter::DialogModeType t) |
bool | InterpretFile (const std::string &filename) |
Runs the interpretation of a file. | |
void | OnMenuQuit (wxCommandEvent &event) |
void | OnMenuAbout (wxCommandEvent &event) |
void | OnMenuEditConfig (wxCommandEvent &WXUNUSED(event)) |
void | OnMenuCreatePackage (wxCommandEvent &WXUNUSED(event)) |
void | OnMenuCreateBlackBox (wxCommandEvent &WXUNUSED(event)) |
void | OnMenuShowImageGraph (wxCommandEvent &WXUNUSED(event)) |
void | OnMenuShowHTMLDoc (wxCommandEvent &WXUNUSED(event)) |
void | OnMenuCreateIndex (wxCommandEvent &WXUNUSED(event)) |
void | OnButtonRun (wxCommandEvent &WXUNUSED(event)) |
bool | InterpreterUserHasOwnHtmlPageViewer () |
void | InterpreterUserViewHtmlPage (const std::string &) |
void | WxGUICommandEnter (const std::string &) |
Callback invoked when a command is entered in the WxGUICommand. | |
virtual bool | Show (bool show=true) |
void | OnWxSignal () |
Private Attributes | |
wxAuiManager | m_mgr |
Interpreter::Pointer | mInterpreter |
wxAuiNotebook * | mwxNotebook |
wxPanel * | mwxPageCommand |
wxPanel * | mwxPageHelp |
WxGUICommand * | mWxGUICommand |
WxGUIOutputMessages * | mWxGUIOutputMessages |
WxGUIHtmlBrowser * | mWxGUIHtmlBrowser |
wxButton * | mwxButtonRun |
Definition at line 70 of file bbtkWxGUIConsole.h.
bbtk::WxGUIConsole::WxGUIConsole | ( | wxWindow * | parent, | |
wxString | title, | |||
wxSize | size | |||
) |
Definition at line 77 of file bbtkWxGUIConsole.cxx.
References _T, bbtkAddWxSignalObserver, bbtk::ID_Button_Run, bbtk::ID_Menu_About, bbtk::ID_Menu_CreateBlackBox, bbtk::ID_Menu_CreateIndex, bbtk::ID_Menu_CreatePackage, bbtk::ID_Menu_EditConfig, bbtk::ID_Menu_Quit, bbtk::ID_Menu_ShowHTMLDoc, bbtk::ID_Menu_ShowImageGraph, m_mgr, mInterpreter, mwxButtonRun, mWxGUICommand, mWxGUIHtmlBrowser, mWxGUIOutputMessages, mwxNotebook, mwxPageCommand, and mwxPageHelp.
00078 : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size) 00079 { 00080 // m_mgr = new wxAuiManager(this); 00081 m_mgr.SetManagedWindow(this); 00082 00083 mInterpreter = bbtk::Interpreter::New(); 00084 mInterpreter->SetUser(this); 00085 mInterpreter->SetCommandLine(true); 00086 mInterpreter->SetThrow(false); 00087 //============== 00088 // Menu 00089 wxInitAllImageHandlers(); 00090 00091 wxMenu *menuFile = new wxMenu; 00092 menuFile->Append( ID_Menu_Quit, _T("&Quit") ); 00093 00094 wxMenu *menuAbout = new wxMenu; 00095 menuAbout->Append( ID_Menu_About, _T("&About...") ); 00096 00097 wxMenu *menuTools = new wxMenu; 00098 menuTools->Append( ID_Menu_EditConfig, _T("&Edit bbtk config") ); 00099 menuTools->Append( ID_Menu_CreatePackage, _T("Create &package") ); 00100 menuTools->Append( ID_Menu_CreateBlackBox, _T("Create &blackbox") ); 00101 menuTools->Append( ID_Menu_ShowImageGraph, _T("&Show last image graph") ); 00102 menuTools->Append( ID_Menu_ShowHTMLDoc, _T("Show &HTML documentation") ); 00103 menuTools->Append( ID_Menu_CreateIndex, _T("&Generate index") ); 00104 00105 00106 wxMenuBar *menuBar = new wxMenuBar; 00107 menuBar->Append( menuFile, _T("&File") ); 00108 menuBar->Append( menuTools, _T("&Tools") ); 00109 menuBar->Append( menuAbout, _T("About") ); 00110 00111 SetMenuBar( menuBar ); 00112 00113 CreateStatusBar(); 00114 SetStatusText( _T("Welcome to bbi !") ); 00115 00116 //============== 00117 // Notebook 00118 00119 // wxFlexGridSizer *sizer = new wxFlexGridSizer(1); 00120 00121 //EED wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); 00122 // mwxNotebook = new wxNotebook(this,-1,wxDefaultPosition, wxDefaultSize, 0); 00123 mwxNotebook = new wxAuiNotebook(this, 00124 -1, 00125 wxPoint(0, 0), 00126 wxSize(500,500), 00127 wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER); 00128 00129 mwxPageCommand = new wxPanel(mwxNotebook,-1); 00130 mwxPageHelp = new wxPanel(mwxNotebook,-1); 00131 00132 00133 wxBoxSizer *cmdsizer = new wxBoxSizer(wxVERTICAL); 00134 00135 mwxPageCommand->SetAutoLayout(true); 00136 mwxPageCommand->SetSizer(cmdsizer); 00137 cmdsizer->Fit(mwxPageCommand); 00138 cmdsizer->SetSizeHints(mwxPageCommand); 00139 00140 wxBoxSizer *helpsizer = new wxBoxSizer(wxVERTICAL); 00141 00142 mwxPageHelp->SetAutoLayout(true); 00143 mwxPageHelp->SetSizer(helpsizer); 00144 helpsizer->Fit(mwxPageHelp); 00145 helpsizer->SetSizeHints(mwxPageHelp); 00146 00147 mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(mwxPageHelp, 00148 //EED wxSize(1200,0)); 00149 wxSize(200,0)); 00150 00151 // mWxGUIHtmlBrowser->SetSize(wxSize(800,1000)); 00152 helpsizer->Add (mWxGUIHtmlBrowser,1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5 ); 00153 // helpsizer->Add ( new wxButton(mwxPageHelp,-1,"perro"), 0, wxEXPAND ); 00154 wxBitmap bmp_run(cc_run_xpm); 00155 mwxButtonRun = new wxBitmapButton( mwxPageHelp,ID_Button_Run,bmp_run);//_T("Run") ); 00156 helpsizer->Add( mwxButtonRun, 0, wxALL, 5 ); 00157 00158 00159 //============== 00160 // Command page 00161 mWxGUIOutputMessages = new WxGUIOutputMessages(mwxPageCommand); 00162 00163 mWxGUICommand = new WxGUICommand(mwxPageCommand,this); 00164 00165 mWxGUICommand->SetFocus(); 00166 00167 cmdsizer->Add (mWxGUIOutputMessages, 1, wxALL | wxGROW, 5); 00168 cmdsizer->Add (mWxGUICommand, 0, wxALL | wxGROW, 5); 00169 00170 00171 // Set the parent window of all bbtk windows as a child of this 00172 bbtk::Wx::SetTopWindowParent(this); 00173 // Top Window Auto Destroys when no more black box window alive 00174 // : this is the default 00175 // bbtk::Wx::SetAutoDestroyTopWindow(true); 00176 // Add the method OnWxSignal as a Wx::Signal observer 00177 bbtkAddWxSignalObserver(WxGUIConsole::OnWxSignal); 00178 00179 00180 // Layout 00181 //EED SetSizer(sizer); 00182 00183 mwxNotebook->AddPage( mwxPageCommand, _T("Command")); 00184 mwxNotebook->AddPage( mwxPageHelp, _T("Help")); 00185 m_mgr.AddPane(mwxNotebook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false)); 00186 m_mgr.Update(); 00187 00188 SetAutoLayout(true); 00189 Layout(); 00190 // Refresh(); 00191 // m_mgr.Update(); 00192 }
bbtk::WxGUIConsole::~WxGUIConsole | ( | ) |
Definition at line 196 of file bbtkWxGUIConsole.cxx.
References m_mgr.
00197 { 00198 m_mgr.UnInit(); 00199 }
Interpreter::Pointer bbtk::WxGUIConsole::GetInterpreter | ( | ) | const [inline] |
Returns the Interpreter used (const).
Returns the Interpreter used ONLY ONE FOR THE MOMENT BUT IN THE FUTURE CAN BE DIFFERENT (DIFFERENT WORKSPACES)
Definition at line 83 of file bbtkWxGUIConsole.h.
00083 { return mInterpreter; }
void bbtk::WxGUIConsole::SetInputs | ( | const std::map< std::string, std::string > & | m | ) | [inline] |
Sets the inputs of the workspace : the map is passed as is to the Executer
Definition at line 87 of file bbtkWxGUIConsole.h.
00088 { mInterpreter->SetInputs(m); }
void bbtk::WxGUIConsole::SetNoExecMode | ( | bool | b | ) | [inline] |
Puts the executer in "no exec" mode, which creates but does not execute pipelines.
Definition at line 92 of file bbtkWxGUIConsole.h.
00092 { mInterpreter->SetNoExecMode(b); }
void bbtk::WxGUIConsole::SetDialogMode | ( | Interpreter::DialogModeType | t | ) | [inline] |
bool bbtk::WxGUIConsole::InterpretFile | ( | const std::string & | filename | ) |
Runs the interpretation of a file.
Runs the interpretation of a file Returns false on error
Definition at line 230 of file bbtkWxGUIConsole.cxx.
References mInterpreter.
00231 { 00232 if ( mInterpreter->InterpretFile(filename) == 00233 Interpreter::Interpreter_ERROR ) 00234 { 00235 return false; 00236 } 00237 return true; 00238 }
void bbtk::WxGUIConsole::OnMenuQuit | ( | wxCommandEvent & | event | ) |
void bbtk::WxGUIConsole::OnMenuAbout | ( | wxCommandEvent & | event | ) |
void bbtk::WxGUIConsole::OnMenuEditConfig | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 289 of file bbtkWxGUIConsole.cxx.
00290 { 00291 std::string commandStr; 00292 std::string configFile = ConfigurationFile::GetInstance().Get_config_xml_full_path(); 00293 #ifdef WIN32 00294 commandStr = "notepad.exe "; 00295 #else 00296 commandStr = "gedit "; 00297 #endif 00298 commandStr = commandStr + configFile; 00299 std::cout << "system: " << commandStr << std::endl; 00300 system ( commandStr.c_str() ); 00301 }
void bbtk::WxGUIConsole::OnMenuCreatePackage | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 306 of file bbtkWxGUIConsole.cxx.
References bbtkMessage.
00307 { 00308 std::string command("toolsbbtk/appli/GUICreatePackage"); 00309 00310 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl); 00311 Interpreter::Pointer I = Interpreter::New(); 00312 I->InterpretFile(command); 00313 }
void bbtk::WxGUIConsole::OnMenuCreateBlackBox | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 318 of file bbtkWxGUIConsole.cxx.
References bbtkMessage.
00319 { 00320 std::string command("toolsbbtk/appli/GUICreateBlackBox"); 00321 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl); 00322 Interpreter::Pointer I = Interpreter::New(); 00323 I->InterpretFile(command); 00324 }
void bbtk::WxGUIConsole::OnMenuShowImageGraph | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 328 of file bbtkWxGUIConsole.cxx.
00329 { 00330 std::string default_temp_dir = ConfigurationFile::GetInstance().Get_default_temp_dir(); 00331 00332 #if defined(WIN32) 00333 std::string strappli="start "; 00334 #else 00335 std::string strappli="gnome-open "; 00336 #endif 00337 std::string strcommand0 = "cd \"" + default_temp_dir+"/temp_dir/" +"\""; 00338 std::string strcommand1 = strappli + "workspace_workspacePrototype.png"; 00339 std::string strcommand = strcommand0 + " && " + strcommand1; 00340 std::cout << "system: " << strcommand << std::endl; 00341 system ( strcommand.c_str() ); 00342 00343 }
void bbtk::WxGUIConsole::OnMenuShowHTMLDoc | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 347 of file bbtkWxGUIConsole.cxx.
00348 { 00349 std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path(); 00350 00351 #if defined(WIN32) 00352 std::string strappli="start "; 00353 #else 00354 std::string strappli="gnome-open "; 00355 #endif 00356 std::string strcommand0 = "cd \"" + doc_path+"\""; 00357 std::string strcommand1 = strappli + "index.html"; 00358 std::string strcommand = strcommand0 + " && " + strcommand1; 00359 std::cout << "system: " << strcommand << std::endl; 00360 system ( strcommand.c_str() ); 00361 00362 }
void bbtk::WxGUIConsole::OnMenuCreateIndex | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 368 of file bbtkWxGUIConsole.cxx.
00369 { 00370 /* 00371 std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path(); 00372 std::string filepath = doc_path+"/bbdoc/make-index.bbs"; 00373 Interpreter* I = new Interpreter; 00374 I->InterpretLine( "exec freeze"); 00375 I->InterpretLine( "include *"); 00376 I->InterpretLine( "help packages"); 00377 I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials"); 00378 I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages"); 00379 I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories"); 00380 I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors"); 00381 delete I; 00382 */ 00383 00384 std::string bin_path = ConfigurationFile::GetInstance().Get_bin_path(); 00385 std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path(); 00386 std::string bbdoc_path = doc_path+"/bbdoc"; 00387 std::string make_index_path = "\"" + bbdoc_path+"/make-index.bbs\""; 00388 00389 std::string strcommand0 = "cd "+bbdoc_path+" && mkdir tmp && cd tmp"; 00390 00391 std::string strcommand1 = "cd "+bbdoc_path+"/tmp"; 00392 std::string strcommand2 = "\""+bin_path+"/bbi\" -N "+make_index_path; 00393 #ifdef WIN32 00394 std::string strcommand3 = "move index*.html ../."; 00395 #else 00396 std::string strcommand3 = "mv index*.html ../."; 00397 #endif 00398 00399 std::string strcommand = strcommand1 +" && "+ 00400 strcommand2 +" && "+ 00401 strcommand3; 00402 00403 std::cout << "system: " << strcommand0 << std::endl; 00404 std::cout << "system: " << strcommand << std::endl; 00405 00406 system ( strcommand0.c_str() ); 00407 system ( strcommand.c_str() ); 00408 }
void bbtk::WxGUIConsole::OnButtonRun | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 242 of file bbtkWxGUIConsole.cxx.
References _T, bbtk::WxGUIHtmlBrowser::GetCurrentPage(), mWxGUIHtmlBrowser, and bbtk::std2wx().
00243 { 00244 // wxString temp = mWxGUIHtmlBrowser->GetCurrentPage(); 00245 std::string filename = mWxGUIHtmlBrowser->GetCurrentPage();//wx2std(temp); 00246 size_t s = filename.length(); 00247 00248 Interpreter::Pointer I = Interpreter::New(); 00249 00250 if ((s>3) && (filename[s-1]=='s') 00251 && (filename[s-2]=='b') 00252 && (filename[s-3]=='b') 00253 && (filename[s-4]=='.')) 00254 { 00255 std::string tmp("Executing "); 00256 tmp += filename; 00257 SetStatusText(std2wx(tmp)); 00258 I->InterpretFile(filename); 00259 } 00260 else 00261 { 00262 SetStatusText(_T("The current page is not a bbs file : cannot execute it")); 00263 } 00264 00265 }
bool bbtk::WxGUIConsole::InterpreterUserHasOwnHtmlPageViewer | ( | ) | [inline, virtual] |
void bbtk::WxGUIConsole::InterpreterUserViewHtmlPage | ( | const std::string & | page | ) | [virtual] |
Reimplemented from bbtk::InterpreterUser.
Definition at line 413 of file bbtkWxGUIConsole.cxx.
References bbtk::WxGUIHtmlBrowser::GoTo(), mWxGUIHtmlBrowser, and mwxNotebook.
00414 { 00415 std::string s(page); 00416 // std::cout << "WxGUIConsole::ShowHtmlPage('"<<page<<"')"<<std::endl; 00417 if (mWxGUIHtmlBrowser->GoTo(s)) 00418 { 00419 //EED mwxNotebook->ChangeSelection(1); 00420 mwxNotebook->SetSelection(1); 00421 } 00422 else 00423 { 00424 // std::cout << "ERROR html"<<std::endl; 00425 } 00426 }
void bbtk::WxGUIConsole::WxGUICommandEnter | ( | const std::string & | command | ) | [virtual] |
Callback invoked when a command is entered in the WxGUICommand.
Reimplemented from bbtk::WxGUICommandUser.
Definition at line 214 of file bbtkWxGUIConsole.cxx.
References mInterpreter, mWxGUIOutputMessages, and bbtk::WxGUIOutputMessages::Print().
00215 { 00216 std::string s("> "); 00217 s += command + "\n"; 00218 mWxGUIOutputMessages->Print(s,wxRED); 00219 00220 if ( mInterpreter->InterpretLine( command ) == 00221 Interpreter::Interpreter_QUIT ) 00222 { 00223 Close(true); 00224 } 00225 }
bool bbtk::WxGUIConsole::Show | ( | bool | show = true |
) | [virtual] |
Definition at line 431 of file bbtkWxGUIConsole.cxx.
00432 { 00433 bbtk::Wx::SetAutoDestroyTopWindow(!show); 00434 return wxFrame::Show(show); 00435 }
void bbtk::WxGUIConsole::OnWxSignal | ( | ) |
Definition at line 203 of file bbtkWxGUIConsole.cxx.
References bbtkDebugMessage.
00204 { 00205 if ((!Wx::TopWindowExists())&&(!IsShown())) 00206 { 00207 bbtkDebugMessage("wx",2," --> bbtk top window destroyed and WxGUIConsole not shown => destructing"<<std::endl); 00208 Close(); 00209 } 00210 }
wxAuiManager bbtk::WxGUIConsole::m_mgr [private] |
Definition at line 127 of file bbtkWxGUIConsole.h.
Referenced by WxGUIConsole(), and ~WxGUIConsole().
Interpreter::Pointer bbtk::WxGUIConsole::mInterpreter [private] |
Definition at line 128 of file bbtkWxGUIConsole.h.
Referenced by InterpretFile(), WxGUICommandEnter(), and WxGUIConsole().
wxAuiNotebook* bbtk::WxGUIConsole::mwxNotebook [private] |
Definition at line 132 of file bbtkWxGUIConsole.h.
Referenced by InterpreterUserViewHtmlPage(), and WxGUIConsole().
wxPanel* bbtk::WxGUIConsole::mwxPageCommand [private] |
wxPanel * bbtk::WxGUIConsole::mwxPageHelp [private] |
WxGUICommand* bbtk::WxGUIConsole::mWxGUICommand [private] |
WxGUIOutputMessages* bbtk::WxGUIConsole::mWxGUIOutputMessages [private] |
Definition at line 136 of file bbtkWxGUIConsole.h.
Referenced by WxGUICommandEnter(), and WxGUIConsole().
WxGUIHtmlBrowser* bbtk::WxGUIConsole::mWxGUIHtmlBrowser [private] |
Definition at line 137 of file bbtkWxGUIConsole.h.
Referenced by InterpreterUserViewHtmlPage(), OnButtonRun(), and WxGUIConsole().
wxButton* bbtk::WxGUIConsole::mwxButtonRun [private] |