]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 914126 ] Cleaning of the forty demo
authorJulian Smart <julian@anthemion.co.uk>
Tue, 23 Mar 2004 21:23:17 +0000 (21:23 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Tue, 23 Mar 2004 21:23:17 +0000 (21:23 +0000)
Also made configurable between use of grid and canvas

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26310 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

demos/forty/canvas.cpp
demos/forty/canvas.h
demos/forty/card.cpp
demos/forty/forty.bkl
demos/forty/forty.cpp
demos/forty/forty.h
demos/forty/game.cpp
demos/forty/pile.cpp
demos/forty/pile.h
demos/forty/playerdg.cpp
demos/forty/scoredg.cpp

index 995e7cbfbfe1e0eea154a52ccbc05522a50b8a79..8a5257d54c7bf98b57ff1c34f29911838af2cd77 100644 (file)
@@ -38,12 +38,12 @@ BEGIN_EVENT_TABLE(FortyCanvas, wxScrolledWindow)
     EVT_MOUSE_EVENTS(FortyCanvas::OnMouseEvent)
 END_EVENT_TABLE()
 
-FortyCanvas::FortyCanvas(wxWindow* parent, int x, int y, int w, int h) :
-       wxScrolledWindow(parent, -1, wxPoint(x, y), wxSize(w, h)),
-       m_helpingHand(TRUE),
-       m_rightBtnUndo(TRUE),
+FortyCanvas::FortyCanvas(wxWindow* parent, const wxPoint& pos, const wxSize& size) :
+       wxScrolledWindow(parent, wxID_ANY, pos, size),
+       m_helpingHand(true),
+       m_rightBtnUndo(true),
        m_playerDialog(0),
-       m_leftBtnDown(FALSE)
+       m_leftBtnDown(false)
 {
 #ifdef __WXGTK__
        m_font = wxTheFontList->FindOrCreateFont(12, wxROMAN, wxNORMAL, wxNORMAL);
@@ -116,7 +116,7 @@ void FortyCanvas::OnDraw(wxDC& dc)
                else
                {
                        // user cancelled the dialog - exit the app
-                       ((wxFrame*)GetParent())->Close(TRUE);
+                       ((wxFrame*)GetParent())->Close(true);
                }
        }
 #endif
@@ -148,7 +148,7 @@ void FortyCanvas::ShowPlayerDialog()
                else
                {
                        // user cancelled the dialog - exit the app
-                       ((wxFrame*)GetParent())->Close(TRUE);
+                       ((wxFrame*)GetParent())->Close(true);
                }
         }
 }
@@ -162,9 +162,9 @@ bool FortyCanvas::OnCloseCanvas()
                wxMessageBox(_T("Are you sure you want to\nabandon the current game?"),
                        _T("Warning"), wxYES_NO | wxICON_QUESTION) == wxNO)
        {
-        return FALSE;
+        return false;
        }
-       return TRUE;
+       return true;
 }
 
 void FortyCanvas::OnMouseEvent(wxMouseEvent& event)
