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

dtrotzjr at crosswire.org dtrotzjr at crosswire.org
Fri Jan 2 16:24:28 MST 2009


Author: dtrotzjr
Date: 2009-01-02 16:24:28 -0700 (Fri, 02 Jan 2009)
New Revision: 186

Modified:
   trunk/src/SwordReader_GUI/SRLexiView.cpp
   trunk/src/SwordReader_GUI/SRLexiView.h
   trunk/src/SwordReader_GUI/SRMainFrame.cpp
   trunk/src/SwordReader_GUI/SRTabbedViews.cpp
   trunk/src/SwordReader_GUI/SRTabbedViews.h
Log:
More dictionary support. Dictionaries can be opened and entries can be displayed. Last opened dictionary and associated entry are remembered upon exit and re-entry of the application. No way to choose a dictionary entry, or switch dictionaries just yet.

Modified: trunk/src/SwordReader_GUI/SRLexiView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiView.cpp	2009-01-02 04:58:40 UTC (rev 185)
+++ trunk/src/SwordReader_GUI/SRLexiView.cpp	2009-01-02 23:24:28 UTC (rev 186)
@@ -4,7 +4,6 @@
 :m_pModule(NULL)
 ,m_fSwordInit(FALSE)
 {
-
 }
 
 
@@ -15,15 +14,33 @@
 
 VOID SRLexiView::SetEntry(const WCString &entry)
 {
-    m_keyEntry.setText(entry.c_str());
+    StrKey newKey(entry.c_str());
+    SWKey *oldKey = m_pModule->getKey();
+
+    if(!oldKey || (*oldKey) == newKey)
+        return;
+    m_pModule->setKey(newKey);
+    m_fEntryChanged = TRUE;
     LoadTextView();
 }
 
+VOID SRLexiView::SetKey(const StrKey &key)
+{
+    SWKey *oldKey = m_pModule->getKey();
+    if(!oldKey || (*oldKey) == key)
+        return;
+    StrKey newKey(key);
+    m_pModule->SetKey(newKey);
+    m_fEntryChanged = TRUE;
+    LoadTextView();
+}
+
 VOID SRLexiView::SetModule(SWModule *pModule)
 {
     if(m_pModule == pModule)
         return;
     m_pModule = pModule;
+    m_pModule->setKey("");
     m_fEntryChanged = TRUE;
     LoadTextView();
 }
@@ -40,23 +57,25 @@
     }
     if(!m_fSwordInit || !m_fEntryChanged)
         return;
-
-    m_pModule->SetKey(m_keyEntry);
-    tmp = m_pModule->RenderText();
+    
+    Clear();
+    
+    tmp = (TCHAR *)m_pModule->RenderText();
     if(tmp.length() == 0){
         tmp = "<b>The current lexicon module (";
         tmp +=  m_pModule->Name();
-        tmp += ") does not have an entry for string \"";
-        tmp += m_keyEntry.getText();
-        tmp += "\"</b>";
+        tmp += ") does not have an entry for given string</b>";
     }else{
         buf += "<b>";
-        buf += m_keyEntry.getText();
-        buf += "</b><br><br>";
+        buf += m_pModule->KeyText();
+        buf += ":</b><br><br>";
     }
     buf += tmp;
     buf += "</body></html>";
     AddText(buf.w_str(), buf.length());
+    
+    m_fEntryChanged = false;
+    RefreshWindow();
 }
 
 VOID SRLexiView::RefreshScreen(BOOL fReloadText)
@@ -78,8 +97,16 @@
         ScrollFullPage(-1);
         break;
     case VK_LEFT:
+        (*m_pModule)--;
+        m_pModule->Error();
+        m_fEntryChanged = true;
+        LoadTextView();
         break;
     case VK_RIGHT:
+        (*m_pModule)++;
+        m_pModule->Error();
+        m_fEntryChanged = true;
+        LoadTextView();
         break;
     default:
         return FALSE;

Modified: trunk/src/SwordReader_GUI/SRLexiView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiView.h	2009-01-02 04:58:40 UTC (rev 185)
+++ trunk/src/SwordReader_GUI/SRLexiView.h	2009-01-02 23:24:28 UTC (rev 186)
@@ -15,16 +15,18 @@
     virtual ~SRLexiView();
 
     VOID        SetEntry(const WCString &entry);
