Implement platform-specific coordinate conversion functions
Generic wxDC::DeviceToLogicalRel{X|Y}() and wxDC::LogicalToDeviceRel{X|Y}() functions don't take into account scaling applied with wxDC::SetTransformMatrix(). We need to implement in wxDCImpl and its platform-specific derivates new conversion functions that take all applied transformations into account. See #18923.
This commit is contained in:
@@ -325,6 +325,8 @@ public:
|
|||||||
// coordinates conversions and transforms
|
// coordinates conversions and transforms
|
||||||
virtual wxPoint DeviceToLogical(wxCoord x, wxCoord y) const;
|
virtual wxPoint DeviceToLogical(wxCoord x, wxCoord y) const;
|
||||||
virtual wxPoint LogicalToDevice(wxCoord x, wxCoord y) const;
|
virtual wxPoint LogicalToDevice(wxCoord x, wxCoord y) const;
|
||||||
|
virtual wxSize DeviceToLogicalRel(int x, int y) const;
|
||||||
|
virtual wxSize LogicalToDeviceRel(int x, int y) const;
|
||||||
|
|
||||||
// bounding box
|
// bounding box
|
||||||
|
|
||||||
|
@@ -124,6 +124,8 @@ public:
|
|||||||
// coordinates conversions and transforms
|
// coordinates conversions and transforms
|
||||||
virtual wxPoint DeviceToLogical(wxCoord x, wxCoord y) const wxOVERRIDE;
|
virtual wxPoint DeviceToLogical(wxCoord x, wxCoord y) const wxOVERRIDE;
|
||||||
virtual wxPoint LogicalToDevice(wxCoord x, wxCoord y) const wxOVERRIDE;
|
virtual wxPoint LogicalToDevice(wxCoord x, wxCoord y) const wxOVERRIDE;
|
||||||
|
virtual wxSize DeviceToLogicalRel(int x, int y) const wxOVERRIDE;
|
||||||
|
virtual wxSize LogicalToDeviceRel(int x, int y) const wxOVERRIDE;
|
||||||
|
|
||||||
// the true implementations
|
// the true implementations
|
||||||
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
|
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
|
||||||
|
@@ -88,6 +88,8 @@ public:
|
|||||||
|
|
||||||
virtual wxPoint DeviceToLogical(wxCoord x, wxCoord y) const wxOVERRIDE;
|
virtual wxPoint DeviceToLogical(wxCoord x, wxCoord y) const wxOVERRIDE;
|
||||||
virtual wxPoint LogicalToDevice(wxCoord x, wxCoord y) const wxOVERRIDE;
|
virtual wxPoint LogicalToDevice(wxCoord x, wxCoord y) const wxOVERRIDE;
|
||||||
|
virtual wxSize DeviceToLogicalRel(int x, int y) const wxOVERRIDE;
|
||||||
|
virtual wxSize LogicalToDeviceRel(int x, int y) const wxOVERRIDE;
|
||||||
|
|
||||||
#if wxUSE_DC_TRANSFORM_MATRIX
|
#if wxUSE_DC_TRANSFORM_MATRIX
|
||||||
virtual bool CanUseTransformMatrix() const wxOVERRIDE;
|
virtual bool CanUseTransformMatrix() const wxOVERRIDE;
|
||||||
|
@@ -512,6 +512,16 @@ wxPoint wxDCImpl::LogicalToDevice(wxCoord x, wxCoord y) const
|
|||||||
return wxPoint(LogicalToDeviceX(x), LogicalToDeviceY(y));
|
return wxPoint(LogicalToDeviceX(x), LogicalToDeviceY(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxDCImpl::DeviceToLogicalRel(int x, int y) const
|
||||||
|
{
|
||||||
|
return wxSize(DeviceToLogicalXRel(x), DeviceToLogicalYRel(y));
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize wxDCImpl::LogicalToDeviceRel(int x, int y) const
|
||||||
|
{
|
||||||
|
return wxSize(LogicalToDeviceXRel(x), LogicalToDeviceYRel(y));
|
||||||
|
}
|
||||||
|
|
||||||
void wxDCImpl::ComputeScaleAndOrigin()
|
void wxDCImpl::ComputeScaleAndOrigin()
|
||||||
{
|
{
|
||||||
m_scaleX = m_logicalScaleX * m_userScaleX;
|
m_scaleX = m_logicalScaleX * m_userScaleX;
|
||||||
|
@@ -613,6 +613,22 @@ wxPoint wxGCDCImpl::LogicalToDevice(wxCoord x, wxCoord y) const
|
|||||||
return wxPoint(wxRound(px), wxRound(py));
|
return wxPoint(wxRound(px), wxRound(py));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxGCDCImpl::DeviceToLogicalRel(int x, int y) const
|
||||||
|
{
|
||||||
|
wxDouble dx = x;
|
||||||
|
wxDouble dy = y;
|
||||||
|
m_matrixCurrentInv.TransformDistance(&dx, &dy);
|
||||||
|
return wxSize(wxRound(dx), wxRound(dy));
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize wxGCDCImpl::LogicalToDeviceRel(int x, int y) const
|
||||||
|
{
|
||||||
|
wxDouble dx = x;
|
||||||
|
wxDouble dy = y;
|
||||||
|
m_matrixCurrent.TransformDistance(&dx, &dy);
|
||||||
|
return wxSize(wxRound(dx), wxRound(dy));
|
||||||
|
}
|
||||||
|
|
||||||
bool wxGCDCImpl::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
|
bool wxGCDCImpl::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
|
||||||
const wxColour& WXUNUSED(col),
|
const wxColour& WXUNUSED(col),
|
||||||
wxFloodFillStyle WXUNUSED(style))
|
wxFloodFillStyle WXUNUSED(style))
|
||||||
|
@@ -2118,6 +2118,28 @@ wxPoint wxMSWDCImpl::LogicalToDevice(wxCoord x, wxCoord y) const
|
|||||||
return wxPoint(p[0].x, p[0].y);
|
return wxPoint(p[0].x, p[0].y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxMSWDCImpl::DeviceToLogicalRel(int x, int y) const
|
||||||
|
{
|
||||||
|
POINT p[2];
|
||||||
|
p[0].x = 0;
|
||||||
|
p[0].y = 0;
|
||||||
|
p[1].x = x;
|
||||||
|
p[1].y = y;
|
||||||
|
::DPtoLP(GetHdc(), p, WXSIZEOF(p));
|
||||||
|
return wxSize(p[1].x-p[0].x, p[1].y-p[0].y);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize wxMSWDCImpl::LogicalToDeviceRel(int x, int y) const
|
||||||
|
{
|
||||||
|
POINT p[2];
|
||||||
|
p[0].x = 0;
|
||||||
|
p[0].y = 0;
|
||||||
|
p[1].x = x;
|
||||||
|
p[1].y = y;
|
||||||
|
::LPtoDP(GetHdc(), p, WXSIZEOF(p));
|
||||||
|
return wxSize(p[1].x-p[0].x, p[1].y-p[0].y);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Transform matrix
|
// Transform matrix
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user