@@ -180,7 +180,7 @@ void FortyCanvas::OnMouseEvent(wxMouseEvent& event)
        {
                if (m_leftBtnDown)
                {
-                       m_leftBtnDown = FALSE;
+                       m_leftBtnDown = false;
                        ReleaseMouse();
                        m_game->LButtonUp(dc, mouseX, mouseY);
                }
@@ -190,7 +190,7 @@ void FortyCanvas::OnMouseEvent(wxMouseEvent& event)
        {
                if (!m_leftBtnDown)
                {
-                       m_leftBtnDown = TRUE;
+                       m_leftBtnDown = true;
                        CaptureMouse();
                        m_game->LButtonDown(dc, mouseX, mouseY);
                }
@@ -199,14 +199,14 @@ void FortyCanvas::OnMouseEvent(wxMouseEvent& event)
        {
                if (m_leftBtnDown)
                {
-                       m_leftBtnDown = FALSE;
+                       m_leftBtnDown = false;
                        ReleaseMouse();
                        m_game->LButtonUp(dc, mouseX, mouseY);
                }
        }
        else if (event.RightDown() && !event.LeftIsDown())
        {
-               // only allow right button undo if m_rightBtnUndo is TRUE
+               // only allow right button undo if m_rightBtnUndo is true
                if (m_rightBtnUndo)
                {
                        if (event.ControlDown() || event.ShiftDown())
index 28ef41f1c6e5318dda62f40589ef0973ce4612be..b7ea7d54594336018967cae42466b8e75e7509f9 100644 (file)
@@ -21,7 +21,7 @@ class PlayerSelectionDialog;
 class FortyCanvas: public wxScrolledWindow
 {
 public:
-       FortyCanvas(wxWindow* parent, int x, int y, int w, int h);
+       FortyCanvas(wxWindow* parent, const wxPoint& pos, const wxSize& size);
        virtual ~FortyCanvas();
 
        virtual void OnDraw(wxDC& dc);
index dcbe119aa9d1efad94258385907d165c2695e8eb..6681cb691ef78e14021c643345461b69dd1fc955 100644 (file)
@@ -111,11 +111,11 @@ Card::Card(int value, WayUp way_up) :
                        break;
                }
                m_pipValue = 1 + (value - 1) % 13;
-               m_status = TRUE;
+               m_status = true;
     }
     else
     {
-        m_status = FALSE;
+        m_status = false;
     }
 } // Card::Card()
 
index d7634dbeb9b6b8d73e75df3b830be20679b1618c..7db5894eb0cb55dd3b8e22e24e49dcec29674303 100644 (file)
@@ -15,6 +15,7 @@
             scorefil.cpp
         </sources>
         <wx-lib>html</wx-lib>
+        <wx-lib>adv</wx-lib>
         <wx-lib>core</wx-lib>
         <wx-lib>base</wx-lib>
         <win32-res>forty.rc</win32-res>
index 9f3fa5cc988ae2c54c290b62a4bc23ca9424b10b..d809a743a5221b878a52f53bf536a1833409ae61 100644 (file)
@@ -74,27 +74,30 @@ FortyApp::~FortyApp()
 
 bool FortyApp::OnInit()
 {
-        bool largecards = FALSE;
+  bool largecards = false;
+
         wxSize size(668,510);
 
         if ((argc > 1) && (!wxStrcmp(argv[1],_T("-L"))))
         {
-            largecards = TRUE;
+    largecards = true;
             size = wxSize(1000,750);
         }
 
        FortyFrame* frame = new FortyFrame(
                        0,
                        _T("Forty Thieves"),
-                        -1, -1, size.x, size.y,largecards
+    wxDefaultPosition,
+    size,
+    largecards
                        );
 
        // Show the frame
-       frame->Show(TRUE);
+       frame->Show(true);
 
         frame->GetCanvas()->ShowPlayerDialog();
 
-       return TRUE;
+       return true;
 }
 
 const wxColour& FortyApp::BackgroundColour()
@@ -128,8 +131,8 @@ const wxColour& FortyApp::TextColour()
 }
 
 // My frame constructor
-FortyFrame::FortyFrame(wxFrame* frame, const wxString& title, int x, int y, int w, int h,bool largecards):
-       wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
+FortyFrame::FortyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size, bool largecards):
+       wxFrame(frame, wxID_ANY, title, pos, size)
 {
 #ifdef __WXMAC__
        wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
@@ -157,21 +160,21 @@ FortyFrame::FortyFrame(wxFrame* frame, const wxString& title, int x, int y, int
        optionsMenu->Append(RIGHT_BUTTON_UNDO,
                        _T("&Right button undo"),
                        _T("Enables/disables right mouse button undo and redo"),
-                       TRUE
+                       true
                        );
        optionsMenu->Append(HELPING_HAND,
                        _T("&Helping hand"),
                        _T("Enables/disables hand cursor when a card can be moved"),
-                       TRUE
+                       true
                        );
         optionsMenu->Append(LARGE_CARDS,
                         _T("&Large cards"),
                         _T("Enables/disables large cards for high resolution displays"),
-                        TRUE
+                        true
                         );
-       optionsMenu->Check(HELPING_HAND, TRUE);
-       optionsMenu->Check(RIGHT_BUTTON_UNDO, TRUE);
-        optionsMenu->Check(LARGE_CARDS, largecards ? TRUE : FALSE);
+       optionsMenu->Check(HELPING_HAND, true);
+       optionsMenu->Check(RIGHT_BUTTON_UNDO, true);
+        optionsMenu->Check(LARGE_CARDS, largecards ? true : false);
 
        wxMenu* helpMenu = new wxMenu;
        helpMenu->Append(wxID_HELP_CONTENTS, _T("&Help Contents"), _T("Displays information about playing the game"));
@@ -188,13 +191,12 @@ FortyFrame::FortyFrame(wxFrame* frame, const wxString& title, int x, int y, int
         if (largecards)
             Card::SetScale(1.3);
 
-       m_canvas = new FortyCanvas(this, 0, 0, 400, 400);
-       wxLayoutConstraints* constr = new wxLayoutConstraints;
-       constr->left.SameAs(this, wxLeft);
-       constr->top.SameAs(this, wxTop);
-       constr->right.SameAs(this, wxRight);
-       constr->height.SameAs(this, wxHeight);
-       m_canvas->SetConstraints(constr);
+       m_canvas = new FortyCanvas(this, wxDefaultPosition, size);
+
+  wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
+  topsizer->Add( m_canvas, 1, wxEXPAND | wxALL, 0);
+  SetSizer( topsizer );
+  topsizer->SetSizeHints( this );
 
        CreateStatusBar();
 }
@@ -222,7 +224,7 @@ FortyFrame::NewGame(wxCommandEvent&)
 void
 FortyFrame::Exit(wxCommandEvent&)
 {
-       Close(TRUE);
+       Close(true);
 }
 
 void
@@ -231,7 +233,7 @@ FortyFrame::Help(wxCommandEvent& event)
 #if wxUSE_HTML
     if (wxFileExists(wxT("about.htm")))
     {
-        FortyAboutDialog dialog(this, -1, wxT("Forty Thieves Instructions"));
+        FortyAboutDialog dialog(this, wxID_ANY, wxT("Forty Thieves Instructions"));
         if (dialog.ShowModal() == wxID_OK)
         {
         }
@@ -380,13 +382,12 @@ bool FortyAboutDialog::AddControls(wxWindow* parent)
 
     item0->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
 
-    parent->SetAutoLayout( TRUE );
     parent->SetSizer( item0 );
     parent->Layout();
     item0->Fit( parent );
     item0->SetSizeHints( parent );
 #endif
 
-    return TRUE;
+    return true;
 }
 
index 100b9edc530c39d93b1c490442f5ba2291e71501..09750b2b583d9498b7f078e968e62038c168f80a 100644 (file)
@@ -34,7 +34,7 @@ class FortyCanvas;
 class FortyFrame: public wxFrame
 {
 public:
-        FortyFrame(wxFrame* frame, const wxString& title, int x, int y, int w, int h,bool largecards);
+  FortyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size, bool largecards);
        virtual ~FortyFrame();
 
        void OnCloseWindow(wxCloseEvent& event);
index 9eed283867f3924fe0e2cfa28a430cb5419c8a2c..d1d38e9d487cc386c8e6f080f99250f97033786b 100644 (file)
@@ -35,7 +35,7 @@
 #include "game.h"
 
 Game::Game(int wins, int games, int score) :
-       m_inPlay(FALSE),
+       m_inPlay(false),
        m_moveIndex(0),
        m_redoIndex(0),
        m_bmap(0),
@@ -181,7 +181,7 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
 
        if (!m_inPlay)
        {
-               m_inPlay = TRUE;
+               m_inPlay = true;
                m_numGames++;
        }
        DisplayScore(dc);
@@ -198,7 +198,7 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
                }
 
                // This game is over
-               m_inPlay = FALSE;
+               m_inPlay = false;
 
                // Redraw the score box to update games won
                DisplayScore(dc);
@@ -212,7 +212,7 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
                else
                {
                        // user cancelled the dialog - exit the app
-                       ((wxFrame*)canvas->GetParent())->Close(TRUE);
+                       ((wxFrame*)canvas->GetParent())->Close(true);
                }
        }
 }
