[sword-svn] r131 - in trunk/src: Dll1 SwordReader_GUI

dtrotzjr at www.crosswire.org dtrotzjr at www.crosswire.org
Tue May 20 13:30:23 MST 2008


Author: dtrotzjr
Date: 2008-05-20 13:30:22 -0700 (Tue, 20 May 2008)
New Revision: 131

Modified:
   trunk/src/Dll1/Dll1.vcp
   trunk/src/SwordReader_GUI/SRMainFrame.cpp
   trunk/src/SwordReader_GUI/SRMainFrame.h
   trunk/src/SwordReader_GUI/SRMenuBar.cpp
   trunk/src/SwordReader_GUI/SRMenuBar.h
   trunk/src/SwordReader_GUI/SRTextView.cpp
   trunk/src/SwordReader_GUI/SRTextView.h
Log:
Everything except the Find dialog is at the same point (functionally) as it was prior to the rewrite/restructure. 

Modified: trunk/src/Dll1/Dll1.vcp
===================================================================
--- trunk/src/Dll1/Dll1.vcp	2008-05-20 18:12:56 UTC (rev 130)
+++ trunk/src/Dll1/Dll1.vcp	2008-05-20 20:30:22 UTC (rev 131)
@@ -4385,12 +4385,14 @@
 	"..\..\..\sword\include\defs.h"\
 	"..\..\..\sword\include\listkey.h"\
 	"..\..\..\sword\include\osisplain.h"\
+	"..\..\..\sword\include\stringmgr.h"\
 	"..\..\..\sword\include\swbasicfilter.h"\
 	"..\..\..\sword\include\swbuf.h"\
 	"..\..\..\sword\include\swfilter.h"\
 	"..\..\..\sword\include\swkey.h"\
 	"..\..\..\sword\include\swmacs.h"\
 	"..\..\..\sword\include\swobject.h"\
+	"..\..\..\sword\include\utilstr.h"\
 	"..\..\..\sword\include\utilxml.h"\
 	"..\..\..\sword\include\versekey.h"\
 	
@@ -4433,12 +4435,14 @@
 	"..\..\..\sword\include\defs.h"\
 	"..\..\..\sword\include\listkey.h"\
 	"..\..\..\sword\include\osisplain.h"\
+	"..\..\..\sword\include\stringmgr.h"\
 	"..\..\..\sword\include\swbasicfilter.h"\
 	"..\..\..\sword\include\swbuf.h"\
 	"..\..\..\sword\include\swfilter.h"\
 	"..\..\..\sword\include\swkey.h"\
 	"..\..\..\sword\include\swmacs.h"\
 	"..\..\..\sword\include\swobject.h"\
+	"..\..\..\sword\include\utilstr.h"\
 	"..\..\..\sword\include\utilxml.h"\
 	"..\..\..\sword\include\versekey.h"\
 	
