Backported Unicode compilation fixes for demos and exec sample.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18693 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-01-12 20:48:13 +00:00
parent c25bc243eb
commit a98477bd0b
16 changed files with 161 additions and 144 deletions

View File

@@ -40,7 +40,7 @@ bool AppClass::OnInit()
level=IDM_EASY; level=IDM_EASY;
BombsFrame = 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 xmax=BombsFrame->BombsCanvas->field_width*BombsFrame->BombsCanvas->x_cell*X_UNIT;
int ymax=BombsFrame->BombsCanvas->field_height*BombsFrame->BombsCanvas->y_cell*Y_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 // Create a menu bar for the frame
wxMenuBar *menuBar1 = new wxMenuBar; wxMenuBar *menuBar1 = new wxMenuBar;
wxMenu *menu1 = new wxMenu; 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->AppendSeparator();
menu1->Append(IDM_ABOUT, "&About..."); // , "Infos on wxBombs"); menu1->Append(IDM_ABOUT, _T("&About...")); // , "Infos on wxBombs");
menuBar1->Append(menu1, "&File"); menuBar1->Append(menu1, _T("&File"));
wxMenu *menu2 = new wxMenu; 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->AppendSeparator();
menu2->Append(IDM_EASY, "&Easy", wxEmptyString, TRUE); // "10x10 play field", TRUE); menu2->Append(IDM_EASY, _T("&Easy"), wxEmptyString, TRUE); // "10x10 play field", TRUE);
menu2->Append(IDM_MEDIUM, "&Medium", wxEmptyString, TRUE); // "15x15 play field", TRUE); menu2->Append(IDM_MEDIUM, _T("&Medium"), wxEmptyString, TRUE); // "15x15 play field", TRUE);
menu2->Append(IDM_DIFFICULT, "&Difficult", wxEmptyString, TRUE); // "25x20 play field", TRUE); menu2->Append(IDM_DIFFICULT, _T("&Difficult"), wxEmptyString, TRUE); // "25x20 play field", TRUE);
menuBar1->Append(menu2, "&Game"); menuBar1->Append(menu2, _T("&Game"));
SetMenuBar(menuBar1); SetMenuBar(menuBar1);
menuBar=menuBar1; menuBar=menuBar1;
menuBar->Check(wxGetApp().level, TRUE); menuBar->Check(wxGetApp().level, TRUE);
@@ -124,7 +124,7 @@ void BombsFrameClass::OnRestart(wxCommandEvent& event)
void BombsFrameClass::OnAbout(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) void BombsFrameClass::OnEasy(wxCommandEvent& event)
@@ -162,7 +162,7 @@ BombsCanvasClass::BombsCanvasClass(wxFrame *parent, const wxPoint& pos, const wx
dc.SetFont(font); dc.SetFont(font);
long chw, chh; long chw, chh;
char buf[]="M"; wxChar buf[]=_T("M");
dc.GetTextExtent(buf, &chw, &chh); dc.GetTextExtent(buf, &chw, &chh);
dc.SetFont(wxNullFont); dc.SetFont(wxNullFont);

View File

@@ -33,15 +33,15 @@
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2) void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
{ int x,y,xmax,ymax; { int x,y,xmax,ymax;
char buf[2]; wxChar buf[2];
long chw, chh; long chw, chh;
wxColour *wxBlack = wxTheColourDatabase->FindColour("BLACK"); wxColour *wxBlack = wxTheColourDatabase->FindColour(_T("BLACK"));
wxColour *wxWhite = wxTheColourDatabase->FindColour("WHITE"); wxColour *wxWhite = wxTheColourDatabase->FindColour(_T("WHITE"));
wxColour *wxRed = wxTheColourDatabase->FindColour("RED"); wxColour *wxRed = wxTheColourDatabase->FindColour(_T("RED"));
wxColour *wxBlue = wxTheColourDatabase->FindColour("BLUE"); wxColour *wxBlue = wxTheColourDatabase->FindColour(_T("BLUE"));
wxColour *wxGrey = wxTheColourDatabase->FindColour("LIGHT GREY"); wxColour *wxGrey = wxTheColourDatabase->FindColour(_T("LIGHT GREY"));
wxColour *wxGreen = wxTheColourDatabase->FindColour("GREEN"); wxColour *wxGreen = wxTheColourDatabase->FindColour(_T("GREEN"));
wxPen *blackPen = wxThePenList->FindOrCreatePen(*wxBlack, 1, wxSOLID); wxPen *blackPen = wxThePenList->FindOrCreatePen(*wxBlack, 1, wxSOLID);
wxPen *redPen = wxThePenList->FindOrCreatePen(*wxRed, 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; wxFont font= BOMBS_FONT;
dc->SetFont(font); dc->SetFont(font);
buf[1]='\0'; buf[1]=_T('\0');
for(x=xc1; x<=xc2; x++) for(x=xc1; x<=xc2; x++)
for(y=yc1; y<=yc2; y++) for(y=yc1; y<=yc2; y++)
{ if (wxGetApp().Game.IsMarked(x,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->SetBrush(* greyBrush);
dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT, dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT,
x_cell*X_UNIT+1, y_cell*Y_UNIT+1); 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)) if (!wxGetApp().Game.IsHidden(x,y) && wxGetApp().Game.IsBomb(x,y))
dc->SetTextForeground(*wxBlue); dc->SetTextForeground(*wxBlue);
else else
@@ -102,7 +102,7 @@ void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
dc->SetBrush(* redBrush); dc->SetBrush(* redBrush);
dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT, dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT,
x_cell*X_UNIT+1, y_cell*Y_UNIT+1); x_cell*X_UNIT+1, y_cell*Y_UNIT+1);
*buf='B'; *buf=_T('B');
dc->SetTextForeground(* wxBlack); dc->SetTextForeground(* wxBlack);
dc->SetTextBackground(* wxRed); dc->SetTextBackground(* wxRed);
dc->GetTextExtent(buf, &chw, &chh); 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->SetBrush(* whiteBrush);
dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT, dc->DrawRectangle( x*x_cell*X_UNIT, y*y_cell*Y_UNIT,
x_cell*X_UNIT+1, y_cell*Y_UNIT+1); 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); dc->GetTextExtent(buf, &chw, &chh);
switch(*buf) switch(*buf)
{ case '0': dc->SetTextForeground(* wxGreen); break; { case _T('0'): dc->SetTextForeground(* wxGreen); break;
case '1': dc->SetTextForeground(* wxBlue); break; case _T('1'): dc->SetTextForeground(* wxBlue); break;
default: dc->SetTextForeground(* wxBlack); break; default: dc->SetTextForeground(* wxBlack); break;
} }
dc->SetTextBackground(* wxWhite); dc->SetTextBackground(* wxWhite);
@@ -140,9 +140,10 @@ void BombsCanvasClass::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
dc->SetFont(wxNullFont); dc->SetFont(wxNullFont);
if (wxGetApp().BombsFrame) if (wxGetApp().BombsFrame)
{ char buf[80]; { wxString buf;
sprintf(buf, "%d bombs %d remaining cells", buf.Printf(_T("%d bombs %d remaining cells"),
wxGetApp().Game.GetBombs(), wxGetApp().Game.GetRemainingCells()); wxGetApp().Game.GetBombs(),
wxGetApp().Game.GetRemainingCells());
wxGetApp().BombsFrame->SetStatusText(buf, 0); 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) if (wxGetApp().Game.IsBomb(x,y) || wxGetApp().Game.GetRemainingCells()==0)
{ wxBell(); { wxBell();
if (!wxGetApp().Game.IsBomb(x,y)) 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); wxOK|wxCENTRE, wxGetApp().BombsFrame);
} }
else // x,y is a bomb else // x,y is a bomb

