Add FromDIP to wxDC and wxGraphicsContext
Using the same implementation as wxWindow has.
This commit is contained in:
@@ -539,6 +539,8 @@ public:
|
|||||||
|
|
||||||
virtual double GetContentScaleFactor() const { return m_contentScaleFactor; }
|
virtual double GetContentScaleFactor() const { return m_contentScaleFactor; }
|
||||||
|
|
||||||
|
virtual wxSize FromDIP(const wxSize& sz) const;
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
// Native Windows functions using the underlying HDC don't honour GDI+
|
// Native Windows functions using the underlying HDC don't honour GDI+
|
||||||
// transformations which may be applied to it. Using this function we can
|
// transformations which may be applied to it. Using this function we can
|
||||||
@@ -827,6 +829,16 @@ public:
|
|||||||
double GetContentScaleFactor() const
|
double GetContentScaleFactor() const
|
||||||
{ return m_pimpl->GetContentScaleFactor(); }
|
{ return m_pimpl->GetContentScaleFactor(); }
|
||||||
|
|
||||||
|
wxSize FromDIP(const wxSize& sz) const
|
||||||
|
{ return m_pimpl->FromDIP(sz); }
|
||||||
|
wxPoint FromDIP(const wxPoint& pt) const
|
||||||
|
{
|
||||||
|
const wxSize sz = FromDIP(wxSize(pt.x, pt.y));
|
||||||
|
return wxPoint(sz.x, sz.y);
|
||||||
|
}
|
||||||
|
int FromDIP(int d) const
|
||||||
|
{ return FromDIP(wxSize(d, 0)).x; }
|
||||||
|
|
||||||
// Right-To-Left (RTL) modes
|
// Right-To-Left (RTL) modes
|
||||||
|
|
||||||
void SetLayoutDirection(wxLayoutDirection dir)
|
void SetLayoutDirection(wxLayoutDirection dir)
|
||||||
|
|||||||
@@ -739,6 +739,17 @@ public:
|
|||||||
// returns the resolution of the graphics context in device points per inch
|
// returns the resolution of the graphics context in device points per inch
|
||||||
virtual void GetDPI( wxDouble* dpiX, wxDouble* dpiY) const;
|
virtual void GetDPI( wxDouble* dpiX, wxDouble* dpiY) const;
|
||||||
|
|
||||||
|
wxSize FromDIP(const wxSize& sz) const;
|
||||||
|
wxPoint FromDIP(const wxPoint& pt) const
|
||||||
|
{
|
||||||
|
const wxSize sz = FromDIP(wxSize(pt.x, pt.y));
|
||||||
|
return wxPoint(sz.x, sz.y);
|
||||||
|
}
|
||||||
|
int FromDIP(int d) const
|
||||||
|
{
|
||||||
|
return FromDIP(wxSize(d, 0)).x;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// sets the current alpha on this context
|
// sets the current alpha on this context
|
||||||
virtual void SetAlpha( wxDouble alpha );
|
virtual void SetAlpha( wxDouble alpha );
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/private/textmeasure.h"
|
#include "wx/private/textmeasure.h"
|
||||||
|
#include "wx/private/rescale.h"
|
||||||
|
#include "wx/display.h"
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
#include "wx/msw/dcclient.h"
|
#include "wx/msw/dcclient.h"
|
||||||
@@ -604,6 +606,17 @@ void wxDCImpl::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
|
|||||||
ComputeScaleAndOrigin();
|
ComputeScaleAndOrigin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxDCImpl::FromDIP(const wxSize& sz) const
|
||||||
|
{
|
||||||
|
#ifdef wxHAS_DPI_INDEPENDENT_PIXELS
|
||||||
|
return sz;
|
||||||
|
#else
|
||||||
|
const wxSize dpi = GetPPI();
|
||||||
|
const wxSize baseline = wxDisplay::GetStdPPI();
|
||||||
|
return wxRescaleCoord(sz).From(baseline).To(dpi);
|
||||||
|
#endif // wxHAS_DPI_INDEPENDENT_PIXELS
|
||||||
|
}
|
||||||
|
|
||||||
bool wxDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
|
bool wxDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
|
||||||
{
|
{
|
||||||
wxTextMeasure tm(GetOwner(), &m_font);
|
wxTextMeasure tm(GetOwner(), &m_font);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/private/graphics.h"
|
#include "wx/private/graphics.h"
|
||||||
|
#include "wx/private/rescale.h"
|
||||||
#include "wx/display.h"
|
#include "wx/display.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -641,6 +642,18 @@ void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxGraphicsContext::FromDIP(const wxSize& sz) const
|
||||||
|
{
|
||||||
|
#ifdef wxHAS_DPI_INDEPENDENT_PIXELS
|
||||||
|
return sz;
|
||||||
|
#else
|
||||||
|
wxRealPoint dpi;
|
||||||
|
GetDPI(&dpi.x, &dpi.y);
|
||||||
|
const wxSize baseline = wxDisplay::GetStdPPI();
|
||||||
|
return wxRescaleCoord(sz).From(baseline).To(wxSize((int)dpi.x, (int)dpi.y));
|
||||||
|
#endif // wxHAS_DPI_INDEPENDENT_PIXELS
|
||||||
|
}
|
||||||
|
|
||||||
// sets the pen
|
// sets the pen
|
||||||
void wxGraphicsContext::SetPen( const wxGraphicsPen& pen )
|
void wxGraphicsContext::SetPen( const wxGraphicsPen& pen )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user