[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kviewshell-0.7/kviewshell/shell
From:       Wilfried Huss <Wilfried.Huss () gmx ! at>
Date:       2006-10-05 19:17:11
Message-ID: 1160075831.727362.4762.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 592787 by whuss:

Fix zoomToPage, zoomToHeight, etc. for displays that have
different horizontal and vertical dpi settings.

 M  +11 -6     pageView.cpp  
 M  +8 -4      presentationwidget.cpp  
 M  +4 -11     simplePageSize.cpp  
 M  +4 -5      simplePageSize.h  


--- branches/work/kviewshell-0.7/kviewshell/shell/pageView.cpp #592786:592787
@@ -30,6 +30,7 @@
 #include "textBox.h"
 
 #include <qcursor.h>
+#include <qpaintdevicemetrics.h>
 #include <qpainter.h>
 #include <qrect.h>
 
@@ -447,15 +448,17 @@
   unsigned int leftTargetWidth = (unsigned int)(ratio * viewportWidth);
 
   const QPaintDevice& device = *viewport();
+  const int dpix = QPaintDeviceMetrics(&device).logicalDpiX();
 
   if (dataModel->preferences()->rotation() == KVSPrefs::EnumRotation::Landscape ||
       dataModel->preferences()->rotation() == KVSPrefs::EnumRotation::Seascape)
   {
-    return pageCache->sizeOfPage(widestPageLeft).zoomForHeight(leftTargetWidth, \
device); +    return \
pageCache->sizeOfPage(widestPageLeft).zoomForHeight(leftTargetWidth, dpix);  }
   else
   {
-    return pageCache->sizeOfPage(widestPageLeft).zoomForWidth(leftTargetWidth, \
device); +
+    return pageCache->sizeOfPage(widestPageLeft).zoomForWidth(leftTargetWidth, \
dpix);  }
 }
 
@@ -504,15 +507,16 @@
   targetPageHeight = (targetViewportHeight - (rows+1) * distanceBetweenWidgets) / \
rows;  
   const QPaintDevice& device = *viewport();
+  const int dpix = QPaintDeviceMetrics(&device).logicalDpiX();
 
   if (dataModel->preferences()->rotation() == KVSPrefs::EnumRotation::Landscape ||
       dataModel->preferences()->rotation() == KVSPrefs::EnumRotation::Seascape)
   {
-    return pageCache->sizeOfPage(pageNumber).zoomForWidth(targetPageHeight, device);
+    return pageCache->sizeOfPage(pageNumber).zoomForWidth(targetPageHeight, dpix);
   }
   else
   {
-    return pageCache->sizeOfPage(pageNumber).zoomForHeight(targetPageHeight, \
device); +    return \
pageCache->sizeOfPage(pageNumber).zoomForHeight(targetPageHeight, dpix);  }
 }
 
@@ -600,15 +604,16 @@
   targetPageWidth = (targetViewportWidth - (columns+1) * distanceBetweenWidgets) / \
columns;  
   const QPaintDevice& device = *viewport();
+  const int dpix = QPaintDeviceMetrics(&device).logicalDpiX();
 
   if (dataModel->preferences()->rotation() == KVSPrefs::EnumRotation::Landscape ||
       dataModel->preferences()->rotation() == KVSPrefs::EnumRotation::Seascape)
   {
-    return pageCache->sizeOfPage(pageNumber).zoomForHeight(targetPageWidth, device);
+    return pageCache->sizeOfPage(pageNumber).zoomForHeight(targetPageWidth, dpix);
   }
   else
   {
-    return pageCache->sizeOfPage(pageNumber).zoomForWidth(targetPageWidth, device);
+    return pageCache->sizeOfPage(pageNumber).zoomForWidth(targetPageWidth, dpix);
   }
 }
 
--- branches/work/kviewshell-0.7/kviewshell/shell/presentationwidget.cpp \
#592786:592787 @@ -85,7 +85,7 @@
     DataView::setupObservers(_dataModel);
 
     oldResolution = dataModel->resolution();
