Fix return value of wxToolBar::GetToolBitmapSize() under GTK/Mac

Fix another pixel units confusion in wxToolBar code and ensure that
"sizeNeeded" is expressed in logical units when a fixed bitmap size is
set, to make it consistent with the case when it is not set, and also
because bitmap size is supposed to be expressed in logical pixels, in
both SetToolBitmapSize() and, for consistency, GetToolBitmapSize() too.

Also explicitly mention the latter in the documentation.

See #23228.

Closes #23222.
This commit is contained in:
Vadim Zeitlin 2023-02-06 15:30:43 +01:00
parent c4b71b3694
commit 453a52b942
2 changed files with 6 additions and 1 deletions

View file

@ -594,6 +594,11 @@ public:
usually unnecessary to call either this function or
SetToolBitmapSize() at all.
This function returns the size in logical pixels, for consistency with
SetToolBitmapSize() which takes size in logical pixels. See @ref
overview_high_dpi for more information about the different pixel types
and how to convert between them.
@remarks Note that this is the size of the bitmap you pass to AddTool(),
and not the eventual size of the tool button.

View file

@ -486,7 +486,7 @@ void wxToolBarBase::AdjustToolBitmapSize()
// We want to round 1.5 down to 1, but 1.75 up to 2.
int scaleFactorRoundedDown =
static_cast<int>(ceil(2*GetDPIScaleFactor())) / 2;
sizeNeeded = m_requestedBitmapSize*scaleFactorRoundedDown;
sizeNeeded = FromPhys(m_requestedBitmapSize*scaleFactorRoundedDown);
}
else // Determine the best size to use from the bitmaps we have.
{