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

dtrotzjr at crosswire.org dtrotzjr at crosswire.org
Sun Feb 1 20:08:54 MST 2009


Author: dtrotzjr
Date: 2009-02-01 20:08:54 -0700 (Sun, 01 Feb 2009)
New Revision: 209

Modified:
   trunk/src/SwordReader_GUI/SRBibleWidget.cpp
   trunk/src/SwordReader_GUI/SRBibleWidget.h
   trunk/src/SwordReader_GUI/SRCommWidget.cpp
   trunk/src/SwordReader_GUI/SRCommWidget.h
   trunk/src/SwordReader_GUI/SRLexiWidget.cpp
   trunk/src/SwordReader_GUI/SRLexiWidget.h
   trunk/src/SwordReader_GUI/SRMainFrame.cpp
   trunk/src/SwordReader_GUI/SRModuleWidget.cpp
   trunk/src/SwordReader_GUI/SRModuleWidget.h
   trunk/src/SwordReader_GUI/SRTabbedViews.cpp
Log:
Fixed several issues with resizing of windows.

Modified: trunk/src/SwordReader_GUI/SRBibleWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRBibleWidget.cpp	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRBibleWidget.cpp	2009-02-02 03:08:54 UTC (rev 209)
@@ -40,10 +40,9 @@
 
 BOOL SRBibleWidget::Init()
 {
-    RECT clientRect;
+    RECT clientRect = GetBounds();
     RECT lexiRect = {0,0,0,0};
     RECT notesRect = {0,0,0,0};
-    GetClientRect(m_hWnd, &clientRect);
 
     m_viewModule = new SRModuleView(BibleView);
     if(!m_viewModule || !m_viewModule->Create(this, clientRect))
@@ -73,6 +72,31 @@
         m_viewModule->Show();
 }
 
+VOID SRBibleWidget::MoveWindow(LPCRECT lpRect,BOOL bRepaint)
+{
+    SRModuleWidget::MoveWindow(lpRect, bRepaint);
+    RECT clientRect = GetBounds();
+    RECT mainRect = clientRect;
+    RECT lexiRect = clientRect;
+    RECT noteRect = clientRect;
+    
+    if(m_fLexiVisible){
+        mainRect.bottom = GetSplitPoint();
+        lexiRect.top = mainRect.bottom;
+        noteRect.top = noteRect.bottom;
+    }else if(m_fNoteVisible){
+        mainRect.bottom = GetSplitPoint();
+        noteRect.top = mainRect.bottom;
+        lexiRect.top = lexiRect.bottom;
+    }else{
+        lexiRect.top = mainRect.bottom;
+        noteRect.top = mainRect.bottom;
+    }
+    m_viewModule->MoveWindow(&mainRect, bRepaint);
+    m_subWndLexi->MoveWindow(&lexiRect, bRepaint);
+    m_subWndNote->MoveWindow(&noteRect, bRepaint);
+}
+
 BOOL SRBibleWidget::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
 {
     if(m_viewModule)

Modified: trunk/src/SwordReader_GUI/SRBibleWidget.h
===================================================================
--- trunk/src/SwordReader_GUI/SRBibleWidget.h	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRBibleWidget.h	2009-02-02 03:08:54 UTC (rev 209)
@@ -30,6 +30,7 @@
     VOID        SetSwordReady();
     
     BOOL        OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
+    virtual VOID        MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
 private:
     VOID        ShowLexiEntry(SWModule *pModule, const WCString &key);
 

Modified: trunk/src/SwordReader_GUI/SRCommWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRCommWidget.cpp	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRCommWidget.cpp	2009-02-02 03:08:54 UTC (rev 209)
@@ -56,6 +56,24 @@
         m_viewModule->Show();
 }
 