-    
+
     // misc stuff
     setMouseTracking( true );
     m_transitionTimer = new QTimer( this );
@@ -453,11 +453,15 @@
         {
           pageSize = pageSize.rotate90();
         }
-        double zoomWidth = pageSize.zoomForWidth(m_width, *this);
-        double zoomHeight = pageSize.zoomForHeight(m_height, *this);
+
+        const int dpix = QPaintDeviceMetrics(this).logicalDpiX();
+        const int dpiy = QPaintDeviceMetrics(this).logicalDpiY();
+
+        double zoomWidth = pageSize.zoomForWidth(m_width, dpix);
+        double zoomHeight = pageSize.zoomForHeight(m_height, dpiy);
         double zoom = QMIN(zoomWidth, zoomHeight);
 
-        dataModel->setResolution(QPaintDeviceMetrics(this).logicalDpiX()*zoom);
+        dataModel->setResolution(dpix * zoom);
         RenderedDocumentPagePixmap* pageData = m_cache->getPage(frame->page, false);
 
         // Prerender the previous and next pages in the rendering thread.
--- branches/work/kviewshell-0.7/kviewshell/shell/simplePageSize.cpp #592786:592787
@@ -11,32 +11,25 @@
 #include "simplePageSize.h"
 #include "kvs_debug.h"
 
-#include <qpaintdevicemetrics.h>
-
-
-double SimplePageSize::zoomForHeight(Q_UINT32 height,
-                                     const QPaintDevice& pd) const
+double SimplePageSize::zoomForHeight(Q_UINT32 height, int dpi) const
 {
   if (!isValid()) {
     kdError(kvs::shell) << "SimplePageSize::zoomForHeight() called when paper height \
was invalid" << endl;  return 0.1;
   }
 
-  const int dpiy = QPaintDeviceMetrics(&pd).logicalDpiY();
-  return double(height) / (dpiy * pageHeight.getLength_in_inch());
+  return double(height) / (dpi * pageHeight.getLength_in_inch());
 }
 
 
-double SimplePageSize::zoomForWidth(Q_UINT32 width,
-                                    const QPaintDevice& pd) const
+double SimplePageSize::zoomForWidth(Q_UINT32 width, int dpi) const
 {
   if (!isValid()) {
     kdError(kvs::shell) << "SimplePageSize::zoomForWidth() called when paper width \
was invalid" << endl;  return 0.1;
   }
 
-  const int dpix = QPaintDeviceMetrics(&pd).logicalDpiX();
-  return double(width) / (dpix * pageWidth.getLength_in_inch());
+  return double(width) / (dpi * pageWidth.getLength_in_inch());
 }
 
 
--- branches/work/kviewshell-0.7/kviewshell/shell/simplePageSize.h #592786:592787
@@ -15,7 +15,6 @@
 
 #include <qsize.h>
 
-class QPaintDevice;
 class QString;
 class QStringList;
 
@@ -90,13 +89,13 @@
   an error message is printed, and an undefined value is returned.
 
   @param height target height in pixels
-  @param device the widget to be printed on.
+  @param dpi of the widget to be printed on.
 
   @returns the zoom value required to scale the page size down to
   'height' pixels. If the pageSize is invalid, an undefined value is
   returned.
   */
-  double zoomForHeight(Q_UINT32 height, const QPaintDevice& device) const;
+  double zoomForHeight(Q_UINT32 height, int dpi) const;
 
   /** \brief Zoom value required to scale to a certain height
 
@@ -106,13 +105,13 @@
   an error message is printed, and an undefined value is returned.
 
   @param width target width in pixels
-  @param device the widget to be printed on.
+  @param dpi of the widget to be printed on.
 
   @returns the zoom value required to scale the page size down to
   'width' pixels. If the pageSize is invalid, an undefined value is
   returned.
   */
-  double zoomForWidth(Q_UINT32 width, const QPaintDevice& device) const;
+  double zoomForWidth(Q_UINT32 width, int dpi) const;
 
   /** \brief Returns a zoom to fit into a certain page size
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic