From: camarasu <> Date: Tue, 22 May 2012 16:46:13 +0000 (+0000) Subject: #1356, #1358 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=bbtkGEditor.git;a=commitdiff_plain;h=b594841a2dad5fa2f18839b0125881fc22f4b6fd #1356, #1358 --- diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index fd7fa65..d9a00b9 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -80,6 +80,7 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) : //========================================================================= wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() { + printf("EED %p ~wxGUIEditorGraphicBBS()\n", this); //EED02JUIN2010 delete _tabsMgr; @@ -459,6 +460,21 @@ void wxGUIEditorGraphicBBS::executeScript(std::string script) { system(command.c_str()); } +//========================================================================= +std::string wxGUIEditorGraphicBBS::CheckExtension(std::string filename, std::string extension) { + if(extension.size() != 4){ + printf("CheckExtension Warning! Extension size != 4\n"); + }else{ + if(filename.size() > 4){ + if( (filename.compare(filename.size()-4,4,extension)) !=0 ){ + filename.append(extension); + } + }else{ + filename.append(extension); + } + } + return filename; +} //========================================================================= // EVENT HANDLERS //========================================================================= @@ -543,7 +559,9 @@ void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event) { wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT); if (saveFileDialog->ShowModal() == wxID_OK) { wxString fileName = saveFileDialog->GetPath(); - SaveActualBBS((const char*) (fileName.mb_str())); + std::string filename = (const char*) (fileName.mb_str()); + filename=CheckExtension (filename, ".bbs"); + SaveActualBBS(filename); } } @@ -604,7 +622,9 @@ void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event) { | wxOVERWRITE_PROMPT); if (saveFileDialog->ShowModal() == wxID_OK) { wxString fileName = saveFileDialog->GetPath(); - SaveActualComplexBox((const char*) (fileName.mb_str())); + std::string filename = (const char*) (fileName.mb_str()); + filename=CheckExtension (filename, ".bbs"); + SaveActualComplexBox(filename); } } @@ -647,9 +667,17 @@ void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs() { wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"), wxT("*.bbg"), wxSAVE | wxOVERWRITE_PROMPT); if (saveFileDialog->ShowModal() == wxID_OK) { - _tabsMgr->SetNameTabPanel(saveFileDialog->GetFilename()); + //_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) { diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index 2afb269..8e29061 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -122,6 +122,8 @@ namespace bbtk // Shows the dialog to change the parameters and values of the black box void editBlackBox(GBlackBoxModel *bbmodel); + // Checks and adds if necessary the .bbg/.bbs extensions + std::string CheckExtension (std::string filename, std::string extension); // Method that can be used to refresh the help and package browser // RaC TOFIX!!! void RegenerateAll(); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx index 5ffbdbe..93ded4c 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx @@ -40,7 +40,7 @@ namespace bbtk { //========================================================================= - wxBlackBoxEditionDialog::wxBlackBoxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model):wxDialog(parent,wxID_ANY,_T(""), wxDefaultPosition, wxSize(480, 640),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) + wxBlackBoxEditionDialog::wxBlackBoxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model):wxDialog(parent,wxID_ANY,_T(""), wxDefaultPosition, wxSize(520, 640),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { _model=model; _parent = parent; @@ -90,7 +90,7 @@ namespace bbtk std::string type = port->getBBTKType(); wxStaticText *lblName = new wxStaticText(scrollWin, -1, std2wx(port->getBBTKName()),wxDefaultPosition,wxSize(100,25)); wxStaticText *lblType = new wxStaticText(scrollWin, -1, std2wx(type),wxDefaultPosition,wxSize(250,25)); - wxTextCtrl *txtValue = new wxTextCtrl(scrollWin, -1, _T(""),wxDefaultPosition,wxSize(90,25)); + wxTextCtrl *txtValue = new wxTextCtrl(scrollWin, -1, _T(""),wxDefaultPosition,wxSize(300,25)); if(port->getValue()!="") {