[sword-svn] r183 - trunk/src/SwordReader_GUI

dtrotzjr at crosswire.org dtrotzjr at crosswire.org
Thu Jan 1 16:44:58 MST 2009


Author: dtrotzjr
Date: 2009-01-01 16:44:58 -0700 (Thu, 01 Jan 2009)
New Revision: 183

Modified:
   trunk/src/SwordReader_GUI/SRFind.h
   trunk/src/SwordReader_GUI/SRTextView.cpp
Log:
Scrolling a full page (i.e. by pressing the nav up/down keys) now scrolls to the top of the line rather than some portion of that line as would happen sometimes depending on the font and line spacing. Partially addresses issue #0000017

Modified: trunk/src/SwordReader_GUI/SRFind.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFind.h	2008-09-22 02:39:40 UTC (rev 182)
+++ trunk/src/SwordReader_GUI/SRFind.h	2009-01-01 23:44:58 UTC (rev 183)
@@ -6,6 +6,7 @@
 #include "SRFramework/SRRadioButton.h"
 #include "SRFramework/SRListBox.h"
 #include "SRFramework/SRProgress.h"
+#include "SRFramework/SRRadioButton.h"
 #include <vector>
 #include <swmodule.h>
 #include <versekey.h>

Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp	2008-09-22 02:39:40 UTC (rev 182)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp	2009-01-01 23:44:58 UTC (rev 183)
@@ -642,6 +642,11 @@
     m_lfCurFont.lfHeight    = lfHeight;
     m_lfCurFont.lfUnderline = lfUnderline;
     
+    if(dwFontCacheIndex < 0 || dwFontCacheIndex >= BTEXT_FONT_CACHE_MAX){
+        ::MessageBox(m_hWnd, L"Error dwFontCacheIndex is out of bounds. This is never supposed to happen. Font change ignored.", L"Error index out of range", MB_OK | MB_ICONERROR);
+        return;
+    }
+    
     if(!m_hFontCache[dwFontCacheIndex]){
         m_hFontCache[dwFontCacheIndex] = CreateFontIndirect(&m_lfCurFont);
     }
@@ -925,11 +930,27 @@
     GetClientRect(m_hWnd,&rectClientRect);
     INT     nRollBy     = rectClientRect.bottom - rectClientRect.top;
     INT     nCalcDist   = 0;
-    CONST INT UPPER_SB  = 15; // Upper bound on the scrolling per iteration.
+    CONST INT UPPER_SB  = 10; // Upper bound on the scrolling per iteration.
     RECT    rectScroll = rectClientRect;
     rectScroll.bottom -= m_wStatusBarHeight;
-    nDirection          = (nDirection > 0) ? 1 : -1;
+    nDirection          = (nDirection > 0) ? 1 : -1; // normalize nDirection
     
+    // Adjust bottom to not scroll on half a line.
+    for(unsigned int line = 0; line <= m_BTLines.m_dwLastLine; line++){
+        SRTextWord *pTWord = &m_BTLines.m_lpLines[line];
+        if(nDirection == -1){
+            if((pTWord->m_rect.top + m_BTLines.m_nLineH + m_nTop) > rectClientRect.bottom){
+                nRollBy = (pTWord->m_rect.top + m_nTop) - rectClientRect.top;
+                break;
+            }
+        }else if(nDirection == 1){
+            if((pTWord->m_rect.top + m_nTop) > (rectClientRect.top - nRollBy)){
+                nRollBy = rectClientRect.bottom - ((pTWord->m_rect.top + m_nTop) + nRollBy);
+                break;
+            }
+        }
+    }
+
     for(INT i = 0;!fDone && i < nRollBy; i+=nCalcDist){
         nCalcDist = UPPER_SB - (int)(UPPER_SB*((float)i/(float)nRollBy)) + 1;
         nDist = nDirection*nCalcDist;




More information about the sword-cvs mailing list