#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 | OnClose (wxCloseEvent &event) |
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, mwxPageHelp, bbtk::InterpreterVirtual::New(), OnWxSignal(), and bbtk::Wx::SetTopWindow().
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 bbtk::Wx::SetTopWindow(this); 00174 // Top Window Auto Destroys when no more black box window alive 00175 // : this is the default 00176 // bbtk::Wx::SetAutoDestroyTopWindow(true); 00177 // Add the method OnWxSignal as a Wx::Signal observer 00178 bbtkAddWxSignalObserver(WxGUIConsole::OnWxSignal); 00179 00180 00181 // Layout 00182 //EED SetSizer(sizer); 00183 00184 mwxNotebook->AddPage( mwxPageCommand, _T("Command")); 00185 mwxNotebook->AddPage( mwxPageHelp, _T("Help")); 00186 m_mgr.AddPane(mwxNotebook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false)); 00187 m_mgr.Update(); 00188 00189 SetAutoLayout(true); 00190 Layout(); 00191 // Refresh(); 00192 // m_mgr.Update(); 00193 }
bbtk::WxGUIConsole::~WxGUIConsole | ( | ) |
Definition at line 197 of file bbtkWxGUIConsole.cxx.
References m_mgr.
00198 { 00199 m_mgr.UnInit(); 00200 }
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.
Referenced by wxBBIApp::OnInit().
00083 { return mInterpreter; }
bool bbtk::WxGUIConsole::InterpreterUserHasOwnHtmlPageViewer | ( | ) | [inline, virtual] |
void bbtk::WxGUIConsole::InterpreterUserViewHtmlPage | ( | const std::string & | page | ) | [virtual] |
Reimplemented from bbtk::InterpreterUser.
Definition at line 438 of file bbtkWxGUIConsole.cxx.
References bbtk::WxGUIHtmlBrowser::GoTo(), mWxGUIHtmlBrowser, and mwxNotebook.
00439 { 00440 std::string s(page); 00441 // std::cout << "WxGUIConsole::ShowHtmlPage('"<<page<<"')"<<std::endl; 00442 if (mWxGUIHtmlBrowser->GoTo(s)) 00443 { 00444 //EED mwxNotebook->ChangeSelection(1); 00445 mwxNotebook->SetSelection(1); 00446 } 00447 else 00448 { 00449 // std::cout << "ERROR html"<<std::endl; 00450 } 00451 }
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 255 of file bbtkWxGUIConsole.cxx.
References bbtk::InterpreterVirtual::Interpreter_ERROR, and mInterpreter.
Referenced by wxBBIApp::OnInit().
00256 { 00257 if ( mInterpreter->InterpretFile(filename) == 00258 Interpreter::Interpreter_ERROR ) 00259 { 00260 return false; 00261 } 00262 return true; 00263 }
void bbtk::WxGUIConsole::OnButtonRun | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 267 of file bbtkWxGUIConsole.cxx.
References _T, bbtk::WxGUIHtmlBrowser::GetCurrentPage(), mWxGUIHtmlBrowser, bbtk::InterpreterVirtual::New(), and bbtk::std2wx().
00268 { 00269 // wxString temp = mWxGUIHtmlBrowser->GetCurrentPage(); 00270 std::string filename = mWxGUIHtmlBrowser->GetCurrentPage();//wx2std(temp); 00271 size_t s = filename.length(); 00272 00273 Interpreter::Pointer I = Interpreter::New(); 00274 00275 if ((s>3) && (filename[s-1]=='s') 00276 && (filename[s-2]=='b') 00277 && (filename[s-3]=='b') 00278 && (filename[s-4]=='.')) 00279 { 00280 std::string tmp("Executing "); 00281 tmp += filename; 00282 SetStatusText(std2wx(tmp)); 00283 I->InterpretFile(filename); 00284 } 00285 else 00286 { 00287 SetStatusText(_T("The current page is not a bbs file : cannot execute it")); 00288 } 00289 00290 }
void bbtk::WxGUIConsole::OnClose | ( | wxCloseEvent & | event | ) |
Definition at line 204 of file bbtkWxGUIConsole.cxx.
References bbtkDebugMessage.
00205 { 00206 bbtkDebugMessage("widget",9,"bbi::OnClose()"<<std::endl); 00207 //Wx::SetWindowsHaveBeenDestroyedByParent(); 00208 //mInterpreter.reset(); 00209 wxWindowList& list = GetChildren(); 00210 wxWindowList::iterator iter; 00211 for (iter = list.begin(); iter != list.end(); ++iter) 00212 { 00213 (*iter)->Close(); 00214 } 00215 this->Destroy(); 00216 }
void bbtk::WxGUIConsole::OnMenuAbout | ( | wxCommandEvent & | event | ) |
void bbtk::WxGUIConsole::OnMenuCreateBlackBox | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 343 of file bbtkWxGUIConsole.cxx.
References bbtkMessage, and bbtk::InterpreterVirtual::New().
00344 { 00345 std::string command("toolsbbtk/appli/GUICreateBlackBox"); 00346 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl); 00347 Interpreter::Pointer I = Interpreter::New(); 00348 I->InterpretFile(command); 00349 }
void bbtk::WxGUIConsole::OnMenuCreateIndex | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 393 of file bbtkWxGUIConsole.cxx.
References bbtk::ConfigurationFile::Get_bin_path(), bbtk::ConfigurationFile::Get_doc_path(), and bbtk::ConfigurationFile::GetInstance().
00394 { 00395 /* 00396 std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path(); 00397 std::string filepath = doc_path+"/bbdoc/make-index.bbs"; 00398 Interpreter* I = new Interpreter; 00399 I->InterpretLine( "exec freeze"); 00400 I->InterpretLine( "include *"); 00401 I->InterpretLine( "help packages"); 00402 I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials"); 00403 I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages"); 00404 I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories"); 00405 I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors"); 00406 delete I; 00407 */ 00408 00409 std::string bin_path = ConfigurationFile::GetInstance().Get_bin_path(); 00410 std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path(); 00411 std::string bbdoc_path = doc_path+"/bbdoc"; 00412 std::string make_index_path = "\"" + bbdoc_path+"/make-index.bbs\""; 00413 00414 std::string strcommand0 = "cd "+bbdoc_path+" && mkdir tmp && cd tmp"; 00415 00416 std::string strcommand1 = "cd "+bbdoc_path+"/tmp"; 00417 std::string strcommand2 = "\""+bin_path+"/bbi\" -N "+make_index_path; 00418 #ifdef WIN32 00419 std::string strcommand3 = "move index*.html ../."; 00420 #else 00421 std::string strcommand3 = "mv index*.html ../."; 00422 #endif 00423 00424 std::string strcommand = strcommand1 +" && "+ 00425 strcommand2 +" && "+ 00426 strcommand3; 00427 00428 std::cout << "system: " << strcommand0 << std::endl; 00429 std::cout << "system: " << strcommand << std::endl; 00430 00431 system ( strcommand0.c_str() ); 00432 system ( strcommand.c_str() ); 00433 }
void bbtk::WxGUIConsole::OnMenuCreatePackage | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 331 of file bbtkWxGUIConsole.cxx.
References bbtkMessage, and bbtk::InterpreterVirtual::New().
00332 { 00333 std::string command("toolsbbtk/appli/GUICreatePackage"); 00334 00335 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl); 00336 Interpreter::Pointer I = Interpreter::New(); 00337 I->InterpretFile(command); 00338 }
void bbtk::WxGUIConsole::OnMenuEditConfig | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 314 of file bbtkWxGUIConsole.cxx.
References bbtk::ConfigurationFile::Get_config_xml_full_path(), and bbtk::ConfigurationFile::GetInstance().
00315 { 00316 std::string commandStr; 00317 std::string configFile = ConfigurationFile::GetInstance().Get_config_xml_full_path(); 00318 #ifdef WIN32 00319 commandStr = "notepad.exe "; 00320 #else 00321 commandStr = "gedit "; 00322 #endif 00323 commandStr = commandStr + configFile; 00324 std::cout << "system: " << commandStr << std::endl; 00325 system ( commandStr.c_str() ); 00326 }
void bbtk::WxGUIConsole::OnMenuQuit | ( | wxCommandEvent & | event | ) |
void bbtk::WxGUIConsole::OnMenuShowHTMLDoc | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 372 of file bbtkWxGUIConsole.cxx.
References bbtk::ConfigurationFile::Get_doc_path(), and bbtk::ConfigurationFile::GetInstance().
00373 { 00374 std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path(); 00375 00376 #if defined(WIN32) 00377 std::string strappli="start "; 00378 #else 00379 std::string strappli="gnome-open "; 00380 #endif 00381 std::string strcommand0 = "cd \"" + doc_path+"\""; 00382 std::string strcommand1 = strappli + "index.html"; 00383 std::string strcommand = strcommand0 + " && " + strcommand1; 00384 std::cout << "system: " << strcommand << std::endl; 00385 system ( strcommand.c_str() ); 00386 00387 }
void bbtk::WxGUIConsole::OnMenuShowImageGraph | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Definition at line 353 of file bbtkWxGUIConsole.cxx.
References bbtk::ConfigurationFile::Get_default_temp_dir(), and bbtk::ConfigurationFile::GetInstance().
00354 { 00355 std::string default_temp_dir = ConfigurationFile::GetInstance().Get_default_temp_dir(); 00356 00357 #if defined(WIN32) 00358 std::string strappli="start "; 00359 #else 00360 std::string strappli="gnome-open "; 00361 #endif 00362 std::string strcommand0 = "cd \"" + default_temp_dir+"/temp_dir/" +"\""; 00363 std::string strcommand1 = strappli + "workspace_workspacePrototype.png"; 00364 std::string strcommand = strcommand0 + " && " + strcommand1; 00365 std::cout << "system: " << strcommand << std::endl; 00366 system ( strcommand.c_str() ); 00367 00368 }
void bbtk::WxGUIConsole::OnWxSignal | ( | ) |
Definition at line 220 of file bbtkWxGUIConsole.cxx.
References bbtkDebugMessage, and bbtk::Wx::IsSomeWindowAlive().
Referenced by WxGUIConsole().
00221 { 00222 if ((!bbtk::Wx::IsSomeWindowAlive())&&(!IsShown())) 00223 { 00224 bbtkDebugMessage("wx",2," --> bbtk top window destroyed and WxGUIConsole not shown => destructing"<<std::endl); 00225 /* 00226 wxWindowList& list = GetChildren(); 00227 wxWindowList::iterator iter; 00228 for (iter = list.begin(); iter != list.end(); ++iter) 00229 { 00230 (*iter)->Close(); 00231 } 00232 */ 00233 Close(); 00234 } 00235 }
void bbtk::WxGUIConsole::SetDialogMode | ( | Interpreter::DialogModeType | t | ) | [inline] |
Definition at line 94 of file bbtkWxGUIConsole.h.
Referenced by wxBBIApp::OnInit().
00095 { mInterpreter->SetDialogMode(t); }
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.
Referenced by wxBBIApp::OnInit().
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.
Referenced by wxBBIApp::OnInit().
00092 { mInterpreter->SetNoExecMode(b); }
bool bbtk::WxGUIConsole::Show | ( | bool | show = true |
) | [virtual] |
Definition at line 457 of file bbtkWxGUIConsole.cxx.
Referenced by wxBBIApp::OnInit().
00458 { 00459 // bbtk::Wx::SetAutoDestroyTopWindow(!show); 00460 return wxFrame::Show(show); 00461 }
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 239 of file bbtkWxGUIConsole.cxx.
References bbtk::InterpreterVirtual::Interpreter_QUIT, mInterpreter, mWxGUIOutputMessages, and bbtk::WxGUIOutputMessages::Print().
00240 { 00241 std::string s("> "); 00242 s += command + "\n"; 00243 mWxGUIOutputMessages->Print(s,wxRED); 00244 00245 if ( mInterpreter->InterpretLine( command ) == 00246 Interpreter::Interpreter_QUIT ) 00247 { 00248 Close(true); 00249 } 00250 }
wxAuiManager bbtk::WxGUIConsole::m_mgr [private] |
Definition at line 129 of file bbtkWxGUIConsole.h.
Referenced by WxGUIConsole(), and ~WxGUIConsole().
Definition at line 130 of file bbtkWxGUIConsole.h.
Referenced by InterpretFile(), WxGUICommandEnter(), and WxGUIConsole().
wxButton* bbtk::WxGUIConsole::mwxButtonRun [private] |
WxGUICommand* bbtk::WxGUIConsole::mWxGUICommand [private] |
Definition at line 139 of file bbtkWxGUIConsole.h.
Referenced by InterpreterUserViewHtmlPage(), OnButtonRun(), and WxGUIConsole().
Definition at line 138 of file bbtkWxGUIConsole.h.
Referenced by WxGUICommandEnter(), and WxGUIConsole().
wxAuiNotebook* bbtk::WxGUIConsole::mwxNotebook [private] |
Definition at line 134 of file bbtkWxGUIConsole.h.
Referenced by InterpreterUserViewHtmlPage(), and WxGUIConsole().
wxPanel* bbtk::WxGUIConsole::mwxPageCommand [private] |
wxPanel * bbtk::WxGUIConsole::mwxPageHelp [private] |