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

dtrotzjr at crosswire.org dtrotzjr at crosswire.org
Sun Feb 1 10:27:17 MST 2009


Author: dtrotzjr
Date: 2009-02-01 10:27:17 -0700 (Sun, 01 Feb 2009)
New Revision: 204

Added:
   trunk/src/SwordReader_GUI/SRScripRefView.cpp
   trunk/src/SwordReader_GUI/SRScripRefView.h
Modified:
   trunk/src/SwordReader_GUI/SRCommWidget.cpp
   trunk/src/SwordReader_GUI/SRCommWidget.h
   trunk/src/SwordReader_GUI/SRTabbedViews.cpp
   trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
Log:
Scripture references are now working for the commentary view.

Modified: trunk/src/SwordReader_GUI/SRCommWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRCommWidget.cpp	2009-02-01 00:16:21 UTC (rev 203)
+++ trunk/src/SwordReader_GUI/SRCommWidget.cpp	2009-02-01 17:27:17 UTC (rev 204)
@@ -1,8 +1,9 @@
 #include "SRCommWidget.h"
+#include <listkey.h>
 
 SRCommWidget::SRCommWidget()
-:m_viewBibleRef(NULL)
-,m_fBibleRefVisible(FALSE)
+:m_viewScripRef(NULL)
+,m_fScripRefVisible(FALSE)
 {
     /*
     m_wcsClassName = "SRCommWidget";
@@ -13,10 +14,10 @@
 
 SRCommWidget::~SRCommWidget()
 {
-    if(m_viewBibleRef)
-        delete m_viewBibleRef;
-    if(m_subWndBibleRef)
-        delete m_subWndBibleRef;
+    if(m_viewScripRef)
+        delete m_viewScripRef;
+    if(m_subWndScripRef)
+        delete m_subWndScripRef;
 }
 
 
@@ -24,8 +25,8 @@
 {
     if(m_viewModule)
         m_viewModule->SetSwordReady();
-    if(m_viewBibleRef)
-        m_viewBibleRef->SetSwordReady();
+    if(m_viewScripRef)
+        m_viewScripRef->SetSwordReady();
 }
 
 BOOL SRCommWidget::Init()
@@ -38,11 +39,11 @@
     if(!m_viewModule || !m_viewModule->Create(this, clientRect))
         return FALSE;
     
-    m_viewBibleRef = new SRModuleView(BibleView);
-    if(!m_viewBibleRef) // Create is handled in the sub-window
+    m_viewScripRef = new SRScripRefView();
+    if(!m_viewScripRef) // Create is handled in the sub-window
         return FALSE;
-    m_subWndBibleRef = new SRSubWindow(m_viewBibleRef);
-    if(!m_subWndBibleRef || !m_subWndBibleRef->Create(this, bibleRect))
+    m_subWndScripRef = new SRSubWindow(m_viewScripRef);
+    if(!m_subWndScripRef || !m_subWndScripRef->Create(this, bibleRect))
         return FALSE;
 
     return TRUE;
@@ -62,44 +63,50 @@
     return FALSE;
 }
 
-VOID SRCommWidget::ShowBibleRefSubWindow()
+VOID SRCommWidget::ShowScripRefSubWindow()
 {
-    if(m_fBibleRefVisible)
+    if(m_fScripRefVisible)
         return;
-    ShowSubWindow(m_subWndBibleRef);
-    m_fBibleRefVisible = TRUE;
+    ShowSubWindow(m_subWndScripRef);
+    m_fScripRefVisible = TRUE;
 }
     
 
-VOID SRCommWidget::ShowBibleRef(SWModule *pModule, const WCString &key)
+VOID SRCommWidget::ShowScripRef(SWModule *pModule, const WCString &key)
 {
-    if(!pModule || !m_viewBibleRef)
+    VerseKey context = m_viewModule->GetVerseKey();
+    ListKey verses = context.ParseVerseList(key.c_str());
+    if(!pModule || !m_viewScripRef)
         return;
-    m_viewBibleRef->SetModule(pModule);
-    m_viewBibleRef->SetKey(key.c_str());
-    if(!m_fBibleRefVisible){
-        ShowBibleRefSubWindow();
+
+    m_viewScripRef->SetModule(pModule);
+    m_viewScripRef->SetKeys(verses);
+    if(!m_fScripRefVisible){
+        ShowScripRefSubWindow();
     }
 }
 
-VOID SRCommWidget::ShowBibleRef(const WCString &key)
+VOID SRCommWidget::ShowScripRef(const WCString &key)
 {
-    if(!m_viewBibleRef)
+    VerseKey context = m_viewModule->GetVerseKey();
+    ListKey verses = context.ParseVerseList(key.c_str());
+    if(!m_viewScripRef)
         return;
-    m_viewBibleRef->SetKey(key.c_str());
-    if(!m_fBibleRefVisible){
-        ShowBibleRefSubWindow();
+
+    m_viewScripRef->SetKeys(verses);
+    if(!m_fScripRefVisible){
+        ShowScripRefSubWindow();
     }
 }
     
 VOID SRCommWidget::HideSubWindow(SRSubWindow *pSubWnd)
 {
     SRModuleWidget::HideSubWindow(pSubWnd);
-    m_fBibleRefVisible = FALSE;
+    m_fScripRefVisible = FALSE;
 }
 
-VOID SRCommWidget::SetBibleRefModule(SWModule *pModule)
+VOID SRCommWidget::SetScripRefModule(SWModule *pModule)
 {
-    if(m_viewBibleRef)
-        m_viewBibleRef->SetModule(pModule);
+    if(m_viewScripRef)
+        m_viewScripRef->SetModule(pModule);
 }
\ No newline at end of file

Modified: trunk/src/SwordReader_GUI/SRCommWidget.h
===================================================================
--- trunk/src/SwordReader_GUI/SRCommWidget.h	2009-02-01 00:16:21 UTC (rev 203)
+++ trunk/src/SwordReader_GUI/SRCommWidget.h	2009-02-01 17:27:17 UTC (rev 204)
@@ -1,5 +1,6 @@
 #pragma once
 #include "SRModuleView.h"
+#include "SRScripRefView.h"
 #include "SRModuleWidget.h"
 #include "SRSubWindow.h"
 #include "swmodule.h"
@@ -12,17 +13,17 @@
     ~SRCommWidget();
     BOOL        Init();
     VOID        Show();
-    VOID        ShowBibleRef(const WCString &note);
+    VOID        ShowScripRef(const WCString &note);
     VOID        HideSubWindow(SRSubWindow *pSubWnd);
-    VOID        ShowBibleRef(SWModule *pModule, const WCString &key);
-    VOID        ShowBibleRefSubWindow();
-    VOID        SetBibleRefModule(SWModule *pModule);
+    VOID        ShowScripRef(SWModule *pModule, const WCString &key);
+    VOID        ShowScripRefSubWindow();
+    VOID        SetScripRefModule(SWModule *pModule);
     VOID        SetSwordReady();
     
     BOOL        OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
 private:
 
-    SRModuleView    *m_viewBibleRef;
-    SRSubWindow     *m_subWndBibleRef;
-    BOOL            m_fBibleRefVisible;
+    SRScripRefView  *m_viewScripRef;
+    SRSubWindow     *m_subWndScripRef;
+    BOOL             m_fScripRefVisible;
 };
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRScripRefView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRScripRefView.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRScripRefView.cpp	2009-02-01 17:27:17 UTC (rev 204)
@@ -0,0 +1,142 @@
+#include "SRScripRefView.h"
+#include "SRFramework/WCString.h"
+#include "SRMainFrame.h"
+#include <string.h>
+
+
+SRScripRefView::SRScripRefView()
+: SRTextView()
+, m_pModule(NULL)
+, m_fSwordInit(FALSE)
+{
+}
+
+SRScripRefView::~SRScripRefView(void)
+{
+}
+
+BOOL SRScripRefView::OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl)
+{
+    if(m_pParentWnd){
+        return m_pParentWnd->OnCommand(wNotifyCode, wID, hWndCtl);
+    }
+    return FALSE;
+}
+
+VOID SRScripRefView::SetModule(SWModule *pModule)
+{
+    if(m_pModule == pModule)
+        return;
+    m_pModule = pModule;
+    LoadTextView();
+}
+
+VOID SRScripRefView::SetKeys(const ListKey &refs)
+{
+    m_refs = refs;
+    LoadTextView();
+}
+
+VOID SRScripRefView::LoadTextView()
+{
+	WCString buf, text, s;
+    SWKey *keyCur;
+    INT nCur = 0;
+
+    if(!m_fSwordInit || !m_refs.Count())
+        return;
+    keyCur = m_refs.getElement(nCur++);
+
+    Clear();
+    buf = "<html><body>";
+    AddText(buf.w_str(), buf.length()); // a <style> section presumably gets skipped
+    
+    while (keyCur) {
+        
+        m_pModule->SetKey(keyCur);
+        int pvHeading = 0;
+        text = (TCHAR *)m_pModule->RenderText();
+        
+        s = "";
+
+        s += GetVerseHeader(SWDYNAMIC_CAST(VerseKey,keyCur));
+        s += text + "<br>";
+		
+        AddText(s.w_str(), s.length());
+        keyCur = m_refs.getElement(nCur++);
+	}
+
+    buf = "</body></html>";
+    AddText(buf.w_str(), buf.length());
+
+    RefreshWindow();
+}
+
+void SRScripRefView::ClearGlobalOptions()
+{/*
+    m_pModule->
+for (int i = 0; i < m_nTotalOpts; i++) {
+            SWBuf val = m_swmgr->getGlobalOption(m_bufModOptions[i]);
+            if ((i + MENU_OPTS_START) == wID) {
+                val = (val == "On") ? "Off" : "On";
+                m_swmgr->setGlobalOption(m_bufModOptions[i], val);
+                m_menuBar->CheckOptionsMenuItem(wID, (val == "On"));
+                m_fChapterChanged = true;
+            }
+        }*/
+}
+
+WCString SRScripRefView::GetVerseHeader(VerseKey* key) const
+{
+    if(!key)
+        return "";
+    wchar_t wverse[16] = {0};
+    wchar_t wchap[16] = {0};
+    _itow(key->Verse(), wverse, 10);
+    _itow(key->Chapter(), wchap, 10);
+
+	WCString result = "\n<b>";
+    result += key->getBookAbbrev();
+	result += wchap;
+	result += ":";
+	result += wverse;
+	result += "</b>&nbsp;";
+
+	return result;
+}
+
+VOID SRScripRefView::RefreshScreen(BOOL fReloadText)
+{
+    LoadTextView();
+}
+
+
+BOOL SRScripRefView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+    INT a = 0;
+    switch(nChar)
+    {
+    case VK_UP:
+        ScrollFullPage(1);
+        break;
+    case VK_DOWN:
+        ScrollFullPage(-1);
+        break;
+    default:
+        return FALSE;
+    }
+    
+    return TRUE;
+}
+
+WCString SRScripRefView::GetWindowTitle()
+{    
+    wchar_t wverse[16] = {0};
+    wchar_t wchapt[16] = {0};
+    if(!m_fSwordInit)
+        return "";
+    WCString title = WCString(m_pModule->Name());
+    
+    return title;
+}
+


