Fix warnings and modernize demo code
Fix wxFont, wxPen and wxBrush style deprecation warnings. Add wxFALLTHROUGH to resolve implicit fallthrough warnings in switch statements. Fix build error when using long for GetTextExtent (with wxUSE_GRID 0). Remove unused icon from fractal demo.
This commit is contained in:
@@ -218,8 +218,7 @@ BombsCanvas::BombsCanvas(wxFrame *parent, BombsGame *game)
|
||||
m_game = game;
|
||||
int sx, sy;
|
||||
wxClientDC dc(this);
|
||||
wxFont font= BOMBS_FONT;
|
||||
dc.SetFont(font);
|
||||
dc.SetFont(BOMBS_FONT);
|
||||
|
||||
wxCoord chw, chh;
|
||||
wxString buf = wxT("M");
|
||||
|
@@ -118,7 +118,7 @@ private:
|
||||
* BombsCanvas::x_cell and y_cell
|
||||
*/
|
||||
|
||||
#define BOMBS_FONT wxFont(14, wxROMAN, wxNORMAL, wxNORMAL)
|
||||
#define BOMBS_FONT wxFont(wxFontInfo(14).Family(wxFONTFAMILY_ROMAN))
|
||||
|
||||
#endif // #ifndef _WX_DEMOS_BOMBS_BOMBS_H_
|
||||
|
||||
|
@@ -33,14 +33,6 @@ void BombsCanvas::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
|
||||
wxString buf;
|
||||
wxCoord chw, chh;
|
||||
|
||||
wxColour wxYellow = wxTheColourDatabase->Find(wxT("YELLOW"));
|
||||
wxColour wxFocused = wxTheColourDatabase->Find(wxT("GREY"));
|
||||
|
||||
wxPen *bluePen = wxThePenList->FindOrCreatePen(*wxBLUE, 1, wxSOLID);
|
||||
|
||||
wxBrush *focusedBrush = wxTheBrushList->FindOrCreateBrush(wxFocused, wxSOLID);
|
||||
wxBrush *yellowBrush = wxTheBrushList->FindOrCreateBrush(wxYellow, wxSOLID);
|
||||
|
||||
dc->SetPen(*wxBLACK_PEN);
|
||||
|
||||
int x, y;
|
||||
@@ -52,8 +44,7 @@ void BombsCanvas::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
|
||||
dc->DrawLine(0, y*m_cellHeight*Y_UNIT, xMax, y*m_cellHeight*Y_UNIT);
|
||||
|
||||
|
||||
wxFont font= BOMBS_FONT;
|
||||
dc->SetFont(font);
|
||||
dc->SetFont(BOMBS_FONT);
|
||||
|
||||
for(x=xc1; x<=xc2; x++)
|
||||
for(y=yc1; y<=yc2; y++)
|
||||
@@ -63,7 +54,7 @@ void BombsCanvas::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
|
||||
dc->SetPen(*wxBLACK_PEN);
|
||||
|
||||
if (m_game->IsFocussed(x, y))
|
||||
dc->SetBrush(*focusedBrush);
|
||||
dc->SetBrush(*wxMEDIUM_GREY_BRUSH);
|
||||
else
|
||||
dc->SetBrush(*wxLIGHT_GREY_BRUSH);
|
||||
|
||||
@@ -94,7 +85,7 @@ void BombsCanvas::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
|
||||
{
|
||||
dc->SetPen(*wxBLACK_PEN);
|
||||
if (m_game->IsFocussed(x, y))
|
||||
dc->SetBrush(*focusedBrush);
|
||||
dc->SetBrush(*wxMEDIUM_GREY_BRUSH);
|
||||
else
|
||||
dc->SetBrush(*wxLIGHT_GREY_BRUSH);
|
||||
|
||||
@@ -116,7 +107,7 @@ void BombsCanvas::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
|
||||
y*m_cellHeight*Y_UNIT + (m_cellHeight*Y_UNIT-chh)/2);
|
||||
if (m_game->IsExploded(x,y))
|
||||
{
|
||||
dc->SetPen(*bluePen);
|
||||
dc->SetPen(*wxBLUE_PEN);
|
||||
dc->DrawLine(x*m_cellWidth*X_UNIT, y*m_cellHeight*Y_UNIT,
|
||||
(x+1)*m_cellWidth*X_UNIT, (y+1)*m_cellHeight*Y_UNIT);
|
||||
dc->DrawLine(x*m_cellWidth*X_UNIT, (y+1)*m_cellHeight*Y_UNIT,
|
||||
@@ -127,11 +118,11 @@ void BombsCanvas::DrawField(wxDC *dc, int xc1, int yc1, int xc2, int yc2)
|
||||
{
|
||||
dc->SetPen(*wxBLACK_PEN);
|
||||
if (m_game->IsFocussed(x, y))
|
||||
dc->SetBrush(*focusedBrush);
|
||||
dc->SetBrush(*wxMEDIUM_GREY_BRUSH);
|
||||
else if (m_game->IsSelected(x,y))
|
||||
dc->SetBrush(*wxWHITE_BRUSH);
|
||||
else
|
||||
dc->SetBrush(*yellowBrush);
|
||||
dc->SetBrush(*wxYELLOW_BRUSH);
|
||||
dc->DrawRectangle( x*m_cellWidth*X_UNIT, y*m_cellHeight*Y_UNIT,
|
||||
m_cellWidth*X_UNIT+1, m_cellHeight*Y_UNIT+1);
|
||||
|
||||
|
@@ -42,9 +42,9 @@ FortyCanvas::FortyCanvas(wxWindow* parent, const wxPoint& pos, const wxSize& siz
|
||||
SetScrollbars(0, 0, 0, 0);
|
||||
|
||||
#ifdef __WXGTK__
|
||||
m_font = wxTheFontList->FindOrCreateFont(12, wxROMAN, wxNORMAL, wxNORMAL);
|
||||
m_font = wxTheFontList->FindOrCreateFont(wxFontInfo(12).Family(wxFONTFAMILY_ROMAN));
|
||||
#else
|
||||
m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
m_font = wxTheFontList->FindOrCreateFont(wxFontInfo(10).Family(wxFONTFAMILY_SWISS));
|
||||
#endif
|
||||
SetBackgroundColour(FortyApp::BackgroundColour());
|
||||
|
||||
|
@@ -127,9 +127,7 @@ void Card::SetScale(double scale)
|
||||
void Card::Erase(wxDC& dc, int x, int y)
|
||||
{
|
||||
wxPen* pen = wxThePenList->FindOrCreatePen(
|
||||
FortyApp::BackgroundColour(),
|
||||
1,
|
||||
wxSOLID
|
||||
FortyApp::BackgroundColour()
|
||||
);
|
||||
dc.SetPen(* pen);
|
||||
dc.SetBrush(FortyApp::BackgroundBrush());
|
||||
@@ -169,7 +167,7 @@ void Card::Draw(wxDC& dc, int x, int y)
|
||||
dc.SetBackground(* wxRED_BRUSH);
|
||||
dc.SetBackgroundMode(wxSOLID);
|
||||
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(
|
||||
*wxBLACK, wxCROSSDIAG_HATCH
|
||||
*wxBLACK, wxBRUSHSTYLE_CROSSDIAG_HATCH
|
||||
);
|
||||
dc.SetBrush(* brush);
|
||||
|
||||
@@ -283,6 +281,7 @@ void Card::Draw(wxDC& dc, int x, int y)
|
||||
symsize * m_suit,
|
||||
sympos,
|
||||
wxCOPY);
|
||||
wxFALLTHROUGH;
|
||||
case 2:
|
||||
dc.Blit((wxCoord)(x - symdist + m_width / 2),
|
||||
(wxCoord)(y - symdist + m_height / 4),
|
||||
@@ -311,6 +310,7 @@ void Card::Draw(wxDC& dc, int x, int y)
|
||||
symsize * m_suit,
|
||||
sympos,
|
||||
wxCOPY);
|
||||
wxFALLTHROUGH;
|
||||
case 4:
|
||||
dc.Blit((wxCoord)(x - symdist + m_width / 4),
|
||||
(wxCoord)(y - symdist + m_height / 4),
|
||||
@@ -355,6 +355,7 @@ void Card::Draw(wxDC& dc, int x, int y)
|
||||
symsize * m_suit,
|
||||
sympos2,
|
||||
wxCOPY);
|
||||
wxFALLTHROUGH;
|
||||
case 7:
|
||||
dc.Blit((wxCoord)(x - symdist + 5 * m_width / 10),
|
||||
(wxCoord)(y - symdist + 3 * m_height / 8),
|
||||
@@ -364,6 +365,7 @@ void Card::Draw(wxDC& dc, int x, int y)
|
||||
symsize * m_suit,
|
||||
sympos,
|
||||
wxCOPY);
|
||||
wxFALLTHROUGH;
|
||||
case 6:
|
||||
dc.Blit((wxCoord)(x - symdist + m_width / 4),
|
||||
(wxCoord)(y - symdist + m_height / 4),
|
||||
@@ -421,6 +423,7 @@ void Card::Draw(wxDC& dc, int x, int y)
|
||||
symsize * m_suit,
|
||||
sympos2,
|
||||
wxCOPY);
|
||||
wxFALLTHROUGH;
|
||||
case 9:
|
||||
dc.Blit((wxCoord)(x - symdist + m_width / 4),
|
||||
(wxCoord)(y - symdist2 + m_height / 4),
|
||||
@@ -497,7 +500,9 @@ void Card::Draw(wxDC& dc, int x, int y)
|
||||
wxCOPY);
|
||||
break;
|
||||
case 11:
|
||||
wxFALLTHROUGH;
|
||||
case 12:
|
||||
wxFALLTHROUGH;
|
||||
case 13:
|
||||
memoryDC.SelectObject(*m_pictureBmap);
|
||||
int picwidth = 40,picheight = 45;
|
||||
@@ -544,7 +549,7 @@ void Card::Draw(wxDC& dc, int x, int y)
|
||||
//+-------------------------------------------------------------+
|
||||
void Card::DrawNullCard(wxDC& dc, int x, int y)
|
||||
{
|
||||
wxPen* pen = wxThePenList->FindOrCreatePen(FortyApp::TextColour(), 1, wxSOLID);
|
||||
wxPen* pen = wxThePenList->FindOrCreatePen(FortyApp::TextColour());
|
||||
dc.SetBrush(FortyApp::BackgroundBrush());
|
||||
dc.SetPen(*pen);
|
||||
dc.DrawRoundedRectangle(x, y, m_width, m_height, 4);
|
||||
|
@@ -112,7 +112,7 @@ const wxBrush& FortyApp::BackgroundBrush()
|
||||
{
|
||||
if (!m_backgroundBrush)
|
||||
{
|
||||
m_backgroundBrush = new wxBrush(BackgroundColour(), wxSOLID);
|
||||
m_backgroundBrush = new wxBrush(BackgroundColour());
|
||||
}
|
||||
|
||||
return *m_backgroundBrush;
|
||||
|
@@ -215,7 +215,7 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
|
||||
void Game::DisplayScore(wxDC& dc)
|
||||
{
|
||||
wxColour bgColour = FortyApp::BackgroundColour();
|
||||
wxPen* pen = wxThePenList->FindOrCreatePen(bgColour, 1, wxSOLID);
|
||||
wxPen* pen = wxThePenList->FindOrCreatePen(bgColour);
|
||||
dc.SetTextBackground(bgColour);
|
||||
dc.SetTextForeground(FortyApp::TextColour());
|
||||
dc.SetBrush(FortyApp::BackgroundBrush());
|
||||
|
@@ -47,9 +47,9 @@ ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint&
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
#ifdef __WXGTK__
|
||||
m_font = wxTheFontList->FindOrCreateFont(12, wxROMAN, wxNORMAL, wxNORMAL);
|
||||
m_font = wxTheFontList->FindOrCreateFont(wxFontInfo(12).Family(wxFONTFAMILY_ROMAN));
|
||||
#else
|
||||
m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
m_font = wxTheFontList->FindOrCreateFont(wxFontInfo(10).Family(wxFONTFAMILY_SWISS));
|
||||
#endif
|
||||
|
||||
wxArrayString players;
|
||||
@@ -92,7 +92,7 @@ void ScoreCanvas::OnDraw(wxDC& dc)
|
||||
// get the line spacing for the current font
|
||||
int lineSpacing;
|
||||
{
|
||||
long w, h;
|
||||
wxCoord w, h;
|
||||
dc.GetTextExtent(wxT("Testing"), &w, &h);
|
||||
lineSpacing = (int)h;
|
||||
}
|
||||
|
@@ -149,16 +149,16 @@ MyCanvas::MyCanvas(wxFrame *frame):
|
||||
wxWindow(frame, wxID_ANY)
|
||||
{
|
||||
wxColour wxCol1(255,255,255);
|
||||
SnowPen = wxPen(wxCol1, 2, wxSOLID);
|
||||
SnowPen = wxPen(wxCol1, 2);
|
||||
|
||||
wxColour wxCol2(128,0,0);
|
||||
MtnPen = wxPen(wxCol2, 1, wxSOLID);
|
||||
MtnPen = wxPen(wxCol2);
|
||||
|
||||
wxColour wxCol3(0,128,0);
|
||||
GreenPen = wxPen(wxCol3, 1, wxSOLID);
|
||||
GreenPen = wxPen(wxCol3);
|
||||
|
||||
wxColour wxCol4(0,0,128);
|
||||
WaterBrush = wxBrush(wxCol4, wxSOLID);
|
||||
WaterBrush = wxBrush(wxCol4);
|
||||
}
|
||||
|
||||
void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||
|
@@ -1,4 +1,2 @@
|
||||
wxSTD_FRAME ICON "mondrian.ico"
|
||||
|
||||
#include "wx/msw/wx.rc"
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 766 B |
@@ -99,9 +99,9 @@ MainWindow *TheMainWindow = NULL;
|
||||
// Create the fonts
|
||||
void MainWindow::CreateFonts()
|
||||
{
|
||||
m_normalFont = wxTheFontList->FindOrCreateFont(pointSize, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
m_boldFont = wxTheFontList->FindOrCreateFont(pointSize, wxSWISS, wxNORMAL, wxBOLD);
|
||||
m_italicFont = wxTheFontList->FindOrCreateFont(pointSize, wxSWISS, wxITALIC, wxNORMAL);
|
||||
m_normalFont = wxTheFontList->FindOrCreateFont(wxFontInfo(pointSize).Family(wxFONTFAMILY_SWISS));
|
||||
m_boldFont = wxTheFontList->FindOrCreateFont(wxFontInfo(pointSize).Family(wxFONTFAMILY_SWISS).Bold());
|
||||
m_italicFont = wxTheFontList->FindOrCreateFont(wxFontInfo(pointSize).Family(wxFONTFAMILY_SWISS).Italic());
|
||||
}
|
||||
|
||||
wxBEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
||||
|
Reference in New Issue
Block a user