@@ -315,7 +315,7 @@ void Game::Deal()
                m_totalScore += m_currentScore;
        }
     m_currentScore = 0;
-    m_inPlay = FALSE;
+    m_inPlay = false;
 }
 
 
@@ -524,21 +524,21 @@ void Game::LButtonDblClk(wxDC& dc, int x, int y)
 // i.e. m_pack, discard and bases are empty
 bool Game::HaveYouWon()
 {
-    if (m_pack->GetTopCard()) return FALSE;
-    if (m_discard->GetTopCard()) return FALSE;
+    if (m_pack->GetTopCard()) return false;
+    if (m_discard->GetTopCard()) return false;
     for(int i = 0; i < 10; i++)
     {
-       if (m_bases[i]->GetTopCard()) return FALSE;
+       if (m_bases[i]->GetTopCard()) return false;
     }
     m_numWins++;
     m_totalScore += m_currentScore;
     m_currentScore = 0;
-    return TRUE;
+    return true;
 }
 
 
 // See whether the card under the cursor can be moved somewhere else
-// Returns TRUE if it can be moved, FALSE otherwise
+// Returns 'true' if it can be moved, 'false' otherwise
 bool Game::CanYouGo(int x, int y)
 {
     Pile* pile = WhichPile(x, y);
@@ -553,7 +553,7 @@ bool Game::CanYouGo(int x, int y)
            {
                if (m_foundations[i]->AcceptCard(card) && m_foundations[i] != pile)
                {
-                    return TRUE;
+                    return true;
                }
             }
            for(i = 0; i < 10; i++)
@@ -562,12 +562,12 @@ bool Game::CanYouGo(int x, int y)
                    m_bases[i]->AcceptCard(card) &&
                    m_bases[i] != pile)
                {
-                   return TRUE;
+                   return true;
                }
             }
        }
     }
