]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dc.cpp
fix GTKGetLabel() and DoApplyWidgetStyle(): children are GtkWidget, not GtkBoxChild
[wxWidgets.git] / src / msw / dc.cpp
index 5079795653467c33fff3bb3246dde2d7e290cf1d..962054ae85524e9a6cf76deb63fa74b2afdef09c 100644 (file)
@@ -34,6 +34,7 @@
     #include "wx/bitmap.h"
     #include "wx/dcmemory.h"
     #include "wx/log.h"
+    #include "wx/math.h"
     #include "wx/icon.h"
     #include "wx/dcprint.h"
     #include "wx/module.h"
@@ -82,7 +83,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxMSWDCImpl, wxDCImpl)
 // constants
 // ---------------------------------------------------------------------------
 
-static const int VIEWPORT_EXTENT = 1000;
+static const int VIEWPORT_EXTENT = 1024;
 
 // ROPs which don't have standard names (see "Ternary Raster Operations" in the
 // MSDN docs for how this and other numbers in wxDC::Blit() are obtained)
@@ -1967,11 +1968,39 @@ void wxMSWDCImpl::RealizeScaleAndOrigin()
 #ifndef __WXWINCE__
     ::SetMapMode(GetHdc(), MM_ANISOTROPIC);
 
-    int width = DeviceToLogicalXRel(VIEWPORT_EXTENT)*m_signX,
-        height = DeviceToLogicalYRel(VIEWPORT_EXTENT)*m_signY;
+    // wxWidgets API assumes that the coordinate space is "infinite" (i.e. only
+    // limited by 2^32 range of the integer coordinates) but in MSW API we must
+    // actually specify the extents that we use. So we more or less arbitrarily
+    // decide to use "base" VIEWPORT_EXTENT and adjust it depending on scale.
+    //
+    // To avoid rounding errors we prefer to multiply by the scale if it's > 1
+    // and to divide by it if it's < 1.
+    int devExtX, devExtY,   // Viewport, i.e. device space, extents.
+        logExtX, logExtY;   // Window, i.e. logical coordinate space, extents.
+    if ( m_scaleX >= 1 )
+    {
+        devExtX = wxRound(VIEWPORT_EXTENT*m_scaleX);
+        logExtX = m_signX*VIEWPORT_EXTENT;
+    }
+    else
+    {
+        devExtX = VIEWPORT_EXTENT;
+        logExtX = wxRound(m_signX*VIEWPORT_EXTENT/m_scaleX);
+    }
+
+    if ( m_scaleY >= 1 )
+    {
+        devExtY = wxRound(VIEWPORT_EXTENT*m_scaleY);
+        logExtY = m_signY*VIEWPORT_EXTENT;
+    }
+    else
+    {
+        devExtY = VIEWPORT_EXTENT;
+        logExtY = wxRound(m_signY*VIEWPORT_EXTENT/m_scaleY);
+    }
 
-    ::SetViewportExtEx(GetHdc(), VIEWPORT_EXTENT, VIEWPORT_EXTENT, NULL);
-    ::SetWindowExtEx(GetHdc(), width, height, NULL);
+    ::SetViewportExtEx(GetHdc(), devExtX, devExtY, NULL);
+    ::SetWindowExtEx(GetHdc(), logExtX, logExtY, NULL);
 
     ::SetViewportOrgEx(GetHdc(), m_deviceOriginX, m_deviceOriginY, NULL);
     ::SetWindowOrgEx(GetHdc(), m_logicalOriginX, m_logicalOriginY, NULL);