@@ -5284,6 +5288,97 @@
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\..\sword\src\modules\filters\teihtmlhref.cpp
+
+!IF  "$(CFG)" == "Dll1 - Win32 (WCE ARM) Release"
+
+DEP_CPP_TEIHT=\
+	"..\..\..\sword\include\defs.h"\
+	"..\..\..\sword\include\listkey.h"\
+	"..\..\..\sword\include\multimapwdef.h"\
+	"..\..\..\sword\include\swbasicfilter.h"\
+	"..\..\..\sword\include\swbuf.h"\
+	"..\..\..\sword\include\swcacher.h"\
+	"..\..\..\sword\include\swconfig.h"\
+	"..\..\..\sword\include\swdisp.h"\
+	"..\..\..\sword\include\swfilter.h"\
+	"..\..\..\sword\include\swkey.h"\
+	"..\..\..\sword\include\swmodule.h"\
+	"..\..\..\sword\include\swobject.h"\
+	"..\..\..\sword\include\swsearchable.h"\
+	"..\..\..\sword\include\teihtmlhref.h"\
+	"..\..\..\sword\include\url.h"\
+	"..\..\..\sword\include\utilxml.h"\
+	
+
+!ELSEIF  "$(CFG)" == "Dll1 - Win32 (WCE ARM) Debug"
+
+DEP_CPP_TEIHT=\
+	"..\..\..\sword\include\defs.h"\
+	"..\..\..\sword\include\listkey.h"\
+	"..\..\..\sword\include\multimapwdef.h"\
+	"..\..\..\sword\include\swbasicfilter.h"\
+	"..\..\..\sword\include\swbuf.h"\
+	"..\..\..\sword\include\swcacher.h"\
+	"..\..\..\sword\include\swconfig.h"\
+	"..\..\..\sword\include\swdisp.h"\
+	"..\..\..\sword\include\swfilter.h"\
+	"..\..\..\sword\include\swkey.h"\
+	"..\..\..\sword\include\swmodule.h"\
+	"..\..\..\sword\include\swobject.h"\
+	"..\..\..\sword\include\swsearchable.h"\
+	"..\..\..\sword\include\teihtmlhref.h"\
+	"..\..\..\sword\include\url.h"\
+	"..\..\..\sword\include\utilxml.h"\
+	
+
+!ELSEIF  "$(CFG)" == "Dll1 - Win32 (WCE x86) Release"
+
+DEP_CPP_TEIHT=\
+	"..\..\..\sword\include\defs.h"\
+	"..\..\..\sword\include\listkey.h"\
+	"..\..\..\sword\include\multimapwdef.h"\
+	"..\..\..\sword\include\swbasicfilter.h"\
+	"..\..\..\sword\include\swbuf.h"\
+	"..\..\..\sword\include\swcacher.h"\
+	"..\..\..\sword\include\swconfig.h"\
+	"..\..\..\sword\include\swdisp.h"\
+	"..\..\..\sword\include\swfilter.h"\
+	"..\..\..\sword\include\swkey.h"\
+	"..\..\..\sword\include\swmodule.h"\
+	"..\..\..\sword\include\swobject.h"\
+	"..\..\..\sword\include\swsearchable.h"\
+	"..\..\..\sword\include\teihtmlhref.h"\
+	"..\..\..\sword\include\url.h"\
+	"..\..\..\sword\include\utilxml.h"\
+	
+
+!ELSEIF  "$(CFG)" == "Dll1 - Win32 (WCE x86) Debug"
+
+DEP_CPP_TEIHT=\
+	"..\..\..\sword\include\defs.h"\
+	"..\..\..\sword\include\listkey.h"\
+	"..\..\..\sword\include\multimapwdef.h"\
+	"..\..\..\sword\include\swbasicfilter.h"\
+	"..\..\..\sword\include\swbuf.h"\
+	"..\..\..\sword\include\swcacher.h"\
+	"..\..\..\sword\include\swconfig.h"\
+	"..\..\..\sword\include\swdisp.h"\
+	"..\..\..\sword\include\swfilter.h"\
+	"..\..\..\sword\include\swkey.h"\
+	"..\..\..\sword\include\swmodule.h"\
+	"..\..\..\sword\include\swobject.h"\
+	"..\..\..\sword\include\swsearchable.h"\
+	"..\..\..\sword\include\teihtmlhref.h"\
+	"..\..\..\sword\include\url.h"\
+	"..\..\..\sword\include\utilxml.h"\
+	
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\..\sword\src\modules\filters\teiplain.cpp
 
 !IF  "$(CFG)" == "Dll1 - Win32 (WCE ARM) Release"
@@ -8593,6 +8688,7 @@
 	"..\..\..\sword\include\swmodule.h"\
 	"..\..\..\sword\include\swobject.h"\
 	"..\..\..\sword\include\swsearchable.h"\
+	"..\..\..\sword\include\teihtmlhref.h"\
 	"..\..\..\sword\include\teiplain.h"\
 	"..\..\..\sword\include\teirtf.h"\
 	"..\..\..\sword\include\thmlgbf.h"\
