[sword-svn] r188 - in trunk/src/SwordReader_GUI: . SRFramework

dtrotzjr at crosswire.org dtrotzjr at crosswire.org
Fri Jan 2 21:05:48 MST 2009


Author: dtrotzjr
Date: 2009-01-02 21:05:48 -0700 (Fri, 02 Jan 2009)
New Revision: 188

Added:
   trunk/src/SwordReader_GUI/SRFramework/SRLabel.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRLabel.h
   trunk/src/SwordReader_GUI/SRLexiWidget.cpp
   trunk/src/SwordReader_GUI/SRLexiWidget.h
Modified:
   trunk/src/SwordReader_GUI/SRFramework/SRComboBox.h
   trunk/src/SwordReader_GUI/SRLexiView.h
   trunk/src/SwordReader_GUI/SRMainFrame.cpp
   trunk/src/SwordReader_GUI/SRTabbedViews.cpp
   trunk/src/SwordReader_GUI/SRTabbedViews.h
   trunk/src/SwordReader_GUI/SRTextView.h
   trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
Log:
More dictionary work. Almost there. This commit builds but does not run as the FillDictEntries needs to be smarter about what to fill.

Modified: trunk/src/SwordReader_GUI/SRFramework/SRComboBox.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRComboBox.h	2009-01-03 00:04:27 UTC (rev 187)
+++ trunk/src/SwordReader_GUI/SRFramework/SRComboBox.h	2009-01-03 04:05:48 UTC (rev 188)
@@ -9,7 +9,7 @@
     public:
         SRComboBox(VOID);
         virtual ~SRComboBox(VOID);
-        BOOL Create(SRWnd *pParentWnd, RECT bounds, INT nChildID = NULL, DWORD dwStyle = WS_CHILD | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_NOTIFY | WS_BORDER | LBS_NOINTEGRALHEIGHT);
+        BOOL Create(SRWnd *pParentWnd, RECT bounds, INT nChildID = NULL, DWORD dwStyle = WS_CHILD | WS_BORDER | CBS_DROPDOWN | WS_VSCROLL);
         // Does not need to be registered the call to InitCommonControlsEx 
         // does that for us. 
         BOOL Register() { return TRUE; } 

Added: trunk/src/SwordReader_GUI/SRFramework/SRLabel.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRLabel.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRLabel.cpp	2009-01-03 04:05:48 UTC (rev 188)
@@ -0,0 +1,45 @@
+#include "SRLabel.h"
+#include "SRApp.h"
+#include <commctrl.h>
+
+using namespace SRFramework;
+
+
+SRLabel::SRLabel(const WCString &label)
+{
+    m_hInstance = SRFramework::SRApp::GetInstanceHandle();
+    m_wcsClassName = "static";
+    m_wcsWindowName = label;
+}
+
+SRLabel::~SRLabel(void)
+{
+
+}
+
+BOOL SRLabel::Create(SRWnd *pParentWnd, RECT bounds, INT nChildID, DWORD dwStyle)
+{
+    if(!Register())
+        return FALSE;
+    if(!SRWnd::Create(m_wcsClassName,m_wcsWindowName, dwStyle, bounds, pParentWnd, (HMENU)nChildID, m_hInstance))
+        return FALSE;
+    
+    return TRUE;
+}
+
+WCString SRLabel::GetText()
+{
+    TCHAR *strQuery = NULL;
+    INT nQueryLen = ::SendMessage(m_hWnd, WM_GETTEXTLENGTH, NULL, NULL) + 1;
+    strQuery = new TCHAR[nQueryLen];
+    ::SendMessage(m_hWnd,WM_GETTEXT,(WPARAM)nQueryLen,(LPARAM)strQuery);
+    strQuery[nQueryLen - 1] = 0; // in case the buffer was exceeded
+    return strQuery;
+}
+
+BOOL SRLabel::SetText(const WCString &label)
+{
+    return ::SendMessage(m_hWnd, WM_SETTEXT, NULL, (LPARAM)label.w_str());
+}
+
+


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

