-#define USE_GRID_FOR_SCORE 0
+// adjust USE_GRID_FOR_SCORE with O or 1 to your preferences
+// by default it takes wxGrid component for score display if available in target port
+#define USE_GRID_FOR_SCORE wxUSE_GRID
- ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size);
- virtual ~ScoreCanvas();
+ ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size);
+ virtual ~ScoreCanvas();
};
ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size) :
};
ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size) :
- wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER)
+ wxScrolledWindow(parent, wxID_ANY, pos, size, wxSUNKEN_BORDER)
- m_font = wxTheFontList->FindOrCreateFont(12, wxROMAN, wxNORMAL, wxNORMAL);
+ m_font = wxTheFontList->FindOrCreateFont(12, wxROMAN, wxNORMAL, wxNORMAL);
- m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
+ m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
- scoreFile->GetPlayerList( players);
-
- wxString os;
-
- os << wxT("Player\tWins\tGames\tScore\n");
- for (unsigned int i = 0; i < players.Count(); i++)
- {
- int wins, games, score;
- scoreFile->ReadPlayersScore(players[i], wins, games, score);
- int average = 0;
- if (games > 0)
- {
- average = (2 * score + games) / (2 * games);
- }
-
- os << players[i] << wxT('\t')
- << wins << wxT('\t')
- << games << wxT('\t')
- << average << wxT('\n');
- }
- os << wxT('\0');
- m_text = os;
+ scoreFile->GetPlayerList( players);
+
+ wxString os;
+
+ os << wxT("Player\tWins\tGames\tScore\n");
+ for (unsigned int i = 0; i < players.Count(); i++)
+ {
+ int wins, games, score;
+ scoreFile->ReadPlayersScore(players[i], wins, games, score);
+ int average = 0;
+ if (games > 0)
+ {
+ average = (2 * score + games) / (2 * games);
+ }
+
+ os << players[i] << wxT('\t')
+ << wins << wxT('\t')
+ << games << wxT('\t')
+ << average << wxT('\n');
+ }
+ os << wxT('\0');
+ m_text = os;
- dc.SetFont(* m_font);
-
- const wxChar* str = m_text;
- unsigned int tab = 0;
- unsigned int tabstops[] = { 5, 100, 150, 200 };
-
- // get the line spacing for the current font
- int lineSpacing;
- {
- long w, h;
- dc.GetTextExtent(wxT("Testing"), &w, &h);
- lineSpacing = (int)h;
- }
-
- int y = 0;
- while (*str)
- {
- wxChar text[256];
- wxChar* dest = text;
-
- while (*str && *str >= ' ') *dest++ = *str++;
- *dest = '\0';
-
- dc.DrawText(text, tabstops[tab], y);
-
- if (*str == '\t')
- {
- if (tab < sizeof(tabstops) / sizeof(tabstops[0]) - 1)
- {
- tab++;
- }
- }
- else if (*str == '\n')
- {
- tab = 0;
- y += lineSpacing;
- }
- if (*str) str++;
- }
+ dc.SetFont(* m_font);
+
+ const wxChar* str = m_text;
+ unsigned int tab = 0;
+ unsigned int tabstops[] = { 5, 100, 150, 200 };
+
+ // get the line spacing for the current font
+ int lineSpacing;
+ {
+ long w, h;
+ dc.GetTextExtent(wxT("Testing"), &w, &h);
+ lineSpacing = (int)h;
+ }
+
+ int y = 0;
+ while (*str)
+ {
+ wxChar text[256];
+ wxChar* dest = text;
+
+ while (*str && *str >= ' ') *dest++ = *str++;
+ *dest = '\0';
+
+ dc.DrawText(text, tabstops[tab], y);
+
+ if (*str == '\t')
+ {
+ if (tab < sizeof(tabstops) / sizeof(tabstops[0]) - 1)
+ {
+ tab++;
+ }
+ }
+ else if (*str == '\n')
+ {
+ tab = 0;
+ y += lineSpacing;
+ }
+ if (*str) str++;
+ }
- wxDialog(parent, wxID_ANY, _("Scores"),
- wxDefaultPosition, wxSize(400, 300),
- wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
- m_scoreFile(file)
+ wxDialog(parent, wxID_ANY, _("Scores"),
+ wxDefaultPosition, wxSize(400, 300)),
+ m_scoreFile(file)
- wxGrid* list = new wxGrid(this, wxID_ANY, wxDefaultPosition, sz, 0);
+ wxGrid* list = new wxGrid(this, wxID_ANY, wxDefaultPosition, sz, 0);
- for (unsigned int i = 0; i < players.Count(); i++)
- {
- int wins, games, score;
+ for (unsigned int i = 0; i < players.Count(); i++)
+ {
+ int wins, games, score;
- file->ReadPlayersScore(players[i], wins, games, score);
- int average = 0;
- if (games > 0)
- {
- average = (2 * score + games) / (2 * games);
- }
+ file->ReadPlayersScore(players[i], wins, games, score);
+ int average = 0;
+ if (games > 0)
+ {
+ average = (2 * score + games) / (2 * games);
+ }
- list->SetColLabelValue(0, _T("Players"));
- list->SetColLabelValue(1, _T("Wins"));
- list->SetColLabelValue(2, _T("Games"));
- list->SetColLabelValue(3, _T("Score"));
+ list->SetColLabelValue(0, wxT("Players"));
+ list->SetColLabelValue(1, wxT("Wins"));
+ list->SetColLabelValue(2, wxT("Games"));
+ list->SetColLabelValue(3, wxT("Score"));
list->EnableDragRowSize(false);
list->EnableDragColSize(false);
list->EnableDragGridSize(false);
list->EnableDragRowSize(false);
list->EnableDragColSize(false);
list->EnableDragGridSize(false);
- ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile, wxDefaultPosition, sz);
+ ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile, wxDefaultPosition, sz);
// locate and resize with sizers
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
topsizer->Add( list, 1, wxALL|wxGROW, 10 );
// 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 );
+ wxButton *button = new wxButton(this, wxID_OK);
+ topsizer->Add( button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL , 10 );
+ button->SetFocus();