+    VOID        SetKey(const StrKey &key);
     VOID        SetModule(SWModule *pModule);
     VOID        SetSwordReady() { m_fSwordInit = TRUE; }
     VOID        RefreshScreen(BOOL fReloadText);
     BOOL        OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
     VOID        Show();
+    const  SWModule *GetModule() { return m_pModule; }
+    const  SWKey   &GetKey() { return *m_pModule->getKey(); }
 private:
     VOID LoadTextView();
     
     BOOL        m_fEntryChanged;
     BOOL        m_fSwordInit;  
-    StrKey      m_keyEntry;
     SWModule    *m_pModule;
 };
\ No newline at end of file

Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp	2009-01-02 04:58:40 UTC (rev 185)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp	2009-01-02 23:24:28 UTC (rev 186)
@@ -216,13 +216,17 @@
 
     for (it = m_swmgr->Modules.begin(); it != m_swmgr->Modules.end(); it++) {
         curMod = (*it).second;
+        
         if (!strcmp(curMod->Type(), "Biblical Texts")) {
             (*m_modBibles)[curMod->Name()] = curMod;
         }
         if (!strcmp(curMod->Type(), "Commentaries")) {
             (*m_modComms)[curMod->Name()] = curMod;
-            
         }
+        if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
+            (*m_modDicts)[curMod->Name()] = curMod;
+        }
+        
         if (curMod->getConfig().has("Feature", "GreekDef")) {
             m_modGreekLex = curMod;
         }
@@ -362,6 +366,8 @@
     (*m_confOptions)["History"]["LastBiblePassage"] = m_tabViews->GetBibleVerseKey().getText();
     (*m_confOptions)["History"]["LastCommVersion"] = m_tabViews->GetCommModule()->Name();
     (*m_confOptions)["History"]["LastCommPassage"] = m_tabViews->GetCommVerseKey().getText();
+    (*m_confOptions)["History"]["LastDictVersion"] = m_tabViews->GetDictModule()->Name();
+    (*m_confOptions)["History"]["LastDictEntry"] = m_tabViews->GetDictKey().getText();
     sprintf(buff, "%d", m_tabViews->m_tabs.GetCurSel());
     (*m_confOptions)["History"]["LastTabViewed"] = buff;
 
@@ -516,7 +522,9 @@
     SWBuf val;    
     sword::SWModule* bibleMod = NULL;
     sword::SWModule* commMod = NULL;
+    sword::SWModule* dictMod = NULL;
     sword::VerseKey* verse = NULL;
+    sword::StrKey* entry = NULL;
     INT nCurID = 0;
     
     for(int i = 0; i < m_nTotalOpts; i++){
@@ -526,16 +534,22 @@
     }   
     
     bibleMod = m_swmgr->getModule((*m_confOptions)["History"].getWithDefault("LastBibleVersion", "KJV"));
-    if(!bibleMod){
+    if(!bibleMod && m_modBibles){
         bibleMod = m_modBibles->begin()->second;
     }
     m_tabViews->SetBibleModule(bibleMod);
     
     commMod = m_swmgr->getModule((*m_confOptions)["History"].getWithDefault("LastCommVersion", "Clarke"));
-    if(!commMod){
+    if(!commMod && m_modComms){
         commMod = m_modComms->begin()->second;
     }
     m_tabViews->SetCommModule(commMod);
+
+    dictMod = m_swmgr->getModule((*m_confOptions)["History"].getWithDefault("LastDictVersion", "WebstersDict"));
+    if(!dictMod && m_modDicts){
+        dictMod = m_modDicts->begin()->second;
+    }
+    m_tabViews->SetDictModule(dictMod);
     /*REM
     nCurID = MENU_TRANS_START;
     for (ModuleMap::iterator it = m_modTexts->begin(); it != m_modTexts->end(); it++) {
@@ -548,13 +562,18 @@
     */
     INT nLastTab = atoi((*m_confOptions)["History"].getWithDefault("LastTabViewed", "0"));
     m_tabViews->ManualChangeCurrentTab(nLastTab);
+
     verse = new VerseKey((*m_confOptions)["History"].getWithDefault("LastBiblePassage", "Gen 1:1"));
     m_tabViews->SetBibleKey(*verse);
     delete verse;
+    
     verse = new VerseKey((*m_confOptions)["History"].getWithDefault("LastCommPassage", "Gen 1:1"));
     m_tabViews->SetCommKey(*verse);
     delete verse;
     
+    entry = new StrKey((*m_confOptions)["History"].getWithDefault("LastDictEntry", "jeweler"));
+    m_tabViews->SetDictKey(*entry);
+    delete entry;
 }
 
 void SRMainFrame::SetWindowTitle(const WCString &wcsTitle)

Modified: trunk/src/SwordReader_GUI/SRTabbedViews.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2009-01-02 04:58:40 UTC (rev 185)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2009-01-02 23:24:28 UTC (rev 186)
@@ -9,7 +9,8 @@
     m_wcsClassName = "SRTabbedViews";
     m_wcsWindowName = "";
     m_hInstance = SRFramework::SRApp::GetInstanceHandle();
-    m_keyDummy.setText("Gen 1:1", true);
+    m_verseDummy.setText("Gen 1:1", true);
+    m_dictDummy.setText("");
 }
 
 SRTabbedViews::~SRTabbedViews(void)
