Don't scale the value(s) of -1 in wxWindow::FromDIP().
Using FromDIP() in wxXRC broke creating controls whose width or height was specified as -1 as it became -2 when sufficiently high DPI was used, and so lost the special meaning of "unspecified" that -1 had. Avoid this problem by never scaling -1 in FromDIP(), this is unlikely to ever be useful and could result in more difficult to debug problems in the future.
This commit is contained in:
@@ -2873,8 +2873,10 @@ wxWindowBase::FromDIP(const wxSize& sz, const wxWindowBase* WXUNUSED(w))
|
||||
{
|
||||
const wxSize dpi = wxScreenDC().GetPPI();
|
||||
|
||||
return wxSize(wxMulDivInt32(sz.x, dpi.x, BASELINE_DPI),
|
||||
wxMulDivInt32(sz.y, dpi.y, BASELINE_DPI));
|
||||
// Take care to not scale -1 because it has a special meaning of
|
||||
// "unspecified" which should be preserved.
|
||||
return wxSize(sz.x == -1 ? -1 : wxMulDivInt32(sz.x, dpi.x, BASELINE_DPI),
|
||||
sz.y == -1 ? -1 : wxMulDivInt32(sz.y, dpi.y, BASELINE_DPI));
|
||||
}
|
||||
|
||||
#endif // !wxHAVE_DPI_INDEPENDENT_PIXELS
|
||||
|
Reference in New Issue
Block a user