Made the various logical 2 device transforms consistent with what's drawn on all platforms
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53648 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -368,12 +368,12 @@ wxDCImpl::~wxDCImpl()
|
|||||||
|
|
||||||
wxCoord wxDCImpl::DeviceToLogicalX(wxCoord x) const
|
wxCoord wxDCImpl::DeviceToLogicalX(wxCoord x) const
|
||||||
{
|
{
|
||||||
return wxRound((double)(x - m_deviceOriginX - m_deviceLocalOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
|
return wxRound( (double)((x - m_deviceOriginX - m_deviceLocalOriginX) * m_signX) / m_scaleX ) + m_logicalOriginX ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCoord wxDCImpl::DeviceToLogicalY(wxCoord y) const
|
wxCoord wxDCImpl::DeviceToLogicalY(wxCoord y) const
|
||||||
{
|
{
|
||||||
return wxRound((double)(y - m_deviceOriginY - m_deviceLocalOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
|
return wxRound( (double)((y - m_deviceOriginY - m_deviceLocalOriginY) * m_signY) / m_scaleY ) + m_logicalOriginY ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCoord wxDCImpl::DeviceToLogicalXRel(wxCoord x) const
|
wxCoord wxDCImpl::DeviceToLogicalXRel(wxCoord x) const
|
||||||
@@ -388,12 +388,12 @@ wxCoord wxDCImpl::DeviceToLogicalYRel(wxCoord y) const
|
|||||||
|
|
||||||
wxCoord wxDCImpl::LogicalToDeviceX(wxCoord x) const
|
wxCoord wxDCImpl::LogicalToDeviceX(wxCoord x) const
|
||||||
{
|
{
|
||||||
return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX * m_signY + m_deviceLocalOriginX;
|
return wxRound( (double)((x - m_logicalOriginX) * m_signX) * m_scaleX) + m_deviceOriginX + m_deviceLocalOriginX;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCoord wxDCImpl::LogicalToDeviceY(wxCoord y) const
|
wxCoord wxDCImpl::LogicalToDeviceY(wxCoord y) const
|
||||||
{
|
{
|
||||||
return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY * m_signY + m_deviceLocalOriginY;
|
return wxRound( (double)((y - m_logicalOriginY) * m_signY) * m_scaleY) + m_deviceOriginY + m_deviceLocalOriginY;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCoord wxDCImpl::LogicalToDeviceXRel(wxCoord x) const
|
wxCoord wxDCImpl::LogicalToDeviceXRel(wxCoord x) const
|
||||||
|
@@ -363,11 +363,13 @@ void wxGCDCImpl::ComputeScaleAndOrigin()
|
|||||||
if ( m_graphicContext )
|
if ( m_graphicContext )
|
||||||
{
|
{
|
||||||
m_matrixCurrent = m_graphicContext->CreateMatrix();
|
m_matrixCurrent = m_graphicContext->CreateMatrix();
|
||||||
m_matrixCurrent.Translate( m_deviceOriginX, m_deviceOriginY );
|
|
||||||
m_matrixCurrent.Scale( m_scaleX, m_scaleY );
|
|
||||||
// the logical origin sets the origin to have new coordinates
|
// the logical origin sets the origin to have new coordinates
|
||||||
m_matrixCurrent.Translate( -m_logicalOriginX, -m_logicalOriginY );
|
m_matrixCurrent.Translate( m_deviceOriginX - m_logicalOriginX * m_signX * m_scaleX,
|
||||||
|
m_deviceOriginY-m_logicalOriginY * m_signY * m_scaleY);
|
||||||
|
|
||||||
|
m_matrixCurrent.Scale( m_scaleX * m_signX, m_scaleY * m_signY );
|
||||||
|
|
||||||
m_graphicContext->SetTransform( m_matrixOriginal );
|
m_graphicContext->SetTransform( m_matrixOriginal );
|
||||||
m_graphicContext->ConcatTransform( m_matrixCurrent );
|
m_graphicContext->ConcatTransform( m_matrixCurrent );
|
||||||
}
|
}
|
||||||
|
@@ -502,7 +502,7 @@ bool wxWindowDCImpl::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
|
|||||||
void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
|
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
|
||||||
|
|
||||||
if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
|
if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
|
||||||
{
|
{
|
||||||
if (m_gdkwindow)
|
if (m_gdkwindow)
|
||||||
@@ -2106,11 +2106,7 @@ void wxWindowDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, w
|
|||||||
|
|
||||||
wxCoord xx, yy, ww, hh;
|
wxCoord xx, yy, ww, hh;
|
||||||
m_currentClippingRegion.GetBox( xx, yy, ww, hh );
|
m_currentClippingRegion.GetBox( xx, yy, ww, hh );
|
||||||
#if wxUSE_NEW_DC
|
|
||||||
wxGTKDCImpl::DoSetClippingRegion( xx, yy, ww, hh );
|
wxGTKDCImpl::DoSetClippingRegion( xx, yy, ww, hh );
|
||||||
#else
|
|
||||||
wxDC::DoSetClippingRegion( xx, yy, ww, hh );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GdkRegion* gdkRegion = m_currentClippingRegion.GetRegion();
|
GdkRegion* gdkRegion = m_currentClippingRegion.GetRegion();
|
||||||
gdk_gc_set_clip_region(m_penGC, gdkRegion);
|
gdk_gc_set_clip_region(m_penGC, gdkRegion);
|
||||||
@@ -2143,11 +2139,7 @@ void wxWindowDCImpl::DoSetClippingRegionAsRegion( const wxRegion ®ion )
|
|||||||
|
|
||||||
wxCoord xx, yy, ww, hh;
|
wxCoord xx, yy, ww, hh;
|
||||||
m_currentClippingRegion.GetBox( xx, yy, ww, hh );
|
m_currentClippingRegion.GetBox( xx, yy, ww, hh );
|
||||||
#if wxUSE_NEW_DC
|
|
||||||
wxGTKDCImpl::DoSetClippingRegion( xx, yy, ww, hh );
|
wxGTKDCImpl::DoSetClippingRegion( xx, yy, ww, hh );
|
||||||
#else
|
|
||||||
wxDC::DoSetClippingRegion( xx, yy, ww, hh );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GdkRegion* gdkRegion = m_currentClippingRegion.GetRegion();
|
GdkRegion* gdkRegion = m_currentClippingRegion.GetRegion();
|
||||||
gdk_gc_set_clip_region(m_penGC, gdkRegion);
|
gdk_gc_set_clip_region(m_penGC, gdkRegion);
|
||||||
@@ -2160,11 +2152,7 @@ void wxWindowDCImpl::DestroyClippingRegion()
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
|
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
|
||||||
|
|
||||||
#if wxUSE_NEW_DC
|
|
||||||
wxDCImpl::DestroyClippingRegion();
|
wxDCImpl::DestroyClippingRegion();
|
||||||
#else
|
|
||||||
wxDC::DestroyClippingRegion();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_currentClippingRegion.Clear();
|
m_currentClippingRegion.Clear();
|
||||||
|
|
||||||
@@ -2221,11 +2209,7 @@ void wxWindowDCImpl::ComputeScaleAndOrigin()
|
|||||||
{
|
{
|
||||||
const wxRealPoint origScale(m_scaleX, m_scaleY);
|
const wxRealPoint origScale(m_scaleX, m_scaleY);
|
||||||
|
|
||||||
#if wxUSE_NEW_DC
|
|
||||||
wxDCImpl::ComputeScaleAndOrigin();
|
wxDCImpl::ComputeScaleAndOrigin();
|
||||||
#else
|
|
||||||
wxDC::ComputeScaleAndOrigin();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// if scale has changed call SetPen to recalulate the line width
|
// if scale has changed call SetPen to recalulate the line width
|
||||||
if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.IsOk() )
|
if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.IsOk() )
|
||||||
|
@@ -2017,9 +2017,15 @@ void wxMSWDCImpl::SetLogicalOrigin(wxCoord x, wxCoord y)
|
|||||||
|
|
||||||
wxDCImpl::SetLogicalOrigin( x, y );
|
wxDCImpl::SetLogicalOrigin( x, y );
|
||||||
|
|
||||||
#ifndef __WXWINCE__
|
RealizeScaleAndOrigin();
|
||||||
::SetWindowOrgEx(GetHdc(), (int)m_logicalOriginX, (int)m_logicalOriginY, NULL);
|
}
|
||||||
#endif
|
|
||||||
|
// For use by wxWidgets only, unless custom units are required.
|
||||||
|
void wxMSWDCImpl::SetLogicalScale(double x, double y)
|
||||||
|
{
|
||||||
|
WXMICROWIN_CHECK_HDC
|
||||||
|
|
||||||
|
wxDCImpl::SetLogicalScale(x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMSWDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)
|
void wxMSWDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)
|
||||||
@@ -2389,14 +2395,6 @@ wxSize wxMSWDCImpl::GetPPI() const
|
|||||||
return wxSize(x, y);
|
return wxSize(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For use by wxWidgets only, unless custom units are required.
|
|
||||||
void wxMSWDCImpl::SetLogicalScale(double x, double y)
|
|
||||||
{
|
|
||||||
WXMICROWIN_CHECK_HDC
|
|
||||||
|
|
||||||
wxDCImpl::SetLogicalScale(x,y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// DC caching
|
// DC caching
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user