@@ -145,10 +146,17 @@
 const VerseKey &SRTabbedViews::GetBibleVerseKey()
 {
     if(!m_viewBible)
-        return m_keyDummy;
+        return m_verseDummy;
     return m_viewBible->GetVerseKey();
 }
 
+const SWKey &SRTabbedViews::GetDictKey()
+{
+    if(!m_viewDict)
+        return m_dictDummy;
+    return m_viewDict->GetKey();
+}
+
 VOID SRTabbedViews::SetBibleModule(SWModule *pModule)
 {
     if(m_viewBible)
@@ -162,10 +170,17 @@
     return m_viewComm->GetModule();
 }
 
+const SWModule *SRTabbedViews::GetDictModule()
+{
+    if(!m_viewDict)
+        return NULL;
+    return m_viewDict->GetModule();
+}
+
 const VerseKey &SRTabbedViews::GetCommVerseKey()
 {
     if(!m_viewComm)
-        return m_keyDummy;
+        return m_verseDummy;
     return m_viewComm->GetVerseKey();
 }
 
@@ -175,6 +190,12 @@
         m_viewComm->SetModule(pModule);
 }
 
+VOID SRTabbedViews::SetDictModule(SWModule *pModule)
+{
+    if(m_viewDict)
+        m_viewDict->SetModule(pModule);
+}
+
 VOID SRTabbedViews::SetSwordReady()
 {
     if(m_viewBible)
@@ -269,7 +290,7 @@
 {
     SRModuleView *view = dynamic_cast<SRModuleView *>(GetCurrentView());
     if(!view)
-        return m_keyDummy; // ??? Not a good way to return from this error.
+        return m_verseDummy; // ??? Not a good way to return from this error.
     return view->GetVerseKey();
 }
 
@@ -364,6 +385,12 @@
         m_viewComm->SetKey(verse);
 }
 
+VOID SRTabbedViews::SetDictKey(const StrKey &entry)
+{
+    if(m_viewDict)
+        m_viewDict->SetKey(entry);
+}
+
 BOOL SRTabbedViews::OnNotify(int idCtrl, LPNMHDR pnmh)
 {
     UINT test = TCN_SELCHANGE;

Modified: trunk/src/SwordReader_GUI/SRTabbedViews.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.h	2009-01-02 04:58:40 UTC (rev 185)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.h	2009-01-02 23:24:28 UTC (rev 186)
@@ -25,12 +25,16 @@
     BOOL UpdateWindow();
     const SWModule *GetBibleModule();
     const SWModule *GetCommModule();
+    const SWModule *GetDictModule();
     const VerseKey &GetBibleVerseKey();
     const VerseKey &GetCommVerseKey();
+    const SWKey   &GetDictKey();
     VOID SetBibleModule(SWModule *pModule);
     VOID SetBibleKey(const VerseKey &verse);
     VOID SetCommModule(SWModule *pModule);
     VOID SetCommKey(const VerseKey &verse);
+    VOID SetDictModule(SWModule *pModule);
+    VOID SetDictKey(const StrKey &entry);
     const SWModule *GetCurrentModule();
     VOID SetSwordReady();
     VOID RefreshScreen(BOOL fReloadText);
@@ -59,7 +63,10 @@
     BOOL InitTabs();
     BOOL InitViews();
     SRTextView *GetCurrentView();
-    VerseKey m_keyDummy;
+    // When there is nothing valid to return return these dummy keys.
+    VerseKey m_verseDummy;
+    SWKey  m_dictDummy;
+    
     static BOOL s_fRegistered;
     
     SRModuleView *m_viewBible;




More information about the sword-cvs mailing list