@@ -8728,6 +8824,7 @@
 	"..\..\..\sword\include\swmodule.h"\
 	"..\..\..\sword\include\swobject.h"\
 	"..\..\..\sword\include\swsearchable.h"\
+	"..\..\..\sword\include\teihtmlhref.h"\
 	"..\..\..\sword\include\teiplain.h"\
 	"..\..\..\sword\include\teirtf.h"\
 	"..\..\..\sword\include\thmlgbf.h"\
@@ -10330,6 +10427,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\..\sword\include\teihtmlhref.h
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\..\sword\include\thmlfootnotes.h
 # End Source File
 # Begin Source File

Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp	2008-05-20 18:12:56 UTC (rev 130)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp	2008-05-20 20:30:22 UTC (rev 131)
@@ -117,11 +117,8 @@
     if(!m_viewText->Create(this, view_rect))
         return FALSE;
     m_viewText->Show();
+    LoadTextView();
     
-    /* The following should be removed... */
-    WCString test_str = "This is a <b>test</b>. It worked?";
-    m_viewText->AddText(test_str.w_str(),test_str.length());
-
     m_viewBook = new SRBookChooser(s_wcsBookNames,MENU_CHAP);
     if(!m_viewBook->Create(this, view_rect))
         return FALSE;
@@ -195,11 +192,11 @@
 
     m_keyCurVerse = new VerseKey((*m_confOptions)["History"].getWithDefault("LastPassage", "Gen 1:1"));
 
-    if(!m_menuBar || !m_menuBar->FillTranslationsSubMenu(m_modTexts,MENU_TRANS_START))
+    if(!m_menuBar || !m_menuBar->FillTranslationsSubMenu(m_modTexts, m_modCurText, MENU_TRANS_START))
         return FALSE;
     
-    GetSupportedOptions();
-    if(!m_menuBar->FillOptionsSubMenu(m_bufModOptions,MENU_OPTS_START, m_nTotalOpts))
+    // Gets the supported global options and fills the options sub menu.
+    if(!GetSupportedOptions())
         return FALSE;
 
     return TRUE;
@@ -219,8 +216,9 @@
 	PostThreadMessage(g_tMain, WM_TXT_START, NULL, NULL);
     */
     m_viewText->Clear();
-    //VerseKey keyCur(m_keyCurVerse);
-    m_keyCurVerse->Verse(1);
+    VerseKey keyCur(m_keyCurVerse);
+    //m_keyCurVerse->Verse(1);
+    keyCur.Verse(1);
     WCString buf = "";//"<html><head><meta name=\"MobileOptimized\" content=\"240\"><title></title></head><body>";
 
     m_viewText->AddText(buf.w_str(), buf.length()); // a <style> section presumably gets skipped
@@ -228,8 +226,9 @@
 	WCString heading;
 	char strNum[10];
 	while (true) {
-        m_modCurText->SetKey(m_keyCurVerse);
-		int pvHeading = 0;
+        //m_modCurText->SetKey(m_keyCurVerse);
+		m_modCurText->SetKey(keyCur);
+        int pvHeading = 0;
 		do {
 			sprintf(strNum, "%i", pvHeading++);
             SWBuf preverseHeading = m_modCurText->getEntryAttributes()["Heading"]["Preverse"][strNum].c_str();
@@ -241,24 +240,28 @@
 			}
 			else break;
 		} while (true);
-        s = GetVerseHeader(*m_keyCurVerse);
+        //s = GetVerseHeader(*m_keyCurVerse);
+        s = GetVerseHeader(keyCur);
         s += (TCHAR *)m_modCurText->RenderText();
         s += " "; // Many verses do not have a space after them.
 		if (s.length() > 0) {
             // If the following failed it was due to a bad tag in this verse. 
             // Use the stripped version instead.
             if(!m_viewText->AddText(s.w_str(), s.length())){ 
-                s = GetVerseHeader(*m_keyCurVerse);
+                //s = GetVerseHeader(*m_keyCurVerse);
+                s = GetVerseHeader(keyCur);
                 s += (TCHAR *)m_modCurText->StripText();
                 s += " "; // Many verses do not have a space after them. 
                 m_viewText->AddText(s.w_str(), s.length());
             }
 
 		}
