_frameAUIMgr->Update();
_actualPkgBrowserBoxName="";
_actualPkgBrowserPkgName="";
+ refreshGUIControls();
}
//Adds a tool btn to the toolbar
toolbar->AddTool(ID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
toolbar->AddTool(ID_OPEN,_T("Open diagram"),bmp_open, wxNullBitmap, wxITEM_NORMAL,_T("Open a diagram"), _T("Open a diagram"));
- toolbar->AddTool(ID_SAVE,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual diagram"));
+ toolbar->AddTool(ID_SAVE_AS_DIAGRAM,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual diagram"));
toolbar->AddTool(ID_RUN,_T("Run"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram"));
toolbar->AddTool(ID_DELETEALL,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes"));
toolbar->AddTool(ID_CENTERVIEW,_T("Center view"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Center view"), _T("Center view"));
// connect command event handlers
Connect(ID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
Connect(ID_OPEN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram));
- Connect(ID_SAVE,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
+ Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
Connect(ID_RUN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram));
Connect(ID_DELETEALL,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram));
Connect(ID_CENTERVIEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram));
void wxGUIEditorGraphicBBS::initMenu()
{
// create a menu bar
- wxMenu *fileMenu = new wxMenu;
-
- // the "About" item should be in the help menu
- wxMenu *helpMenu = new wxMenu;
- helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
+ wxMenu *fileMenu = new wxMenu();
+ fileMenu->Append(ID_NEW, _T("New diagram"), _T("New"));
+ fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save diagram"), _T("Save 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"));
+ Connect(ID_NEW,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
+ Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
+ Connect(ID_SAVE_AS_BBS,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualBBS));
+ Connect(ID_SAVE_AS_COMPLEXBOX,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualComplexBox));
Connect(wxID_EXIT,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit));
+ // the "About" item should be in the help menu
+ wxMenu *helpMenu = new wxMenu;
+ helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
+
// now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(fileMenu, _T("&File"));
menuBar->Append(helpMenu, _T("&Help"));
// attach this menu bar to the frame
- SetMenuBar(menuBar);
+ SetMenuBar(menuBar);
}
//=========================================================================
void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event)
{
_tabsMgr->addNewTab();
- refreshToolbar();
+ refreshGUIControls();
}
//=========================================================================
void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event)
{
- std::string script = _tabsMgr->getActualDiagramScript();
+ std::string script = _tabsMgr->getActualDiagramBBS();
cout<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<<endl;
cout<<script<<endl;
executeScript(script);
}
+ //=========================================================================
+ // HANDLERS
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event)
+ {
+ wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save actual BBS"),wxEmptyString,"NewBBS","*.bbs",wxSAVE|wxOVERWRITE_PROMPT);
+ if (saveFileDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = saveFileDialog->GetPath();
+
+ ofstream file;
+ file.open(fileName.c_str());
+
+ std::string content="";
+
+ // writing file header
+ content += "# ----------------------------------\n";
+ content += "# - BBTKGEditor v 1.0 BBS BlackBox Script\n";
+ content += "# ----------------------------------\n";
+ content += "\n";
+ content += _tabsMgr->getActualDiagramBBS();
+ file << content;
+ file.close();
+ }
+
+ }
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event)
+ {
+ wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of complex box"));
+ std::string cbName="";
+ if (nameDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = nameDialog->GetValue();
+ cbName=fileName;
+ }
+
+ if(!cbName.empty())
+ {
+ wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save Complex Box BBS"),wxEmptyString,cbName,"*.bbs",wxSAVE|wxOVERWRITE_PROMPT);
+ if (saveFileDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = saveFileDialog->GetPath();
+
+ ofstream file;
+ 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 += "# ----------------------------------\n";
+ content += "\n";
+ content += _tabsMgr->getActualComplexBoxBBS(cbName);
+ file << content;
+ file.close();
+ }
+ }
+
+ }
+
//=========================================================================
- /*****************************************************/
- /* HANDLERS
- /*****************************************************/
void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
{
wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save actual diagram"),wxEmptyString,"NewDiagram","*.bbd",wxSAVE|wxOVERWRITE_PROMPT);
//=========================================================================
- void wxGUIEditorGraphicBBS::refreshToolbar()
+ void wxGUIEditorGraphicBBS::refreshGUIControls()
{
wxToolBar* toolbar = GetToolBar();
if(_tabsMgr->isActualDiagramComplexBox())
{
toolbar->ToggleTool(ID_BTNCOMPLEXBOX,true);
- }
- else
- {
- toolbar->ToggleTool(ID_BTNCOMPLEXBOX,false);
- }
-
- bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
- if(temp)
- {
toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true);
toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true);
+
+ GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,true);
+ GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,false);
}
else
{
+ toolbar->ToggleTool(ID_BTNCOMPLEXBOX,false);
toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
+
+ GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,false);
+ GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,true);
}
+
}
//=========================================================================
_tabsMgr->loadDiagram(inputStream);
inputStream.close();
-
-
}
+ refreshGUIControls();
}
//=========================================================================
bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
if(temp)
{
- toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true);
- toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true);
_tabsMgr->setActualDiagramComplexBox(true);
}
else
{
- toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
- toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
_tabsMgr->setActualDiagramComplexBox(false);
}
-
+ refreshGUIControls();
}
//=========================================================================