View File

@@ -56,7 +56,7 @@ FortyCanvas::FortyCanvas(wxWindow* parent, int x, int y, int w, int h) :
m_arrowCursor = new wxCursor(wxCURSOR_ARROW); m_arrowCursor = new wxCursor(wxCURSOR_ARROW);
wxString name = wxTheApp->GetAppName(); wxString name = wxTheApp->GetAppName();
if (name.Length() <= 0) name = "forty"; if (name.Length() <= 0) name = _T("forty");
m_scoreFile = new ScoreFile(name); m_scoreFile = new ScoreFile(name);
m_game = new Game(0, 0, 0); m_game = new Game(0, 0, 0);
m_game->Deal(); m_game->Deal();
@@ -159,8 +159,8 @@ Called when the main frame is closed
bool FortyCanvas::OnCloseCanvas() bool FortyCanvas::OnCloseCanvas()
{ {
if (m_game->InPlay() && if (m_game->InPlay() &&
wxMessageBox("Are you sure you want to\nabandon the current game?", wxMessageBox(_T("Are you sure you want to\nabandon the current game?"),
"Warning", wxYES_NO | wxICON_QUESTION) == wxNO) _T("Warning"), wxYES_NO | wxICON_QUESTION) == wxNO)
{ {
return FALSE; return FALSE;
} }

View File

@@ -67,25 +67,25 @@ Card::Card(int value, WayUp way_up) :
if (!m_symbolBmap) if (!m_symbolBmap)
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
m_symbolBmap = new wxBitmap("CardSymbols", wxBITMAP_TYPE_BMP_RESOURCE); m_symbolBmap = new wxBitmap(_T("CardSymbols"), wxBITMAP_TYPE_BMP_RESOURCE);
#else #else
m_symbolBmap = new wxBitmap(Symbols_bits, Symbols_width, Symbols_height); m_symbolBmap = new wxBitmap(Symbols_bits, Symbols_width, Symbols_height);
#endif #endif
if (!m_symbolBmap->Ok()) if (!m_symbolBmap->Ok())
{ {
::wxMessageBox("Failed to load bitmap CardSymbols", "Error"); ::wxMessageBox(_T("Failed to load bitmap CardSymbols"), _T("Error"));
} }
} }
if (!m_pictureBmap) if (!m_pictureBmap)
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
m_pictureBmap = new wxBitmap("CardPictures", wxBITMAP_TYPE_BMP_RESOURCE); m_pictureBmap = new wxBitmap(_T("CardPictures"), wxBITMAP_TYPE_BMP_RESOURCE);
#else #else
m_pictureBmap = new wxBitmap(Pictures); m_pictureBmap = new wxBitmap(Pictures);
#endif #endif
if (!m_pictureBmap->Ok()) 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.SetBackground(* wxRED_BRUSH);
dc.SetBackgroundMode(wxSOLID); dc.SetBackgroundMode(wxSOLID);
wxBrush* brush = wxTheBrushList->FindOrCreateBrush( wxBrush* brush = wxTheBrushList->FindOrCreateBrush(
"BLACK", wxCROSSDIAG_HATCH _T("BLACK"), wxCROSSDIAG_HATCH
); );
dc.SetBrush(* brush); dc.SetBrush(* brush);

