]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
Documentation panel on the right of bbEditor as a menu option, for lake of use.
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.cxx
index fd7fa6528d6bae23f661004c5f2a6ff8a7a02716..bf26a19399977d21321a5aa5325c7d5a6000586a 100644 (file)
@@ -69,8 +69,8 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) :
        initToolbar();
        initTabPanelsManager();
        initPackageBrowser();
-       initHelpHTMLBrowser();
-
+        // JGGR & CM  initHelpHTMLBrowser();
+        _helpHtmlBrowser = NULL;
        CreateStatusBar();
        _frameAUIMgr->Update();
        _actualPkgBrowserBoxName = "";
@@ -80,6 +80,7 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) :
 
 //=========================================================================
 wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() {
+
        printf("EED %p ~wxGUIEditorGraphicBBS()\n", this);
 
        //EED02JUIN2010         delete _tabsMgr;
@@ -154,6 +155,7 @@ void wxGUIEditorGraphicBBS::initToolbar() {
 
        
        // connect command event handlers
+
        Connect(ID_NEW, wxEVT_COMMAND_TOOL_CLICKED,
                        wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
        Connect(ID_OPEN, wxEVT_COMMAND_TOOL_CLICKED,
@@ -192,11 +194,11 @@ void wxGUIEditorGraphicBBS::initToolbar() {
 }
 //=========================================================================
 void wxGUIEditorGraphicBBS::initHelpHTMLBrowser() {
-       //TO FIX THE PATH OF BBTK BIN  IN ORDER TO USE REGENERATE EXECUTABLES
-       //RegenerateAll();
+       // JGRR & CM 
        _helpHtmlBrowser = new WxGUIHtmlBrowser(this, wxSize(200, 0));
-       _frameAUIMgr->AddPane(_helpHtmlBrowser, wxAuiPaneInfo().Right().MinSize(
-                       200, 200));
+   
+       // EO JGRR & CM 
+       
 }
 
 //=========================================================================
@@ -459,6 +461,17 @@ void wxGUIEditorGraphicBBS::executeScript(std::string script) {
        system(command.c_str());
 }
 
+//=========================================================================
+std::string wxGUIEditorGraphicBBS::CheckExtension(std::string filename, std::string extension) {
+        if(filename.size() > extension.size() ){
+                if( (filename.compare(filename.size()-extension.size(), extension.size(),extension)) !=0 ){
+                        filename.append(extension);
+                }
+        }else{
+                filename.append(extension);
+        }
+       return filename;
+}
 //=========================================================================
 // EVENT HANDLERS
 //=========================================================================
@@ -543,7 +556,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 +619,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 +664,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) {
@@ -743,9 +768,10 @@ void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event) {
                wxString fileName = openFileDialog->GetPath();
                ifstream inputStream;
                std::string fName = (const char*) (fileName.mb_str());
+
                inputStream.open(fName.c_str());
+               assert(inputStream.good()); // fails
                _tabsMgr->addNewTab(openFileDialog->GetFilename());
-
                _tabsMgr->loadDiagram(inputStream, fName);
 
                inputStream.close();
@@ -868,10 +894,21 @@ void wxGUIEditorGraphicBBS::OnPlugPackage(wxCommandEvent& event) {
 //=========================================================================
 void wxGUIEditorGraphicBBS::OnEditConfig(wxCommandEvent& event) {
        printf("EED wxGUIEditorGraphicBBS::OnEditConfig ... not implemented ..\n");
-}
-//=========================================================================
-void wxGUIEditorGraphicBBS::OnShowHTMLDoc(wxCommandEvent& event) {
-       printf("EED wxGUIEditorGraphicBBS::OnShowHTMLDoc ... not implemented ..\n");
+    }
+    //=========================================================================
+
+    void wxGUIEditorGraphicBBS::OnShowHTMLDoc(wxCommandEvent& event) {
+        // JGRR & CM WH
+        if (_helpHtmlBrowser != NULL){
+             _frameAUIMgr->DetachPane(_helpHtmlBrowser);
+            _helpHtmlBrowser->Destroy();   
+        }
+        initHelpHTMLBrowser();
+        _frameAUIMgr->AddPane(_helpHtmlBrowser, wxAuiPaneInfo().Right().MinSize(200, 200));
+        _frameAUIMgr->Update();
+        refreshGUIControls();
+        
+        // EO JGRR    & CM WH       
 }
 //=========================================================================
 void wxGUIEditorGraphicBBS::OnCreateIndex(wxCommandEvent& event) {
@@ -884,6 +921,8 @@ void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event) {
        Close(true);
 }
 
+
+
 //=========================================================================
 
 } // EO namespace bbtk