diff --git a/minesweeper.cpp b/minesweeper.cpp index 2751b78..b88a06f 100644 --- a/minesweeper.cpp +++ b/minesweeper.cpp @@ -11,6 +11,8 @@ wxBEGIN_EVENT_TABLE(MainFrame, wxFrame) EVT_CLOSE(MainFrame::OnExitProgram) EVT_TIMER(TIMER_ID, MainFrame::OnTimer) + EVT_MENU(wxID_NEW, MainFrame::OnNewGame) + EVT_MENU(wxID_EXIT, MainFrame::OnExitGame) wxEND_EVENT_TABLE() MainFrame::MainFrame(const wxString &title) @@ -20,7 +22,7 @@ MainFrame::MainFrame(const wxString &title) //Adding menubar and menus wxMenu * m_menu = new wxMenu(); - m_menu->Append(wxID_OPEN, wxT("&New")); + m_menu->Append(wxID_NEW, wxT("&New")); m_menu->Append(wxID_EXIT, wxT("&Exit")); wxMenuBar * m_menubar = new wxMenuBar(); m_menubar->Append(m_menu, wxT("File")); @@ -53,6 +55,14 @@ MainFrame::MainFrame(const wxString &title) dashSizer->Add(flagSizer, 0, wxALIGN_CENTER | wxALL); srand((unsigned)time(NULL)); + // status bar + wxStatusBar * m_status = new wxStatusBar(this, wxID_ANY, wxST_SIZEGRIP); + int widths[] = { 60, 60, -1 }; + m_status->SetFieldsCount(WXSIZEOF(widths), widths); + m_status->SetStatusText(_("Ready"),0); + + SetStatusBar(m_status); + int id = 0; for (int x = 0; x < 9; x++) @@ -91,7 +101,7 @@ MainFrame::~MainFrame() Destroy(); } -void MainFrame::OnExitProgram(wxCloseEvent &event) +void MainFrame::OnExitProgram(wxCloseEvent & WXUNUSED(event)) { Destroy(); } @@ -240,6 +250,16 @@ void MainFrame::StopTimer() { m_timer->Stop(); } + +void MainFrame::OnNewGame(wxCommandEvent& WXUNUSED(event)) +{ + wxMessageBox("Are you sure?"); +} + +void MainFrame::OnExitGame(wxCommandEvent& WXUNUSED(event)) +{ + Destroy(); +} wxDECLARE_APP(Minesweeper); wxIMPLEMENT_APP(Minesweeper); diff --git a/minesweeper.h b/minesweeper.h index 1f85cc2..cbaa466 100644 --- a/minesweeper.h +++ b/minesweeper.h @@ -22,6 +22,8 @@ class MainFrame : public wxFrame ~MainFrame(); void OnExitProgram(wxCloseEvent&); void OnMouseEvent(wxMouseEvent&); + void OnNewGame(wxCommandEvent&); + void OnExitGame(wxCommandEvent&); void UnCover(int, int); void Reveal(); @@ -49,4 +51,4 @@ enum FIELD_EMPTY = 0, FIELD_MINE }; -#endif +#endif \ No newline at end of file