+VOID SRCommWidget::MoveWindow(LPCRECT lpRect,BOOL bRepaint)
+{
+    SRModuleWidget::MoveWindow(lpRect, bRepaint);
+    RECT clientRect = GetBounds();
+    RECT mainRect = clientRect;
+    RECT scripRect = clientRect;
+    
+    if(m_fScripRefVisible){
+        mainRect.bottom = GetSplitPoint();
+        scripRect.top = mainRect.bottom;
+    }else{
+        scripRect.top = mainRect.bottom;
+    }
+    m_viewModule->MoveWindow(&mainRect, bRepaint);
+    m_subWndScripRef->MoveWindow(&scripRect, bRepaint);
+}
+
+
 BOOL SRCommWidget::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
 {
     if(m_viewModule)

Modified: trunk/src/SwordReader_GUI/SRCommWidget.h
===================================================================
--- trunk/src/SwordReader_GUI/SRCommWidget.h	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRCommWidget.h	2009-02-02 03:08:54 UTC (rev 209)
@@ -20,6 +20,7 @@
     VOID        SetScripRefModule(SWModule *pModule);
     VOID        SetSwordReady();
     
+    virtual VOID MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
     BOOL        OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
 private:
 

Modified: trunk/src/SwordReader_GUI/SRLexiWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiWidget.cpp	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRLexiWidget.cpp	2009-02-02 03:08:54 UTC (rev 209)
@@ -48,6 +48,33 @@
     return m_wcsWindowName;
 }
 
+VOID SRLexiWidget::MoveWindow(LPCRECT lpRect,BOOL bRepaint)
+{
+    SRWnd::MoveWindow(lpRect, bRepaint);
+    RECT clientRect = GetBounds();
+    RECT lblRect = clientRect;
+    RECT cmbRect = clientRect;
+    RECT viewRect = clientRect;
+
+    lblRect.top = 4;
+    lblRect.left = 4;
+    lblRect.right = 60;
+    lblRect.bottom = 20;
+
+    cmbRect.top = 0;
+    cmbRect.left = 60;
+    cmbRect.bottom = 20;
+    
+    viewRect.top = 20;  
+    if(m_viewLexi)
+        m_viewLexi->MoveWindow(&viewRect, bRepaint);
+    if(m_cmbDictEntry)
+        m_cmbDictEntry->MoveWindow(&cmbRect, bRepaint);
+    if(m_lblEntry)
+        m_lblEntry->MoveWindow(&lblRect, bRepaint);
+
+}
+
 BOOL SRLexiWidget::Register()
 {
     // Register window class...
@@ -76,33 +103,25 @@
 
 BOOL SRLexiWidget::Init()
 {
-    RECT rectClient;
-    GetClientRect(m_hWnd, &rectClient);
-    RECT lblRect = rectClient;
-    RECT cmbRect = rectClient;
-    RECT viewRect = rectClient;
-    lblRect.top = 4;
-    lblRect.left = 4;
-    lblRect.right = 60;
-    cmbRect.left = 60;
-    lblRect.bottom = 20;
-    viewRect.top = 20;
-    
+    RECT clientRect = GetBounds();
+
     m_lblEntry = new SRLabel("Lookup:");
-    if(!m_lblEntry || !m_lblEntry->Create(this, lblRect))
+    if(!m_lblEntry || !m_lblEntry->Create(this, clientRect))
         return FALSE;
     m_lblEntry->Show();
 
     m_cmbDictEntry = new SRComboBox();
-    if(!m_cmbDictEntry || !m_cmbDictEntry->Create(this, cmbRect))
+    if(!m_cmbDictEntry || !m_cmbDictEntry->Create(this, clientRect))
         return FALSE;
     m_cmbDictEntry->Show();
 
     m_viewLexi = new SRLexiView();
-    if(!m_viewLexi || !m_viewLexi->Create(this, viewRect))
+    if(!m_viewLexi || !m_viewLexi->Create(this, clientRect))
         return FALSE;
     m_viewLexi->Show();
     
+    MoveWindow(&clientRect, TRUE);
+
     return TRUE;
 }
 

Modified: trunk/src/SwordReader_GUI/SRLexiWidget.h
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiWidget.h	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRLexiWidget.h	2009-02-02 03:08:54 UTC (rev 209)
@@ -25,6 +25,7 @@
     VOID            RefreshScreen(BOOL fReloadText);
     VOID            FillDictEntries();
     BOOL            OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl);
