Skip to content

Commit

Permalink
added status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
henrykorir committed Jul 5, 2024
1 parent 28b58ee commit 1bf3008
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 22 additions & 2 deletions minesweeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"));
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -91,7 +101,7 @@ MainFrame::~MainFrame()
Destroy();
}

void MainFrame::OnExitProgram(wxCloseEvent &event)
void MainFrame::OnExitProgram(wxCloseEvent & WXUNUSED(event))
{
Destroy();
}
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion minesweeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -49,4 +51,4 @@ enum
FIELD_EMPTY = 0, FIELD_MINE
};

#endif
#endif

0 comments on commit 1bf3008

Please sign in to comment.