+ std::string name = _tabsMgr->GetNameTabPanel();
+ if(name[name.length() - 1] == '*')
+ {
+ name =name.substr(0,name.length()-1);
+ }
+ _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
+ }
+
+ GetToolBar()->EnableTool(ID_UNDO,disable);
+ GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
+ GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
+ GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
+ refreshGUIControls();
+}
+
+//=========================================================================
+
+void wxGUIEditorGraphicBBS::OnRedo(wxCommandEvent& event) {
+ unsigned short disable;
+ std::string stundo;
+ std::string stredo;
+
+ _tabsMgr->loadTempDiagram(1);
+ std::string name = _tabsMgr->GetNameTabPanel();
+ if(name[name.length() - 1] != '*')
+ name +="*";
+ _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
+ GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
+ GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
+ GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
+ GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
+ refreshGUIControls();
+}
+
+void wxGUIEditorGraphicBBS::OnChangeName(wxCommandEvent& event){
+}
+
+//=========================================================================
+
+void wxGUIEditorGraphicBBS::OnEditDiagramProperties(wxCommandEvent& event)
+{
+ wxDiagramPropertiesEditionDialog* dialog =
+ new wxDiagramPropertiesEditionDialog(this);
+ dialog->Show();
+}
+
+//=========================================================================
+
+void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) {
+ std::string script1 = _tabsMgr->getActualDiagramBBS(true);
+ cout << endl << "RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"
+ << endl << endl;
+ cout << script1 << endl;
+
+ std::string script2 = _tabsMgr->getActualDiagramBBS(false);
+ executeScript(script2);
+}
+
+//=========================================================================
+// HANDLERS
+//=========================================================================
+void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event) {
+ wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open BBS"),
+ wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxOPEN);
+ if (openFileDialog->ShowModal() == wxID_OK) {
+ wxString fileName = openFileDialog->GetPath();
+
+ _tabsMgr->addNewTab(openFileDialog->GetFilename());
+
+ bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New(
+ this->_tabsMgr->getActualTabPanel()->getSceneManager(),
+ _pkgBrowser->GetFactory());
+
+ // We tell the interpreter to throw exceptions on error
+ I->SetThrow(true);
+ // Interpret the file supposed to define a box called 'Processing'
+ I->InterpretFile((const char*) (fileName.mb_str()));
+ }
+ refreshGUIControls();
+}
+
+void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename) {
+ ofstream file;
+
+ //EED file.open(fileName.c_str());
+ file.open(filename.c_str());
+ std::string content = "";
+ // writing file header
+ content += "# ----------------------------------\n";
+ content += "# - BBTKGEditor v 1.3 BBS BlackBox Script\n";
+ content += "# - ";
+ content += filename;
+ content += "\n";
+ content += "# ----------------------------------\n";
+ content += "\n";
+ content += _tabsMgr->getActualDiagramBBS();
+ file << content;
+ file.close();
+}
+
+void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event) {
+ wxFileDialog * saveFileDialog = new wxFileDialog(this,
+ wxT("Save actual BBS"), wxEmptyString, wxT("NewBBS"),
+ wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
+ if (saveFileDialog->ShowModal() == wxID_OK) {
+ wxString fileName = saveFileDialog->GetPath();
+ std::string filename = (const char*) (fileName.mb_str());
+ filename=CheckExtension (filename, ".bbs");
+ SaveActualBBS(filename);
+ }
+
+}
+
+void wxGUIEditorGraphicBBS::AskComplexBoxConfiguration() {
+ std::string cbName = _tabsMgr->GetCbName();
+ std::string paName = _tabsMgr->GetCbPackageName();
+
+ wxTextEntryDialog *cbNameDialog = new wxTextEntryDialog(this,
+ wxT("Complex Box name"));
+ wxTextEntryDialog *paNameDialog = new wxTextEntryDialog(this,
+ wxT("Package name"));
+
+ cbNameDialog->SetValue(wxString(cbName.c_str(), wxConvUTF8));
+ paNameDialog->SetValue(wxString(paName.c_str(), wxConvUTF8));
+
+ if (cbNameDialog->ShowModal() == wxID_OK) {
+ wxString complexboxname = cbNameDialog->GetValue();
+ cbName = (const char*) (complexboxname.mb_str());
+ }
+
+ if (paNameDialog->ShowModal() == wxID_OK) {
+ wxString packagename = paNameDialog->GetValue();
+ paName = (const char*) (packagename.mb_str());
+ }
+
+ _tabsMgr->SetCbName(cbName);
+ _tabsMgr->SetCbPackageName(paName);
+}
+
+//=========================================================================
+
+void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename) {
+ ofstream file;
+ file.open(filename.c_str());
+
+ std::string content = "";
+
+ // writing file header
+ content += "# ----------------------------------\n";
+ content += "# - BBTKGEditor v 1.3 BBS BlackBox Script (Complex Box)\n";
+ content += "# - ";
+ content += filename;
+ content += "\n";
+ content += "# ----------------------------------\n";
+ content += "\n";
+ content += _tabsMgr->getActualComplexBoxBBS();
+ file << content;
+ file.close();
+}
+
+//=========================================================================
+
+void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event) {
+ wxFileDialog * saveFileDialog = new wxFileDialog(this,
+ wxT("Save Complex Box BBS"), wxEmptyString,
+ _T("ComplexBoxName"), wxT("*.bbs"), wxSAVE
+ | wxOVERWRITE_PROMPT);
+ if (saveFileDialog->ShowModal() == wxID_OK) {
+ wxString fileName = saveFileDialog->GetPath();
+ std::string filename = (const char*) (fileName.mb_str());
+ filename=CheckExtension (filename, ".bbs");
+ SaveActualComplexBox(filename);
+ }
+}
+
+//=========================================================================
+void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) {
+ ofstream file;
+ file.open(filename.c_str());
+
+ std::string content = "";
+
+ // writing file header
+ content += "# ----------------------------------\n";
+ content += "# - BBTKGEditor v 1.3 BBG BlackBox Diagram file\n";
+ content += "# - ";
+
+ content += filename;
+
+ content += "\n";
+ content += "# ----------------------------------\n";
+ content += "\n";
+ content += "APP_START\n";
+ _tabsMgr->saveActualDiagram(content, filename); //DFCH
+ content += "APP_END\n";
+ file << content;
+ file.close();
+}
+
+//=========================================================================
+void wxGUIEditorGraphicBBS::SaveTempActualDiagram(const std::string &action)
+{
+ std::string stundo;
+ std::string stredo;
+ std::string name = _tabsMgr->GetNameTabPanel();
+ if(name[name.length() - 1] != '*')
+ name +="*";
+ _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
+ _tabsMgr->saveTempActualDiagram(action);
+ GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
+ GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
+ GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
+ GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
+}
+
+//=========================================================================
+
+//The following method allows to save the current diagram asking the filename
+//DFCH
+void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs() {
+ wxFileDialog * saveFileDialog = new wxFileDialog(this,
+ wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"),
+ wxT("*.bbg"), wxSAVE | wxOVERWRITE_PROMPT);
+ if (saveFileDialog->ShowModal() == wxID_OK) {
+ //_tabsMgr->SetNameTabPanel(saveFileDialog->GetFilename());
+ wxString pathfileName = saveFileDialog->GetPath();
+ std::string pathfilename = (const char*) (pathfileName.mb_str());
+ pathfilename=CheckExtension (pathfilename, ".bbg");
+
+ //modify the tab name accordingly
+ wxString fileName = saveFileDialog->GetFilename();
+ std::string filename = (const char*) (fileName.mb_str());
+ filename=CheckExtension (filename, ".bbg");
+ _tabsMgr->SetNameTabPanel( wxString (filename.c_str(), wxConvUTF8) );
+
+ std::string pathfilenamebbs = pathfilename;
+ pathfilenamebbs[pathfilenamebbs.length() - 1] = 's';
+ if (_tabsMgr->isActualDiagramComplexBox() == false) {
+ SaveActualDiagram(pathfilename);
+ SaveActualBBS(pathfilenamebbs);
+ } else {
+ AskComplexBoxConfiguration();
+ SaveActualDiagram(pathfilename);
+ SaveActualComplexBox(pathfilenamebbs);
+ } //if isActualDiagramComplexBox
+ } // if saveFileDialog
+}
+//=========================================================================
+//DFCH
+void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) {
+ std::string pathfilename = _tabsMgr->GetCurrentTabPanelPath();
+ if (pathfilename.empty()) {
+ SaveCurrentDiagramAs();
+ } else {
+ std::string pathfilenamebbs = pathfilename;
+ pathfilenamebbs[pathfilenamebbs.length() - 1] = 's';