Added: trunk/src/SwordReader_GUI/SRFramework/SRLabel.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRLabel.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRLabel.h	2009-01-03 04:05:48 UTC (rev 188)
@@ -0,0 +1,21 @@
+#pragma once
+#include "SRWnd.h"
+#include "WCString.h"
+#include <commctrl.h>
+
+namespace SRFramework{
+
+    class SRLabel : public SRFramework::SRWnd
+    {
+    public:
+        SRLabel(const WCString &label = "");
+        virtual ~SRLabel(VOID);
+        BOOL Create(SRWnd *pParentWnd, RECT bounds, INT nChildID = NULL, DWORD dwStyle = WS_CHILD | SS_LEFT | WS_TABSTOP);
+        // Does not need to be registered the call to InitCommonControlsEx 
+        // does that for us. 
+        BOOL Register() { return TRUE; } 
+        WCString GetText();
+        BOOL SetText(const WCString &label);
+    };
+
+}
\ No newline at end of file


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

Modified: trunk/src/SwordReader_GUI/SRLexiView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiView.h	2009-01-03 00:04:27 UTC (rev 187)
+++ trunk/src/SwordReader_GUI/SRLexiView.h	2009-01-03 04:05:48 UTC (rev 188)
@@ -21,7 +21,7 @@
     VOID        RefreshScreen(BOOL fReloadText);
     BOOL        OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
     VOID        Show();
-    const  SWModule *GetModule() { return m_pModule; }
+    SWModule *GetModule() { return m_pModule; }
     const  SWKey   &GetKey() { return *m_pModule->getKey(); }
 private:
     VOID LoadTextView();

Added: trunk/src/SwordReader_GUI/SRLexiWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiWidget.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRLexiWidget.cpp	2009-01-03 04:05:48 UTC (rev 188)
@@ -0,0 +1,153 @@
+
+#include "SRLexiWidget.h"
+#include "SRFramework\SRApp.h"
+#include "swmodule.h"
+#include "swkey.h"
+
+using namespace SRFramework;
+
+BOOL SRLexiWidget::s_fRegistered = false;
+
+SRLexiWidget::SRLexiWidget(void)
+:m_cmbDictEntry(NULL)
+,m_viewLexi(NULL)
+,m_keyDummy("")
+{
+    m_wcsClassName = "SRLexiWidget";
+    m_wcsWindowName = "";
+    m_hInstance = SRFramework::SRApp::GetInstanceHandle();
+
+}
+
+SRLexiWidget::~SRLexiWidget(void)
+{
+
+}
+
+BOOL SRLexiWidget::Create(SRWnd *pParentWnd, RECT bounds)
+{
+    if(!Register())
+        return FALSE;
+
+    if(!SRWnd::Create(m_wcsClassName,m_wcsWindowName,WS_CHILD | WS_VISIBLE, bounds, pParentWnd, NULL, m_hInstance))
+        return FALSE;
+
+
+    return TRUE;
+}
+
+BOOL SRLexiWidget::Register()
+{
+    // Register window class...
+    WNDCLASS    wc;
+    if(s_fRegistered)
+        return TRUE;
+
+    wc.style            = CS_HREDRAW | CS_VREDRAW | CS_PARENTDC;
+    wc.lpfnWndProc      = (WNDPROC) MessageRoute;
+    wc.cbClsExtra       = 0;
+    wc.cbWndExtra       = 0;
+    wc.hInstance        = m_hInstance;
+    wc.hIcon            = NULL;
+    wc.hCursor          = 0;
+    wc.hbrBackground    = (HBRUSH) GetStockObject(WHITE_BRUSH);
+    wc.lpszMenuName     = 0;
+    wc.lpszClassName    = m_wcsClassName.w_str();
+
+    if(RegisterClass(&wc) == 0) 
+        return FALSE;
+    
+    s_fRegistered = TRUE;
+
+    return TRUE;
+}
+
+BOOL SRLexiWidget::Init()
+{
+    RECT lblRect = m_rect;
+    RECT cmbRect = m_rect;
+    RECT viewRect = m_rect;
+    lblRect.right = 60;
+    cmbRect.left = 60;
+    cmbRect.bottom = 60;
+    lblRect.bottom = 20;
+    viewRect.top = 20;
+    
+    m_lblEntry = new SRLabel("Lookup:");
+    if(!m_lblEntry || !m_lblEntry->Create(this, lblRect))
+        return FALSE;
+    m_lblEntry->Show();
+
+    m_cmbDictEntry = new SRComboBox();
+    if(!m_cmbDictEntry || !m_cmbDictEntry->Create(this, cmbRect))
+        return FALSE;
+    m_cmbDictEntry->Show();
+
+    m_viewLexi = new SRLexiView();
+    if(!m_viewLexi || !m_viewLexi->Create(this, viewRect))
+        return FALSE;
+    m_viewLexi->Show();
+    
+    return TRUE;
+}
+
+VOID SRLexiWidget::FillDictEntries()
+{
+    if(!m_cmbDictEntry)
+        return;
+    SWModule *pModule = m_viewLexi->GetModule();
+    if(!pModule)
+        return;
+    pModule->setKey("");
+    pModule->Error();
+    while(!pModule->Error()){
+        m_cmbDictEntry->AddItem(pModule->getKeyText());
+        (*pModule)++;
+    }
+}
+
+const SWKey &SRLexiWidget::GetKey()
+{
+    if(!m_viewLexi)
+        return m_keyDummy;
+    return m_viewLexi->GetKey();
+}
+
+const SWModule *SRLexiWidget::GetModule()
+{
+    if(!m_viewLexi)
+        return NULL;
+    return m_viewLexi->GetModule();
+}
+
+VOID SRLexiWidget::SetModule(sword::SWModule *pModule)
+{
+    if(m_viewLexi){
+        m_viewLexi->SetModule(pModule);
+        FillDictEntries();
+    }
+}
+
+VOID SRLexiWidget::SetSwordReady()
+{
+    if(m_viewLexi)
+        m_viewLexi->SetSwordReady();
+}
+
+VOID SRLexiWidget::RefreshWindow()
+{
+    if(m_viewLexi)
+        m_viewLexi->RefreshWindow();
+}
+
+VOID SRLexiWidget::RefreshScreen(BOOL fReloadText)
+{
+    if(m_viewLexi)
+        m_viewLexi->RefreshScreen(fReloadText);
+}
+
+VOID SRLexiWidget::SetKey(const sword::StrKey &key)
+{
+    if(m_viewLexi)
+        m_viewLexi->SetKey(key);
+}

