OnClose event scaffold

This commit is contained in:
Timothy Warren 2015-04-15 21:26:09 -04:00
parent 0c0152d324
commit 0103c323bd
3 changed files with 28 additions and 3 deletions

View File

@ -146,7 +146,7 @@ void MainFrame::BindEvents()
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnOpen, this, wxID_OPEN);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnSave, this, wxID_SAVE);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnSaveAs, this, wxID_SAVEAS);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnFileClose, this, wxID_CLOSE);
Bind(wxEVT_CLOSE_WINDOW, &TabContainer::OnClose, notebook, wxID_CLOSE);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnAbout, this, wxID_ABOUT);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnQuit, this, wxID_EXIT);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditCut, this, wxID_CUT);
@ -186,8 +186,11 @@ void MainFrame::OnFileClose(wxCommandEvent &WXUNUSED(event))
void MainFrame::OnSave(wxCommandEvent &WXUNUSED(event))
{
wxString file = notebook->GetCurrentEditor()->fileName;
notebook->GetCurrentEditor()->SaveFile(file);
EditPane *editor = notebook->GetCurrentEditor();
wxString file = editor->fileName;
editor->SetSavePoint();
editor->SaveFile(file);
}
void MainFrame::OnSaveAs(wxCommandEvent &WXUNUSED(event))

View File

@ -64,3 +64,24 @@ EditPane *TabContainer::GetCurrentEditor()
{
return (EditPane *) this->GetCurrentPage();
}
void TabContainer::OnClose(wxCloseEvent &event)
{
//EditPane *currentTab = this->GetCurrentEditor();
if (event.CanVeto() && false)//currentTab->isModified())
{
if (
wxMessageBox("The file has not been saved... continue closing?",
"Please confirm",
wxICON_QUESTION | wxYES_NO
) != wxYES
)
{
event.Veto();
return;
}
}
Destroy();
}

View File

@ -30,6 +30,7 @@ public:
void AddTab();
void AddTab(wxString filePath);
void OnEditSelectAll(wxCommandEvent &event);
void OnClose(wxCloseEvent &event);
EditPane *GetCurrentEditor();
private:
};