Move scale factor-related functions to wxGDIImage from wxBitmap

This makes them available in wxIcon (and, less importantly, wxCursor)
too which is needed in order to use icons correctly in high DPI.

This is also more consistent with the other platforms, where wxIcon does
have these methods.

Document these methods in wxIcon now that they're available there under
all platforms and also document wxIcon::GetSize() which had been
available even before, but wasn't documented.
This commit is contained in:
Vadim Zeitlin
2022-01-22 22:54:39 +00:00
parent c1d91d5566
commit b4946c2fe3
5 changed files with 101 additions and 62 deletions

View File

@@ -335,6 +335,47 @@ void wxGDIImage::InitStandardHandlers()
#endif // wxUSE_PNG_RESOURCE_HANDLER
}
// ----------------------------------------------------------------------------
// scale factor-related functions
// ----------------------------------------------------------------------------
// wxMSW doesn't really use scale factor, but we must still store it to use the
// correct sizes in the code which uses it to decide on the bitmap size to use.
void wxGDIImage::SetScaleFactor(double scale)
{
wxCHECK_RET( IsOk(), wxT("invalid bitmap") );
GetGDIImageData()->m_scaleFactor = scale;
}
double wxGDIImage::GetScaleFactor() const
{
wxCHECK_MSG( IsOk(), -1, wxT("invalid bitmap") );
return GetGDIImageData()->m_scaleFactor;
}
wxSize wxGDIImage::GetDIPSize() const
{
return GetSize() / GetScaleFactor();
}
double wxGDIImage::GetLogicalWidth() const
{
return GetWidth();
}
double wxGDIImage::GetLogicalHeight() const
{
return GetHeight();
}
wxSize wxGDIImage::GetLogicalSize() const
{
return GetSize();
}
// ----------------------------------------------------------------------------
// wxBitmap handlers
// ----------------------------------------------------------------------------