]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
This commit was manufactured by cvs2svn to create tag 'CREATOOLS_2-0-3'.
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.cxx
index 592d7d01ebbd795038e2019a62a01e11a125022c..f3f6a04d7e6e8624a984ff3240e38ea3541f9940 100644 (file)
@@ -440,100 +440,133 @@ namespace bbtk
                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.1 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(  );
-
-                       ofstream file;
-
-//EED                  file.open(fileName.c_str());
-                       file.open( (const char*) (fileName.mb_str()) );
-
-                       std::string content="";
-
-                       // writing file header
-                       content += "# ----------------------------------\n";
-                       content += "# - BBTKGEditor v 1.1 BBS BlackBox Script\n";
-                       content += "# ----------------------------------\n";
-                       content += "\n";
-                       content += _tabsMgr->getActualDiagramBBS();
-                       file << content;
-                       file.close();
+            SaveActualBBS( (const char*) (fileName.mb_str())  );
                }
 
        }
 
+
        //=========================================================================
 
-       void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event)
+       void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename)
        {
                wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of complex box"));
                std::string cbName="";
                if (nameDialog->ShowModal() == wxID_OK)
                {
-                       wxString fileName = nameDialog->GetValue();
-                       cbName=(const char*) (fileName.mb_str());
+                       wxString complexboxname = nameDialog->GetValue();
+                       cbName=(const char*) (complexboxname.mb_str());
                }
 
                if(!cbName.empty())
                {
-                       wxFileDialog * saveFileDialog = new wxFileDialog(this ,wxT("Save Complex Box BBS") ,wxEmptyString, wxString( cbName.c_str(), wxConvUTF8),wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
-                       if (saveFileDialog->ShowModal() == wxID_OK)
-                       {
-                               wxString fileName = saveFileDialog->GetPath();
 
                                ofstream file;
-                               file.open( (const char*) (fileName.mb_str()) );
+                               file.open( filename.c_str() );
 
                                std::string content="";
 
                                // writing file header
                                content += "# ----------------------------------\n";
                                content += "# - BBTKGEditor v 1.1 BBS BlackBox Script (Complex Box)\n";
+                content += "# - ";
+                content += filename;
+                content += "\n";
                                content += "# ----------------------------------\n";
                                content += "\n";
                                content += _tabsMgr->getActualComplexBoxBBS(cbName);
                                file << content;
                                file.close();
-                       }
                }
 
+
        }
 
        //=========================================================================
 
-       void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
+       void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event)
        {
-               wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save  actual diagram"),wxEmptyString,wxT("NewDiagram"),wxT("*.bbg"),wxSAVE|wxOVERWRITE_PROMPT);
-               if (saveFileDialog->ShowModal() == wxID_OK)
-               {
-                       wxString fileName = saveFileDialog->GetPath();
+        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();
+            SaveActualComplexBox( (const char*) (fileName.mb_str()) );
+        }
+       }
+
+       //=========================================================================
+       void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename)
+       {
+        ofstream file;
+        file.open( filename.c_str() );
 
-                       ofstream file;
-                       file.open( (const char*) (fileName.mb_str()) );
+        std::string content="";
 
-                       std::string content="";
+        // writing file header
+        content += "# ----------------------------------\n";
+        content += "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file\n";
+        content += "# - ";
 
-                       // writing file header
-                       content += "# ----------------------------------\n";
-                       content += "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file\n";
-                       content += "# - ";
+        content += filename;
 
-                       content += (const char*) (fileName.mb_str());
+        content += "\n";
+        content += "# ----------------------------------\n";
+        content += "\n";
+        content += "APP_START\n";
+        _tabsMgr->saveActualDiagram(content);
+        content += "APP_END\n";
+        file << content;
+        file.close();
+    }
 
-                       content += "\n";
-                       content += "# ----------------------------------\n";
-                       content += "\n";
-                       content += "APP_START\n";
-                       _tabsMgr->saveActualDiagram(content);
-                       content += "APP_END\n";
-                       file << content;
-                       file.close();
-               }
 
+       //=========================================================================
+       void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
+       {
+               wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save  actual diagram"),wxEmptyString,wxT("NewDiagram"),wxT("*.bbg"),wxSAVE|wxOVERWRITE_PROMPT);
+               if (saveFileDialog->ShowModal() == wxID_OK)
+               {
+                       wxString fileName       = saveFileDialog->GetPath();
+                       std::string filename    = (const char*) (fileName.mb_str());
+            std::string filenamebbs = filename+"s";
+
+            SaveActualDiagram( filename );
+            if (_tabsMgr->isActualDiagramComplexBox()==false)
+            {
+                SaveActualBBS(filenamebbs);
+            } else {
+                SaveActualComplexBox(filenamebbs);
+            } //if isActualDiagramComplexBox
+               } // if saveFileDialog
        }
 
        //=========================================================================
@@ -689,21 +722,21 @@ namespace bbtk
                _tabsMgr->copySelectedBBoxesToComplexDiagram();
        }
 
-       
+
        void wxGUIEditorGraphicBBS::OnHelpBBeditor(wxCommandEvent& event)
        {
                printf("wxGUIEditorGraphicBBS::OnHelpBBeditor ......\n");
        }
-       
-       
-       
+
+
+
        //=========================================================================
 
        void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
        {
                Close(true);
        }
-       
+
 
 
        //=========================================================================