From 2cc44337c69e64c67c65b33cf98ce58e933ef6df Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Sep 2018 15:29:42 +0200 Subject: [PATCH] Use only wxFont ctor from wxFontInfo in the samples Follow the documentation advice and prefer to use the ctor taking wxFontInfo as it makes the code slightly shorter and more readable. --- samples/caret/caret.cpp | 3 +-- samples/drawing/drawing.cpp | 2 +- samples/exec/exec.cpp | 3 +-- samples/fswatcher/fswatcher.cpp | 3 +-- samples/keyboard/keyboard.cpp | 3 +-- samples/opengl/pyramid/pyramid.cpp | 2 +- samples/ribbon/ribbondemo.cpp | 2 +- samples/splash/splash.cpp | 2 +- samples/thread/thread.cpp | 3 +-- 9 files changed, 9 insertions(+), 14 deletions(-) diff --git a/samples/caret/caret.cpp b/samples/caret/caret.cpp index f44f5c5392..f4332fe901 100644 --- a/samples/caret/caret.cpp +++ b/samples/caret/caret.cpp @@ -337,8 +337,7 @@ void MyCanvas::CreateCaret() void MyCanvas::SetFontSize(int fontSize) { - m_font = wxFont(fontSize, wxFONTFAMILY_TELETYPE, - wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + m_font = wxFont(wxFontInfo(fontSize).Family(wxFONTFAMILY_TELETYPE)); wxClientDC dc(this); dc.SetFont(m_font); diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index 563a8b13a1..0d462b5b7f 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -1072,7 +1072,7 @@ void MyCanvas::DrawAlpha(wxDC& dc) dc.SetTextBackground( wxColour(160, 192, 160, 160) ); dc.SetTextForeground( wxColour(255, 128, 128, 128) ); - dc.SetFont( wxFont( 40, wxFONTFAMILY_SWISS, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL ) ); + dc.SetFont( wxFontInfo(40).Family(wxFONTFAMILY_SWISS).Italic() ); dc.DrawText( wxT("Hello!"), 120, 80 ); } #endif // wxDRAWING_DC_SUPPORTS_ALPHA || wxUSE_GRAPHICS_CONTEXT diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp index ae59f17575..209ee250d9 100644 --- a/samples/exec/exec.cpp +++ b/samples/exec/exec.cpp @@ -522,8 +522,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) // create the listbox in which we will show misc messages as they come m_lbox = new wxListBox(this, wxID_ANY); - wxFont font(12, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL); + wxFont font(wxFontInfo(12).Family(wxFONTFAMILY_TELETYPE)); if ( font.IsOk() ) m_lbox->SetFont(font); diff --git a/samples/fswatcher/fswatcher.cpp b/samples/fswatcher/fswatcher.cpp index 187345f003..b4724733dc 100644 --- a/samples/fswatcher/fswatcher.cpp +++ b/samples/fswatcher/fswatcher.cpp @@ -244,8 +244,7 @@ MyFrame::MyFrame(const wxString& title) wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL); // set monospace font to have output in nice columns - wxFont font(9, wxFONTFAMILY_TELETYPE, - wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + wxFont font(wxFontInfo(9).Family(wxFONTFAMILY_TELETYPE)); headerText->SetFont(font); m_evtConsole->SetFont(font); diff --git a/samples/keyboard/keyboard.cpp b/samples/keyboard/keyboard.cpp index 800bac943c..556fa66516 100644 --- a/samples/keyboard/keyboard.cpp +++ b/samples/keyboard/keyboard.cpp @@ -206,8 +206,7 @@ MyFrame::MyFrame(const wxString& title) wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxHSCROLL); // set monospace font to have output in nice columns - wxFont font(10, wxFONTFAMILY_TELETYPE, - wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_TELETYPE)); headerText->SetFont(font); m_logText->SetFont(font); diff --git a/samples/opengl/pyramid/pyramid.cpp b/samples/opengl/pyramid/pyramid.cpp index 365062cdcf..20ef5a33da 100644 --- a/samples/opengl/pyramid/pyramid.cpp +++ b/samples/opengl/pyramid/pyramid.cpp @@ -489,7 +489,7 @@ bool MyGLCanvas::oglInit() int swi = 0, shi = 0; //Image sizes wxString stg("wxWidgets"); // Set the font. Use a big pointsize so as to smoothing edges. - wxFont font(48, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + wxFont font(wxFontInfo(48).Family(wxFONTFAMILY_MODERN)); if ( !font.IsOk() ) font = *wxSWISS_FONT; wxColour bgrdColo(*wxBLACK); diff --git a/samples/ribbon/ribbondemo.cpp b/samples/ribbon/ribbondemo.cpp index 8a7de6d5fe..673eba5f57 100644 --- a/samples/ribbon/ribbondemo.cpp +++ b/samples/ribbon/ribbondemo.cpp @@ -387,7 +387,7 @@ MyFrame::MyFrame() sizer_panelsizer_h->Add(sizer_panelsizer_v, 0); sizer_panel->SetSizer(sizer_panelsizer_h); - wxFont label_font(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT); + wxFont label_font(wxFontInfo(8).Light()); m_bitmap_creation_dc.SetFont(label_font); wxRibbonPage* scheme = new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Appearance"), eye_xpm); diff --git a/samples/splash/splash.cpp b/samples/splash/splash.cpp index fbaa160028..ba9bfd0486 100644 --- a/samples/splash/splash.cpp +++ b/samples/splash/splash.cpp @@ -248,7 +248,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) text->SetBackgroundColour(*wxWHITE); text->SetForegroundColour(*wxBLACK); wxFont font = text->GetFont(); - font.SetPointSize(2*font.GetPointSize()/3); + font.SetFractionalPointSize(2.0*font.GetFractionalPointSize()/3.0); text->SetFont(font); #endif } diff --git a/samples/thread/thread.cpp b/samples/thread/thread.cpp index edc078efd7..7d5ec11e97 100644 --- a/samples/thread/thread.cpp +++ b/samples/thread/thread.cpp @@ -402,8 +402,7 @@ MyFrame::MyFrame(const wxString& title) wxLog::SetActiveTarget(this); // use fixed width font to align output in nice columns - wxFont font(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_TELETYPE, - wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + wxFont font(wxFontInfo().Family(wxFONTFAMILY_TELETYPE)); header->SetFont(font); m_txtctrl->SetFont(font);