Merge branch 'gtk-dpi'

A bunch of improvements for per-monitor DPI support in wxGTK and
wxGraphicsContext more generally.

Closes https://github.com/wxWidgets/wxWidgets/pull/995
This commit is contained in:
Vadim Zeitlin
2018-11-10 12:15:27 +01:00
23 changed files with 241 additions and 101 deletions

View File

@@ -49,6 +49,10 @@ public:
// primary display and the only one which is always supported
wxDisplay(unsigned n = 0);
// create display object corresponding to the display of the given window
// or the default one if the window display couldn't be found
explicit wxDisplay(const wxWindow* window);
// dtor is not virtual as this is a concrete class not meant to be derived
// from

View File

@@ -452,7 +452,7 @@ private:
class WXDLLIMPEXP_CORE wxGraphicsContext : public wxGraphicsObject
{
public:
wxGraphicsContext(wxGraphicsRenderer* renderer);
wxGraphicsContext(wxGraphicsRenderer* renderer, wxWindow* window = NULL);
virtual ~wxGraphicsContext();
@@ -490,6 +490,9 @@ public:
// create a context that can be used for measuring texts only, no drawing allowed
static wxGraphicsContext * Create();
// Return the window this context is associated with, if any.
wxWindow* GetWindow() const { return m_window; }
// begin a new document (relevant only for printing / pdf etc) if there is a progress dialog, message will be shown
virtual bool StartDoc( const wxString& message );
@@ -788,6 +791,12 @@ protected:
wxDouble angle,
const wxGraphicsBrush& backgroundBrush);
private:
// The associated window, if any, i.e. if one was passed directly to
// Create() or the associated window of the wxDC this context was created
// from.
wxWindow* const m_window;
wxDECLARE_NO_COPY_CLASS(wxGraphicsContext);
wxDECLARE_ABSTRACT_CLASS(wxGraphicsContext);
};

View File

@@ -81,8 +81,11 @@ public:
// return the depth or 0 if unknown
virtual int GetDepth() const = 0;
// return the resolution of the display, uses GetSizeMM() by default but
// can be also overridden directly
// return the scale factor used to convert logical pixels to physical ones
virtual double GetScaleFactor() const { return 1.0; }
// return the resolution of the display, uses GetSize(), GetScaleFactor()
// and GetSizeMM() by default but can be also overridden directly
virtual wxSize GetPPI() const;
// return the physical size of the display or (0, 0) if unknown: this is
@@ -115,6 +118,11 @@ protected:
// create the object providing access to the display with the given index
wxDisplayImpl(unsigned n) : m_index(n) { }
// Compute PPI from the sizes in pixels and mm.
//
// Return (0, 0) if physical size (in mm) is not known, i.e. 0.
static wxSize ComputePPI(int pxX, int pxY, int mmX, int mmY);
// the index of this display (0 is always the primary one)
const unsigned m_index;