Property changes on: trunk/src/SwordReader_GUI/SRScripRefView.cpp
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/src/SwordReader_GUI/SRScripRefView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRScripRefView.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRScripRefView.h	2009-02-01 17:27:17 UTC (rev 204)
@@ -0,0 +1,33 @@
+#pragma once
+#include "SRTextView.h"
+#include <versekey.h>
+#include <swmodule.h>
+
+using namespace sword;
+using namespace SRFramework;
+
+class SRScripRefView :
+    public SRTextView
+{
+public:
+    SRScripRefView();
+    virtual ~SRScripRefView(void);
+
+    BOOL        OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl);
+    
+    VOID        SetModule(SWModule *pModule);
+    VOID        SetKeys(const ListKey &refs);
+    VOID        RefreshScreen(BOOL fReloadText = FALSE);
+    BOOL        OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
+    WCString    GetWindowTitle();
+    const SWModule*   GetModule() { return m_pModule;               }
+    VOID        SetSwordReady() { m_fSwordInit = TRUE; }
+    void        ClearGlobalOptions();
+private:
+    VOID        LoadTextView();
+    WCString    GetVerseHeader(VerseKey *key) const;
+
+    ListKey     m_refs;
+    SWModule    *m_pModule;
+    BOOL        m_fSwordInit;  
+};


