X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/63cafd2799b6e9dcbe34ce63635f1f8a807d895f..9a98a85452729f479bad8538738ee899a0b1aa34:/samples/forty/playerdg.cpp?ds=sidebyside diff --git a/samples/forty/playerdg.cpp b/samples/forty/playerdg.cpp index 38160488da..fa3ea03d04 100644 --- a/samples/forty/playerdg.cpp +++ b/samples/forty/playerdg.cpp @@ -37,6 +37,7 @@ BEGIN_EVENT_TABLE(PlayerSelectionDialog, wxDialog) EVT_BUTTON(wxID_OK, PlayerSelectionDialog::ButtonCallback) EVT_BUTTON(wxID_CANCEL, PlayerSelectionDialog::ButtonCallback) EVT_LISTBOX(ID_LISTBOX, PlayerSelectionDialog::SelectCallback) + EVT_CLOSE(PlayerSelectionDialog::OnCloseWindow) END_EVENT_TABLE() PlayerSelectionDialog::PlayerSelectionDialog( @@ -44,7 +45,7 @@ PlayerSelectionDialog::PlayerSelectionDialog( ScoreFile* file ) : wxDialog(parent, -1, "Player Selection", - wxDefaultPosition, wxSize(250, 200), + wxDefaultPosition, wxSize(320, 200), wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE), m_scoreFile(file) { @@ -59,14 +60,13 @@ PlayerSelectionDialog::PlayerSelectionDialog( 0, 0, wxLB_SINGLE ); - int numPlayers = 0; - wxString* players = 0; - m_scoreFile->GetPlayerList(&players, numPlayers); - for (int i = 0; i < numPlayers; i++) + + wxArrayString players; + m_scoreFile->GetPlayerList(players); + for (unsigned int i = 0; i < players.Count(); i++) { list->Append(players[i]); } - delete players; m_textField = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, 0); @@ -129,34 +129,31 @@ PlayerSelectionDialog::~PlayerSelectionDialog() { } -void PlayerSelectionDialog::OnSize(wxSizeEvent& event) +void PlayerSelectionDialog::OnSize(wxSizeEvent& WXUNUSED(event)) { Layout(); } const wxString& PlayerSelectionDialog::GetPlayersName() { +/* m_player = ""; Show(TRUE); +*/ return m_player; } -bool PlayerSelectionDialog::OnClose() +void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& event) { - // hide the dialog - // NB don't return TRUE otherwise delete is called m_player = ""; - Show(FALSE); - return FALSE; + EndModal(wxID_CANCEL); } void PlayerSelectionDialog::SelectCallback(wxCommandEvent& event) { if (event.GetEventType() == wxEVT_COMMAND_LISTBOX_SELECTED) { -#ifdef __WXGTK__ - if (event.IsSelection()) -#endif +// if (event.IsSelection()) m_textField->SetValue(event.GetString()); } } @@ -175,17 +172,17 @@ void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event) else { m_player = name; - Show(FALSE); + EndModal(wxID_OK); } } else { - wxMessageBox("Please enter your name", "Forty Thieves"); + wxMessageBox("Please enter your name", "Forty Thieves"); } } else { m_player = ""; - Show(FALSE); + EndModal(wxID_CANCEL); } }