Make wxWindow::GetContentScaleFactor() return 1 under MSW again
This reverts bc492a9e6e
(Make wxWindow::GetContentScaleFactor() useful
for non-OSX platforms., 2015-03-18) and restores the old behaviour from
wxWidgets 3.0, which consisted in only returning factor different from 1
from this function for the platforms distinguishing logical and physical
pixels.
After this change, the return value of this function can be portably
used on all platforms to convert between logical and physical pixels,
independently of the current DPI.
This commit is contained in:
parent
1422991602
commit
cd8b2d3096
@ -529,8 +529,10 @@ public:
|
||||
return wxSize( wxMax( client.x, best.x ), wxMax( client.y, best.y ) );
|
||||
}
|
||||
|
||||
// returns the magnification of the content of this window
|
||||
// e.g. 2.0 for a window on a retina screen
|
||||
// Return the magnification of the content of this window for the platforms
|
||||
// using logical pixels different from physical ones, i.e. those for which
|
||||
// wxHAVE_DPI_INDEPENDENT_PIXELS is defined. For the other ones, always
|
||||
// returns 1, regardless of DPI scale factor returned by the function below.
|
||||
virtual double GetContentScaleFactor() const;
|
||||
|
||||
// Return the ratio of the DPI used by this window to the standard DPI,
|
||||
|
@ -1376,8 +1376,29 @@ public:
|
||||
virtual wxSize GetBestVirtualSize() const;
|
||||
|
||||
/**
|
||||
Returns the magnification of the backing store of this window, eg 2.0
|
||||
for a window on a retina screen.
|
||||
Returns the factor mapping logical pixels of this window to physical
|
||||
pixels.
|
||||
|
||||
This function can be used to portably determine the number of physical
|
||||
pixels in a window of the given size, by multiplying the window size by
|
||||
the value returned from it. I.e. it returns the factor converting window
|
||||
coordinates to "content view" coordinates, where the view can be just a
|
||||
simple window displaying a wxBitmap or wxGLCanvas or any other kind of
|
||||
window rendering arbitrary "content" on screen.
|
||||
|
||||
For the platforms not doing any pixel mapping, i.e. where logical and
|
||||
physical pixels are one and the same, this function always returns 1.0
|
||||
and so using it is, in principle, unnecessary and could be avoided by
|
||||
using preprocessor check for @c wxHAVE_DPI_INDEPENDENT_PIXELS @e not
|
||||
being defined, however using this function unconditionally under all
|
||||
platforms is usually simpler and so preferable.
|
||||
|
||||
@note Current behaviour of this function is compatible with wxWidgets
|
||||
3.0, but different from its behaviour in versions 3.1.0 to 3.1.3,
|
||||
where it returned the same value as GetDPIScaleFactor(). Please use
|
||||
the other function if you need to use a scaling factor greater than
|
||||
1.0 even for the platforms without @c wxHAVE_DPI_INDEPENDENT_PIXELS,
|
||||
such as wxMSW.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
@ -1387,7 +1408,8 @@ public:
|
||||
Returns the ratio of the DPI used by this window to the standard DPI.
|
||||
|
||||
The returned value is 1 for standard DPI screens or 2 for "200%
|
||||
scaling".
|
||||
scaling" and, unlike for GetContentScaleFactor(), is the same under all
|
||||
platforms.
|
||||
|
||||
This factor should be used to increase the size of icons and similar
|
||||
windows whose best size is not based on text metrics when using DPI
|
||||
@ -1396,9 +1418,10 @@ public:
|
||||
E.g. the program may load a 32px bitmap if the content scale factor is
|
||||
1.0 or 64px version of the same bitmap if it is 2.0 or bigger.
|
||||
|
||||
Notice that this method should @e not be used for window sizes, as they
|
||||
are already scaled by this factor by the underlying toolkit under some
|
||||
platforms. Use FromDIP() for anything window-related instead.
|
||||
Notice that this method should @e not be used for window sizes expressed
|
||||
in pixels, as they are already scaled by this factor by the underlying
|
||||
toolkit under some platforms. Use FromDIP() for anything window-related
|
||||
instead.
|
||||
|
||||
@since 3.1.4
|
||||
*/
|
||||
|
@ -812,7 +812,12 @@ static wxSize GetDPIHelper(const wxWindowBase* w)
|
||||
|
||||
double wxWindowBase::GetContentScaleFactor() const
|
||||
{
|
||||
return GetDPIScaleFactor();
|
||||
// By default, we assume that there is no mapping between logical and
|
||||
// physical pixels and so the content scale factor is just 1. Only the
|
||||
// platforms that do perform such mapping (currently ports for Apple
|
||||
// platforms and GTK 3) override this function to return something
|
||||
// different.
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
double wxWindowBase::GetDPIScaleFactor() const
|
||||
|
@ -12687,11 +12687,8 @@ bool wxRichTextImage::LoadAndScaleImageCache(wxImage& image, const wxSize& sz, w
|
||||
else
|
||||
{
|
||||
double scaleFactor = 1.0;
|
||||
// Scaled bitmaps only work on Mac currently
|
||||
#ifdef __WXOSX_COCOA__
|
||||
if (context.GetBuffer() && context.GetBuffer()->GetRichTextCtrl())
|
||||
scaleFactor = context.GetBuffer()->GetRichTextCtrl()->GetContentScaleFactor();
|
||||
#endif
|
||||
|
||||
// If the original width and height is small, e.g. 400 or below,
|
||||
// scale up and then down to improve image quality. This can make
|
||||
|
@ -301,12 +301,8 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface, WindowID w
|
||||
hdcOwned = true;
|
||||
if (width < 1) width = 1;
|
||||
if (height < 1) height = 1;
|
||||
#ifdef __WXMSW__
|
||||
bitmap = new wxBitmap(width, height);
|
||||
#else
|
||||
bitmap = new wxBitmap();
|
||||
bitmap->CreateScaled(width, height,wxBITMAP_SCREEN_DEPTH,(GETWIN(winid))->GetContentScaleFactor());
|
||||
#endif
|
||||
mdc->SelectObject(*bitmap);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user