Property changes on: trunk/src/SwordReader_GUI/SRScripRefView.h
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/src/SwordReader_GUI/SRTabbedViews.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2009-02-01 00:16:21 UTC (rev 203)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2009-02-01 17:27:17 UTC (rev 204)
@@ -177,7 +177,7 @@
     if(m_viewBible)
         m_viewBible->SetModule(pModule);
     if(m_viewComm)
-        m_viewComm->SetBibleRefModule(pModule);
+        m_viewComm->SetScripRefModule(pModule);
 }
 
 const SWModule *SRTabbedViews::GetCommModule()
@@ -555,5 +555,5 @@
 VOID SRTabbedViews::ShowScriptRef(const WCString &ref)
 {
     if(m_viewComm)
-        m_viewComm->ShowBibleRef(ref);
+        m_viewComm->ShowScripRef(ref);
 }
\ No newline at end of file

Modified: trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
===================================================================
--- trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj	2009-02-01 00:16:21 UTC (rev 203)
+++ trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj	2009-02-01 17:27:17 UTC (rev 204)
@@ -914,6 +914,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\SRScripRefView.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\SRSubWindow.cpp"
 				>
 			</File>
@@ -1051,6 +1055,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\SRScripRefView.h"
+				>
+			</File>
+			<File
 				RelativePath=".\SRSubWindow.h"
 				>
 			</File>
@@ -1136,11 +1144,11 @@
 			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
 			>
 			<File
-				RelativePath="..\gui\BibleReader.ICO"
+				RelativePath=".\BibleReader.ICO"
 				>
 			</File>
 			<File
-				RelativePath=".\BibleReader.ICO"
+				RelativePath="..\gui\BibleReader.ICO"
 				>
 			</File>
 			<File




More information about the sword-cvs mailing list