-    return FALSE;
+    return false;
 }
 
 
@@ -642,12 +642,12 @@ void Game::LButtonUp(wxDC& dc, int x, int y)
 
 bool Game::DropCard(int x, int y, Pile* pile, Card* card)
 {
-    bool retval = FALSE;
+    bool retval = false;
     if (pile->Overlap(x, y))
     {
        if (pile->AcceptCard(card))
        {
-           retval = TRUE;
+           retval = true;
         }
     }
     return retval;
@@ -843,20 +843,20 @@ Base::Base(int x, int y) : Pile(x, y, 0, 12)
 
 bool Base::AcceptCard(Card* card)
 {
-    bool retval = FALSE;
+    bool retval = false;
 
     if (m_topCard >= 0)
     {
            if (m_cards[m_topCard]->GetSuit() == card->GetSuit() &&
                m_cards[m_topCard]->GetPipValue() - 1 == card->GetPipValue())
            {
-            retval = TRUE;
+            retval = true;
         }
     }
     else
     {
                // pile is empty - ACCEPT
-        retval = TRUE;
+        retval = true;
     }
     return retval;
 }
@@ -877,20 +877,20 @@ Foundation::Foundation(int x, int y) : Pile(x, y, 0, 0)
 
 bool Foundation::AcceptCard(Card* card)
 {
-    bool retval = FALSE;
+    bool retval = false;
 
     if (m_topCard >= 0)
     {
            if (m_cards[m_topCard]->GetSuit() == card->GetSuit() &&
                m_cards[m_topCard]->GetPipValue() + 1 == card->GetPipValue())
            {
-            retval = TRUE;
+            retval = true;
         }
     }
     else if (card->GetPipValue() == 1)
     {
            // It's an ace and the pile is empty - ACCEPT
-        retval = TRUE;
+        retval = true;
     }
     return retval;
 }
index cf1564751d69325eab66412e2f50c4d321ae429e..e8b5296f05014dccf0d76136f99c9369d7dbf866 100644 (file)
@@ -224,9 +224,9 @@ bool Pile::CanCardLeave(Card* card)
 {
     for (int i = 0; i <= m_topCard; i++)
     {
-       if (card == m_cards[i]) return TRUE;
+       if (card == m_cards[i]) return true;
     }
-    return FALSE;
+    return false;
 }
 
 // Calculate how far x, y is from top card in the pile
@@ -294,9 +294,9 @@ bool Pile::Overlap(int x, int y)
     if (x >= cardX - Card::GetWidth()  && x <= cardX + Card::GetWidth() &&
         y >= cardY - Card::GetHeight() && y <= cardY + Card::GetHeight())
     {
-           return TRUE;
+           return true;
     }
-    return FALSE;
+    return false;
 }
 
 