-        if (m_keyCurVerse->Verse() == GetMaxVerses())
+        //if (m_keyCurVerse->Verse() == GetMaxVerses())
+        if (keyCur.Verse() == GetMaxVerses())
 			break;
 		else
-            m_keyCurVerse->increment(1);
+            //m_keyCurVerse->increment(1);
+            keyCur.increment(1);
 	}
     buf = "</body></html>";
     m_viewText->AddText(buf.w_str(), buf.length());
@@ -275,6 +278,7 @@
 	*/
 
     m_viewText->RefreshWindow();
+    m_viewText->ScrollToVerse(m_keyCurVerse->Verse());
 }
 
 
@@ -383,11 +387,12 @@
 
 }
 
-void SRMainFrame::GetSupportedOptions()
+BOOL SRMainFrame::GetSupportedOptions()
 {
     StringList optionNames = m_swmgr->getGlobalOptions();
     StringList::iterator i;
     bool fSupported = true;
+    bool *pfOptsState = NULL;
     StringList optionValues;
     INT optionIndex = 0;
 
@@ -408,6 +413,7 @@
     }
 
     m_bufModOptions = new SWBuf[m_nTotalOpts];
+    pfOptsState = new bool[m_nTotalOpts];
 
     // place the options
     for (i = optionNames.begin(); i != optionNames.end(); i++) {
@@ -416,11 +422,19 @@
         for (StringList::iterator j = optionValues.begin(); j != optionValues.end(); j++) {
             if ((*j != "On") && (*j != "Off"))
                 fSupported = false;
+
         }
-        if (fSupported) {
+        if (fSupported) {           
+            pfOptsState[optionIndex] = strcmp(m_swmgr->getGlobalOption(*i), "On") == 0;
             m_bufModOptions[optionIndex++] = *i;
         }
-    }
+    }    
+    
+    if(!m_menuBar->FillOptionsSubMenu(m_bufModOptions, pfOptsState, MENU_OPTS_START, m_nTotalOpts))
+        return FALSE;
+
+    delete [] pfOptsState;
+    return TRUE;
 }
 
 void SRMainFrame::ToggleOption(WORD wID)

Modified: trunk/src/SwordReader_GUI/SRMainFrame.h
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.h	2008-05-20 18:12:56 UTC (rev 130)
+++ trunk/src/SwordReader_GUI/SRMainFrame.h	2008-05-20 20:30:22 UTC (rev 131)
@@ -32,7 +32,7 @@
     BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl);
 
     void SelectModule(INT nModIndex);
-    void GetSupportedOptions();
+    BOOL GetSupportedOptions();
     void ToggleOption(WORD wID);
     
     // Sword related

Modified: trunk/src/SwordReader_GUI/SRMenuBar.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMenuBar.cpp	2008-05-20 18:12:56 UTC (rev 130)
+++ trunk/src/SwordReader_GUI/SRMenuBar.cpp	2008-05-20 20:30:22 UTC (rev 131)
@@ -44,18 +44,22 @@
     return TRUE;
 }
 
-BOOL SRMenuBar::FillTranslationsSubMenu(ModuleMap *texts, int nStartID)
+BOOL SRMenuBar::FillTranslationsSubMenu(ModuleMap *texts, const SWModule *modCurr, int nStartID)
 {
     int nCurID = nStartID;
     m_nTotalTrans = 0;
 	for (ModuleMap::iterator i = texts->begin(); i != texts->end(); i++) {
-        m_menuTrans->AppendMenu(0, nCurID++, i->first);        	    
+        m_menuTrans->AppendMenu(0, nCurID, i->first);  
         m_nTotalTrans++;
+        if(i->second == modCurr){
+            CheckTranslationsMenuItem(nCurID);
+        }
+        nCurID++;
     }
     return TRUE;
 }
 
