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:
@@ -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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user