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, #23222.

(cherry picked from commit 453a52b942fa27c8f412716c8290dbcb6172d0e4)
This commit is contained in:
Vadim Zeitlin 2023-02-06 15:30:43 +01:00
parent 087f0c7742
commit ee2a2ccaee
3 changed files with 7 additions and 1 deletions

View File

@ -262,6 +262,7 @@ All (GUI):
- Improve month selection in wxGenericCalendarCtrl (Lauri Nurmi, #22853).
- Fix maximum length of wxPropertyGrid editors (#23033).
- Add support for Caps/Num/Scroll Lock to wxGetKeyState() (elfmz, #23195).
- Fix wxToolBar::GetToolBitmapSize() in high DPI under non-MSW (#23222).
wxGTK:

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

@ -489,7 +489,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.
{