-BOOL SRMenuBar::FillOptionsSubMenu(SWBuf *bufOpts, int nStartID, int nTotalOpts)
+BOOL SRMenuBar::FillOptionsSubMenu(SWBuf *bufOpts, bool *fOptsState, int nStartID, int nTotalOpts)
 {
 	int nCurID = nStartID;
 
@@ -63,7 +67,9 @@
         m_nTotalOpts = nTotalOpts;
         // count the supported options
         for (int i = 0; i < m_nTotalOpts; i++){
-            m_menuOpts->AppendMenu(0,nCurID++, (bufOpts[i]).c_str());
+            m_menuOpts->AppendMenu(0,nCurID, (bufOpts[i]).c_str());
+            m_menuOpts->CheckMenuItem(nCurID, fOptsState[i] ? MF_CHECKED : MF_UNCHECKED);
+            nCurID++;
         }
 	}
 	// TODO: if no options, disable options menu

Modified: trunk/src/SwordReader_GUI/SRMenuBar.h
===================================================================
--- trunk/src/SwordReader_GUI/SRMenuBar.h	2008-05-20 18:12:56 UTC (rev 130)
+++ trunk/src/SwordReader_GUI/SRMenuBar.h	2008-05-20 20:30:22 UTC (rev 131)
@@ -14,8 +14,8 @@
 {
 public:
     BOOL Create(SRWnd* pWndParent, UINT nBarID);
-    BOOL FillTranslationsSubMenu(ModuleMap *texts, int nStartID);
-    BOOL FillOptionsSubMenu(SWBuf *bufOpts, int nStartID, int nTotalOpts);
+    BOOL FillTranslationsSubMenu(ModuleMap *texts, const SWModule *modCurr, int nStartID);
+    BOOL FillOptionsSubMenu(SWBuf *bufOpts, bool *fOptsState, int nStartID, int nTotalOpts);
     BOOL CheckTranslationsMenuItem(UINT nIDCheckItem);
     BOOL CheckOptionsMenuItem(UINT nIDCheckItem, BOOL fChecked);
     INT  GetTotalTranslations() { return m_nTotalTrans; }

Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp	2008-05-20 18:12:56 UTC (rev 130)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp	2008-05-20 20:30:22 UTC (rev 131)
@@ -504,6 +504,7 @@
         thisWord.m_dwHrefLen        = rsState.m_dwHrefLen;
         thisWord.m_dwlWordNum       = rsState.m_dwlWordNum;
         thisWord.m_dwSubWordNum     = rsState.m_dwSubWordNum;
+        thisWord.m_wVerseNum        = rsState.m_wVerseNum;
         // Determine if we encountered any special entities...
         if(rsState.m_wTotalSpclEnt > 0){
             InterpretSpecialEntities(dwWordIndex, dwWordEnd, &thisWord);
@@ -878,6 +879,29 @@
     }
 }
 
