]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
Feature #1380
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.cxx
index 25c4298571c017fe73111c325ae3b4d81f171053..4fb42dbdafb20feab9362ca47ff96ae116f06d49 100644 (file)
@@ -147,6 +147,7 @@ void wxGUIEditorGraphicBBS::initToolbar() {
        toolbar->AddSeparator();
        toolbar->AddTool(ID_UNDO, _T("Undo"),bmp_undo, wxNullBitmap, wxITEM_NORMAL,     _T("Undo"), _T("Undo"));
        toolbar->AddTool(ID_REDO, _T("Redo"),bmp_redo, wxNullBitmap, wxITEM_NORMAL,     _T("Redo"), _T("Redo"));
+       
        toolbar->EnableTool(ID_UNDO, false);
        toolbar->EnableTool(ID_REDO, false);
        toolbar->SetMargins(2, 2);
@@ -304,7 +305,7 @@ void wxGUIEditorGraphicBBS::initPackageBrowser() {
        _pkgBrowser = new WxGUIPackageBrowser2(this);
        _pkgBrowser->IncludeAll();
        _frameAUIMgr->AddPane(_pkgBrowser,
-                       wxAuiPaneInfo().Left().MinSize(200, 200).CloseButton(false));
+                       wxAuiPaneInfo().Left().MinSize(480, 400).CloseButton(false));
 }
 
 //================================================================
@@ -492,8 +493,11 @@ void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) {
 
 void wxGUIEditorGraphicBBS::OnUndo(wxCommandEvent& event) {
        unsigned short disable;
+       std::string stundo;
+       std::string stredo;
+
        _tabsMgr->loadTempDiagram(0);
-       disable = _tabsMgr->getUndoState();
+       disable = _tabsMgr->getUndoState(stundo);
        if(disable == 0)
        {
                std::string name = _tabsMgr->GetNameTabPanel();
@@ -505,15 +509,26 @@ void wxGUIEditorGraphicBBS::OnUndo(wxCommandEvent& event) {
        }
 
        GetToolBar()->EnableTool(ID_UNDO,disable);
-       GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState());
+       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);
-       GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState());
-       GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState());
+       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();
 }
 
@@ -673,13 +688,19 @@ void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) {
 }
 
 //=========================================================================
-void wxGUIEditorGraphicBBS::SaveTempActualDiagram() 
+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();
+       _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));
 }
 
 //=========================================================================
@@ -725,6 +746,12 @@ void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) {
                pathfilenamebbs[pathfilenamebbs.length() - 1] = 's';
                
                if (_tabsMgr->isActualDiagramComplexBox() == false) {
+                       std::string name = _tabsMgr->GetNameTabPanel();
+                       if(name[name.length() - 1] == '*')
+                       {
+                               name =name.substr(0,name.length()-1);
+                       }
+                       _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
                        SaveActualDiagram(pathfilename);
                        SaveActualBBS(pathfilenamebbs);
                } else {
@@ -742,6 +769,8 @@ void wxGUIEditorGraphicBBS::OnSaveAsActualDiagram(wxCommandEvent& event) {
 //=========================================================================
 
 void wxGUIEditorGraphicBBS::refreshGUIControls() {
+       std::string stundo;
+       std::string stredo;
        wxToolBar* toolbar = GetToolBar();
        if (_tabsMgr->isActualDiagramComplexBox()) {
                toolbar->ToggleTool(ID_BTNCOMPLEXBOX, true);
@@ -759,8 +788,10 @@ void wxGUIEditorGraphicBBS::refreshGUIControls() {
                GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, true);
        }
 
-       GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState());
-       GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState());
+       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));
 
        if (_tabsMgr->getNumActualSelectedObjects() > 0) {
                GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true);
@@ -803,7 +834,9 @@ void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event) {
                assert(inputStream.good()); // fails
                _tabsMgr->addNewTab(openFileDialog->GetFilename());
                _tabsMgr->loadDiagram(inputStream, fName);
-
+               _tabsMgr->saveTempActualDiagram("load diagram");
+               GetToolBar()->EnableTool(ID_UNDO, false);
+               GetToolBar()->EnableTool(ID_UNDO, false);
                inputStream.close();
        }
        refreshGUIControls();
@@ -820,20 +853,14 @@ void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event) {
 
                wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
                
-               // save empty state!!
-       /*      if (_tabsMgr->getNumActualSelectedObjects() == 0)
-               {
-                       SaveTempActualDiagram();
-               }
-               */
+
                if (pnl != NULL) {
                        wxVtkSceneManager *scn = pnl->getSceneManager();
                        scn->createGBlackBox(50, 50, packageName, typeName);
                        scn->refresh();
                }
-               if (GetToolBar()->GetToolEnabled(ID_UNDO) == false)
-                       GetToolBar()->EnableTool(ID_UNDO,true);
-               SaveTempActualDiagram();
+
+               SaveTempActualDiagram("New Box");
                // if pnl
        }// if bbDes
 }