Added: trunk/src/SwordReader_GUI/SRLexiWidget.h
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiWidget.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRLexiWidget.h	2009-01-03 04:05:48 UTC (rev 188)
@@ -0,0 +1,33 @@
+#pragma once
+#include "SRFramework/SRWnd.h"
+#include "SRFramework/SRComboBox.h"
+#include "SRFramework/SRLabel.h"
+#include "SRLexiView.h"
+#include "swmodule.h"
+#include "swkey.h"
+
+using namespace SRFramework;
+
+class SRLexiWidget : public SRFramework::SRWnd
+{
+public:
+    SRLexiWidget(void);
+    ~SRLexiWidget(void);
+    BOOL            Create(SRWnd *pParentWnd, RECT bounds);
+    BOOL            Register();
+    BOOL            Init();
+    const SWKey     &GetKey();
+    const SWModule  *GetModule();
+    VOID            SetKey(const StrKey &key);
+    VOID            SetModule(SWModule *pModule);
+    VOID            SetSwordReady();
+    VOID            RefreshWindow();
+    VOID            RefreshScreen(BOOL fReloadText);
+    VOID            FillDictEntries();
+private:
+    static BOOL s_fRegistered;
+    SRComboBox  *m_cmbDictEntry;
+    SRLabel     *m_lblEntry;
+    SRLexiView  *m_viewLexi;
+    SWKey       m_keyDummy;
+};

Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp	2009-01-03 00:04:27 UTC (rev 187)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp	2009-01-03 04:05:48 UTC (rev 188)
@@ -359,17 +359,28 @@
 VOID SRMainFrame::SaveOptions()
 {
     CHAR buff[32] = {0};   
+    const SWModule *pModule = NULL;
     if(!m_fInit)
         return;
+    if(m_tabViews){
+        pModule = m_tabViews->GetBibleModule();
+        if(pModule)
+            (*m_confOptions)["History"]["LastBibleVersion"] = pModule->Name();
+        (*m_confOptions)["History"]["LastBiblePassage"] = m_tabViews->GetBibleVerseKey().getText();
+        
+        pModule = m_tabViews->GetCommModule();
+        if(pModule)
+            (*m_confOptions)["History"]["LastCommVersion"] = pModule->Name();
+        (*m_confOptions)["History"]["LastCommPassage"] = m_tabViews->GetCommVerseKey().getText();
+        
+        pModule = m_tabViews->GetDictModule();
+        if(pModule)
+            (*m_confOptions)["History"]["LastDictVersion"] = pModule->Name();
+        (*m_confOptions)["History"]["LastDictEntry"] = m_tabViews->GetDictKey().getText();
 
-    (*m_confOptions)["History"]["LastBibleVersion"] = m_tabViews->GetBibleModule()->Name();
-    (*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;
+        sprintf(buff, "%d", m_tabViews->GetCurTabSel());
+        (*m_confOptions)["History"]["LastTabViewed"] = buff;
+    }
 
     for(int i = 0; i < m_nTotalOpts; i++){
         (*m_confOptions)["GlobalOptions"][m_bufModOptions[i].c_str()] = m_swmgr->getGlobalOption(m_bufModOptions[i]);

Modified: trunk/src/SwordReader_GUI/SRTabbedViews.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2009-01-03 00:04:27 UTC (rev 187)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2009-01-03 04:05:48 UTC (rev 188)
@@ -90,9 +90,10 @@
         return FALSE;
     m_viewComm->Hide();
 
-    m_viewDict = new SRLexiView();
+    m_viewDict = new SRLexiWidget();
     if(!m_viewDict || !m_viewDict->Create(this, m_rect))
         return FALSE;
+    m_viewDict->Init();
     m_viewDict->Hide();
 
     // Create the tab control
@@ -130,10 +131,13 @@
 
 BOOL SRTabbedViews::UpdateWindow()
 {
-    SRTextView *view = GetCurrentView();
-    if(!view)
-        return FALSE;
-    return view->UpdateWindow();
+    SRTextView *view = dynamic_cast<SRTextView*>(GetCurrentView());
+    if(view)
+        return view->UpdateWindow();
+    SRLexiWidget *lexi = dynamic_cast<SRLexiWidget*>(GetCurrentView());
+    //if(lexi)
+    //    return lexi->UpdateWindow();
+    return FALSE;
 }
 
 const SWModule *SRTabbedViews::GetBibleModule()
@@ -207,7 +211,7 @@
 }
     
     
-SRTextView *SRTabbedViews::GetCurrentView()
+SRWnd *SRTabbedViews::GetCurrentView()
 {
     switch(m_tabs.GetCurSel())
     {
@@ -230,8 +234,8 @@
         mview->RefreshScreen(fReloadText);
         return;
     }
-    SRLexiView *lview = dynamic_cast<SRLexiView *>(GetCurrentView());
-    if(mview){
+    SRLexiWidget *lview = dynamic_cast<SRLexiWidget *>(GetCurrentView());
+    if(lview){
         lview->RefreshScreen(fReloadText);
         return;
     }
@@ -335,7 +339,7 @@
 
 BOOL SRTabbedViews::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
 {
-    SRTextView *view = GetCurrentView();
+    SRWnd *view = GetCurrentView();
     if(!view)
         return FALSE;
     return view->OnKeyDown(nChar, nRepCnt, nFlags);
@@ -416,37 +420,37 @@
     switch(m_tabs.GetCurSel())
     {
     case SR_TAB_BIBLE:
-        if(m_viewBible){
-            m_viewBible->SetKey(m_keyLinked);
-            m_viewBible->Show();
-        }
         if(m_viewComm){
             m_viewComm->Hide();
         }
         if(m_viewDict)
             m_viewDict->Hide();
+        if(m_viewBible){
+            m_viewBible->SetKey(m_keyLinked);
+            m_viewBible->Show();
+        }
         return SR_TAB_BIBLE;
     case SR_TAB_COMM:
-        if(m_viewComm){
-            m_viewComm->SetKey(m_keyLinked);
-            m_viewComm->Show();
-        }
         if(m_viewBible){
             m_viewBible->Hide();
         }
         if(m_viewDict)
             m_viewDict->Hide();
+        if(m_viewComm){
+            m_viewComm->SetKey(m_keyLinked);
+            m_viewComm->Show();
+        }
         return SR_TAB_COMM;
     case SR_TAB_DICT:
-        if(m_viewDict){
-            m_viewDict->Show();
-        }
         if(m_viewBible){
             m_viewBible->Hide();
         }
         if(m_viewComm){
             m_viewComm->Hide();
         }
+        if(m_viewDict){
+            m_viewDict->Show();
+        }
         return SR_TAB_DICT;
     }
     return -1;
@@ -456,4 +460,10 @@
 {
     m_tabs.SetCurSel(nNewTab);
     SwitchToCurrentView();
+}
+
+
+INT SRTabbedViews::GetCurTabSel()
+{
+    return m_tabs.GetCurSel();
 }
\ No newline at end of file

Modified: trunk/src/SwordReader_GUI/SRTabbedViews.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.h	2009-01-03 00:04:27 UTC (rev 187)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.h	2009-01-03 04:05:48 UTC (rev 188)
@@ -2,7 +2,7 @@
 #include "SRFramework/SRWnd.h"
 #include "SRFramework/SRTabCtrl.h"
 #include "SRModuleView.h"
-#include "SRLexiView.h"
+#include "SRLexiWidget.h"
 
 #define SR_TAB_BIBLE 0
 #define SR_TAB_COMM  1
@@ -52,7 +52,7 @@
     VOID SetCurrentKey(const VerseKey &verse);
     VOID SetLinkedKey(const VerseKey &key) { m_keyLinked = key; }
     VOID ManualChangeCurrentTab(INT nNewTab);
-    
+    INT  GetCurTabSel();
     void MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
     BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
 
@@ -62,7 +62,7 @@
     SRTabCtrl m_tabs;
     BOOL InitTabs();
     BOOL InitViews();
-    SRTextView *GetCurrentView();
+    SRWnd *GetCurrentView();
     // When there is nothing valid to return return these dummy keys.
     VerseKey m_verseDummy;
     SWKey  m_dictDummy;
@@ -71,6 +71,6 @@
     
     SRModuleView *m_viewBible;
     SRModuleView *m_viewComm;
-    SRLexiView   *m_viewDict;
+    SRLexiWidget  *m_viewDict;
     VerseKey     m_keyLinked;
 };

Modified: trunk/src/SwordReader_GUI/SRTextView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.h	2009-01-03 00:04:27 UTC (rev 187)
+++ trunk/src/SwordReader_GUI/SRTextView.h	2009-01-03 04:05:48 UTC (rev 188)
@@ -481,10 +481,13 @@
     */
     virtual BOOL CurrentPageFilled();
 	
+    VOID    RefreshWindow();
+    
     // Friend classes, not needed in Visual Studio 2005
 	// but needed in eVC 3
 	friend class SRTextWord;
 	friend class SRTextLines;
+    
 
 protected:
     // Private Methods
@@ -692,7 +695,6 @@
     //! Like PreRenderBuff(HDC hdc) except this method gets the device context itself.
     VOID    PreRenderBuff();
 
-    VOID    RefreshWindow();
 
     VOID    ClearFontCache(HDC hdc);
 

Modified: trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
===================================================================
--- trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj	2009-01-03 00:04:27 UTC (rev 187)
+++ trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj	2009-01-03 04:05:48 UTC (rev 188)
@@ -878,6 +878,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\SRLexiWidget.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\SRMainFrame.cpp"
 				>
 			</File>
@@ -933,6 +937,10 @@
 					>
 				</File>
 				<File
+					RelativePath=".\SRFramework\SRLabel.cpp"
+					>
+				</File>
+				<File
 					RelativePath=".\SRFramework\SRListBox.cpp"
 					>
 				</File>
@@ -987,6 +995,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\SRLexiWidget.h"
+				>
+			</File>
+			<File
 				RelativePath=".\SRMainFrame.h"
 				>
 			</File>
@@ -1046,6 +1058,10 @@
 					>
 				</File>
 				<File
+					RelativePath=".\SRFramework\SRLabel.h"
+					>
+				</File>
+				<File
 					RelativePath=".\SRFramework\SRListBox.h"
 					>
 				</File>




More information about the sword-cvs mailing list