]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/forty/playerdg.cpp
Added the forgotten file txtstrm.tex
[wxWidgets.git] / samples / forty / playerdg.cpp
index c85ca7286592d197cebe76b7700d6be37c5e5d98..fa3ea03d046635a980e8bb183a87e0f594a8fe4c 100644 (file)
@@ -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(
@@ -62,7 +63,7 @@ PlayerSelectionDialog::PlayerSelectionDialog(
     
        wxArrayString players;
        m_scoreFile->GetPlayerList(players);
-       for (int i = 0; i < players.Count(); i++)
+       for (unsigned int i = 0; i < players.Count(); i++)
        {
                list->Append(players[i]);
        }
@@ -128,7 +129,7 @@ PlayerSelectionDialog::~PlayerSelectionDialog()
 {
 }
 
-void PlayerSelectionDialog::OnSize(wxSizeEvent& event)
+void PlayerSelectionDialog::OnSize(wxSizeEvent& WXUNUSED(event))
 {
        Layout();
 }
@@ -142,22 +143,17 @@ const wxString& PlayerSelectionDialog::GetPlayersName()
        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());
        }
 }
@@ -176,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);
        }
 }