+    virtual VOID MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
 
     BOOL            OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
     BOOL            OnPaint();

Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp	2009-02-02 03:08:54 UTC (rev 209)
@@ -416,119 +416,25 @@
 		WCString wcsValue = url.getParameterValue("value");
 		WCString wcsType = url.getParameterValue("type");
         if(wcsType == "scripRef"){
+            SWBuf foot = m_swmgr->getGlobalOption("Footnotes");
+            SWBuf cross = m_swmgr->getGlobalOption("Cross-references");
+            SWBuf strongs = m_swmgr->getGlobalOption("Strong's Numbers");
+            SWBuf morph = m_swmgr->getGlobalOption("Morphological Tags");
+            m_swmgr->setGlobalOption("Footnotes", "Off");
+            m_swmgr->setGlobalOption("Cross-references", "Off");
+            m_swmgr->setGlobalOption("Strong's Numbers", "Off");
+            m_swmgr->setGlobalOption("Morphological Tags", "Off");
             m_tabViews->ShowScriptRef(wcsValue);
+            m_swmgr->setGlobalOption("Footnotes", foot);
+            m_swmgr->setGlobalOption("Cross-references", cross);
+            m_swmgr->setGlobalOption("Strong's Numbers", strongs);
+            m_swmgr->setGlobalOption("Morphological Tags", morph);
         }
         return TRUE;
     }
     return TRUE;
 }
 
