]> git.saurik.com Git - wxWidgets.git/blobdiff - demos/forty/card.cpp
Fix a crash in wxExecute() in wxMSW too.
[wxWidgets.git] / demos / forty / card.cpp
index 41ff006cd855b43d29e327f52960f421624c0e3c..ccb8102ef4b17185fa50a126d8415ab57e9e9763 100644 (file)
 //| hbmap_pictures.
 //+-------------------------------------------------------------+
 
-#ifdef __GNUG__
-#pragma implementation
-#pragma interface
-#endif
-
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
 #include "forty.h"
 #include "card.h"
 
-#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXX11__)
 #include "pictures.xpm"
-#include "symbols.xbm"
-#endif
+#include "symbols.xpm"
 
 wxBitmap* Card::m_pictureBmap = 0;
 wxBitmap* Card::m_symbolBmap = 0;
@@ -66,26 +59,18 @@ Card::Card(int value, WayUp way_up) :
 {
     if (!m_symbolBmap)
     {
-#ifdef __WXMSW__
-        m_symbolBmap = new wxBitmap(_T("CardSymbols"), wxBITMAP_TYPE_BMP_RESOURCE);
-#else
-        m_symbolBmap = new wxBitmap(Symbols_bits, Symbols_width, Symbols_height);
-#endif
-        if (!m_symbolBmap->Ok())
+        m_symbolBmap = new wxBitmap(symbols_xpm);
+        if (!m_symbolBmap->IsOk())
         {
-            ::wxMessageBox(_T("Failed to load bitmap CardSymbols"), _T("Error"));
+            ::wxMessageBox(wxT("Failed to load bitmap CardSymbols"), wxT("Error"));
         }
     }
     if (!m_pictureBmap)
     {
-#ifdef __WXMSW__
-        m_pictureBmap = new wxBitmap(_T("CardPictures"), wxBITMAP_TYPE_BMP_RESOURCE);
-#else
         m_pictureBmap = new wxBitmap(Pictures);
-#endif
-        if (!m_pictureBmap->Ok())
+        if (!m_pictureBmap->IsOk())
         {
-            ::wxMessageBox(_T("Failed to load bitmap CardPictures"), _T("Error"));
+            ::wxMessageBox(wxT("Failed to load bitmap CardPictures"), wxT("Error"));
         }
     }
 
@@ -133,17 +118,6 @@ void Card::SetScale(double scale)
     m_height = int(70*scale);
 }
 
-//+-------------------------------------------------------------+
-//| Card::~Card()                                               |
-//+-------------------------------------------------------------+
-//| Description:                                                |
-//| Destructor - nothing to do at present.                      |
-//+-------------------------------------------------------------+
-Card::~Card()
-{
-}
-
-
 //+-------------------------------------------------------------+
 //| Card::Erase()                                               |
 //+-------------------------------------------------------------+
@@ -196,7 +170,7 @@ void Card::Draw(wxDC& dc, int x, int y)
         dc.SetBackground(* wxRED_BRUSH);
         dc.SetBackgroundMode(wxSOLID);
         wxBrush* brush = wxTheBrushList->FindOrCreateBrush(
-                            _T("BLACK"), wxCROSSDIAG_HATCH
+                            *wxBLACK, wxCROSSDIAG_HATCH
                             );
         dc.SetBrush(* brush);
 
@@ -255,272 +229,272 @@ void Card::Draw(wxDC& dc, int x, int y)
         // Draw the value
         dc.Blit((wxCoord)(x + m_scale*3),
                 (wxCoord)(y + m_scale*3),
-                valuewidth, 
+                valuewidth,
                 valueheight,
-                &memoryDC, 
-                valuewidth * (m_pipValue - 1), 
-                valuepos, 
+                &memoryDC,
+                valuewidth * (m_pipValue - 1),
+                valuepos,
                 wxCOPY);
