]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/forty/canvas.cpp
Added the forgotten file txtstrm.tex
[wxWidgets.git] / samples / forty / canvas.cpp
index 18dec216f241d6e742ed0124e5d2bc128ef6802b..384d2bebbed510408edc32908a312b31b432c08e 100644 (file)
@@ -50,8 +50,7 @@ FortyCanvas::FortyCanvas(wxWindow* parent, int x, int y, int w, int h) :
 #else
        m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
 #endif
 #else
        m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
 #endif
-       SetBackgroundColour(*FortyApp::BackgroundColour());
-       AllowDoubleClick(true);
+       SetBackgroundColour(FortyApp::BackgroundColour());
 
        m_handCursor = new wxCursor(wxCURSOR_HAND);
        m_arrowCursor = new wxCursor(wxCURSOR_ARROW);
 
        m_handCursor = new wxCursor(wxCURSOR_HAND);
        m_arrowCursor = new wxCursor(wxCURSOR_ARROW);
@@ -91,14 +90,15 @@ void FortyCanvas::UpdateScores()
 
 void FortyCanvas::OnDraw(wxDC& dc)
 {
 
 void FortyCanvas::OnDraw(wxDC& dc)
 {
-       dc.SetFont(m_font);
+       dc.SetFont(m_font);
        m_game->Redraw(dc);
 
        // if player name not set (and selection dialog is not displayed)
        // then ask the player for their name
        if (m_player.Length() == 0 && !m_playerDialog)
        {
        m_game->Redraw(dc);
 
        // if player name not set (and selection dialog is not displayed)
        // then ask the player for their name
        if (m_player.Length() == 0 && !m_playerDialog)
        {
-               m_playerDialog = new PlayerSelectionDialog(this, m_scoreFile);
+               m_playerDialog = new PlayerSelectionDialog(this, m_scoreFile);
+               m_playerDialog->ShowModal();
                m_player = m_playerDialog->GetPlayersName();
                if (m_player.Length() > 0)
                {
                m_player = m_playerDialog->GetPlayersName();
                if (m_player.Length() > 0)
                {
@@ -107,8 +107,9 @@ void FortyCanvas::OnDraw(wxDC& dc)
                        m_scoreFile->ReadPlayersScore(m_player, wins, games, score);
                        m_game->NewPlayer(wins, games, score);
                        m_game->DisplayScore(dc);
                        m_scoreFile->ReadPlayersScore(m_player, wins, games, score);
                        m_game->NewPlayer(wins, games, score);
                        m_game->DisplayScore(dc);
-                       delete m_playerDialog;
+                       m_playerDialog->Destroy();
                        m_playerDialog = 0;
                        m_playerDialog = 0;
+                       Refresh();
                }
                else
                {
                }
                else
                {
@@ -121,13 +122,13 @@ void FortyCanvas::OnDraw(wxDC& dc)
 /*
 Called when the main frame is closed
 */
 /*
 Called when the main frame is closed
 */
-bool FortyCanvas::OnClose()
+bool FortyCanvas::OnCloseCanvas()
 {
        if (m_game->InPlay() &&
                wxMessageBox("Are you sure you want to\nabandon the current game?",
                        "Warning", wxYES_NO | wxICON_QUESTION) == wxNO)
        {
 {
        if (m_game->InPlay() &&
                wxMessageBox("Are you sure you want to\nabandon the current game?",
                        "Warning", wxYES_NO | wxICON_QUESTION) == wxNO)
        {
-               return FALSE;
+        return FALSE;
        }
        return TRUE;
 }
        }
        return TRUE;
 }
@@ -139,7 +140,7 @@ void FortyCanvas::OnMouseEvent(wxMouseEvent& event)
 
        wxClientDC dc(this); 
        PrepareDC(dc);
 
        wxClientDC dc(this); 
        PrepareDC(dc);
-       dc.SetFont(m_font);
+       dc.SetFont(m_font);
 
        if (event.LeftDClick())
        {
 
        if (event.LeftDClick())
        {
@@ -206,7 +207,7 @@ void FortyCanvas::SetCursorStyle(int x, int y)
 
                        wxClientDC dc(this); 
                        PrepareDC(dc);
 
                        wxClientDC dc(this); 
                        PrepareDC(dc);
-                       dc.SetFont(m_font);
+                       dc.SetFont(m_font);
                        m_game->Redraw(dc);
                }
                else
                        m_game->Redraw(dc);
                }
                else
@@ -220,11 +221,11 @@ void FortyCanvas::SetCursorStyle(int x, int y)
        // the card under the cursor can go somewhere 
        if (m_game->CanYouGo(x, y) && m_helpingHand)
        {
        // the card under the cursor can go somewhere 
        if (m_game->CanYouGo(x, y) && m_helpingHand)
        {
-               SetCursor(m_handCursor);
+               SetCursor(m_handCursor);
        }
        else
        {
        }
        else
        {
-               SetCursor(m_arrowCursor);
+               SetCursor(m_arrowCursor);
        }
 
 }
        }
 
 }
@@ -239,7 +240,7 @@ void FortyCanvas::Undo()
 {
        wxClientDC dc(this); 
        PrepareDC(dc);
 {
        wxClientDC dc(this); 
        PrepareDC(dc);
-       dc.SetFont(m_font);
+       dc.SetFont(m_font);
        m_game->Undo(dc);
 }
 
        m_game->Undo(dc);
 }
 
@@ -247,6 +248,6 @@ void FortyCanvas::Redo()
 {
        wxClientDC dc(this); 
        PrepareDC(dc);
 {
        wxClientDC dc(this); 
        PrepareDC(dc);
-       dc.SetFont(m_font);
+       dc.SetFont(m_font);
        m_game->Redo(dc);
 }
        m_game->Redo(dc);
 }