index 5248db0586c9778b09a65532093b6a45bd04175b..372fb9d1cefda88fac71132dd0f7b597d39ab4c7 100644 (file)
@@ -66,7 +66,7 @@ public:
        virtual Card* RemoveTopCard(wxDC& pDC, int xOffset = 0, int yOffset = 0);
 
        // Functions to add a card to the top of a pile
-       virtual bool AcceptCard(Card*) { return FALSE; }
+       virtual bool AcceptCard(Card*) { return false; }
        virtual void AddCard(Card* card);       // Add card to top of pile
        virtual void AddCard(wxDC& pDC, Card* card);    // Add card + redraw it
         void SetPos(int x,int y) {m_x = x;m_y = y;};
index 32f72be25de3b59fbf1f404cbfed882bfb26e768..1daa8905ddf062964de47b3b8f8366901628e7dc 100644 (file)
@@ -44,15 +44,12 @@ PlayerSelectionDialog::PlayerSelectionDialog(
                                                        wxWindow* parent,
                                                        ScoreFile* file
                                                        ) :
-       wxDialog(parent, -1, _T("Player Selection"),
-                       wxDefaultPosition, wxSize(320, 200),
+       wxDialog(parent, wxID_ANY, _T("Player Selection"),
+                       wxDefaultPosition, wxDefaultSize,
                        wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
        m_scoreFile(file)
 {
-       // enable constraints
-       SetAutoLayout (TRUE);
-
-       wxStaticText* msg = new wxStaticText(this, -1, _T("Please select a name or type a new one:"));
+       wxStaticText* msg = new wxStaticText(this, wxID_ANY, _T("Please select a name or type a new one:"));
 
        wxListBox* list = new wxListBox(
                                                this, ID_LISTBOX,
@@ -68,63 +65,24 @@ PlayerSelectionDialog::PlayerSelectionDialog(
                list->Append(players[i]);
        }
 
-       m_textField = new wxTextCtrl(this, -1, _T(""), wxDefaultPosition, wxDefaultSize, 0);
+       m_textField = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, 0);
 
        m_OK = new wxButton(this, wxID_OK, _T("OK"));
        m_cancel = new wxButton(this, wxID_CANCEL, _T("Cancel"));
 
-       wxLayoutConstraints* layout;
-
-       // Constrain the msg at the top of the window
-       layout = new wxLayoutConstraints;
-       layout->left.SameAs             (this,  wxLeft,         10);
-       layout->top.SameAs              (this,  wxTop,  10);
-       layout->height.AsIs();
-       layout->width.AsIs();
-       msg->SetConstraints(layout);
-
-       // Constrain the OK button
-       layout = new wxLayoutConstraints;
-       layout->left.SameAs             (this,  wxLeft,         10);
-       layout->bottom.SameAs   (this,   wxBottom,      10);
-       layout->height.AsIs();
-       layout->width.AsIs();
-       m_OK->SetConstraints(layout);
-
-       // Constrain the OK button
-       layout = new wxLayoutConstraints;
-       layout->left.RightOf    (m_OK,  10);
-       layout->bottom.SameAs   (this,  wxBottom,       10);
-       layout->height.AsIs();
-       layout->width.AsIs();
-       m_cancel->SetConstraints(layout);
-
-       // Constrain the Name text entry field
-       layout = new wxLayoutConstraints;
-       layout->left.SameAs             (this,  wxLeft,         10);
-       layout->right.SameAs    (this,  wxRight,        10);
-       layout->bottom.SameAs   (m_OK,  wxTop,          10);
-       layout->height.AsIs();
-       m_textField->SetConstraints(layout);
-
-       // Constrain the list of players
-       layout = new wxLayoutConstraints;
-       layout->left.SameAs             (this,  wxLeft,         10);
-       layout->right.SameAs    (this,  wxRight,        10);
-       layout->top.Below               (msg,   10);
-       layout->bottom.SameAs   (m_textField,   wxTop,  10);
-       list->SetConstraints(layout);
-
-       wxString prevPlayer = m_scoreFile->GetPreviousPlayer();
-       if ((prevPlayer.Length() > 0) && (list->FindString(prevPlayer) != -1))
-       {
-               list->SetStringSelection(prevPlayer);
-               m_textField->SetValue(prevPlayer);
-       }
+  wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
+  button_sizer->Add( m_OK, 0, wxALL, 10 );
+  button_sizer->Add( m_cancel, 0, wxALL, 10 );
 
-    m_textField->SetFocus();
+  wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
+  topsizer->Add( msg, 0, wxALL , 10 );
+  topsizer->Add( list, 1, wxEXPAND | wxLEFT | wxRIGHT, 10 );
+  topsizer->Add( m_textField, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 10 );
+  topsizer->Add( button_sizer, 0, wxALIGN_LEFT );
 
-       Layout();
+  SetSizer( topsizer );
+
+  topsizer->SetSizeHints( this );
     
     CentreOnParent();
 }
@@ -142,7 +100,7 @@ const wxString& PlayerSelectionDialog::GetPlayersName()
 {
 /*
        m_player = "";
-       Show(TRUE);
+       Show(true);
 */
        return m_player;
 }
index 2d2dd133896a7276f661c0cae77bbaf8d4c66df9..84d278412bb9b8c825dfd4392e081d53591a9c19 100644 (file)
 #include "scorefil.h"
 #include "scoredg.h"
 
+#define USE_GRID_FOR_SCORE 0
+
+#if USE_GRID_FOR_SCORE
+#include "wx/grid.h"
+#else
 class ScoreCanvas : public wxScrolledWindow
 {
 public:
-       ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile);
+       ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size);
        virtual ~ScoreCanvas();
 
        void OnDraw(wxDC& dc);
@@ -43,17 +48,17 @@ private:
        wxString        m_text;
 };
 
