From cbf13e68a26ff3c78ea124e080484feb9fcdb520 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 25 Nov 2017 16:59:54 +0100 Subject: [PATCH 1/7] Replace deprecated std::auto_ptr with wxScopedPtr --- samples/sockets/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/sockets/client.cpp b/samples/sockets/client.cpp index b59736b2ed..ae392f1106 100644 --- a/samples/sockets/client.cpp +++ b/samples/sockets/client.cpp @@ -32,7 +32,7 @@ #include "wx/url.h" #include "wx/sstream.h" #include "wx/thread.h" -#include +#include "wx/scopedptr.h" // -------------------------------------------------------------------------- // resources @@ -594,7 +594,7 @@ void DoDownload(const wxString& urlname) // Try to get the input stream (connects to the given URL) wxLogMessage("Establishing connection to \"%s\"...", urlname); - const std::auto_ptr data(url.GetInputStream()); + const wxScopedPtr data(url.GetInputStream()); if ( !data.get() ) { wxLogError("Failed to retrieve URL \"%s\"", urlname); From 2156d298013e861349876038b553a41893e1d253 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 25 Nov 2017 17:04:11 +0100 Subject: [PATCH 2/7] Add FindOrCreateFont overload accepting wxFontInfo --- include/wx/font.h | 6 ++++++ interface/wx/font.h | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/include/wx/font.h b/include/wx/font.h index 354f458396..27935bac55 100644 --- a/include/wx/font.h +++ b/include/wx/font.h @@ -558,6 +558,12 @@ public: wxFontEncoding encoding = wxFONTENCODING_DEFAULT) { return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underline, face, encoding); } + + wxFont *FindOrCreateFont(const wxFontInfo& fontInfo) + { return FindOrCreateFont(fontInfo.GetPointSize(), fontInfo.GetFamily(), + fontInfo.GetStyle(), fontInfo.GetWeight(), + fontInfo.IsUnderlined(), fontInfo.GetFaceName(), + fontInfo.GetEncoding()); } }; extern WXDLLIMPEXP_DATA_CORE(wxFontList*) wxTheFontList; diff --git a/interface/wx/font.h b/interface/wx/font.h index e798a95d84..1fcb7ab4b3 100644 --- a/interface/wx/font.h +++ b/interface/wx/font.h @@ -1261,6 +1261,14 @@ public: wxFontWeight weight, bool underline = false, const wxString& facename = wxEmptyString, wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + + /** + Finds a font of the given specification, or creates one and adds it to the + list. See the @ref wxFont "wxFont constructor" for details of the arguments. + + @since 3.1.1 + */ + wxFont* FindOrCreateFont(const wxFontInfo& fontInfo); }; From dc6858d905f01ddecbb72d1d63e9bf4e59907478 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 25 Nov 2017 17:32:17 +0100 Subject: [PATCH 3/7] Fix wxPen and wxBrush style deprecation warnings in utils Fix a warning about hidden local variable in the helpview util. --- utils/emulator/src/emulator.cpp | 2 +- utils/helpview/src/helpview.cpp | 6 +++--- utils/screenshotgen/src/customcombo.cpp | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/utils/emulator/src/emulator.cpp b/utils/emulator/src/emulator.cpp index 1f6306ab53..d651e06da8 100644 --- a/utils/emulator/src/emulator.cpp +++ b/utils/emulator/src/emulator.cpp @@ -396,7 +396,7 @@ void wxEmulatorContainer::OnEraseBackground(wxEraseEvent& event) dc = new wxClientDC(this); } - dc->SetBackground(wxBrush(wxGetApp().m_emulatorInfo.m_emulatorBackgroundColour, wxSOLID)); + dc->SetBackground(wxBrush(wxGetApp().m_emulatorInfo.m_emulatorBackgroundColour)); dc->Clear(); if (!event.GetDC()) diff --git a/utils/helpview/src/helpview.cpp b/utils/helpview/src/helpview.cpp index 8ad412e589..583a33706b 100644 --- a/utils/helpview/src/helpview.cpp +++ b/utils/helpview/src/helpview.cpp @@ -119,15 +119,15 @@ bool hvApp::OnInit() } else if ( argStr.Find( wxT("--Style") ) >= 0 ) { - long i; + long style; wxString numb = argStr.AfterLast(wxT('e')); - if ( !(numb.ToLong(&i) ) ) + if ( !(numb.ToLong(&style) ) ) { wxLogError( wxT("Integer conversion failed for --Style") ); } else { - istyle = i; + istyle = style; } } else diff --git a/utils/screenshotgen/src/customcombo.cpp b/utils/screenshotgen/src/customcombo.cpp index 6d133d02b0..4e1b35fce9 100644 --- a/utils/screenshotgen/src/customcombo.cpp +++ b/utils/screenshotgen/src/customcombo.cpp @@ -58,29 +58,29 @@ void PenStyleComboBox::OnDrawItem( wxDC& dc, r.Deflate(3); r.height -= 2; - int penStyle = wxSOLID; + wxPenStyle penStyle = wxPENSTYLE_SOLID; // if ( item == 1 ) -// penStyle = wxTRANSPARENT; +// penStyle = wxPENSTYLE_TRANSPARENT; // else if ( item == 2 ) -// penStyle = wxDOT; +// penStyle = wxPENSTYLE_DOT; // else if ( item == 3 ) -// penStyle = wxLONG_DASH; +// penStyle = wxPENSTYLE_LONG_DASH; // else if ( item == 4 ) -// penStyle = wxSHORT_DASH; +// penStyle = wxPENSTYLE_SHORT_DASH; if ( item == 0 ) - penStyle = wxDOT_DASH; + penStyle = wxPENSTYLE_DOT_DASH; else if ( item == 1 ) - penStyle = wxBDIAGONAL_HATCH; + penStyle = wxPENSTYLE_BDIAGONAL_HATCH; else if ( item == 2 ) - penStyle = wxCROSSDIAG_HATCH; + penStyle = wxPENSTYLE_CROSSDIAG_HATCH; // else if ( item == 8 ) -// penStyle = wxFDIAGONAL_HATCH; +// penStyle = wxPENSTYLE_FDIAGONAL_HATCH; // else if ( item == 9 ) -// penStyle = wxCROSS_HATCH; +// penStyle = wxPENSTYLE_CROSS_HATCH; // else if ( item == 10 ) -// penStyle = wxHORIZONTAL_HATCH; +// penStyle = wxPENSTYLE_HORIZONTAL_HATCH; // else if ( item == 11 ) -// penStyle = wxVERTICAL_HATCH; +// penStyle = wxPENSTYLE_VERTICAL_HATCH; wxPen pen( dc.GetTextForeground(), 3, penStyle ); From 4d8fad3d8042acbdd4ef2b376ac5e60fde6dc6ad Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 25 Nov 2017 17:39:44 +0100 Subject: [PATCH 4/7] 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. --- demos/bombs/bombs.cpp | 3 +-- demos/bombs/bombs.h | 2 +- demos/bombs/bombs1.cpp | 21 ++++++--------------- demos/forty/canvas.cpp | 4 ++-- demos/forty/card.cpp | 15 ++++++++++----- demos/forty/forty.cpp | 2 +- demos/forty/game.cpp | 2 +- demos/forty/scoredg.cpp | 6 +++--- demos/fractal/fractal.cpp | 8 ++++---- demos/fractal/fractal.rc | 2 -- demos/fractal/mondrian.ico | Bin 766 -> 0 bytes demos/poem/wxpoem.cpp | 6 +++--- 12 files changed, 32 insertions(+), 39 deletions(-) delete mode 100644 demos/fractal/mondrian.ico diff --git a/demos/bombs/bombs.cpp b/demos/bombs/bombs.cpp index 58671c7c06..0a903d88f9 100644 --- a/demos/bombs/bombs.cpp +++ b/demos/bombs/bombs.cpp @@ -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"); diff --git a/demos/bombs/bombs.h b/demos/bombs/bombs.h index f3d4f77c76..a5000eb984 100644 --- a/demos/bombs/bombs.h +++ b/demos/bombs/bombs.h @@ -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_ diff --git a/demos/bombs/bombs1.cpp b/demos/bombs/bombs1.cpp index 59e67c8118..2cb950c025 100644 --- a/demos/bombs/bombs1.cpp +++ b/demos/bombs/bombs1.cpp @@ -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); diff --git a/demos/forty/canvas.cpp b/demos/forty/canvas.cpp index 066e94c529..5698cc1a5e 100644 --- a/demos/forty/canvas.cpp +++ b/demos/forty/canvas.cpp @@ -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()); diff --git a/demos/forty/card.cpp b/demos/forty/card.cpp index c82ef33388..316c49361b 100644 --- a/demos/forty/card.cpp +++ b/demos/forty/card.cpp @@ -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); diff --git a/demos/forty/forty.cpp b/demos/forty/forty.cpp index 4960a34652..7a2d35ab2b 100644 --- a/demos/forty/forty.cpp +++ b/demos/forty/forty.cpp @@ -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; diff --git a/demos/forty/game.cpp b/demos/forty/game.cpp index 4b137d8316..894077e8b7 100644 --- a/demos/forty/game.cpp +++ b/demos/forty/game.cpp @@ -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()); diff --git a/demos/forty/scoredg.cpp b/demos/forty/scoredg.cpp index 32ed7a766d..60533afbe8 100644 --- a/demos/forty/scoredg.cpp +++ b/demos/forty/scoredg.cpp @@ -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; } diff --git a/demos/fractal/fractal.cpp b/demos/fractal/fractal.cpp index 28c232c93b..23e2a6f7d6 100644 --- a/demos/fractal/fractal.cpp +++ b/demos/fractal/fractal.cpp @@ -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)) diff --git a/demos/fractal/fractal.rc b/demos/fractal/fractal.rc index e3b11b0116..82bdf07561 100644 --- a/demos/fractal/fractal.rc +++ b/demos/fractal/fractal.rc @@ -1,4 +1,2 @@ -wxSTD_FRAME ICON "mondrian.ico" - #include "wx/msw/wx.rc" diff --git a/demos/fractal/mondrian.ico b/demos/fractal/mondrian.ico deleted file mode 100644 index 2310c5d275a87af295d5ea8dc79ea417a5e74c53..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmZQzU<5)11px*Sc)`TLAO@s0fLH;D9e|jTfdxnc0ZFindOrCreateFont(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) From 6315ae04fb50918bb067f14e49dc78994425a00a Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 25 Nov 2017 17:46:04 +0100 Subject: [PATCH 5/7] Fix reading poems from file in wxPoem demo When using ftell to get the position in the file, it should be opened in binary mode. Regenerate the poem index file with the correct start positions. Use the wxICON macro for creating the icon, so .ico is used on Windows. --- demos/poem/wxpoem.cpp | 8 +- demos/poem/wxpoem.idx | 268 +++++++++++++++++++++--------------------- demos/poem/wxpoem.rc | 2 +- 3 files changed, 139 insertions(+), 139 deletions(-) diff --git a/demos/poem/wxpoem.cpp b/demos/poem/wxpoem.cpp index c74351df1f..cfca656f6e 100644 --- a/demos/poem/wxpoem.cpp +++ b/demos/poem/wxpoem.cpp @@ -119,7 +119,7 @@ MainWindow::MainWindow(wxFrame *frame, wxWindowID id, const wxString& title, ReadPreferences(); CreateFonts(); - SetIcon(wxpoem_xpm); + SetIcon(wxICON(wxpoem)); m_corners[0] = new wxIcon( corner1_xpm ); m_corners[1] = new wxIcon( corner2_xpm ); @@ -788,7 +788,7 @@ bool LoadPoem(const wxChar *file_name, long position) } wxSprintf(buf, wxT("%s.dat"), file_name); - data_file = wxFopen(buf, wxT("r")); + data_file = wxFopen(buf, wxT("rb")); if (data_file == NULL) { @@ -862,7 +862,7 @@ long MainWindow::DoSearch(void) if (data_filename) wxSprintf(buf, wxT("%s.dat"), data_filename); - file = wxFopen(buf, wxT("r")); + file = wxFopen(buf, wxT("rb")); if (! (data_filename && file)) { wxSprintf(error_buf, wxT("Poetry data file %s not found\n"), buf); @@ -948,7 +948,7 @@ bool Compile(void) if (data_filename) wxSprintf(buf, wxT("%s.dat"), data_filename); - file = wxFopen(buf, wxT("r")); + file = wxFopen(buf, wxT("rb")); if (! (data_filename && file)) { wxSprintf(error_buf, wxT("Poetry data file %s not found\n"), buf); diff --git a/demos/poem/wxpoem.idx b/demos/poem/wxpoem.idx index d31ae1002f..0004670168 100644 --- a/demos/poem/wxpoem.idx +++ b/demos/poem/wxpoem.idx @@ -1,137 +1,137 @@ 135 0 -448 -706 -886 -1046 -1354 -1754 -2127 -2806 -3376 -3992 -4381 -4620 -5195 -5918 -6165 -6801 -7497 -8216 -8687 -9145 -9398 -10065 -10397 -10631 -10881 -11290 -11589 -11981 -12126 -12807 -13441 -14112 -14568 -15238 -15927 -16617 -17092 -17415 -18121 -18775 -19327 -19870 -20557 -21198 -21657 -22441 -22949 -23526 -23701 -23954 -24362 -24535 -24743 -24921 -27139 -27335 -27576 -28162 -28342 -28766 -28935 -29132 -29339 -29543 -29765 -29989 -30422 -31079 -31624 -32028 -32667 -34127 -34595 -34937 -35071 -35295 -35482 -35745 -36172 -36665 -37076 -37225 -37812 -38323 -38810 -40525 -40914 -41585 -42287 -44104 -45220 -46627 -47212 -47952 -48559 -49044 -49535 -50201 -51482 -52736 -53914 -54701 -55477 -55990 -56254 -56527 -57020 -57428 -57625 -58263 -59074 -59747 -60702 -61439 -62934 -63483 -63698 -64019 -64311 -64531 -64687 -65222 -65419 -66021 -66876 -67342 -67664 -68721 -69524 -70788 -71483 -72201 -72922 -73604 +432 +678 +849 +1000 +1289 +1676 +2036 +2695 +3247 +3839 +4214 +4444 +5002 +5705 +5943 +6559 +7236 +7935 +8387 +8826 +9065 +9712 +10030 +10251 +10488 +10879 +11165 +11541 +11679 +12341 +12952 +13601 +14037 +14685 +15355 +16023 +16480 +16789 +17472 +18104 +18634 +19160 +19828 +20450 +20892 +21651 +22144 +22697 +22863 +23105 +23495 +23659 +23858 +24027 +26188 +26375 +26605 +27170 +27341 +27752 +27912 +28100 +28298 +28493 +28705 +28919 +29336 +29969 +30491 +30876 +31495 +32918 +33373 +33703 +33830 +34045 +34223 +34477 +34889 +35367 +35760 +35898 +36461 +36950 +37417 +39079 +39455 +40104 +40787 +42555 +43641 +45010 +45571 +46287 +46870 +47331 +47808 +48457 +49704 +50924 +52070 +52830 +53582 +54076 +54328 +54590 +55064 +55453 +55643 +56256 +57048 +57698 +58621 +59337 +60780 +61314 +61518 +61825 +62104 +62315 +62462 +62980 +63167 +63748 +64581 +65034 +65343 +66368 +67140 +68358 +69033 +69732 +70434 +71096 diff --git a/demos/poem/wxpoem.rc b/demos/poem/wxpoem.rc index 98bfc4ed7c..00ea0842a2 100644 --- a/demos/poem/wxpoem.rc +++ b/demos/poem/wxpoem.rc @@ -1,4 +1,4 @@ -aaaa ICON "wxpoem.ico" +wxpoem ICON "wxpoem.ico" #include "wx/msw/wx.rc" From afc02a34ee0e6589d1a2e825f6ebe7044a03752c Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 25 Nov 2017 17:48:37 +0100 Subject: [PATCH 6/7] More use of wxFALLTHROUGH in MSW code and samples --- samples/listctrl/listtest.cpp | 3 ++- src/generic/datavgen.cpp | 1 + src/generic/vlbox.cpp | 1 + src/msw/combobox.cpp | 1 + src/msw/fontutil.cpp | 1 + src/msw/spinctrl.cpp | 1 + src/msw/treectrl.cpp | 1 + src/msw/utils.cpp | 1 + src/msw/utilsexc.cpp | 3 ++- src/msw/window.cpp | 15 +++++++++++++++ src/ribbon/art_msw.cpp | 1 + 11 files changed, 27 insertions(+), 2 deletions(-) diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index de6056068e..6eb4eb4544 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -1344,8 +1344,9 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event) { InsertItemInReportView(event.GetIndex()); } + break; } - //else: fall through + wxFALLTHROUGH; default: LogEvent(event, wxT("OnListKeyDown")); diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 1ba46abea9..b143a705e7 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3932,6 +3932,7 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event ) break; } // else: fall through to WXK_F2 handling + wxFALLTHROUGH; } case WXK_F2: diff --git a/src/generic/vlbox.cpp b/src/generic/vlbox.cpp index 60c524dbd2..9efeccdaf7 100644 --- a/src/generic/vlbox.cpp +++ b/src/generic/vlbox.cpp @@ -664,6 +664,7 @@ void wxVListBox::OnKeyDown(wxKeyEvent& event) // events for the tabs on MSW HandleAsNavigationKey(event); // fall through to default + wxFALLTHROUGH; #endif default: event.Skip(); diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 9e88873b5e..8361c354c8 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -329,6 +329,7 @@ bool wxComboBox::MSWCommand(WXUINT param, WXWORD id) // fall through: for compatibility with wxGTK, also send the text // update event when the selection changes (this also seems more // logical as the text does change) + wxFALLTHROUGH; case CBN_EDITCHANGE: if ( m_allowTextEvents ) diff --git a/src/msw/fontutil.cpp b/src/msw/fontutil.cpp index faae55ff18..3a6489b392 100644 --- a/src/msw/fontutil.cpp +++ b/src/msw/fontutil.cpp @@ -182,6 +182,7 @@ wxFontEncoding wxGetFontEncFromCharSet(int cs) default: wxFAIL_MSG( wxT("unexpected Win32 charset") ); // fall through and assume the system charset + wxFALLTHROUGH; case DEFAULT_CHARSET: fontEncoding = wxFONTENCODING_SYSTEM; diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 1b47c3e428..b51c10a605 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -95,6 +95,7 @@ wxBuddyTextWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if ( (WXHWND)wParam == spin->GetHWND() ) break; //else: fall through + wxFALLTHROUGH; case WM_KILLFOCUS: case WM_CHAR: diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index db3f171292..1082912d9b 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -460,6 +460,7 @@ public: if ( image != -1 ) break; //else: fall through + wxFALLTHROUGH; case wxTreeItemIcon_Selected: case wxTreeItemIcon_Expanded: diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 29a3968e94..90708c2b04 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -1090,6 +1090,7 @@ wxString wxGetOsDescription() break; } //else: must be XP, fall through + wxFALLTHROUGH; case 1: str = "Windows XP"; diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index 6eef84bbd1..60841d8edd 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -988,10 +988,11 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler, { default: wxFAIL_MSG( wxT("unexpected WaitForInputIdle() return code") ); - // fall through + wxFALLTHROUGH; case WAIT_FAILED: wxLogLastError(wxT("WaitForInputIdle() in wxExecute")); + wxFALLTHROUGH; case WAIT_TIMEOUT: wxLogDebug(wxT("Timeout too small in WaitForInputIdle")); diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 68f0fedcc4..dedfc8a303 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -5075,8 +5075,10 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h), WXUINT wParam) default: wxFAIL_MSG( wxT("unexpected WM_SIZE parameter") ); // fall through nevertheless + wxFALLTHROUGH; case SIZE_MAXHIDE: + wxFALLTHROUGH; case SIZE_MAXSHOW: // we're not interested in these messages at all break; @@ -5088,6 +5090,7 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h), WXUINT wParam) case SIZE_MAXIMIZED: /* processed = */ HandleMaximize(); // fall through to send a normal size event as well + wxFALLTHROUGH; case SIZE_RESTORED: // don't use w and h parameters as they specify the client size @@ -5097,6 +5100,7 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h), WXUINT wParam) event.SetEventObject(this); processed = HandleWindowEvent(event); + break; } return processed; @@ -6195,60 +6199,70 @@ WXWORD WXToVK(int wxk, bool *isExtended) { case WXK_PAGEUP: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_PAGEUP: vk = VK_PRIOR; break; case WXK_PAGEDOWN: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_PAGEDOWN: vk = VK_NEXT; break; case WXK_END: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_END: vk = VK_END; break; case WXK_HOME: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_HOME: vk = VK_HOME; break; case WXK_LEFT: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_LEFT: vk = VK_LEFT; break; case WXK_UP: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_UP: vk = VK_UP; break; case WXK_RIGHT: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_RIGHT: vk = VK_RIGHT; break; case WXK_DOWN: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_DOWN: vk = VK_DOWN; break; case WXK_INSERT: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_INSERT: vk = VK_INSERT; break; case WXK_DELETE: extended = true; + wxFALLTHROUGH; case WXK_NUMPAD_DELETE: vk = VK_DELETE; break; @@ -6264,6 +6278,7 @@ WXWORD WXToVK(int wxk, bool *isExtended) { vk = (WXWORD)wxk; } + break; } if ( isExtended ) diff --git a/src/ribbon/art_msw.cpp b/src/ribbon/art_msw.cpp index 87e651650f..2baddeef67 100644 --- a/src/ribbon/art_msw.cpp +++ b/src/ribbon/art_msw.cpp @@ -1628,6 +1628,7 @@ void wxRibbonMSWArtProvider::DrawScrollButton( { case wxRIBBON_SCROLL_BTN_LEFT: rect.x++; + wxFALLTHROUGH; case wxRIBBON_SCROLL_BTN_RIGHT: rect.y--; rect.width--; From a96171def42dafc63a5f877c951bb9b6949b09ed Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 25 Nov 2017 17:50:08 +0100 Subject: [PATCH 7/7] Fix unused variable and parameter warnings in samples These variables are only used in debug builds, causing warnings in release builds. --- samples/aui/auidemo.cpp | 1 + samples/propgrid/propgrid.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/samples/aui/auidemo.cpp b/samples/aui/auidemo.cpp index 7e85086561..f165a1e22b 100644 --- a/samples/aui/auidemo.cpp +++ b/samples/aui/auidemo.cpp @@ -1375,6 +1375,7 @@ void MyFrame::OnNotebookPageClose(wxAuiNotebookEvent& evt) void MyFrame::OnNotebookPageClosed(wxAuiNotebookEvent& evt) { wxAuiNotebook* ctrl = (wxAuiNotebook*)evt.GetEventObject(); + wxUnusedVar(ctrl); // selection should always be a valid index wxASSERT_MSG( ctrl->GetSelection() < (int)ctrl->GetPageCount(), diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index aaa72e8716..2496138fac 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -912,6 +912,7 @@ void FormMain::OnPropertyGridColDragging( wxPropertyGridEvent& event ) void FormMain::OnPropertyGridColEndDrag( wxPropertyGridEvent& event ) { + wxUnusedVar(event); wxLogDebug(wxT("Splitter %i resize ended"), event.GetColumn()); } @@ -1788,6 +1789,7 @@ wxEND_EVENT_TABLE() void wxMyPropertyGridPage::OnPropertySelect( wxPropertyGridEvent& event ) { wxPGProperty* p = event.GetProperty(); + wxUnusedVar(p); wxLogDebug(wxT("wxMyPropertyGridPage::OnPropertySelect('%s' is %s"), p->GetName().c_str(), IsPropertySelected(p)? wxT("selected"): wxT("unselected"));