]> git.saurik.com Git - wxWidgets.git/commitdiff
Unicode compilation fixes.
authorMattia Barbon <mbarbon@cpan.org>
Sun, 22 Dec 2002 19:57:17 +0000 (19:57 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Sun, 22 Dec 2002 19:57:17 +0000 (19:57 +0000)
  wxpoem now compiles with default settings (making it compilable with
Unicode is a lost cause).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18396 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

15 files changed:
demos/bombs/bombs.cpp
demos/bombs/bombs1.cpp
demos/forty/canvas.cpp
demos/forty/card.cpp
demos/forty/forty.cpp
demos/forty/forty.h
demos/forty/game.cpp
demos/forty/playerdg.cpp
demos/forty/scoredg.cpp
demos/forty/scorefil.cpp
demos/forty/scorefil.h
demos/fractal/fractal.cpp
demos/life/game.h
demos/life/life.cpp
demos/poem/wxpoem.cpp

index 875e9600738bcd9466551c8816c023da6d2930b7..26a17794092a9a3f09d4159ba86b5d1af42f8a06 100644 (file)
@@ -40,7 +40,7 @@ bool AppClass::OnInit()
   level=IDM_EASY;
 
   BombsFrame = 
-    new BombsFrameClass(NULL, "wxBombs", wxPoint(155, 165), wxSize(300, 300), wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION);
+    new BombsFrameClass(NULL, _T("wxBombs"), wxPoint(155, 165), wxSize(300, 300), wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION);
 
   int xmax=BombsFrame->BombsCanvas->field_width*BombsFrame->BombsCanvas->x_cell*X_UNIT;
   int ymax=BombsFrame->BombsCanvas->field_height*BombsFrame->BombsCanvas->y_cell*Y_UNIT;
@@ -72,17 +72,17 @@ BombsFrameClass::BombsFrameClass(wxFrame *parent, const wxString& title, const w
   // Create a menu bar for the frame
   wxMenuBar *menuBar1 = new wxMenuBar;
   wxMenu *menu1 = new wxMenu;
-  menu1->Append(IDM_EXIT, "E&xit"); // , "Quit the program");
+  menu1->Append(IDM_EXIT, _T("E&xit")); // , "Quit the program");
   menu1->AppendSeparator();
-  menu1->Append(IDM_ABOUT, "&About..."); // , "Infos on wxBombs");
-  menuBar1->Append(menu1, "&File");
+  menu1->Append(IDM_ABOUT, _T("&About...")); // , "Infos on wxBombs");
+  menuBar1->Append(menu1, _T("&File"));
   wxMenu *menu2 = new wxMenu;
-  menu2->Append(IDM_RESTART, "&Restart"); // , "Clear the play field");
+  menu2->Append(IDM_RESTART, _T("&Restart")); // , "Clear the play field");
   menu2->AppendSeparator();
-  menu2->Append(IDM_EASY, "&Easy", wxEmptyString, TRUE); // "10x10 play field", TRUE);
-  menu2->Append(IDM_MEDIUM, "&Medium", wxEmptyString, TRUE); // "15x15 play field", TRUE);
-  menu2->Append(IDM_DIFFICULT, "&Difficult", wxEmptyString, TRUE); // "25x20 play field", TRUE);
-  menuBar1->Append(menu2, "&Game");
+  menu2->Append(IDM_EASY, _T("&Easy"), wxEmptyString, TRUE); // "10x10 play field", TRUE);
+  menu2->Append(IDM_MEDIUM, _T("&Medium"), wxEmptyString, TRUE); // "15x15 play field", TRUE);
+  menu2->Append(IDM_DIFFICULT, _T("&Difficult"), wxEmptyString, TRUE); // "25x20 play field", TRUE);
+  menuBar1->Append(menu2, _T("&Game"));
   SetMenuBar(menuBar1);
   menuBar=menuBar1;
   menuBar->Check(wxGetApp().level, TRUE);
@@ -124,7 +124,7 @@ void BombsFrameClass::OnRestart(wxCommandEvent& event)
 
 void BombsFrameClass::OnAbout(wxCommandEvent& event)
 {
-    wxMessageBox("wxBombs (c) 1996 by P. Foggia\n<foggia@amalfi.dis.unina.it>", "About wxBombs");
+    wxMessageBox(_T("wxBombs (c) 1996 by P. Foggia\n<foggia@amalfi.dis.unina.it>"), _T("About wxBombs"));
 }
 
 void BombsFrameClass::OnEasy(wxCommandEvent& event)
@@ -162,7 +162,7 @@ BombsCanvasClass::BombsCanvasClass(wxFrame *parent, const wxPoint& pos, const wx
   dc.SetFont(font);
 
   long chw, chh;
-  char buf[]="M";
+  wxChar buf[]=_T("M");
 
   dc.GetTextExtent(buf, &chw, &chh);
   dc.SetFont(wxNullFont);
index 173bce23831ed76b0ed5d3ff8125e1c430bfbc98..e884888349c447c00bc14809d891d7b172904e2c 100644 (file)
 /*---------------------------------------------------------------------*/
 void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
 { int x,y,xmax,ymax;
-  char buf[2];
+  wxChar buf[2];
   long chw, chh;
 
-  wxColour *wxBlack = wxTheColourDatabase->FindColour("BLACK");
-  wxColour *wxWhite = wxTheColourDatabase->FindColour("WHITE");
-  wxColour *wxRed = wxTheColourDatabase->FindColour("RED");
-  wxColour *wxBlue = wxTheColourDatabase->FindColour("BLUE");
-  wxColour *wxGrey = wxTheColourDatabase->FindColour("LIGHT GREY");
-  wxColour *wxGreen = wxTheColourDatabase->FindColour("GREEN");
+  wxColour *wxBlack = wxTheColourDatabase->FindColour(_T("BLACK"));
+  wxColour *wxWhite = wxTheColourDatabase->FindColour(_T("WHITE"));
+  wxColour *wxRed = wxTheColourDatabase->FindColour(_T("RED"));
+  wxColour *wxBlue = wxTheColourDatabase->FindColour(_T("BLUE"));
+  wxColour *wxGrey = wxTheColourDatabase->FindColour(_T("LIGHT GREY"));
+  wxColour *wxGreen = wxTheColourDatabase->FindColour(_T("GREEN"));
 
   wxPen *blackPen = wxThePenList->FindOrCreatePen(*wxBlack, 1, wxSOLID);
   wxPen *redPen = wxThePenList->FindOrCreatePen(*wxRed, 1, wxSOLID);
@@ -64,7 +64,7 @@ void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
   wxFont font= BOMBS_FONT;
   dc->SetFont(font); 
 
-  buf[1]='\0';
+  buf[1]=_T('\0');
   for(x=xc1; x<=xc2; x++)
     for(y=yc1; y<=yc2; y++)
       { if (wxGetApp().Game.IsMarked(x,y))
@@ -72,7 +72,7 @@ void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
             dc->SetBrush(* greyBrush);
             dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT,
                                x_cell*X_UNIT+1, y_cell*Y_UNIT+1);
-            *buf='M';
+            *buf=_T('M');
             if (!wxGetApp().Game.IsHidden(x,y) && wxGetApp().Game.IsBomb(x,y))
               dc->SetTextForeground(*wxBlue);
             else
@@ -102,7 +102,7 @@ void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
             dc->SetBrush(* redBrush);
             dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT,
                                x_cell*X_UNIT+1, y_cell*Y_UNIT+1);
-            *buf='B';
+            *buf=_T('B');
             dc->SetTextForeground(* wxBlack);
             dc->SetTextBackground(* wxRed);
             dc->GetTextExtent(buf, &chw, &chh);
@@ -123,11 +123,11 @@ void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
             dc->SetBrush(* whiteBrush);
             dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT,
                                x_cell*X_UNIT+1, y_cell*Y_UNIT+1);
-            *buf = (wxGetApp().Game.Get(x,y) & BG_MASK) + '0';
+            *buf = (wxGetApp().Game.Get(x,y) & BG_MASK) + _T('0');
             dc->GetTextExtent(buf, &chw, &chh);
             switch(*buf)
-              { case '0': dc->SetTextForeground(* wxGreen); break;
-                case '1': dc->SetTextForeground(* wxBlue); break;
+              { case _T('0'): dc->SetTextForeground(* wxGreen); break;
+                case _T('1'): dc->SetTextForeground(* wxBlue); break;
                 default:  dc->SetTextForeground(* wxBlack); break;
               }
             dc->SetTextBackground(* wxWhite);
@@ -140,9 +140,10 @@ void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
   dc->SetFont(wxNullFont);
 
   if (wxGetApp().BombsFrame)
-    { char buf[80];
-      sprintf(buf, "%d bombs  %d remaining cells",
-              wxGetApp().Game.GetBombs(), wxGetApp().Game.GetRemainingCells());
+    { wxString buf;
+      buf.Printf(_T("%d bombs  %d remaining cells"),
+                 wxGetApp().Game.GetBombs(),
+                 wxGetApp().Game.GetRemainingCells());
       wxGetApp().BombsFrame->SetStatusText(buf, 0);
     }
 }
@@ -172,7 +173,7 @@ void BombsCanvasClass::Uncover(int x, int y)
   if (wxGetApp().Game.IsBomb(x,y) || wxGetApp().Game.GetRemainingCells()==0)
     { wxBell();
       if (!wxGetApp().Game.IsBomb(x,y))
-       { wxMessageBox("Nice! You found all the bombs!", "wxWin Bombs",
+       { wxMessageBox(_T("Nice! You found all the bombs!"), _T("wxWin Bombs"),
                       wxOK|wxCENTRE, wxGetApp().BombsFrame);
        }
       else // x,y is a bomb
index 81e7985234fa46c35d79f9c6b5c9d54952559e66..995e7cbfbfe1e0eea154a52ccbc05522a50b8a79 100644 (file)
@@ -56,7 +56,7 @@ FortyCanvas::FortyCanvas(wxWindow* parent, int x, int y, int w, int h) :
        m_arrowCursor = new wxCursor(wxCURSOR_ARROW);
 
        wxString name = wxTheApp->GetAppName();
-       if (name.Length() <= 0) name = "forty";
+       if (name.Length() <= 0) name = _T("forty");
        m_scoreFile = new ScoreFile(name);
        m_game = new Game(0, 0, 0);
        m_game->Deal();
@@ -159,8 +159,8 @@ Called when the main frame is closed
 bool FortyCanvas::OnCloseCanvas()
 {
        if (m_game->InPlay() &&
-               wxMessageBox("Are you sure you want to\nabandon the current game?",
-                       "Warning", wxYES_NO | wxICON_QUESTION) == wxNO)
+               wxMessageBox(_T("Are you sure you want to\nabandon the current game?"),
+                       _T("Warning"), wxYES_NO | wxICON_QUESTION) == wxNO)
        {
         return FALSE;
        }
index 295e7c5947c387b2a9c0cc262dec29012338e707..94df4387328be7ae4de57d507c7ba7f7b0adb5c6 100644 (file)
@@ -67,25 +67,25 @@ Card::Card(int value, WayUp way_up) :
        if (!m_symbolBmap)
        {
 #ifdef __WXMSW__
-               m_symbolBmap = new wxBitmap("CardSymbols", wxBITMAP_TYPE_BMP_RESOURCE);
+               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())
                {
-                       ::wxMessageBox("Failed to load bitmap CardSymbols", "Error");
+                       ::wxMessageBox(_T("Failed to load bitmap CardSymbols"), _T("Error"));
                }
        }
        if (!m_pictureBmap)
        {
 #ifdef __WXMSW__
-               m_pictureBmap = new wxBitmap("CardPictures", wxBITMAP_TYPE_BMP_RESOURCE);
+               m_pictureBmap = new wxBitmap(_T("CardPictures"), wxBITMAP_TYPE_BMP_RESOURCE);
 #else
                m_pictureBmap = new wxBitmap(Pictures);
 #endif
                if (!m_pictureBmap->Ok())
                {
-                       ::wxMessageBox("Failed to load bitmap CardPictures", "Error");
+                       ::wxMessageBox(_T("Failed to load bitmap CardPictures"), _T("Error"));
                }
        }
 
@@ -196,7 +196,7 @@ void Card::Draw(wxDC& dc, int x, int y)
                dc.SetBackground(* wxRED_BRUSH);
                dc.SetBackgroundMode(wxSOLID);
                wxBrush* brush = wxTheBrushList->FindOrCreateBrush(
-                                                       "BLACK", wxCROSSDIAG_HATCH
+                                                       _T("BLACK"), wxCROSSDIAG_HATCH
                                                        );
                dc.SetBrush(* brush);
 
index cb37828bef94330c925a72265e1e278b8fc97eaf..582cb08f3dbe865fde0cb1e7d0072fc1c3c4dcc2 100644 (file)
@@ -76,7 +76,7 @@ bool FortyApp::OnInit()
         bool largecards = FALSE;
         wxSize size(668,510);
 
-        if ((argc > 1) && (!wxStrcmp(argv[1],"-L")))
+        if ((argc > 1) && (!wxStrcmp(argv[1],_T("-L"))))
         {
             largecards = TRUE;
             size = wxSize(1000,750);
@@ -84,7 +84,7 @@ bool FortyApp::OnInit()
 
        FortyFrame* frame = new FortyFrame(
                        0,
-                       "Forty Thieves",
+                       _T("Forty Thieves"),
                         -1, -1, size.x, size.y,largecards
                        );
 
@@ -120,14 +120,14 @@ const wxColour& FortyApp::TextColour()
 {
        if (!m_textColour)
        {
-               m_textColour = new wxColour("BLACK");
+               m_textColour = new wxColour(_T("BLACK"));
        }
 
        return *m_textColour;
 }
 
 // My frame constructor
-FortyFrame::FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,bool largecards):
+FortyFrame::FortyFrame(wxFrame* frame, const wxString& title, int x, int y, int w, int h,bool largecards):
        wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
 {
 #ifdef __WXMAC__
@@ -136,7 +136,7 @@ FortyFrame::FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,b
 #endif
        // set the icon
 #ifdef __WXMSW__
-       SetIcon(wxIcon("CardsIcon"));
+       SetIcon(wxIcon(_T("CardsIcon")));
 #else
 #ifdef GTK_TBD
        SetIcon(wxIcon(Cards_bits, Cards_width, Cards_height));
@@ -145,28 +145,28 @@ FortyFrame::FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,b
 
        // Make a menu bar
        wxMenu* gameMenu = new wxMenu;
-       gameMenu->Append(NEW_GAME, "&New", "Start a new game");
-       gameMenu->Append(SCORES, "&Scores...", "Displays scores");
-       gameMenu->Append(EXIT, "E&xit", "Exits Forty Thieves");
+       gameMenu->Append(NEW_GAME, _T("&New"), _T("Start a new game"));
+       gameMenu->Append(SCORES, _T("&Scores..."), _T("Displays scores"));
+       gameMenu->Append(EXIT, _T("E&xit"), _T("Exits Forty Thieves"));
 
        wxMenu* editMenu = new wxMenu;
-       editMenu->Append(UNDO, "&Undo", "Undo the last move");
-       editMenu->Append(REDO, "&Redo", "Redo a move that has been undone");
+       editMenu->Append(UNDO, _T("&Undo"), _T("Undo the last move"));
+       editMenu->Append(REDO, _T("&Redo"), _T("Redo a move that has been undone"));
 
        wxMenu* optionsMenu = new wxMenu;
        optionsMenu->Append(RIGHT_BUTTON_UNDO,
-                       "&Right button undo",
-                       "Enables/disables right mouse button undo and redo",
+                       _T("&Right button undo"),
+                       _T("Enables/disables right mouse button undo and redo"),
                        TRUE
                        );
        optionsMenu->Append(HELPING_HAND,
-                       "&Helping hand",
-                       "Enables/disables hand cursor when a card can be moved",
+                       _T("&Helping hand"),
+                       _T("Enables/disables hand cursor when a card can be moved"),
                        TRUE
                        );
         optionsMenu->Append(LARGE_CARDS,
-                        "&Large cards",
-                        "Enables/disables large cards for high resolution displays",
+                        _T("&Large cards"),
+                        _T("Enables/disables large cards for high resolution displays"),
                         TRUE
                         );
        optionsMenu->Check(HELPING_HAND, TRUE);
@@ -174,13 +174,13 @@ FortyFrame::FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,b
         optionsMenu->Check(LARGE_CARDS, largecards ? TRUE : FALSE);
 
        wxMenu* helpMenu = new wxMenu;
-       helpMenu->Append(ABOUT, "&About...", "Displays information about the game");
+       helpMenu->Append(ABOUT, _T("&About..."), _T("Displays information about the game"));
 
        m_menuBar = new wxMenuBar;
-       m_menuBar->Append(gameMenu,    "&Game");
-       m_menuBar->Append(editMenu,    "&Edit");
-       m_menuBar->Append(optionsMenu, "&Options");
-       m_menuBar->Append(helpMenu,    "&Help");
+       m_menuBar->Append(gameMenu,    _T("&Game"));
+       m_menuBar->Append(editMenu,    _T("&Edit"));
+       m_menuBar->Append(optionsMenu, _T("&Options"));
+       m_menuBar->Append(helpMenu,    _T("&Help"));
 
        SetMenuBar(m_menuBar);
 
@@ -243,14 +243,14 @@ FortyFrame::About(wxCommandEvent&)
 #endif
     {
         wxMessageBox(
-            "Forty Thieves\n\n"
-            "A freeware program using the wxWindows\n"
-            "portable C++ GUI toolkit.\n"
-            "http://www.wxwindows.org\n"
-            "http://www.freiburg.linux.de/~wxxt\n\n"
-            "Author: Chris Breeze (c) 1992-1998\n"
-            "email: chris.breeze@iname.com",
-            "About Forty Thieves",
+            _T("Forty Thieves\n\n")
+            _T("A freeware program using the wxWindows\n")
+            _T("portable C++ GUI toolkit.\n")
+            _T("http://www.wxwindows.org\n")
+            _T("http://www.freiburg.linux.de/~wxxt\n\n")
+            _T("Author: Chris Breeze (c) 1992-1998\n")
+            _T("email: chris.breeze@iname.com"),
+            _T("About Forty Thieves"),
             wxOK, this
             );
     }
@@ -331,7 +331,7 @@ bool FortyAboutDialog::AddControls(wxWindow* parent)
             wxFile file;
             file.Open(htmlFile, wxFile::read);
             long len = file.Length();
-            char* buf = htmlText.GetWriteBuf(len + 1);
+            wxChar* buf = htmlText.GetWriteBuf(len + 1);
             file.Read(buf, len);
             buf[len] = 0;
             htmlText.UngetWriteBuf();
@@ -349,7 +349,7 @@ bool FortyAboutDialog::AddControls(wxWindow* parent)
     verString.Printf("%.2f", stVERSION_NUMBER);
     htmlText.Replace(wxT("$VERSION$"), verString);
 #endif
-    htmlText.Replace(wxT("$DATE$"), __DATE__);
+    htmlText.Replace(wxT("$DATE$"), _T(__DATE__));
 
     wxSize htmlSize(400, 290);
 
@@ -373,7 +373,7 @@ bool FortyAboutDialog::AddControls(wxWindow* parent)
     wxASSERT( item1 );
     item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 );
 
-    wxButton *item2 = new wxButton( parent, wxID_CANCEL, "&Close", wxDefaultPosition, wxDefaultSize, 0 );
+    wxButton *item2 = new wxButton( parent, wxID_CANCEL, _T("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
     item2->SetDefault();
     item2->SetFocus();
 
index 0ad38bae0acf7dfa16f269299c49a1299ded0b0e..9a4383c9a1c3b752799726e3733843117bf28bb4 100644 (file)
@@ -34,7 +34,7 @@ class FortyCanvas;
 class FortyFrame: public wxFrame
 {
 public:
-        FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,bool largecards);
+        FortyFrame(wxFrame* frame, const wxString& title, int x, int y, int w, int h,bool largecards);
        virtual ~FortyFrame();
 
        void OnCloseWindow(wxCloseEvent& event);
index e137996530984c08eda42826e0b5f99852691225..9b9048f6de85169424bee16673b936a03bfc3ea5 100644 (file)
@@ -163,7 +163,7 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
     {
                if (src == dest)
                {
-                       wxMessageBox("Game::DoMove() src == dest", "Debug message",
+                       wxMessageBox(_T("Game::DoMove() src == dest"), _T("Debug message"),
                                   wxOK | wxICON_EXCLAMATION);
                }
                m_moves[m_moveIndex].src = src;
@@ -175,7 +175,7 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
     }
     else
     {
-               wxMessageBox("Game::DoMove() Undo buffer full", "Debug message",
+               wxMessageBox(_T("Game::DoMove() Undo buffer full"), _T("Debug message"),
                           wxOK | wxICON_EXCLAMATION);
     }
 
@@ -203,8 +203,8 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
                // Redraw the score box to update games won
                DisplayScore(dc);
 
-               if (wxMessageBox("Do you wish to play again?",
-                       "Well Done, You have won!", wxYES_NO | wxICON_QUESTION) == wxYES)
+               if (wxMessageBox(_T("Do you wish to play again?"),
+                       _T("Well Done, You have won!"), wxYES_NO | wxICON_QUESTION) == wxYES)
                {
                        Deal();
                        canvas->Refresh();
@@ -241,25 +241,25 @@ void Game::DisplayScore(wxDC& dc)
        int w, h;
        {
                long width, height;
-               dc.GetTextExtent("Average score:m_x", &width, &height);
+               dc.GetTextExtent(_T("Average score:m_x"), &width, &height);
                w = width;
                h = height;
        }
        dc.DrawRectangle(x + w, y, 20, 4 * h);
 
-    char str[80];
-    sprintf(str, "%d", m_currentScore);
-    dc.DrawText("Score:", x, y);
+    wxString str;
+    str.Printf(_T("%d"), m_currentScore);
+    dc.DrawText(_T("Score:"), x, y);
     dc.DrawText(str, x + w, y);
     y += h;
 
-    sprintf(str, "%d", m_numGames);
-    dc.DrawText("Games played:", x, y);
+    str.Printf(_T("%d"), m_numGames);
+    dc.DrawText(_T("Games played:"), x, y);
     dc.DrawText(str, x + w, y);
     y += h;
 
-    sprintf(str, "%d", m_numWins);
-    dc.DrawText("Games won:", x, y);
+    str.Printf(_T("%d"), m_numWins);
+    dc.DrawText(_T("Games won:"), x, y);
     dc.DrawText(str, x + w, y);
     y += h;
 
@@ -268,8 +268,8 @@ void Game::DisplayScore(wxDC& dc)
        {
                average = (2 * (m_currentScore + m_totalScore) + m_numGames ) / (2 * m_numGames);
        }
-    sprintf(str, "%d", average);
-    dc.DrawText("Average score:", x, y);
+    str.Printf(_T("%d"), average);
+    dc.DrawText(_T("Average score:"), x, y);
     dc.DrawText(str, x + w, y);
 }
 
@@ -798,8 +798,8 @@ void Pack::Redraw(wxDC& dc)
 {
     Pile::Redraw(dc);
 
-    char str[10];
-    sprintf(str, "%d  ", m_topCard + 1);
+    wxString str;
+    str.Printf(_T("%d  "), m_topCard + 1);
 
     dc.SetBackgroundMode( wxSOLID );
        dc.SetTextBackground(FortyApp::BackgroundColour());
@@ -816,7 +816,7 @@ void Pack::AddCard(Card* card)
     }
     else
     {
-               wxMessageBox("Pack::AddCard() Undo error", "Forty Thieves: Warning",
+               wxMessageBox(_T("Pack::AddCard() Undo error"), _T("Forty Thieves: Warning"),
                   wxOK | wxICON_EXCLAMATION);
     }
     card->TurnCard(facedown);
index 674758143b9697be9130980cca731b6a39502adb..4c5c48e3fc86fce28ea5f67301521fd5e84ba134 100644 (file)
@@ -44,7 +44,7 @@ PlayerSelectionDialog::PlayerSelectionDialog(
                                                        wxWindow* parent,
                                                        ScoreFile* file
                                                        ) :
-       wxDialog(parent, -1, "Player Selection",
+       wxDialog(parent, -1, _T("Player Selection"),
                        wxDefaultPosition, wxSize(320, 200),
                        wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
        m_scoreFile(file)
@@ -52,7 +52,7 @@ PlayerSelectionDialog::PlayerSelectionDialog(
        // enable constraints
        SetAutoLayout (TRUE);
 
-       wxStaticText* msg = new wxStaticText(this, -1, "Please select a name or type a new one:");
+       wxStaticText* msg = new wxStaticText(this, -1, _T("Please select a name or type a new one:"));
 
        wxListBox* list = new wxListBox(
                                                this, ID_LISTBOX,
@@ -68,10 +68,10 @@ PlayerSelectionDialog::PlayerSelectionDialog(
                list->Append(players[i]);
        }
 
-       m_textField = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, 0);
+       m_textField = new wxTextCtrl(this, -1, _T(""), wxDefaultPosition, wxDefaultSize, 0);
 
-       m_OK = new wxButton(this, wxID_OK, "OK");
-       m_cancel = new wxButton(this, wxID_CANCEL, "Cancel");
+       m_OK = new wxButton(this, wxID_OK, _T("OK"));
+       m_cancel = new wxButton(this, wxID_CANCEL, _T("Cancel"));
 
        wxLayoutConstraints* layout;
 
@@ -149,7 +149,7 @@ const wxString& PlayerSelectionDialog::GetPlayersName()
 
 void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& event)
 {
-       m_player = "";
+       m_player = _T("");
     EndModal(wxID_CANCEL);
 }
 
@@ -169,9 +169,9 @@ void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event)
                wxString name = m_textField->GetValue();
                if (!name.IsNull() && name.Length() > 0)
                {
-                       if (name.Contains('@'))
+                       if (name.Contains(_T('@')))
                        {
-                               wxMessageBox("Names should not contain the '@' character", "Forty Thieves");
+                               wxMessageBox(_T("Names should not contain the '@' character"), _T("Forty Thieves"));
                        }
                        else
                        {
@@ -181,12 +181,12 @@ void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event)
                }
                else
                {
-                       wxMessageBox("Please enter your name", "Forty Thieves");
+                       wxMessageBox(_T("Please enter your name"), _T("Forty Thieves"));
                }
        }
        else
        {
-               m_player = "";
+               m_player = _T("");
                EndModal(wxID_CANCEL);
        }
 }
index fddbc0e3c4c783c8da222051df65544c7433714e..d8f31924a293f6e9650f323735c4bbd2e8591ae3 100644 (file)
 #include "wx/wx.h"
 #endif
 
-#if wxUSE_IOSTREAMH
-#if defined(__WXMSW__) && !defined(__GNUWIN32__) && !defined(__MWERKS__)
-#include <strstrea.h>
-#else
-#include <strstream.h>
-#endif
-#else
-#include <strstream>
-//using namespace std;
-#endif
 #include "scorefil.h"
 #include "scoredg.h"
 
@@ -66,9 +56,9 @@ ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile) :
         wxArrayString players;
        scoreFile->GetPlayerList( players);
 
-       ostrstream os;
+       wxString os;
 
-       os << "Player\tWins\tGames\tScore\n";
+       os << _T("Player\tWins\tGames\tScore\n");
        for (unsigned int i = 0; i < players.Count(); i++)
        {
                int wins, games, score;
@@ -79,15 +69,13 @@ ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile) :
                        average = (2 * score + games) / (2 * games);
                }
 
-               os << players[i] << '\t' 
-                  << wins  << '\t'
-                  << games << '\t'
-                  << average << '\n';
+               os << players[i] << _T('\t') 
+                  << wins  << _T('\t')
+                  << games << _T('\t')
+                  << average << _T('\n');
        }
-       os << '\0';
-       char* str = os.str();
-       m_text = str;
-       delete str;
+       os << _T('\0');
+       m_text = os;
 }
 
 ScoreCanvas::~ScoreCanvas()
@@ -98,7 +86,7 @@ void ScoreCanvas::OnDraw(wxDC& dc)
 {
        dc.SetFont(* m_font);
 
-       const char* str = m_text;
+       const wxChar* str = m_text;
        unsigned int tab = 0;
        unsigned int tabstops[] = { 5, 100, 150, 200 };
 
@@ -106,29 +94,29 @@ void ScoreCanvas::OnDraw(wxDC& dc)
        int lineSpacing;
        {
                long w, h;
-               dc.GetTextExtent("Testing", &w, &h);
+               dc.GetTextExtent(_T("Testing"), &w, &h);
                lineSpacing = (int)h;
        }
 
        int y = 0;
        while (*str)
        {
-               char text[256];
-               char* dest = text;
+               wxChar text[256];
+               wxChar* dest = text;
                
-               while (*str && *str >= ' ') *dest++ = *str++;
-               *dest = '\0';
+               while (*str && *str >= _T(' ')) *dest++ = *str++;
+               *dest = _T('\0');
 
                dc.DrawText(text, tabstops[tab], y);
 
-               if (*str == '\t')
+               if (*str == _T('\t'))
                {
                        if (tab < sizeof(tabstops) / sizeof(tabstops[0]) - 1)
                        {
                                tab++;
                        }
                }
-               else if (*str == '\n')
+               else if (*str == _T('\n'))
                {
                        tab = 0;
                        y += lineSpacing;
@@ -145,7 +133,7 @@ ScoreDialog::ScoreDialog(
                                                        wxWindow* parent,
                                                        ScoreFile* file
                                                        ) :
-       wxDialog(parent, -1, "Scores",
+       wxDialog(parent, -1, _T("Scores"),
                        wxDefaultPosition, wxSize(310, 200),
                        wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
        m_scoreFile(file)
@@ -154,7 +142,7 @@ ScoreDialog::ScoreDialog(
        SetAutoLayout (TRUE);
 
        ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile);
-       m_OK = new wxButton(this, wxID_OK, "OK");
+       m_OK = new wxButton(this, wxID_OK, _T("OK"));
 
        wxLayoutConstraints* layout;
 
index 307b0610c3aba034c6b74df054cc030d23b6e832..ef98e7761b04d0fe43dc709a2e97f2908bb6f17f 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "scorefil.h"
 
-ScoreFile::ScoreFile(const char* appName)
+ScoreFile::ScoreFile(const wxString& appName)
 {
 #if 0
        wxString filename;
@@ -68,7 +68,8 @@ ScoreFile::ScoreFile(const char* appName)
        }
 #endif
 
-       m_config = new wxConfig(appName, "wxWindows", appName, "", wxCONFIG_USE_LOCAL_FILE);  // only local
+       m_config = new wxConfig(appName, _T("wxWindows"), appName, _T(""),
+                                wxCONFIG_USE_LOCAL_FILE);  // only local
 }
 
 ScoreFile::~ScoreFile()
@@ -84,7 +85,7 @@ ScoreFile::~ScoreFile()
 
 void ScoreFile::GetPlayerList( wxArrayString &list )
 {
-       m_config->SetPath("/Players");
+       m_config->SetPath(_T("/Players"));
        int length = m_config->GetNumberOfGroups();
 
        if (length <= 0) return;
@@ -106,12 +107,14 @@ void ScoreFile::GetPlayerList( wxArrayString &list )
 
 // Calculate an encrypted check number to prevent tampering with
 // score file
-long ScoreFile::CalcCheck(const char* name, int p1, int p2, int p3)
+long ScoreFile::CalcCheck(const wxString& name, int p1, int p2, int p3)
 {
     long check = 0;
-    while (*name)
+    size_t i, max = name.length();
+
+    for(i = 0; i < max; ++i )
        {
-               check = (check << 1) ^ (long)*name++;
+               check = (check << 1) ^ (long)name[i];
                check = ((check >> 23) ^ check) & 0xFFFFFF;
        }
        check = (check << 1) ^ (long)p1;
@@ -126,13 +129,13 @@ long ScoreFile::CalcCheck(const char* name, int p1, int p2, int p3)
 wxString ScoreFile::GetPreviousPlayer() const
 {
        wxString result;
-       m_config->SetPath("/General");
-       m_config->Read("LastPlayer", &result);
+       m_config->SetPath(_T("/General"));
+       m_config->Read(_T("LastPlayer"), &result);
        return result;
 }
 
 void ScoreFile::ReadPlayersScore(
-                                               const char* player,
+                                               const wxString& player,
                                                int& wins,
                                                int& games,
                                                int& score)
@@ -142,17 +145,17 @@ void ScoreFile::ReadPlayersScore(
 
        games = wins = score = 0;
 
-       m_config->SetPath("/Players");
+       m_config->SetPath(_T("/Players"));
        m_config->SetPath(player);
-       if (m_config->Read("Score", &myScore, 0L) &&
-               m_config->Read("Games", &myGames, 0L) &&
-               m_config->Read("Wins",  &myWins, 0L) &&
-               m_config->Read("Check", &check, 0L))
+       if (m_config->Read(_T("Score"), &myScore, 0L) &&
+               m_config->Read(_T("Games"), &myGames, 0L) &&
+               m_config->Read(_T("Wins"),  &myWins, 0L) &&
+               m_config->Read(_T("Check"), &check, 0L))
        {
            if (check != CalcCheck(player, myGames, myWins, myScore))
                {
-                       wxMessageBox("Score file corrupted", "Warning",
-                                               wxOK | wxICON_EXCLAMATION);
+                       wxMessageBox(_T("Score file corrupted"), _T("Warning"),
+                                     wxOK | wxICON_EXCLAMATION);
                }
                else
                {
@@ -165,18 +168,18 @@ void ScoreFile::ReadPlayersScore(
 }
 
 
-void ScoreFile::WritePlayersScore(const char* player, int wins, int games, int score)
+void ScoreFile::WritePlayersScore(const wxString& player, int wins, int games, int score)
 {
     if (player)
        {
-               m_config->SetPath("/General");
-               m_config->Write("LastPlayer", wxString(player)); // Without wxString tmp, thinks it's bool in VC++
+               m_config->SetPath(_T("/General"));
+               m_config->Write(_T("LastPlayer"), wxString(player)); // Without wxString tmp, thinks it's bool in VC++
 
-               m_config->SetPath("/Players");
+               m_config->SetPath(_T("/Players"));
                m_config->SetPath(player);
-               m_config->Write("Score", (long)score);
-               m_config->Write("Games", (long)games);
-               m_config->Write("Wins", (long)wins);
-               m_config->Write("Check", CalcCheck(player, games, wins, score));
+               m_config->Write(_T("Score"), (long)score);
+               m_config->Write(_T("Games"), (long)games);
+               m_config->Write(_T("Wins"), (long)wins);
+               m_config->Write(_T("Check"), CalcCheck(player, games, wins, score));
        }
 }
index 25c1ee717d24ccc311c8616eb2f883316f259f03..d73bb62540995714ff7acde8a21cd3d9e1cf3663 100644 (file)
 
 class ScoreFile {
 public:
-       ScoreFile(const char* appName);
+       ScoreFile(const wxString& appName);
        virtual ~ScoreFile();
 
        void GetPlayerList( wxArrayString &list );
        wxString GetPreviousPlayer() const;
 
-       void ReadPlayersScore(const char* player, int& wins, int& games, int &score);
-       void WritePlayersScore(const char* player, int wins, int games, int score);
+       void ReadPlayersScore(const wxString& player, int& wins, int& games, int &score);
+       void WritePlayersScore(const wxString& player, int wins, int games, int score);
 
 private:
-       long CalcCheck(const char* name, int p1, int p2, int p3);
+       long CalcCheck(const wxString& name, int p1, int p2, int p3);
        wxString            m_configFilename;
        wxConfig*           m_config;
 };
index fe84a6a58424cf4c35080690057822cd2a180c55..0bf697e9e6184940eab2d9f28a4fbfcc78f12571 100644 (file)
@@ -90,13 +90,13 @@ DECLARE_EVENT_TABLE()
 bool MyApp::OnInit()
 {
   // Create the main frame window
-  MyFrame *frame = new MyFrame(NULL, "Fractal Mountains for wxWindows", wxPoint(-1, -1), wxSize(640, 480));
+  MyFrame *frame = new MyFrame(NULL, _T("Fractal Mountains for wxWindows"), wxPoint(-1, -1), wxSize(640, 480));
 
   // Make a menubar
   wxMenu *file_menu = new wxMenu;
-  file_menu->Append(wxID_EXIT, "E&xit");
+  file_menu->Append(wxID_EXIT, _T("E&xit"));
   menuBar = new wxMenuBar;
-  menuBar->Append(file_menu, "&File");
+  menuBar->Append(file_menu, _T("&File"));
   frame->SetMenuBar(menuBar);
 
   int width, height;
index 8605e51376beff5be83fa9e8034938007c7504c9..b86757ebf988c00afba760beeb964f76ba198c80 100644 (file)
@@ -58,9 +58,18 @@ public:
         m_name        = name;
         m_description = description;
         m_rules       = _("");
-        m_shape.Add( wxString::Format("%i %i", -width/2, -height/2) );
+        m_shape.Add( wxString::Format(_T("%i %i"), -width/2, -height/2) );
         for(int j = 0; j < height; j++)
-            m_shape.Add( wxString(shape + (j * width), (size_t) width) );        
+        {
+            wxString tmp;
+
+            for(int i = 0; i < width; i++)
+            {
+                tmp += wxChar(shape[j * width + i]);
+            }
+
+            m_shape.Add( tmp );
+        }
     };
 
     wxString      m_name;
index 35bcc5b6b47514cf86f9a4980a0358a004f7e703..7f14638a7af6f05fd3f6dcd4abe2d1c9048dd6e3 100644 (file)
@@ -194,9 +194,9 @@ LifeFrame::LifeFrame() : wxFrame((wxFrame *)0, -1, _("Life!"), wxPoint(200, 200)
     SetIcon(wxICON(mondrian));
 
     // menu bar
-    wxMenu *menuFile = new wxMenu("", wxMENU_TEAROFF);
-    wxMenu *menuView = new wxMenu("", wxMENU_TEAROFF);
-    wxMenu *menuGame = new wxMenu("", wxMENU_TEAROFF);
+    wxMenu *menuFile = new wxMenu(_T(""), wxMENU_TEAROFF);
+    wxMenu *menuView = new wxMenu(_T(""), wxMENU_TEAROFF);
+    wxMenu *menuGame = new wxMenu(_T(""), wxMENU_TEAROFF);
 
     menuFile->Append(ID_NEW, _("&New"), _("Start a new game"));
     menuFile->Append(ID_OPEN, _("&Open..."), _("Open an existing Life pattern"));
index 8a883d1543c553377899174921399a0418f45799..09e02e276965d56adf8e10b91bc82acd5850deea 100644 (file)
@@ -206,7 +206,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y)
     dc->SetFont(* NormalFont);
     long xx;
     long yy;
-    dc->GetTextExtent("X", &xx, &yy);
+    dc->GetTextExtent(_T("X"), &xx, &yy);
     char_height = (int)yy;
 
     if (current_page == 0)
@@ -844,9 +844,13 @@ int GetIndex()
 // Read preferences
 void ReadPreferences()
 {
+#if wxUSE_RESOURCES
+#if wxUSE_RESOURCES
   wxGetResource("wxPoem", "FontSize", &pointSize);
   wxGetResource("wxPoem", "X", &XPos);
   wxGetResource("wxPoem", "Y", &YPos);
+#endif
+#endif
 }
 
 // Write preferences to disk
@@ -854,10 +858,14 @@ void WritePreferences()
 {
 #ifdef __WXMSW__
   TheMainWindow->GetPosition(&XPos, &YPos);
+#if wxUSE_RESOURCES
+#if wxUSE_RESOURCES
   wxWriteResource("wxPoem", "FontSize", pointSize);
   wxWriteResource("wxPoem", "X", XPos);
   wxWriteResource("wxPoem", "Y", YPos);
 #endif
+#endif
+#endif
 }
 
 // Load a poem from given file, at given point in file.