]> git.saurik.com Git - wxWidgets.git/blobdiff - demos/forty/scoredg.cpp
implementing delayed freezing, fixes #12865
[wxWidgets.git] / demos / forty / scoredg.cpp
index 8c02afc433bf1de5ced40a0d292f7b652fcd7a68..07cbb2487e8a50a7216094eac9987c06fa5d7406 100644 (file)
@@ -9,11 +9,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(__APPLE__)
-#pragma implementation
-#pragma interface
-#endif
-
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
@@ -28,7 +23,9 @@
 #include "scorefil.h"
 #include "scoredg.h"
 
 #include "scorefil.h"
 #include "scoredg.h"
 
-#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
 
 #if USE_GRID_FOR_SCORE
 #include "wx/grid.h"
 
 #if USE_GRID_FOR_SCORE
 #include "wx/grid.h"
@@ -159,32 +156,39 @@ ScoreDialog::ScoreDialog(wxWindow* parent, ScoreFile* file) :
             average = (2 * score + games) / (2 * games);
         }
         list->SetCellValue(i,0,players[i]);
             average = (2 * score + games) / (2 * games);
         }
         list->SetCellValue(i,0,players[i]);
-        string_value.Printf( _T("%u"), wins );
+        string_value.Printf( wxT("%u"), wins );
         list->SetCellValue(i,1,string_value);
         list->SetCellValue(i,1,string_value);
-        string_value.Printf( _T("%u"), games );
+        string_value.Printf( wxT("%u"), games );
         list->SetCellValue(i,2,string_value);
         list->SetCellValue(i,2,string_value);
-        string_value.Printf( _T("%u"), average );
+        string_value.Printf( wxT("%u"), average );
         list->SetCellValue(i,3,string_value);
     }
         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->SetColLabelValue(0, wxT("Players"));
+    list->SetColLabelValue(1, wxT("Wins"));
+    list->SetColLabelValue(2, wxT("Games"));
+    list->SetColLabelValue(3, wxT("Score"));
+    list->EnableEditing(false);
     list->AutoSizeColumns();
     list->AutoSizeRows();
     list->SetRowLabelSize(0);
     list->EnableDragRowSize(false);
     list->EnableDragColSize(false);
     list->EnableDragGridSize(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
 
 #else
     ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile, wxDefaultPosition, sz);
 #endif
 
+    list->SetInitialSize(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();
 
     SetSizer( topsizer );
 
 
     SetSizer( topsizer );
 
@@ -194,13 +198,9 @@ ScoreDialog::ScoreDialog(wxWindow* parent, ScoreFile* file) :
     CentreOnParent();
 }
 
     CentreOnParent();
 }
 
-ScoreDialog::~ScoreDialog()
-{
-}
-
 void ScoreDialog::Display()
 {
 void ScoreDialog::Display()
 {
-    Show(true);
+    ShowModal();
 }
 
 void ScoreDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
 }
 
 void ScoreDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))