Apply review comments

This commit is contained in:
Maarten Bent
2019-09-29 19:03:23 +02:00
parent 0a7c191e27
commit 2b41ba2702
7 changed files with 17 additions and 9 deletions

View File

@@ -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_

View File

@@ -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()

View File

@@ -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) )

View File

@@ -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<AutoSystemDpiAware> dpiAwareness;
wxScopedPtr<wxMSWImpl::AutoSystemDpiAware> 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;

View File

@@ -150,7 +150,7 @@ int wxFontDialog::ShowModal()
chooseFontStruct.Flags = flags;
AutoSystemDpiAware dpiAwareness;
wxMSWImpl::AutoSystemDpiAware dpiAwareness;
if ( ChooseFont(&chooseFontStruct) != 0 )
{

View File

@@ -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);

View File

@@ -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