View File

@@ -76,7 +76,7 @@ bool FortyApp::OnInit()
bool largecards = FALSE; bool largecards = FALSE;
wxSize size(668,510); wxSize size(668,510);
if ((argc > 1) && (!wxStrcmp(argv[1],"-L"))) if ((argc > 1) && (!wxStrcmp(argv[1],_T("-L"))))
{ {
largecards = TRUE; largecards = TRUE;
size = wxSize(1000,750); size = wxSize(1000,750);
@@ -84,7 +84,7 @@ bool FortyApp::OnInit()
FortyFrame* frame = new FortyFrame( FortyFrame* frame = new FortyFrame(
0, 0,
"Forty Thieves", _T("Forty Thieves"),
-1, -1, size.x, size.y,largecards -1, -1, size.x, size.y,largecards
); );
@@ -120,14 +120,14 @@ const wxColour& FortyApp::TextColour()
{ {
if (!m_textColour) if (!m_textColour)
{ {
m_textColour = new wxColour("BLACK"); m_textColour = new wxColour(_T("BLACK"));
} }
return *m_textColour; return *m_textColour;
} }
// My frame constructor // 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)) wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
{ {
#ifdef __WXMAC__ #ifdef __WXMAC__
@@ -136,7 +136,7 @@ FortyFrame::FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,b
#endif #endif
// set the icon // set the icon
#ifdef __WXMSW__ #ifdef __WXMSW__
SetIcon(wxIcon("CardsIcon")); SetIcon(wxIcon(_T("CardsIcon")));
#else #else
#ifdef GTK_TBD #ifdef GTK_TBD
SetIcon(wxIcon(Cards_bits, Cards_width, Cards_height)); 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 // Make a menu bar
wxMenu* gameMenu = new wxMenu; wxMenu* gameMenu = new wxMenu;
gameMenu->Append(NEW_GAME, "&New", "Start a new game"); gameMenu->Append(NEW_GAME, _T("&New"), _T("Start a new game"));
gameMenu->Append(SCORES, "&Scores...", "Displays scores"); gameMenu->Append(SCORES, _T("&Scores..."), _T("Displays scores"));
gameMenu->Append(EXIT, "E&xit", "Exits Forty Thieves"); gameMenu->Append(EXIT, _T("E&xit"), _T("Exits Forty Thieves"));
wxMenu* editMenu = new wxMenu; wxMenu* editMenu = new wxMenu;
editMenu->Append(UNDO, "&Undo", "Undo the last move"); editMenu->Append(UNDO, _T("&Undo"), _T("Undo the last move"));
editMenu->Append(REDO, "&Redo", "Redo a move that has been undone"); editMenu->Append(REDO, _T("&Redo"), _T("Redo a move that has been undone"));
wxMenu* optionsMenu = new wxMenu; wxMenu* optionsMenu = new wxMenu;
optionsMenu->Append(RIGHT_BUTTON_UNDO, optionsMenu->Append(RIGHT_BUTTON_UNDO,
"&Right button undo", _T("&Right button undo"),
"Enables/disables right mouse button undo and redo", _T("Enables/disables right mouse button undo and redo"),
TRUE TRUE
); );
optionsMenu->Append(HELPING_HAND, optionsMenu->Append(HELPING_HAND,
"&Helping hand", _T("&Helping hand"),
"Enables/disables hand cursor when a card can be moved", _T("Enables/disables hand cursor when a card can be moved"),
TRUE TRUE
); );
optionsMenu->Append(LARGE_CARDS, optionsMenu->Append(LARGE_CARDS,
"&Large cards", _T("&Large cards"),
"Enables/disables large cards for high resolution displays", _T("Enables/disables large cards for high resolution displays"),
TRUE TRUE
); );
optionsMenu->Check(HELPING_HAND, 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); optionsMenu->Check(LARGE_CARDS, largecards ? TRUE : FALSE);
wxMenu* helpMenu = new wxMenu; 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 = new wxMenuBar;
m_menuBar->Append(gameMenu, "&Game"); m_menuBar->Append(gameMenu, _T("&Game"));
m_menuBar->Append(editMenu, "&Edit"); m_menuBar->Append(editMenu, _T("&Edit"));
m_menuBar->Append(optionsMenu, "&Options"); m_menuBar->Append(optionsMenu, _T("&Options"));
m_menuBar->Append(helpMenu, "&Help"); m_menuBar->Append(helpMenu, _T("&Help"));
SetMenuBar(m_menuBar); SetMenuBar(m_menuBar);
@@ -243,14 +243,14 @@ FortyFrame::About(wxCommandEvent&)
#endif #endif
{ {
wxMessageBox( wxMessageBox(
"Forty Thieves\n\n" _T("Forty Thieves\n\n")
"A freeware program using the wxWindows\n" _T("A freeware program using the wxWindows\n")
"portable C++ GUI toolkit.\n" _T("portable C++ GUI toolkit.\n")
"http://www.wxwindows.org\n" _T("http://www.wxwindows.org\n")
"http://www.freiburg.linux.de/~wxxt\n\n" _T("http://www.freiburg.linux.de/~wxxt\n\n")
"Author: Chris Breeze (c) 1992-1998\n" _T("Author: Chris Breeze (c) 1992-1998\n")
"email: chris.breeze@iname.com", _T("email: chris.breeze@iname.com"),
"About Forty Thieves", _T("About Forty Thieves"),
wxOK, this wxOK, this
); );
} }
@@ -331,7 +331,7 @@ bool FortyAboutDialog::AddControls(wxWindow* parent)
wxFile file; wxFile file;
file.Open(htmlFile, wxFile::read); file.Open(htmlFile, wxFile::read);
long len = file.Length(); long len = file.Length();
char* buf = htmlText.GetWriteBuf(len + 1); wxChar* buf = htmlText.GetWriteBuf(len + 1);
file.Read(buf, len); file.Read(buf, len);
buf[len] = 0; buf[len] = 0;
htmlText.UngetWriteBuf(); htmlText.UngetWriteBuf();
@@ -349,7 +349,7 @@ bool FortyAboutDialog::AddControls(wxWindow* parent)
verString.Printf("%.2f", stVERSION_NUMBER); verString.Printf("%.2f", stVERSION_NUMBER);
htmlText.Replace(wxT("$VERSION$"), verString); htmlText.Replace(wxT("$VERSION$"), verString);
#endif #endif
htmlText.Replace(wxT("$DATE$"), __DATE__); htmlText.Replace(wxT("$DATE$"), _T(__DATE__));
wxSize htmlSize(400, 290); wxSize htmlSize(400, 290);
@@ -373,7 +373,7 @@ bool FortyAboutDialog::AddControls(wxWindow* parent)
wxASSERT( item1 ); wxASSERT( item1 );
item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 ); 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->SetDefault();
item2->SetFocus(); item2->SetFocus();

View File

@@ -34,7 +34,7 @@ class FortyCanvas;
class FortyFrame: public wxFrame class FortyFrame: public wxFrame
{ {
public: 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(); virtual ~FortyFrame();
void OnCloseWindow(wxCloseEvent& event); void OnCloseWindow(wxCloseEvent& event);

View File

@@ -163,7 +163,7 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
{ {
if (src == dest) if (src == dest)
{ {
wxMessageBox("Game::DoMove() src == dest", "Debug message", wxMessageBox(_T("Game::DoMove() src == dest"), _T("Debug message"),
wxOK | wxICON_EXCLAMATION); wxOK | wxICON_EXCLAMATION);
} }
m_moves[m_moveIndex].src = src; m_moves[m_moveIndex].src = src;
@@ -175,7 +175,7 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
} }
else else
{ {
wxMessageBox("Game::DoMove() Undo buffer full", "Debug message", wxMessageBox(_T("Game::DoMove() Undo buffer full"), _T("Debug message"),
wxOK | wxICON_EXCLAMATION); wxOK | wxICON_EXCLAMATION);
} }
@@ -203,8 +203,8 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
// Redraw the score box to update games won // Redraw the score box to update games won
DisplayScore(dc); DisplayScore(dc);
if (wxMessageBox("Do you wish to play again?", if (wxMessageBox(_T("Do you wish to play again?"),
"Well Done, You have won!", wxYES_NO | wxICON_QUESTION) == wxYES) _T("Well Done, You have won!"), wxYES_NO | wxICON_QUESTION) == wxYES)
{ {
Deal(); Deal();
canvas->Refresh(); canvas->Refresh();
@@ -241,25 +241,25 @@ void Game::DisplayScore(wxDC& dc)
int w, h; int w, h;
{ {
long width, height; long width, height;
dc.GetTextExtent("Average score:m_x", &width, &height); dc.GetTextExtent(_T("Average score:m_x"), &width, &height);
w = width; w = width;
h = height; h = height;
} }
dc.DrawRectangle(x + w, y, 20, 4 * h); dc.DrawRectangle(x + w, y, 20, 4 * h);
char str[80]; wxString str;
sprintf(str, "%d", m_currentScore); str.Printf(_T("%d"), m_currentScore);
dc.DrawText("Score:", x, y); dc.DrawText(_T("Score:"), x, y);
dc.DrawText(str, x + w, y); dc.DrawText(str, x + w, y);
y += h; y += h;
sprintf(str, "%d", m_numGames); str.Printf(_T("%d"), m_numGames);
dc.DrawText("Games played:", x, y); dc.DrawText(_T("Games played:"), x, y);
dc.DrawText(str, x + w, y); dc.DrawText(str, x + w, y);
y += h; y += h;
sprintf(str, "%d", m_numWins); str.Printf(_T("%d"), m_numWins);
dc.DrawText("Games won:", x, y); dc.DrawText(_T("Games won:"), x, y);
dc.DrawText(str, x + w, y); dc.DrawText(str, x + w, y);
y += h; y += h;
@@ -268,8 +268,8 @@ void Game::DisplayScore(wxDC& dc)
{ {
average = (2 * (m_currentScore + m_totalScore) + m_numGames ) / (2 * m_numGames); average = (2 * (m_currentScore + m_totalScore) + m_numGames ) / (2 * m_numGames);
} }
sprintf(str, "%d", average); str.Printf(_T("%d"), average);
dc.DrawText("Average score:", x, y); dc.DrawText(_T("Average score:"), x, y);
dc.DrawText(str, x + w, y); dc.DrawText(str, x + w, y);
} }
@@ -798,8 +798,8 @@ void Pack::Redraw(wxDC& dc)
{ {
Pile::Redraw(dc); Pile::Redraw(dc);
char str[10]; wxString str;
sprintf(str, "%d ", m_topCard + 1); str.Printf(_T("%d "), m_topCard + 1);
dc.SetBackgroundMode( wxSOLID ); dc.SetBackgroundMode( wxSOLID );
dc.SetTextBackground(FortyApp::BackgroundColour()); dc.SetTextBackground(FortyApp::BackgroundColour());
@@ -816,7 +816,7 @@ void Pack::AddCard(Card* card)
} }
else else
{ {
wxMessageBox("Pack::AddCard() Undo error", "Forty Thieves: Warning", wxMessageBox(_T("Pack::AddCard() Undo error"), _T("Forty Thieves: Warning"),
wxOK | wxICON_EXCLAMATION); wxOK | wxICON_EXCLAMATION);
} }
card->TurnCard(facedown); card->TurnCard(facedown);

View File

@@ -44,7 +44,7 @@ PlayerSelectionDialog::PlayerSelectionDialog(
wxWindow* parent, wxWindow* parent,
ScoreFile* file ScoreFile* file
) : ) :
wxDialog(parent, -1, "Player Selection", wxDialog(parent, -1, _T("Player Selection"),
wxDefaultPosition, wxSize(320, 200), wxDefaultPosition, wxSize(320, 200),
wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE), wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
m_scoreFile(file) m_scoreFile(file)
@@ -52,7 +52,7 @@ PlayerSelectionDialog::PlayerSelectionDialog(
// enable constraints // enable constraints
SetAutoLayout (TRUE); 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( wxListBox* list = new wxListBox(
this, ID_LISTBOX, this, ID_LISTBOX,
@@ -68,10 +68,10 @@ PlayerSelectionDialog::PlayerSelectionDialog(
list->Append(players[i]); 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_OK = new wxButton(this, wxID_OK, _T("OK"));
m_cancel = new wxButton(this, wxID_CANCEL, "Cancel"); m_cancel = new wxButton(this, wxID_CANCEL, _T("Cancel"));
wxLayoutConstraints* layout; wxLayoutConstraints* layout;
@@ -149,7 +149,7 @@ const wxString& PlayerSelectionDialog::GetPlayersName()
void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& event) void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& event)
{ {
m_player = ""; m_player = _T("");
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
} }
@@ -169,9 +169,9 @@ void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event)
wxString name = m_textField->GetValue(); wxString name = m_textField->GetValue();
if (!name.IsNull() && name.Length() > 0) 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 else
{ {
@@ -181,12 +181,12 @@ void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event)
} }
else else
{ {
wxMessageBox("Please enter your name", "Forty Thieves"); wxMessageBox(_T("Please enter your name"), _T("Forty Thieves"));
} }
} }
else else
{ {
m_player = ""; m_player = _T("");
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
} }
} }

View File

@@ -86,7 +86,7 @@ void ScoreCanvas::OnDraw(wxDC& dc)
{ {
dc.SetFont(* m_font); dc.SetFont(* m_font);
const char* str = m_text; const wxChar* str = m_text;
unsigned int tab = 0; unsigned int tab = 0;
unsigned int tabstops[] = { 5, 100, 150, 200 }; unsigned int tabstops[] = { 5, 100, 150, 200 };
@@ -94,29 +94,29 @@ void ScoreCanvas::OnDraw(wxDC& dc)
int lineSpacing; int lineSpacing;
{ {
long w, h; long w, h;
dc.GetTextExtent("Testing", &w, &h); dc.GetTextExtent(_T("Testing"), &w, &h);
lineSpacing = (int)h; lineSpacing = (int)h;
} }
int y = 0; int y = 0;
while (*str) while (*str)
{ {
char text[256]; wxChar text[256];
char* dest = text; wxChar* dest = text;
while (*str && *str >= ' ') *dest++ = *str++; while (*str && *str >= _T(' ')) *dest++ = *str++;
*dest = '\0'; *dest = _T('\0');
dc.DrawText(text, tabstops[tab], y); dc.DrawText(text, tabstops[tab], y);
if (*str == '\t') if (*str == _T('\t'))
{ {
if (tab < sizeof(tabstops) / sizeof(tabstops[0]) - 1) if (tab < sizeof(tabstops) / sizeof(tabstops[0]) - 1)
{ {
tab++; tab++;
} }
} }
else if (*str == '\n') else if (*str == _T('\n'))
{ {
tab = 0; tab = 0;
y += lineSpacing; y += lineSpacing;
@@ -133,7 +133,7 @@ ScoreDialog::ScoreDialog(
wxWindow* parent, wxWindow* parent,
ScoreFile* file ScoreFile* file
) : ) :
wxDialog(parent, -1, "Scores", wxDialog(parent, -1, _T("Scores"),
wxDefaultPosition, wxSize(310, 200), wxDefaultPosition, wxSize(310, 200),
wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE), wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
m_scoreFile(file) m_scoreFile(file)
@@ -142,7 +142,7 @@ ScoreDialog::ScoreDialog(
SetAutoLayout (TRUE); SetAutoLayout (TRUE);
ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile); 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; wxLayoutConstraints* layout;

View File

@@ -38,7 +38,7 @@
#include "scorefil.h" #include "scorefil.h"
ScoreFile::ScoreFile(const char* appName) ScoreFile::ScoreFile(const wxString& appName)
{ {
#if 0 #if 0
wxString filename; wxString filename;
@@ -68,7 +68,8 @@ ScoreFile::ScoreFile(const char* appName)
} }
#endif #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() ScoreFile::~ScoreFile()
@@ -84,7 +85,7 @@ ScoreFile::~ScoreFile()
void ScoreFile::GetPlayerList( wxArrayString &list ) void ScoreFile::GetPlayerList( wxArrayString &list )
{ {
m_config->SetPath("/Players"); m_config->SetPath(_T("/Players"));
int length = m_config->GetNumberOfGroups(); int length = m_config->GetNumberOfGroups();
if (length <= 0) return; if (length <= 0) return;
@@ -106,12 +107,14 @@ void ScoreFile::GetPlayerList( wxArrayString &list )
// Calculate an encrypted check number to prevent tampering with // Calculate an encrypted check number to prevent tampering with
// score file // 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; 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 >> 23) ^ check) & 0xFFFFFF;
} }
check = (check << 1) ^ (long)p1; 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 ScoreFile::GetPreviousPlayer() const
{ {
wxString result; wxString result;
m_config->SetPath("/General"); m_config->SetPath(_T("/General"));
m_config->Read("LastPlayer", &result); m_config->Read(_T("LastPlayer"), &result);
return result; return result;
} }
void ScoreFile::ReadPlayersScore( void ScoreFile::ReadPlayersScore(
const char* player, const wxString& player,
int& wins, int& wins,
int& games, int& games,
int& score) int& score)
@@ -142,16 +145,16 @@ void ScoreFile::ReadPlayersScore(
games = wins = score = 0; games = wins = score = 0;
m_config->SetPath("/Players"); m_config->SetPath(_T("/Players"));
m_config->SetPath(player); m_config->SetPath(player);
if (m_config->Read("Score", &myScore, 0L) && if (m_config->Read(_T("Score"), &myScore, 0L) &&
m_config->Read("Games", &myGames, 0L) && m_config->Read(_T("Games"), &myGames, 0L) &&
m_config->Read("Wins", &myWins, 0L) && m_config->Read(_T("Wins"), &myWins, 0L) &&
m_config->Read("Check", &check, 0L)) m_config->Read(_T("Check"), &check, 0L))
{ {
if (check != CalcCheck(player, myGames, myWins, myScore)) if (check != CalcCheck(player, myGames, myWins, myScore))
{ {
wxMessageBox("Score file corrupted", "Warning", wxMessageBox(_T("Score file corrupted"), _T("Warning"),
wxOK | wxICON_EXCLAMATION); wxOK | wxICON_EXCLAMATION);
} }
else 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) if (player)
{ {
m_config->SetPath("/General"); m_config->SetPath(_T("/General"));
m_config->Write("LastPlayer", wxString(player)); // Without wxString tmp, thinks it's bool in VC++ 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->SetPath(player);
m_config->Write("Score", (long)score); m_config->Write(_T("Score"), (long)score);
m_config->Write("Games", (long)games); m_config->Write(_T("Games"), (long)games);
m_config->Write("Wins", (long)wins); m_config->Write(_T("Wins"), (long)wins);
m_config->Write("Check", CalcCheck(player, games, wins, score)); m_config->Write(_T("Check"), CalcCheck(player, games, wins, score));
} }
} }

View File

@@ -24,17 +24,17 @@
class ScoreFile { class ScoreFile {
public: public:
ScoreFile(const char* appName); ScoreFile(const wxString& appName);
virtual ~ScoreFile(); virtual ~ScoreFile();
void GetPlayerList( wxArrayString &list ); void GetPlayerList( wxArrayString &list );
wxString GetPreviousPlayer() const; wxString GetPreviousPlayer() const;
void ReadPlayersScore(const char* player, int& wins, int& games, int &score); void ReadPlayersScore(const wxString& player, int& wins, int& games, int &score);
void WritePlayersScore(const char* player, int wins, int games, int score); void WritePlayersScore(const wxString& player, int wins, int games, int score);
private: 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; wxString m_configFilename;
wxConfig* m_config; wxConfig* m_config;
}; };

View File

@@ -90,13 +90,13 @@ DECLARE_EVENT_TABLE()
bool MyApp::OnInit() bool MyApp::OnInit()
{ {
// Create the main frame window // 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 // Make a menubar
wxMenu *file_menu = new wxMenu; wxMenu *file_menu = new wxMenu;
file_menu->Append(wxID_EXIT, "E&xit"); file_menu->Append(wxID_EXIT, _T("E&xit"));
menuBar = new wxMenuBar; menuBar = new wxMenuBar;
menuBar->Append(file_menu, "&File"); menuBar->Append(file_menu, _T("&File"));
frame->SetMenuBar(menuBar); frame->SetMenuBar(menuBar);
int width, height; int width, height;

View File

@@ -58,9 +58,18 @@ public:
m_name = name; m_name = name;
m_description = description; m_description = description;
m_rules = _(""); 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++) 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; wxString m_name;

View File

@@ -194,9 +194,9 @@ LifeFrame::LifeFrame() : wxFrame((wxFrame *)0, -1, _("Life!"), wxPoint(200, 200)
SetIcon(wxICON(mondrian)); SetIcon(wxICON(mondrian));
// menu bar // menu bar
wxMenu *menuFile = new wxMenu("", wxMENU_TEAROFF); wxMenu *menuFile = new wxMenu(_T(""), wxMENU_TEAROFF);
wxMenu *menuView = new wxMenu("", wxMENU_TEAROFF); wxMenu *menuView = new wxMenu(_T(""), wxMENU_TEAROFF);
wxMenu *menuGame = new wxMenu("", wxMENU_TEAROFF); wxMenu *menuGame = new wxMenu(_T(""), wxMENU_TEAROFF);
menuFile->Append(ID_NEW, _("&New"), _("Start a new game")); menuFile->Append(ID_NEW, _("&New"), _("Start a new game"));
menuFile->Append(ID_OPEN, _("&Open..."), _("Open an existing Life pattern")); menuFile->Append(ID_OPEN, _("&Open..."), _("Open an existing Life pattern"));

View File

@@ -206,7 +206,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y)
dc->SetFont(* NormalFont); dc->SetFont(* NormalFont);
long xx; long xx;
long yy; long yy;
dc->GetTextExtent("X", &xx, &yy); dc->GetTextExtent(_T("X"), &xx, &yy);
char_height = (int)yy; char_height = (int)yy;
if (current_page == 0) if (current_page == 0)
@@ -844,9 +844,11 @@ int GetIndex()
// Read preferences // Read preferences
void ReadPreferences() void ReadPreferences()
{ {
#if wxUSE_RESOURCES
wxGetResource("wxPoem", "FontSize", &pointSize); wxGetResource("wxPoem", "FontSize", &pointSize);
wxGetResource("wxPoem", "X", &XPos); wxGetResource("wxPoem", "X", &XPos);
wxGetResource("wxPoem", "Y", &YPos); wxGetResource("wxPoem", "Y", &YPos);
#endif
} }
// Write preferences to disk // Write preferences to disk
@@ -854,10 +856,12 @@ void WritePreferences()
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
TheMainWindow->GetPosition(&XPos, &YPos); TheMainWindow->GetPosition(&XPos, &YPos);
#if wxUSE_RESOURCES
wxWriteResource("wxPoem", "FontSize", pointSize); wxWriteResource("wxPoem", "FontSize", pointSize);
wxWriteResource("wxPoem", "X", XPos); wxWriteResource("wxPoem", "X", XPos);
wxWriteResource("wxPoem", "Y", YPos); wxWriteResource("wxPoem", "Y", YPos);
#endif #endif
#endif
} }
// Load a poem from given file, at given point in file. // Load a poem from given file, at given point in file.

View File

@@ -202,7 +202,7 @@ protected:
void DoSend() void DoSend()
{ {
m_out.WriteString(m_textIn->GetValue() + '\n'); m_out.WriteString(m_textIn->GetValue() + _T('\n'));
m_textIn->Clear(); m_textIn->Clear();
DoGet(); DoGet();