From 2b41ba27029f2122fcdf725a28bd17fef37399d9 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 29 Sep 2019 19:03:23 +0200 Subject: [PATCH] Apply review comments --- include/wx/msw/private/dpiaware.h | 7 ++++++- samples/toolbar/toolbar.cpp | 3 ++- src/msw/colordlg.cpp | 2 +- src/msw/filedlg.cpp | 4 ++-- src/msw/fontdlg.cpp | 2 +- src/msw/listctrl.cpp | 6 ++++-- src/msw/toolbar.cpp | 2 +- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/wx/msw/private/dpiaware.h b/include/wx/msw/private/dpiaware.h index 2ff769fc35..8467ef3b30 100644 --- a/include/wx/msw/private/dpiaware.h +++ b/include/wx/msw/private/dpiaware.h @@ -2,7 +2,7 @@ // Name: wx/msw/private/dpiaware.h // Purpose: AutoSystemDpiAware class // Author: Maarten Bent -// Created: 10/6/2016 +// Created: 2016-10-06 // Copyright: (c) Maarten Bent // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,6 +18,9 @@ #if wxUSE_DYNLIB_CLASS +namespace wxMSWImpl +{ + // ---------------------------------------------------------------------------- // Temporarily change the DPI Awareness context to System // ---------------------------------------------------------------------------- @@ -69,4 +72,6 @@ class AutoSystemDpiAware { }; #endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS +} // namespace wxMSWImpl + #endif // _WX_MSW_DPI_AWARE_H_ diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index 0666e8a6f8..0c42388dac 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -308,7 +308,6 @@ bool MyApp::OnInit() MyFrame* frame = new MyFrame((wxFrame *) NULL, wxID_ANY, "wxToolBar Sample", wxPoint(100, 100), wxDefaultSize); - frame->SetSize(frame->FromDIP(wxSize(650, 350))); frame->Show(true); @@ -653,6 +652,8 @@ MyFrame::MyFrame(wxFrame* parent, sizer->Add(m_extraToolBar, 0, wxEXPAND, 0); #endif sizer->Add(m_textWindow, 1, wxEXPAND, 0); + + SetInitialSize(FromDIP(wxSize(650, 350))); } MyFrame::~MyFrame() diff --git a/src/msw/colordlg.cpp b/src/msw/colordlg.cpp index 38fac558cc..4eaf44f255 100644 --- a/src/msw/colordlg.cpp +++ b/src/msw/colordlg.cpp @@ -217,7 +217,7 @@ int wxColourDialog::ShowModal() gs_activeDialog = this; wxON_BLOCK_EXIT_NULL(gs_activeDialog); - AutoSystemDpiAware dpiAwareness; + wxMSWImpl::AutoSystemDpiAware dpiAwareness; // do show the modal dialog if ( !::ChooseColor(&chooseColorStruct) ) diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 1801adcbd3..737b001439 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -378,9 +378,9 @@ static bool DoShowCommFileDialog(OPENFILENAME *of, long style, DWORD *err) { // Extra controls do not handle per-monitor DPI, fall back to system DPI // so entire file-dialog is resized. - wxScopedPtr dpiAwareness; + wxScopedPtr dpiAwareness; if ( of->Flags & OFN_ENABLEHOOK ) - dpiAwareness.reset(new AutoSystemDpiAware()); + dpiAwareness.reset(new wxMSWImpl::AutoSystemDpiAware()); if ( style & wxFD_SAVE ? GetSaveFileName(of) : GetOpenFileName(of) ) return true; diff --git a/src/msw/fontdlg.cpp b/src/msw/fontdlg.cpp index 29d62d2a19..06b73674ac 100644 --- a/src/msw/fontdlg.cpp +++ b/src/msw/fontdlg.cpp @@ -150,7 +150,7 @@ int wxFontDialog::ShowModal() chooseFontStruct.Flags = flags; - AutoSystemDpiAware dpiAwareness; + wxMSWImpl::AutoSystemDpiAware dpiAwareness; if ( ChooseFont(&chooseFontStruct) != 0 ) { diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index ddb156bc38..aa5afe781c 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -457,7 +457,8 @@ void wxListCtrl::MSWUpdateFontOnDPIChange(const wxSize& newDPI) void wxListCtrl::OnDPIChanged(wxDPIChangedEvent &event) { const int numCols = GetColumnCount(); - for ( int i = 0; i < numCols; ++i ) { + for ( int i = 0; i < numCols; ++i ) + { int width = GetColumnWidth(i); if ( width > 0 ) width = width * event.GetNewDPI().x / event.GetOldDPI().x; @@ -1003,7 +1004,8 @@ bool wxListCtrl::SetItem(wxListItem& info) else data->attr = new wxItemAttr(attrNew); - if ( data->attr->HasFont() ) { + if ( data->attr->HasFont() ) + { wxFont f = data->attr->GetFont(); f.WXAdjustToPPI(GetDPI()); data->attr->SetFont(f); diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 4aa60f31dc..1a40d6f65d 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1940,7 +1940,7 @@ void wxToolBar::OnDPIChanged(wxDPIChangedEvent& event) } } - // Use CallAfter because creating the toolbar directly does sometimes not + // Use CallAfter because creating the toolbar directly sometimes doesn't // work. E.g. when switching from 125% to 150%. All the sizes are set // correctly, but after all dpi events are handled, 5px of the toolbar are // gone and a dark-gray bar appears. After resizing the window, the gray