-
-ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile) :
-       wxScrolledWindow(parent)
+ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size) :
+       wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER)
 {
+    SetBackgroundColour(*wxWHITE);
 #ifdef __WXGTK__
        m_font = wxTheFontList->FindOrCreateFont(12, wxROMAN, wxNORMAL, wxNORMAL);
 #else
        m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
 #endif
 
-        wxArrayString players;
+    wxArrayString players;
        scoreFile->GetPlayerList( players);
 
        wxString os;
@@ -124,45 +129,72 @@ void ScoreCanvas::OnDraw(wxDC& dc)
                if (*str) str++;
        }
 }
+#endif
 
 BEGIN_EVENT_TABLE(ScoreDialog, wxDialog)
     EVT_CLOSE(ScoreDialog::OnCloseWindow)
 END_EVENT_TABLE()
 
-ScoreDialog::ScoreDialog(
-                                                       wxWindow* parent,
-                                                       ScoreFile* file
-                                                       ) :
-       wxDialog(parent, -1, _("Scores"),
-                       wxDefaultPosition, wxSize(310, 200),
+ScoreDialog::ScoreDialog(wxWindow* parent, ScoreFile* file) :
+       wxDialog(parent, wxID_ANY, _("Scores"),
+                       wxDefaultPosition, wxSize(400, 300),
                        wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
        m_scoreFile(file)
 {
-       // enable constraints
-       SetAutoLayout (TRUE);
-
-       ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile);
-       m_OK = new wxButton(this, wxID_OK, _("OK"));
-
-       wxLayoutConstraints* layout;
-
-       // Constrain the OK button
-       layout = new wxLayoutConstraints;
-       layout->left.SameAs             (this,  wxLeft,         10);
-       layout->bottom.SameAs   (this,   wxBottom,      10);
-       layout->height.AsIs();
-       layout->width.AsIs();
-       m_OK->SetConstraints(layout);
-
-       // Constrain the list of players
-       layout = new wxLayoutConstraints;
-       layout->left.SameAs             (this,  wxLeft,         10);
-       layout->right.SameAs    (this,  wxRight,        10);
-       layout->top.SameAs              (this,  wxTop,          10);
-       layout->bottom.SameAs   (m_OK,  wxTop,          10);
-       list->SetConstraints(layout);
-
-       Layout();
+    // create grid with players
+    wxArrayString players;
+       file->GetPlayerList(players);
+    
+    wxSize sz = wxSize(400, 300);
+
+#if USE_GRID_FOR_SCORE
+       wxGrid* list = new wxGrid(this, wxID_ANY, wxDefaultPosition, sz, 0);
+    list->CreateGrid(players.Count(), 4);
+       for (unsigned int i = 0; i < players.Count(); i++)
+       {
+               int wins, games, score;
+        wxString string_value;
+
+               file->ReadPlayersScore(players[i], wins, games, score);
+               int average = 0;
+               if (games > 0)
+               {
+                       average = (2 * score + games) / (2 * games);
+               }
+        list->SetCellValue(i,0,players[i]);
+        string_value.Printf( _T("%u"), wins );
+        list->SetCellValue(i,1,string_value);
+        string_value.Printf( _T("%u"), games );
+        list->SetCellValue(i,2,string_value);
+        string_value.Printf( _T("%u"), average );
+        list->SetCellValue(i,3,string_value);
+    }
+    list->SetColLabelValue(0, _T("Players"));
+    list->SetColLabelValue(1, _T("Wins"));
+    list->SetColLabelValue(2, _T("Games"));
+    list->SetColLabelValue(3, _T("Score"));
+    list->SetEditable(false);
+    list->AutoSizeColumns();
+    list->AutoSizeRows();
+    list->SetRowLabelSize(0);
+    list->EnableDragRowSize(false);
+    list->EnableDragColSize(false);
+    list->EnableDragGridSize(false);
+#else
+       ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile, wxDefaultPosition, sz);
+#endif
+
+    // locate and resize with sizers
+    wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
+    topsizer->Add( list, 1, wxALL|wxGROW, 10 );
+    topsizer->Add( new wxButton(this, wxID_OK, _("OK")), 0, wxALIGN_CENTER_HORIZONTAL|wxALL , 10 );
+
+    SetSizer( topsizer );
+
+    GetSizer()->Fit(this);
+    GetSizer()->SetSizeHints(this);
+    
+    CentreOnParent();
 }
 
 ScoreDialog::~ScoreDialog()
@@ -171,7 +203,7 @@ ScoreDialog::~ScoreDialog()
 
 void ScoreDialog::Display()
 {
-       Show(TRUE);
+       Show(true);
 }
 
 void ScoreDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))