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

dtrotzjr at www.crosswire.org dtrotzjr at www.crosswire.org
Sat Jul 26 17:42:57 MST 2008


Author: dtrotzjr
Date: 2008-07-26 17:42:57 -0700 (Sat, 26 Jul 2008)
New Revision: 157

Modified:
   trunk/src/SwordReader_GUI/SRTextView.cpp
   trunk/src/SwordReader_GUI/SRTextView.h
Log:
Fixed issue 0000020 and also made minor changes to SRTextView in preparation for demand loading.


Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp	2008-07-27 00:03:32 UTC (rev 156)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp	2008-07-27 00:42:57 UTC (rev 157)
@@ -49,6 +49,8 @@
 , m_dwTrueStartPos(0)
 , m_dwTrueStartTime(0)
 , m_hCurFont(NULL)
+, m_dwWordIndex(0)
+, m_fAppended(FALSE)
 {
     m_wcsClassName = "SRTextView";
     m_wcsWindowName = "SwordReader";
@@ -389,6 +391,9 @@
     //      > < & 
     //      and others (later)
     rsState.m_wTotalSpclEnt = 0;
+    
+    if(dwWordIndex > m_dwBuffEnd)
+        return BTEXT_BUFFER_END;
 
     while(m_lpszBuff[dwWordIndex + dwWordEnd] != 0 && m_lpszBuff[dwWordIndex + dwWordEnd] != ' ' && m_lpszBuff[dwWordIndex + dwWordEnd] != '\n' && m_lpszBuff[dwWordIndex + dwWordEnd] != '<'){
         if(m_lpszBuff[dwWordIndex + dwWordEnd] == '&'){
@@ -435,7 +440,7 @@
     rectDims.right          = 0; 
     rectDims.bottom         = 0;
     INT         nLineH      = (INT)(BTEXT_LINE_SPACING*(FLOAT)DrawText(hdc, L" ", 1, &rectDims, DT_CALCRECT | DT_LEFT | DT_BOTTOM | DT_SINGLELINE));
-    DWORD       dwWordIndex = 0;
+    DWORD       dwWordIndex = m_fAppended ? m_dwWordIndex : 0;
     DWORD       dwWordEnd   = 0;
     INT         nSpaceWidth = rectDims.right - rectDims.left;
     INT         nScreenWidth= (m_rect.right - m_rect.left) - BTEXT_MARGIN;
@@ -474,7 +479,7 @@
         if(tmpI++ == 380)
             tmpI = tmpI + 1;
         dwResult = NextWord(rsState, dwWordIndex, dwWordEnd);
-        if(dwWordEnd == 0){
+        if(dwResult == BTEXT_BUFFER_END || dwWordEnd == 0){
             break;
         }
         rectDims.left = nLineX;
@@ -560,6 +565,8 @@
     if(rsState.m_lpftFontTagHead) // Properly formatted text would never need this, but that cannot be assumed.
         delete rsState.m_lpftFontTagHead; // Do not delete Tail it is a convenience pointer...
 
+    m_dwWordIndex = dwWordIndex;
+    m_fAppended = FALSE;
     m_fPreRendered = TRUE;
 }
 
@@ -1160,6 +1167,11 @@
 
 INT SRTextView::SRTextLines::GetVerseAt(INT yPos)
 {
+    // The following fixes problem when chapter starts w/ a heading but does 
+    // not yet have a verse number assigned. 
+    if(yPos == 0)
+        return 1; 
+
     for(DWORD i = 0; i < m_dwLastLine; i++){
         if(!m_lppLinesLastWord[i]->m_lpPrevWord)
             continue; // We hit a blank line (not neccesarrily the end).

Modified: trunk/src/SwordReader_GUI/SRTextView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.h	2008-07-27 00:03:32 UTC (rev 156)
+++ trunk/src/SwordReader_GUI/SRTextView.h	2008-07-27 00:42:57 UTC (rev 157)
@@ -63,6 +63,8 @@
 #define BTEXT_NEWLINE_ENCOUNTERED   -1
 //! Flag indicating we have encountered an opening bracket for HTML processing.
 #define BTEXT_HTML_OPEN_BRACKET     -2
+//! Flag indicating the end of the buffer has been reached.
+#define BTEXT_BUFFER_END            -3
 
 //! Flag indicating a &lt;br&gt; element was encountered
 #define BTEXT_HTML_BR               0x00000001
@@ -723,6 +725,12 @@
     //! Indicates whether the text stream has been pre-rendered according to 
     //! the current window layout.
     BOOL                        m_fPreRendered;
+    //! Indicates that we have some appended text to be pre-rendered.
+    // If false then the entire buffer is pre-rendered, otherwise only
+    // the portion starting at m_dwWordIndex
+    BOOL                        m_fAppended;
+    //! Where to start pre-rendering at if the flag m_fAppended is true.
+    INT                         m_dwWordIndex;
 
     static BOOL                 s_fRegistered;
 




More information about the sword-cvs mailing list