]> git.saurik.com Git - wxWidgets.git/blobdiff - demos/forty/pile.cpp
Remove some obsolete window styles, added a new sizer flag
[wxWidgets.git] / demos / forty / pile.cpp
index 4622829964ff0846062289f4ff76fbbe2b52a093..e8b5296f05014dccf0d76136f99c9369d7dbf866 100644 (file)
@@ -40,6 +40,8 @@
 #include <string.h>
 #include "card.h"
 #include "pile.h"
+#include "forty.h"
+#include "canvas.h"
 
 #include "wx/app.h"
 
@@ -75,19 +77,18 @@ Pile::Pile(int x, int y, int dx, int dy)
 //+-------------------------------------------------------------+
 void Pile::Redraw(wxDC& dc )
 {
-   wxWindow *frame = wxTheApp->GetTopWindow();
+   FortyFrame *frame = (FortyFrame*) wxTheApp->GetTopWindow();
    wxWindow *canvas = (wxWindow *) NULL;
    if (frame)
    {
-     wxNode *node = frame->GetChildren().First();
-     if (node) canvas = (wxWindow*)node->Data();
+       canvas = frame->GetCanvas();
    }
 
        if (m_topCard >= 0)
        {
                if (m_dx == 0 && m_dy == 0)
                {
-                        if ((canvas) && (canvas->IsExposed(m_x,m_y,Card::GetScale()*60,Card::GetScale()*200)))
+      if ((canvas) && (canvas->IsExposed(m_x,m_y,(int)(Card::GetScale()*60),(int)(Card::GetScale()*200))))
                          m_cards[m_topCard]->Draw(dc, m_x, m_y);
                }
                else
@@ -96,7 +97,7 @@ void Pile::Redraw(wxDC& dc )
                        int y = m_y;
                        for (int i = 0; i <= m_topCard; i++)
                        {
-                              if ((canvas) && (canvas->IsExposed(x,y,Card::GetScale()*60,Card::GetScale()*200)))
+        if ((canvas) && (canvas->IsExposed(x,y,(int)(Card::GetScale()*60),(int)(Card::GetScale()*200))))
                                m_cards[i]->Draw(dc, x, y);
                               x += (int)Card::GetScale()*m_dx;
                               y += (int)Card::GetScale()*m_dy;
@@ -105,7 +106,7 @@ void Pile::Redraw(wxDC& dc )
        }
        else
        {
-            if ((canvas) && (canvas->IsExposed(m_x,m_y,Card::GetScale()*60,Card::GetScale()*200)))
+    if ((canvas) && (canvas->IsExposed(m_x,m_y,(int)(Card::GetScale()*60),(int)(Card::GetScale()*200))))
                Card::DrawNullCard(dc, m_x, m_y);
        }
 }
@@ -223,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
@@ -293,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;
 }