Make wxToolBar::SetToolBitmapSize() take size in logical pixels

Previously it interpreted its argument as being in DIPs, which was
perhaps more convenient, but inconsistent with most of the other
functions and broke the general rule that FromDIP() should be used with
all hard-coded sizes.

Update the sample to use FromDIP() when calling it now, improve the
documentation and fix a bug in AdjustToolBitmapSize() which resulted in
not increasing the bitmap size when moving toolbar sample using "large"
toolbar size from a standard DPI display to a high DPI one: the old code
considered that the new size was the same as the old one and returned
before comparing it with m_requestedBitmapSize, which resulted in the
bitmaps not changing size at all instead of doubling their size as they
were expected to.
This commit is contained in:
Vadim Zeitlin
2022-04-19 23:36:02 +01:00
parent a0abd711f7
commit eb6506e677
4 changed files with 36 additions and 27 deletions

View File

@@ -438,10 +438,12 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar)
toolBarBitmaps[Tool_about] = wxBitmapBundle::FromSVG(svg_data, sizeBitmap);
#endif // wxHAS_SVG
// Note that there is no need for FromDIP() here, wxMSW will adjust the
// size on its own and under the other platforms there is no need for
// scaling the coordinates anyhow.
toolBar->SetToolBitmapSize(sizeBitmap);
// We don't have to call this function at all when using the default bitmap
// size (i.e. when m_smallToolbar == true), but it's harmless to do it.
//
// Note that sizeBitmap is in DIPs, so we need to use FromDIP() to scale it
// up for the current DPI, if necessary.
toolBar->SetToolBitmapSize(FromDIP(sizeBitmap));
toolBar->AddTool(wxID_NEW, "New",
toolBarBitmaps[Tool_new], wxNullBitmap, wxITEM_DROPDOWN,