]> Creatis software - bbtkGEditor.git/commitdiff
#1356, #1358
authorcamarasu <>
Tue, 22 May 2012 16:46:13 +0000 (16:46 +0000)
committercamarasu <>
Tue, 22 May 2012 16:46:13 +0000 (16:46 +0000)
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx

index fd7fa6528d6bae23f661004c5f2a6ff8a7a02716..d9a00b955053d7412eef47ef55078cc77b84f2e2 100644 (file)
@@ -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) {
index 2afb269300b4d3893c9436a2baa197ef5af460af..8e290619b09fc55f38cafdf50927931f3b83db3e 100644 (file)
@@ -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();
index 5ffbdbe68359d58d661c53aa9cbda3cca5f711d7..93ded4c2e29ce18e6945d3a7f3ed4dc5b3360cf5 100644 (file)
@@ -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()!="")
                        {