X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/63cafd2799b6e9dcbe34ce63635f1f8a807d895f..13393ab6233f67b0afe3e02bc6bc3229b8104f43:/samples/forty/scoredg.cpp diff --git a/samples/forty/scoredg.cpp b/samples/forty/scoredg.cpp index bd4d9b93b6..de7d7a6a09 100644 --- a/samples/forty/scoredg.cpp +++ b/samples/forty/scoredg.cpp @@ -27,11 +27,16 @@ #include "wx/wx.h" #endif -#if defined(__WXMSW__) && !defined(GNUWIN32) +#if wxUSE_IOSTREAMH +#if defined(__WXMSW__) && !defined(__GNUWIN32__) #include #else #include #endif +#else +#include +using namespace std; +#endif #include "scorefil.h" #include "scoredg.h" @@ -58,14 +63,13 @@ ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile) : m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL); #endif - wxString* players = 0; - int length = 0; - scoreFile->GetPlayerList(&players, length); + wxArrayString players; + scoreFile->GetPlayerList( players); ostrstream os; os << "Player\tWins\tGames\tScore\n"; - for (int i = 0; i < length; i++) + for (unsigned int i = 0; i < players.Count(); i++) { int wins, games, score; scoreFile->ReadPlayersScore(players[i], wins, games, score); @@ -84,7 +88,6 @@ ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile) : char* str = os.str(); m_text = str; delete str; - delete players; } ScoreCanvas::~ScoreCanvas() @@ -93,7 +96,7 @@ ScoreCanvas::~ScoreCanvas() void ScoreCanvas::OnDraw(wxDC& dc) { - dc.SetFont(m_font); + dc.SetFont(* m_font); const char* str = m_text; unsigned int tab = 0; @@ -134,6 +137,9 @@ void ScoreCanvas::OnDraw(wxDC& dc) } } +BEGIN_EVENT_TABLE(ScoreDialog, wxDialog) + EVT_CLOSE(ScoreDialog::OnCloseWindow) +END_EVENT_TABLE() ScoreDialog::ScoreDialog( wxWindow* parent, @@ -180,10 +186,7 @@ void ScoreDialog::Display() Show(TRUE); } -bool ScoreDialog::OnClose() +void ScoreDialog::OnCloseWindow(wxCloseEvent& event) { - // hide the dialog - // NB don't return TRUE otherwise delete is called - Show(FALSE); - return FALSE; + EndModal(wxID_OK); }