+VOID SRTextView::ScrollToPosition(INT yPos)
+{
+    POINT   pt;
+    RECT    rectUpdateRect;
+    INT     nDragDist = 0;
+
+    if( yPos >= 0){
+        pt.x = 0;
+        pt.y = yPos;
+        nDragDist = m_nTop - pt.y;
+        m_nTop = -pt.y;
+
+        ScrollWindowEx(m_hWnd, 0, nDragDist, NULL, NULL, NULL, &rectUpdateRect, NULL);
+        InvalidateRect(m_hWnd, &rectUpdateRect, TRUE);
+        ::UpdateWindow(m_hWnd);
+    }
+}
+
+VOID SRTextView::ScrollToVerse(WORD wVerseNum)
+{
+    ScrollToPosition(m_BTLines.GetVersePosition(wVerseNum));
+}
+
 BOOL SRTextView::AddText(const TCHAR *szText, DWORD dwSize)
 {
     DWORD i = 0;
@@ -1016,6 +1040,7 @@
     m_rect          = rhs.m_rect;
     m_dwlWordNum    = rhs.m_dwlWordNum;
     m_dwSubWordNum  = rhs.m_dwSubWordNum;
+    m_wVerseNum     = rhs.m_wVerseNum;
 
     if(m_fOwner && rhs.m_lpszWord){
         m_lpszWord = new TCHAR[m_dwWordLen + 1];
@@ -1040,6 +1065,7 @@
     m_rect          = rhs.m_rect;
     m_dwlWordNum    = rhs.m_dwlWordNum;
     m_dwSubWordNum  = rhs.m_dwSubWordNum;
+    m_wVerseNum     = rhs.m_wVerseNum;
 
     if(m_fOwner && m_lpszWord)
         delete [] m_lpszWord;
@@ -1098,6 +1124,15 @@
     }
 }
 
+INT SRTextView::SRTextLines::GetVersePosition(WORD wVerseNum)
+{
+    for(INT i = 0; i < m_dwLastLine; i++){
+        if(m_lppLinesLastWord[i]->m_lpPrevWord->m_wVerseNum == wVerseNum)
+            return m_lppLinesLastWord[i]->m_lpPrevWord->m_rect.top;
+    }
+    return -1;
+}
+
 SRTextView::SRTextLines & SRTextView::SRTextLines::operator=(CONST SRTextView::SRTextLines &rhs)
 {
     if(this == &rhs)

Modified: trunk/src/SwordReader_GUI/SRTextView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.h	2008-05-20 18:12:56 UTC (rev 130)
+++ trunk/src/SwordReader_GUI/SRTextView.h	2008-05-20 20:30:22 UTC (rev 131)
@@ -199,8 +199,8 @@
         //! @endcode
         DWORDLONG       m_dwlfFontState;
 
-				//! Indicates that this SRTextWord object should manage the memory
-				//! pointed to by m_lpszWord.
+		//! Indicates that this SRTextWord object should manage the memory
+		//! pointed to by m_lpszWord.
         //! There are times when this SRTextWord needs to clean up the 
         //! character allocation it points to, such as when Special
         //! Entities are interpreted and stored separately from the main
@@ -220,6 +220,8 @@
         DWORDLONG       m_dwlWordNum;
         //! Indicates which piece of a word this word is (most often it will be 0)
         DWORD           m_dwSubWordNum;
+        //! Indicates what verse this word belongs to.
+        WORD            m_wVerseNum;
     };
 
     //! SRTextLines - Stores all the words in an array of lines.
@@ -281,6 +283,11 @@
         			rightmost extent is returned instead.
          */
         INT     ValidateNewLineWord(CONST DWORDLONG dwlWordNum,CONST INT nLineH, CONST INT nMargin);
+        //! Returns the y coordinate for the given verse number.
+        /*! @param nVerseNum
+            @return the y coordinate of the verse number, -1 otherwise.
+        */
+        INT     GetVersePosition(WORD wVerseNum);
         //! Indicates the total number of lines currently allocated.
         DWORD           m_dwLines;
         //! Indicates the last line actually being used,
@@ -421,6 +428,14 @@
         \endcode
      */
     VOID    ScrollFullPage(INT nDirection);
+    //! Scrolls the window to a given y position.
+    /*! @param yPos the y position to scroll to.
+    */
+    VOID    ScrollToPosition(INT yPos);
+    //! Scrolls the window to a specific verse.
+    /*! @param wVerseNum the verse to scroll to.
+    */
+    VOID    ScrollToVerse(WORD wVerseNum);
     //! Shows the window control.
     //! Calls ShowWindow with the SW_SHOW parameter for the underlying window.
     VOID    Show();




More information about the sword-cvs mailing list