- // 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( wxT("%u"), wins );
+ list->SetCellValue(i,1,string_value);
+ string_value.Printf( wxT("%u"), games );
+ list->SetCellValue(i,2,string_value);
+ string_value.Printf( wxT("%u"), average );
+ list->SetCellValue(i,3,string_value);
+ }
+ list->SetColLabelValue(0, wxT("Players"));
+ list->SetColLabelValue(1, wxT("Wins"));
+ list->SetColLabelValue(2, wxT("Games"));
+ list->SetColLabelValue(3, wxT("Score"));
+ list->SetEditable(false);
+ list->AutoSizeColumns();
+ list->AutoSizeRows();
+ list->SetRowLabelSize(0);
+ list->EnableDragRowSize(false);
+ list->EnableDragColSize(false);
+ list->EnableDragGridSize(false);
+ list->ClearSelection();
+ list->EnableEditing(false);
+ sz.x = wxDefaultCoord;
+#else
+ ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile, wxDefaultPosition, sz);
+#endif