-        dc.Blit((wxCoord)(x + m_width - m_scale*3 - valuewidth), 
+        dc.Blit((wxCoord)(x + m_width - m_scale*3 - valuewidth),
                 (wxCoord)(y + m_height - valueheight - m_scale*3),
-                valuewidth, 
+                valuewidth,
                 valueheight,
-                &memoryDC, 
-                valuewidth * (m_pipValue - 1), 
-                valuepos+valueheight, 
+                &memoryDC,
+                valuewidth * (m_pipValue - 1),
+                valuepos+valueheight,
                 wxCOPY);
 
         // Draw the pips
-        dc.Blit((wxCoord)(x + m_scale*3 + valuewidth+2), 
-                (wxCoord)(y + m_scale*3), 
-                pipsize, 
+        dc.Blit((wxCoord)(x + m_scale*3 + valuewidth+2),
+                (wxCoord)(y + m_scale*3),
+                pipsize,
                 pipsize,
-                &memoryDC, 
-                pipsize * m_suit, 
-                pippos, 
+                &memoryDC,
+                pipsize * m_suit,
+                pippos,
                 wxCOPY);
-        dc.Blit((wxCoord)(x + m_width - m_scale*3-valuewidth-pipsize-2), 
+        dc.Blit((wxCoord)(x + m_width - m_scale*3-valuewidth-pipsize-2),
                 (wxCoord)(y + m_height - pipsize - m_scale*3),
-                pipsize, 
                 pipsize,
-                &memoryDC, 
-                pipsize * m_suit, 
-                pipsize+pippos, 
+                pipsize,
+                &memoryDC,
+                pipsize * m_suit,
+                pipsize+pippos,
                 wxCOPY);
 
         switch (m_pipValue)
         {
         case 1:
-            dc.Blit((wxCoord)(x - symdist + m_width / 2), 
-                    (wxCoord)(y - m_scale*5 + m_height / 2), 
-                    symsize, 
+            dc.Blit((wxCoord)(x - symdist + m_width / 2),
+                    (wxCoord)(y - m_scale*5 + m_height / 2),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             break;
 
         case 3:
-            dc.Blit((wxCoord)(x - symdist + m_width / 2), 
-                    (wxCoord)(y - symdist + m_height / 2), 
-                    symsize, 
+            dc.Blit((wxCoord)(x - symdist + m_width / 2),
+                    (wxCoord)(y - symdist + m_height / 2),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
         case 2:
             dc.Blit((wxCoord)(x - symdist + m_width / 2),
-                    (wxCoord)(y - symdist + m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + m_height / 4),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + m_width / 2),
-                    (wxCoord)(y - symdist + 3 * m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 3 * m_height / 4),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
             break;
 
         case 5:
-            dc.Blit((wxCoord)(x - symdist + m_width / 2), 
-                    (wxCoord)(y - symdist + m_height / 2), 
-                    symsize, 
+            dc.Blit((wxCoord)(x - symdist + m_width / 2),
+                    (wxCoord)(y - symdist + m_height / 2),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
         case 4:
             dc.Blit((wxCoord)(x - symdist +  m_width / 4),
-                    (wxCoord)(y - symdist + m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + m_height / 4),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + m_width / 4),
-                    (wxCoord)(y - symdist + 3 * m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 3 * m_height / 4),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
-                    (wxCoord)(y - symdist + m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + m_height / 4),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
-                    (wxCoord)(y - symdist + 3 * m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 3 * m_height / 4),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
             break;
 
         case 8:
             dc.Blit((wxCoord)(x - symdist + 5 * m_width / 10),
-                    (wxCoord)(y - symdist + 5 * m_height / 8), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 5 * m_height / 8),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
         case 7:
             dc.Blit((wxCoord)(x - symdist + 5 * m_width / 10),
-                    (wxCoord)(y - symdist + 3 * m_height / 8), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 3 * m_height / 8),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
         case 6:
             dc.Blit((wxCoord)(x - symdist + m_width / 4),
-                    (wxCoord)(y - symdist + m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + m_height / 4),
+                    symsize,
                     symsize,
                     &memoryDC, symsize * m_suit, sympos, wxCOPY);
             dc.Blit((wxCoord)(x - symdist + m_width / 4),
-                    (wxCoord)(y - symdist + m_height / 2), 
-                    symsize, 
+                    (wxCoord)(y - symdist + m_height / 2),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + m_width / 4),
-                    (wxCoord)(y - symdist + 3 * m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 3 * m_height / 4),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
-                    (wxCoord)(y - symdist + m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + m_height / 4),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
-                    (wxCoord)(y - symdist + m_height / 2), 
-                    symsize, 
+                    (wxCoord)(y - symdist + m_height / 2),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
-                    (wxCoord)(y - symdist + 3 * m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 3 * m_height / 4),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
             break;
 
         case 10:
             dc.Blit((wxCoord)(x - symdist + m_width / 2),
-                    (wxCoord)(y - symdist + 2 * m_height / 3), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 2 * m_height / 3),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
         case 9:
             dc.Blit((wxCoord)(x - symdist + m_width / 4),
-                    (wxCoord)(y - symdist2 + m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist2 + m_height / 4),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + m_width / 4),
-                    (wxCoord)(y - symdist2 + 5 * m_height / 12), 
-                    symsize, 
+                    (wxCoord)(y - symdist2 + 5 * m_height / 12),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + m_width / 4),
-                    (wxCoord)(y - symdist + 7 * m_height / 12), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 7 * m_height / 12),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + m_width / 4),
-                    (wxCoord)(y - symdist + 3 * m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 3 * m_height / 4),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
 
             dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
-                    (wxCoord)(y - symdist2 + m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist2 + m_height / 4),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
-                    (wxCoord)(y - symdist2 + 5 * m_height / 12), 
-                    symsize, 
+                    (wxCoord)(y - symdist2 + 5 * m_height / 12),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
-                    (wxCoord)(y - symdist + 7 * m_height / 12), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 7 * m_height / 12),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
-                    (wxCoord)(y - symdist + 3 * m_height / 4), 
-                    symsize, 
+                    (wxCoord)(y - symdist + 3 * m_height / 4),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
             dc.Blit((wxCoord)(x - symdist + m_width / 2),
-                    (wxCoord)(y - symdist + m_height / 3), 
-                    symsize, 
+                    (wxCoord)(y - symdist + m_height / 3),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             break;
         case 11:
@@ -528,31 +502,31 @@ void Card::Draw(wxDC& dc, int x, int y)
         case 13:
             memoryDC.SelectObject(*m_pictureBmap);
             int picwidth = 40,picheight = 45;
-            dc.Blit((wxCoord)(x + (m_width-picwidth)/2), 
+            dc.Blit((wxCoord)(x + (m_width-picwidth)/2),
                     (wxCoord)(y - picheight/2 + m_height/2),
-                    picwidth, 
+                    picwidth,
                     picheight,
-                    &memoryDC, 
-                    picwidth * (m_pipValue - 11), 
-                    0, 
+                    &memoryDC,
+                    picwidth * (m_pipValue - 11),
+                    0,
                     wxCOPY);
 
             memoryDC.SelectObject(*m_symbolBmap);
             dc.Blit((wxCoord)(x + m_width-(m_width-picwidth)/2-symsize-3),
-                    (wxCoord)(y - picheight/2+m_height/2+1), 
-                    symsize, 
+                    (wxCoord)(y - picheight/2+m_height/2+1),
+                    symsize,
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos, 
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos,
                     wxCOPY);
             dc.Blit((wxCoord)(x + (m_width-picwidth)/2+2),
-                    (wxCoord)(y + picheight/2 + m_height/2-symsize), 
-                    symsize, 
+                    (wxCoord)(y + picheight/2 + m_height/2-symsize),
                     symsize,
-                    &memoryDC, 
-                    symsize * m_suit, 
-                    sympos2, 
+                    symsize,
+                    &memoryDC,
+                    symsize * m_suit,
+                    sympos2,
                     wxCOPY);
             break;
         }
@@ -576,5 +550,3 @@ void Card::DrawNullCard(wxDC& dc, int x, int y)
     dc.SetPen(*pen);
     dc.DrawRoundedRectangle(x, y, m_width, m_height, 4);
 } // Card::DrawNullCard()
-
-