X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FbbtkwxGUIEditorGraphicBBS.cxx;h=d7ab7dd65975a89cb03b99d23b3946587a8b2cfb;hb=2c0b651d9f793d143396b52631b460280afcc021;hp=94d6e548caf7a07d41f3e9a869ce39bc26694b02;hpb=113e09db81654632fb794ed1945c019e89b729c6;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 94d6e54..d7ab7dd 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -69,8 +69,8 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) : initToolbar(); initTabPanelsManager(); initPackageBrowser(); - initHelpHTMLBrowser(); - + // JGGR & CM initHelpHTMLBrowser(); + _helpHtmlBrowser = NULL; CreateStatusBar(); _frameAUIMgr->Update(); _actualPkgBrowserBoxName = ""; @@ -147,14 +147,15 @@ 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->EnableTool(ID_UNDO, false); + toolbar->EnableTool(ID_REDO, false); toolbar->SetMargins(2, 2); toolbar->Realize(); SetToolBar(toolbar); // connect command event handlers + Connect(ID_NEW, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab)); Connect(ID_OPEN, wxEVT_COMMAND_TOOL_CLICKED, @@ -189,15 +190,15 @@ void wxGUIEditorGraphicBBS::initToolbar() { wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput)); Connect(ID_UNDO,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnUndo)); Connect(ID_REDO,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnRedo)); - + Connect(ID_CHANGENAME, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnChangeName)); } //========================================================================= 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 + } //========================================================================= @@ -209,7 +210,9 @@ void wxGUIEditorGraphicBBS::initMenu() { fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save Diagram As"), _T("Save Diagram As")); //DFCH fileMenu->Append(ID_OPEN_BBS, _T("Open BBS"), _T("Open BBS")); - fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS")); + // CM + fileMenu->Append(ID_OPEN, _T("Open a diagram"), _T("Open a diagram")); + fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS")); fileMenu->Append(ID_SAVE_AS_COMPLEXBOX, _T("Save complex box"), _T("Save complex box")); fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit")); @@ -482,19 +485,33 @@ void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) { void wxGUIEditorGraphicBBS::OnUndo(wxCommandEvent& event) { unsigned short disable; - GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->loadTempDiagram(0)); - if (GetToolBar()->GetToolEnabled(ID_REDO) == false) - GetToolBar()->EnableTool(ID_REDO,true); + _tabsMgr->loadTempDiagram(0); + disable = _tabsMgr->getUndoState(); + if(disable == 0) + { + std::string name = _tabsMgr->GetNameTabPanel(); + if(name[name.length() - 1] == '*') + { + name =name.substr(0,name.length()-1); + } + _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8)); + } + + GetToolBar()->EnableTool(ID_UNDO,disable); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); refreshGUIControls(); } void wxGUIEditorGraphicBBS::OnRedo(wxCommandEvent& event) { unsigned short disable; - GetToolBar()->EnableTool(ID_REDO, _tabsMgr->loadTempDiagram(1)); - if (GetToolBar()->GetToolEnabled(ID_UNDO) == false) - GetToolBar()->EnableTool(ID_UNDO,true); + _tabsMgr->loadTempDiagram(1); + GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState()); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); refreshGUIControls(); } + +void wxGUIEditorGraphicBBS::OnChangeName(wxCommandEvent& event){ +} //========================================================================= void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) { @@ -651,6 +668,10 @@ void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) { //========================================================================= void wxGUIEditorGraphicBBS::SaveTempActualDiagram() { + std::string name = _tabsMgr->GetNameTabPanel(); + if(name[name.length() - 1] != '*') + name +="*"; + _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8)); _tabsMgr->saveTempActualDiagram(); } @@ -695,7 +716,7 @@ void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) { } else { std::string pathfilenamebbs = pathfilename; pathfilenamebbs[pathfilenamebbs.length() - 1] = 's'; - + if (_tabsMgr->isActualDiagramComplexBox() == false) { SaveActualDiagram(pathfilename); SaveActualBBS(pathfilenamebbs); @@ -731,6 +752,9 @@ void wxGUIEditorGraphicBBS::refreshGUIControls() { GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, true); } + GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState()); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); + if (_tabsMgr->getNumActualSelectedObjects() > 0) { GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true); } else { @@ -767,9 +791,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(); @@ -892,10 +917,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) { @@ -908,6 +944,8 @@ void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event) { Close(true); } + + //========================================================================= } // EO namespace bbtk