-/*
-void SimpleNavigator::urlClicked(const WCHAR *target) {   
-    const int BUF_SIZE = 2048;
-    char target_cstr[BUF_SIZE];
-    const char * t = wstrtostr(target_cstr, target, BUF_SIZE);
-    wchar_t buf[BUF_SIZE];
-
-	SWKey *modKey = 0;
-	// MessageBox(0, strtowstr(t), L"This is 't'", MB_OK);
-	// SWMgr swmanager; // don't create new manager - use SwordIndex::manager
-	// Footnote MessageBox
-	WCString oldPos = position.verseToString(); // information to restore the persistent key
-	if (strstr(t, "showNote")) {
-		URL footnote(t);  // t is char* to URL string
-		SWBuf module = footnote.getParameterValue("module");
-		SWBuf key = footnote.getParameterValue("passage");
-		SWBuf footnoteNumber = footnote.getParameterValue("value");
-		// Now that you have extracted all the info you need from the URL,
-		// you can lookup the footnote...
-		// get the module it's in
-		SWModule *mod = SwordIndex::manager->getModule(module); // Thanks Troy for above ...  Nov 2007
-		// set that module to the correct entry
-		// TODO - may need to re-set this afterwards - could save int SimpleNavigator::getID();
-		modKey = mod->getKey(); // get the persistent key
-		modKey->setText(key.c_str()); // set the key itself 
-		// force a parse of the entry
-		mod->RenderText(); 
-		SWBuf body = mod->getEntryAttributes()["Footnote"][footnoteNumber]["body"];
-		const char *Body = mod->RenderText(body.c_str()); // RenderText not StripText used
-		// MessageBox can't display html - need to strip out tagged stuff; but Greek works OK
-		// FIX ME
-        MessageBox(0, (LPCWSTR)Body, L"Footnote", MB_OK); //
-		}
-	// Strongs number MessageBox
-	else if (strstr(t, "showStrongs")) {
-		URL footnote(t);  // t is char* to URL string
-		SWBuf type = footnote.getParameterValue("type");
-		SWBuf number = footnote.getParameterValue("value");
-		SWModule *mod = 0;
-		if(strstr(type.c_str(), "Greek")) 
-			mod = SwordIndex::greekLex;
-		if(strstr(type.c_str(), "Hebrew")) 
-			mod = SwordIndex::hebrewLex;
-		if (! mod) {
-			MessageBox(0, L"No Dictionary found - install Strong's modules", 
-				L"Strong's", MB_OK);
-			return;
-		}
-		modKey = mod->getKey(); 
-		modKey->setText(number.c_str()); 
-		mod->RenderText(); 
-		MessageBox(0, strtowstr(buf, mod->StripText(), BUF_SIZE), L"Strong's", MB_OK);
-		}
-	// Morph MessageBox
-	else if (strstr(t, "showMorph")) {
-		URL footnote(t);  // t is char* to URL string
-		SWBuf type = footnote.getParameterValue("type");
-		SWBuf number = footnote.getParameterValue("value");
-		SWModule *mod = 0;
-		if(strstr(type.c_str(), "robinson")) {
-			mod = SwordIndex::greekMorph;
-			if (! mod) {
-			MessageBox(0, L"No Greek parsing Dictionary found - install Morphological modules", 
-				L"Greek Morphological tags", MB_ICONWARNING);
-			return;
-			}
-		}
-		if(strstr(type.c_str(), "strongMorph")) {
-			mod = SwordIndex::hebrewMorph;
-			if (! mod) {
-			MessageBox(0, L"No Hebrew parsing Dictionary found - install Morphological modules", 
-				L"Hebrew Morphological tags", MB_ICONWARNING);
-			return;
-			}
-		}
-		modKey = mod->getKey(); 
-		modKey->setText(number.c_str()); 
-		mod->RenderText(); 
-		MessageBox(0, strtowstr(buf, mod->StripText(), BUF_SIZE), L"Morph tags", MB_OK);
-	}
-	// X-Ref MessageBox
-	else if (strstr(t, "scripRef")) {
-		URL footnote(t);  // t is char* to URL string
-		SWBuf module = footnote.getParameterValue("module"); // very unlikely to have this
-		SWBuf key = footnote.getParameterValue("value");
-		// get the last bible module used and get xRefs from this version
-		SWModule *mod = SwordIndex::manager->getModule((*g_swordConf)["History"]["LastBible"]);
-		// will fail if user has never looked at a bible - possible??? so check ....
-		if (!mod) {
-			MessageBox(0, L"xRef bible not found", 
-				L"Cross referencing", MB_ICONWARNING);
-			return;
-			}
-		modKey = mod->getKey(); // get the persistent key
-		modKey->setText(key.c_str()); // set the key itself 
-		mod->RenderText(); 
-		// strip out html if present
-		SWBuf body = mod->StripText();
-		// not sure if MessageBox can display html - if it can, re-think this some day
-		MessageBox(0, strtowstr(buf, body, BUF_SIZE), L"Scripture reference", MB_OK);
-		}
-        
-        else //comment next line out in release version
-            MessageBox(0, strtowstr(buf, t, BUF_SIZE), L"Raw entry unresolved", MB_OK); // catch all 
-        modKey->setText((const char *)oldPos.c_str()); // restore the key before leaving
-}*/
 VOID SRMainFrame::SaveOptions()
 {
     CHAR buff[32] = {0};   

Modified: trunk/src/SwordReader_GUI/SRModuleWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRModuleWidget.cpp	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRModuleWidget.cpp	2009-02-02 03:08:54 UTC (rev 209)
@@ -169,6 +169,7 @@
 VOID SRModuleWidget::ShowSubWindow(SRSubWindow *pSubWnd)
 {
     RECT clientRect = GetBounds();
+    INT nBottomMax = GetSplitPoint();
     RECT mainRect, subRect;
     int i,j,tmp;
     if(!pSubWnd || !m_viewModule)
@@ -181,10 +182,14 @@
     pSubWnd->MoveWindow(&subRect);
     pSubWnd->Show();
 
-    for(i = 0, j = 1; i < 80;){
+    for(i = 0, j = 1; i < nBottomMax;){
         tmp = 20 - j++;
         i += tmp;
         mainRect.bottom -= tmp;
+
+        if(mainRect.bottom < nBottomMax)
+            mainRect.bottom = nBottomMax;
+
         subRect.top = mainRect.bottom;
         
         m_viewModule->MoveWindow(&mainRect);
@@ -203,14 +208,20 @@
         return;
 
     mainRect = m_viewModule->GetBounds();
+    INT nBottomMax = GetBounds().bottom;
     subRect = pSubWnd->GetBounds();
     subRect.top += mainRect.bottom;
     subRect.bottom += mainRect.bottom;
             
-    for(i = 0, j = 1; i < 80;){
+    for(i = 0, j = 1; i < nBottomMax;){
         tmp = 20 - j++;
         i += tmp;
         mainRect.bottom += tmp;
+        if(mainRect.bottom > nBottomMax){
+            mainRect.bottom = nBottomMax;
+            i = nBottomMax;
+        }
+
         subRect.top = mainRect.bottom;
         
         m_viewModule->MoveWindow(&mainRect);
@@ -220,4 +231,16 @@
         pSubWnd->RefreshWindow();
     }
     pSubWnd->Hide();
+}
+
+VOID SRModuleWidget::MoveWindow(LPCRECT lpRect,BOOL bRepaint)
+{
+    SRWnd::MoveWindow(lpRect, bRepaint);
+    RECT clientRect = GetBounds();
+    m_viewModule->MoveWindow(&clientRect, bRepaint);
+}
+
+INT SRModuleWidget::GetSplitPoint() { 
+    RECT clientRect = GetBounds();
+    return (INT)(((float)(clientRect.bottom - clientRect.top))*0.65f); 
 }
\ No newline at end of file

Modified: trunk/src/SwordReader_GUI/SRModuleWidget.h
===================================================================
--- trunk/src/SwordReader_GUI/SRModuleWidget.h	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRModuleWidget.h	2009-02-02 03:08:54 UTC (rev 209)
@@ -38,7 +38,10 @@
     virtual INT         GetChapterMax();
     virtual INT         GetVerseMax();
     virtual VOID        SetSwordReady();
+    virtual VOID        MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
 
+    INT                 GetSplitPoint();
+
 protected:
     static BOOL     s_fRegistered;
     SRModuleView    *m_viewModule;

Modified: trunk/src/SwordReader_GUI/SRTabbedViews.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2009-02-01 22:59:23 UTC (rev 208)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2009-02-02 03:08:54 UTC (rev 209)
@@ -91,8 +91,6 @@
 
 BOOL SRTabbedViews::InitViews()
 {
-    RECT tab_rect;
-    RECT views_rect = GetBounds();
     RECT clientRect = GetBounds();
 
     m_viewBible = new SRBibleWidget();
@@ -124,28 +122,8 @@
     if(!InitTabs())
         return FALSE;
 
+    MoveWindow(&clientRect, TRUE);
 
-
-    // Adjust the windows for the tabs...
-    m_tabs.GetItemRect(0, &tab_rect);
-    tab_rect.bottom += 2;
-    if(0){ // Tabs on top... soon to be an option...
-        m_tabs.MoveWindow(clientRect.left,clientRect.top,clientRect.right - clientRect.left, tab_rect.bottom - tab_rect.top, TRUE);
-    }else{
-        m_tabs.MoveWindow(clientRect.left,clientRect.bottom - (tab_rect.bottom - tab_rect.top),clientRect.right - clientRect.left, tab_rect.bottom - tab_rect.top, TRUE);
-    }
-
-    if(0){ // Same as above
-        views_rect.top += (tab_rect.bottom - tab_rect.top);
-    }else{
-        views_rect.bottom -= (tab_rect.bottom - tab_rect.top);
-    }
-
-    m_viewBible->MoveWindow(&views_rect, TRUE);
-    m_viewComm->MoveWindow(&views_rect, TRUE);
-    m_viewDict->MoveWindow(&views_rect, TRUE);
-    m_viewAbout->MoveWindow(&views_rect, TRUE);
-
     return TRUE;
 }
 
@@ -324,14 +302,35 @@
 
 
 void SRTabbedViews::MoveWindow(LPCRECT lpRect,BOOL bRepaint)
-{
-    SRWnd::MoveWindow(lpRect, bRepaint);
+{   
+    RECT tab_rect;
+    RECT views_rect = *lpRect;
+    RECT clientRect = *lpRect;
+    SRWnd::MoveWindow(&clientRect, bRepaint);
+
+    // Adjust the windows for the tabs...
+    m_tabs.GetItemRect(0, &tab_rect);
+    tab_rect.bottom += 2;
+    if(0){ // Tabs on top... soon to be an option...
+        m_tabs.MoveWindow(clientRect.left,clientRect.top,clientRect.right - clientRect.left, tab_rect.bottom - tab_rect.top, bRepaint);
+    }else{
+        m_tabs.MoveWindow(clientRect.left,clientRect.bottom - (tab_rect.bottom - tab_rect.top),clientRect.right - clientRect.left, tab_rect.bottom - tab_rect.top, bRepaint);
+    }
+
+    if(0){ // Same as above
+        views_rect.top += (tab_rect.bottom - tab_rect.top);
+    }else{
+        views_rect.bottom -= (tab_rect.bottom - tab_rect.top);
+    }
+
     if(m_viewBible)
-        m_viewBible->MoveWindow(lpRect, bRepaint);
+        m_viewBible->MoveWindow(&views_rect, bRepaint);
     if(m_viewComm)
-        m_viewComm->MoveWindow(lpRect, bRepaint);
+        m_viewComm->MoveWindow(&views_rect, bRepaint);
     if(m_viewDict)
-        m_viewDict->MoveWindow(lpRect, bRepaint);
+        m_viewDict->MoveWindow(&views_rect, bRepaint);
+    if(m_viewAbout)
+        m_viewAbout->MoveWindow(&views_rect, bRepaint);
     /* ... */
 }
 




More information about the sword-cvs mailing list