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

dtrotzjr at www.crosswire.org dtrotzjr at www.crosswire.org
Fri Sep 12 20:22:29 MST 2008


Author: dtrotzjr
Date: 2008-09-12 20:22:28 -0700 (Fri, 12 Sep 2008)
New Revision: 178

Modified:
   trunk/src/SwordReader_GUI/Doxyfile
   trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRWnd.h
   trunk/src/SwordReader_GUI/SRMainFrame.cpp
   trunk/src/SwordReader_GUI/SRMainFrame.h
   trunk/src/SwordReader_GUI/SRModuleView.cpp
   trunk/src/SwordReader_GUI/SRModuleView.h
   trunk/src/SwordReader_GUI/SRTabbedViews.cpp
   trunk/src/SwordReader_GUI/SRTabbedViews.h
   trunk/src/SwordReader_GUI/SRTextView.cpp
   trunk/src/SwordReader_GUI/SRTextView.h
   trunk/src/SwordReader_GUI/SwordReaderResource.h
   trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
Log:
After many confusing and frustrating hours I think I have fixed the major problems I was having w/ the new tab display.

Modified: trunk/src/SwordReader_GUI/Doxyfile
===================================================================
--- trunk/src/SwordReader_GUI/Doxyfile	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/Doxyfile	2008-09-13 03:22:28 UTC (rev 178)
@@ -1,4 +1,4 @@
-# Doxyfile 1.5.3
+# Doxyfile 1.5.6
 
 #---------------------------------------------------------------------------
 # Project related configuration options
@@ -6,7 +6,7 @@
 DOXYFILE_ENCODING      = UTF-8
 PROJECT_NAME           = SwordReader
 PROJECT_NUMBER         = 0.90alpha3
-OUTPUT_DIRECTORY       = docs
+OUTPUT_DIRECTORY       = C:/SwordDevel/swordreader/src/SwordReader_GUI/docs
 CREATE_SUBDIRS         = NO
 OUTPUT_LANGUAGE        = English
 BRIEF_MEMBER_DESC      = YES
@@ -25,7 +25,7 @@
 ALWAYS_DETAILED_SEC    = NO
 INLINE_INHERITED_MEMB  = NO
 FULL_PATH_NAMES        = YES
-STRIP_FROM_PATH        = /home/dctrotz/tmp/swordreader/src/SwordReader_GUI/
+STRIP_FROM_PATH        = "C:/Documents and Settings/David Trotz/"
 STRIP_FROM_INC_PATH    = 
 SHORT_NAMES            = NO
 JAVADOC_AUTOBRIEF      = NO
@@ -38,10 +38,15 @@
 ALIASES                = 
 OPTIMIZE_OUTPUT_FOR_C  = NO
 OPTIMIZE_OUTPUT_JAVA   = NO
+OPTIMIZE_FOR_FORTRAN   = NO
+OPTIMIZE_OUTPUT_VHDL   = NO
 BUILTIN_STL_SUPPORT    = NO
 CPP_CLI_SUPPORT        = NO
+SIP_SUPPORT            = NO
+IDL_PROPERTY_SUPPORT   = YES
 DISTRIBUTE_GROUP_DOC   = NO
 SUBGROUPING            = YES
+TYPEDEF_HIDES_STRUCT   = NO
 #---------------------------------------------------------------------------
 # Build related configuration options
 #---------------------------------------------------------------------------
@@ -56,12 +61,13 @@
 HIDE_FRIEND_COMPOUNDS  = NO
 HIDE_IN_BODY_DOCS      = NO
 INTERNAL_DOCS          = NO
-CASE_SENSE_NAMES       = YES
+CASE_SENSE_NAMES       = NO
 HIDE_SCOPE_NAMES       = NO
 SHOW_INCLUDE_FILES     = YES
 INLINE_INFO            = YES
 SORT_MEMBER_DOCS       = YES
 SORT_BRIEF_DOCS        = NO
+SORT_GROUP_NAMES       = NO
 SORT_BY_SCOPE_NAME     = NO
 GENERATE_TODOLIST      = YES
 GENERATE_TESTLIST      = YES
@@ -71,6 +77,8 @@
 MAX_INITIALIZER_LINES  = 30
 SHOW_USED_FILES        = YES
 SHOW_DIRECTORIES       = NO
+SHOW_FILES             = YES
+SHOW_NAMESPACES        = YES
 FILE_VERSION_FILTER    = 
 #---------------------------------------------------------------------------
 # configuration options related to warning and progress messages
@@ -85,7 +93,7 @@
 #---------------------------------------------------------------------------
 # configuration options related to the input files
 #---------------------------------------------------------------------------
-INPUT                  = /home/dctrotz/tmp/swordreader/src/SwordReader_GUI
+INPUT                  = C:/SwordDevel/swordreader/src/SwordReader_GUI
 INPUT_ENCODING         = UTF-8
 FILE_PATTERNS          = *.c \
                          *.cc \
@@ -114,20 +122,10 @@
                          *.mm \
                          *.dox \
                          *.py \
-                         *.C \
-                         *.CC \
-                         *.C++ \
-                         *.II \
-                         *.I++ \
-                         *.H \
-                         *.HH \
-                         *.H++ \
-                         *.CS \
-                         *.PHP \
-                         *.PHP3 \
-                         *.M \
-                         *.MM \
-                         *.PY
+                         *.f90 \
+                         *.f \
+                         *.vhd \
+                         *.vhdl
 RECURSIVE              = YES
 EXCLUDE                = 
 EXCLUDE_SYMLINKS       = NO
@@ -168,16 +166,21 @@
 HTML_STYLESHEET        = 
 HTML_ALIGN_MEMBERS     = YES
 GENERATE_HTMLHELP      = NO
+GENERATE_DOCSET        = NO
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+DOCSET_BUNDLE_ID       = org.doxygen.Project
 HTML_DYNAMIC_SECTIONS  = NO
 CHM_FILE               = 
 HHC_LOCATION           = 
 GENERATE_CHI           = NO
+CHM_INDEX_ENCODING     = 
 BINARY_TOC             = NO
 TOC_EXPAND             = NO
 DISABLE_INDEX          = NO
 ENUM_VALUES_PER_LINE   = 4
-GENERATE_TREEVIEW      = YES
+GENERATE_TREEVIEW      = ALL
 TREEVIEW_WIDTH         = 250
+FORMULA_FONTSIZE       = 10
 #---------------------------------------------------------------------------
 # configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
@@ -189,8 +192,8 @@
 PAPER_TYPE             = a4wide
 EXTRA_PACKAGES         = 
 LATEX_HEADER           = 
-PDF_HYPERLINKS         = NO
-USE_PDFLATEX           = NO
+PDF_HYPERLINKS         = YES
+USE_PDFLATEX           = YES
 LATEX_BATCHMODE        = NO
 LATEX_HIDE_INDICES     = NO
 #---------------------------------------------------------------------------
@@ -255,6 +258,8 @@
 MSCGEN_PATH            = 
 HIDE_UNDOC_RELATIONS   = YES
 HAVE_DOT               = YES
+DOT_FONTNAME           = FreeSans
+DOT_FONTPATH           = 
 CLASS_GRAPH            = YES
 COLLABORATION_GRAPH    = YES
 GROUP_GRAPHS           = YES
@@ -267,11 +272,11 @@
 GRAPHICAL_HIERARCHY    = YES
 DIRECTORY_GRAPH        = YES
 DOT_IMAGE_FORMAT       = png
-DOT_PATH               = 
+DOT_PATH               = "C:/Program Files/Graphviz2.20/bin"
 DOTFILE_DIRS           = 
 DOT_GRAPH_MAX_NODES    = 50
 MAX_DOT_GRAPH_DEPTH    = 1000
-DOT_TRANSPARENT        = NO
+DOT_TRANSPARENT        = YES
 DOT_MULTI_TARGETS      = NO
 GENERATE_LEGEND        = YES
 DOT_CLEANUP            = YES

Modified: trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.cpp	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.cpp	2008-09-13 03:22:28 UTC (rev 178)
@@ -1,5 +1,5 @@
 #include "SRTabCtrl.h"
-
+#include "SRApp.h"
 #include <commctrl.h>
 
 using namespace SRFramework;
@@ -11,7 +11,8 @@
 	InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
 	InitCtrlEx.dwICC  = ICC_TAB_CLASSES;
 	InitCommonControlsEx(&InitCtrlEx);
-    
+
+    m_hInstance = SRFramework::SRApp::GetInstanceHandle();
     m_wcsClassName = WC_TABCONTROL;
     m_wcsWindowName = "";
 }
@@ -78,6 +79,8 @@
     BOOL retval = 0;
     TC_ITEM item;
     LPWSTR pszText = (LPWSTR)calloc(wcsItem.length() + 1, sizeof(WCHAR));
+    if(!pszText)
+        return -1;
     wcscpy(pszText, wcsItem.w_str());
     memset(&item, 0, sizeof(TC_ITEM));
     
@@ -88,7 +91,7 @@
         item.mask |= TCIF_PARAM;
     
     item.pszText = pszText;
-    item.cchTextMax = wcsItem.length();
+    item.cchTextMax = wcsItem.length() + 1;
     
     item.iImage = nImage;
     item.lParam = lParam;

Modified: trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp	2008-09-13 03:22:28 UTC (rev 178)
@@ -78,6 +78,11 @@
     ::ShowWindow(m_hWnd, SW_HIDE);
 }
 
+BOOL SRWnd::IsVisible()
+{
+    return ::IsWindowVisible(m_hWnd);
+}
+
 void SRWnd::RefreshWindow()
 {
     ::InvalidateRect(m_hWnd, NULL, TRUE);

Modified: trunk/src/SwordReader_GUI/SRFramework/SRWnd.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRWnd.h	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRFramework/SRWnd.h	2008-09-13 03:22:28 UTC (rev 178)
@@ -44,6 +44,7 @@
 
         virtual void Show();
         virtual void Hide();
+        virtual BOOL IsVisible();
         virtual void RefreshWindow();
         virtual void MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE);
         virtual void MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);

Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp	2008-09-13 03:22:28 UTC (rev 178)
@@ -42,6 +42,7 @@
 ,m_viewFind(NULL)
 ,m_fChapterChanged(TRUE)
 ,m_nCurrentModule(0)
+,m_fInit(FALSE)
 {
     // Create a general options file for storing options 
 	// and navigaiton history
@@ -179,7 +180,8 @@
     m_tabViews->Show();
 
     UpdateWindowTitle();
-    
+
+    m_fInit = TRUE;
     return TRUE;
 }
 
@@ -354,10 +356,13 @@
 VOID SRMainFrame::SaveOptions()
 {
     CHAR buff[32] = {0};   
+    if(!m_fInit)
+        return;
+
     (*m_confOptions)["History"]["LastBibleVersion"] = m_tabViews->GetBibleModule()->Name();
-    (*m_confOptions)["History"]["LastBiblePassage"] = m_tabViews->GetBibleModule()->getKey()->getText();
+    (*m_confOptions)["History"]["LastBiblePassage"] = m_tabViews->GetBibleVerseKey().getText();
     (*m_confOptions)["History"]["LastCommVersion"] = m_tabViews->GetCommModule()->Name();
-    (*m_confOptions)["History"]["LastCommPassage"] = m_tabViews->GetCommModule()->getKey()->getText();
+    (*m_confOptions)["History"]["LastCommPassage"] = m_tabViews->GetCommVerseKey().getText();
     sprintf(buff, "%d", m_tabViews->m_tabs.GetCurSel());
     (*m_confOptions)["History"]["LastTabViewed"] = buff;
 
@@ -512,7 +517,7 @@
         val = (*m_confOptions)["GlobalOptions"].getWithDefault(m_bufModOptions[i],"Off");
         m_swmgr->setGlobalOption(m_bufModOptions[i],val);
         m_menuBar->CheckOptionsMenuItem(i + MENU_OPTS_START, (val == "On" ? TRUE : FALSE));
-    }    
+    }   
     
     bibleMod = m_swmgr->getModule((*m_confOptions)["History"].getWithDefault("LastBibleVersion", "KJV"));
     if(!bibleMod){
@@ -520,7 +525,7 @@
     }
     m_tabViews->SetBibleModule(bibleMod);
     
-    commMod = m_swmgr->getModule((*m_confOptions)["History"].getWithDefault("LastCommVersion", "MHC"));
+    commMod = m_swmgr->getModule((*m_confOptions)["History"].getWithDefault("LastCommVersion", "Clarke"));
     if(!commMod){
         commMod = m_modComms->begin()->second;
     }

Modified: trunk/src/SwordReader_GUI/SRMainFrame.h
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.h	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRMainFrame.h	2008-09-13 03:22:28 UTC (rev 178)
@@ -78,6 +78,8 @@
     SRTabbedViews   *m_tabViews;
     BOOL          m_fChapterChanged;
 
+    BOOL          m_fInit;
+
     static WCString s_wcsBookNames[BIBLE_TOTAL_BOOKS];
     static BOOL s_fRegistered;
 };

Modified: trunk/src/SwordReader_GUI/SRModuleView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRModuleView.cpp	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRModuleView.cpp	2008-09-13 03:22:28 UTC (rev 178)
@@ -8,16 +8,17 @@
     SRModuleView *view = reinterpret_cast<SRModuleView*>(arg);
     if(!view)
         return 1;
+        
     view->m_fThreadRunning = TRUE;
     view->m_wStatusBarHeight = SR_STATUS_BAR_HEIGHT;
     view->LoadTextView(true);
     view->m_wStatusBarHeight = 0;
-    if(!view->m_fAbortThread)
+    if(!view->m_fAbortThread){
         view->RefreshWindow();
+    }
     view->m_fThreadRunning = FALSE;
     view->m_fAbortThread = FALSE;
 
-
     return 0;
 }
 
@@ -40,36 +41,45 @@
 
 VOID SRModuleView::SetModule(SWModule *pModule)
 {
-    EnterCriticalSection(&m_csLoadText);
+    //EnterCriticalSection(EnterCriticalSection(&m_csLoadText);m_csLoadText);
     if(m_pModule == pModule)
         return;
     AbortThread();
     m_pModule = pModule;
     m_fChapterChanged = TRUE;
-    LeaveCriticalSection(&m_csLoadText);
+    //LeaveCriticalSection(LeaveCriticalSection(&m_csLoadText);m_csLoadText);
     LoadTextView();
 }
 
 VOID SRModuleView::AbortThread()
 {
+    DWORD dwTimeout = 200;
     INT rc;
     if(m_fThreadRunning){
         m_fAbortThread = TRUE;
-        rc = WaitForSingleObject(m_hLoadTextThread, INFINITE);
+        rc = WaitForSingleObject(m_hLoadTextThread, dwTimeout);
         while(rc == WAIT_FAILED){
             ::Sleep(20);// Let's sleep for a bit and give the thread a chance to spawn.
-            rc = WaitForSingleObject(m_hLoadTextThread, INFINITE);
+            rc = WaitForSingleObject(m_hLoadTextThread, dwTimeout);
         }
+        if(rc == WAIT_TIMEOUT){
+            // Sometimes the call to ::UpdateWindow never returns. 
+            TerminateThread(m_hLoadTextThread, -1);
+            // Clean up from the rogue thread
+            m_fThreadRunning = FALSE;
+            m_fAbortThread = FALSE;
+            m_wStatusBarHeight = 0;
+        }
     }
 }
 
 VOID SRModuleView::SetKey(const VerseKey &verse)
 {
-    if(m_verse == verse)
+    if(!m_fChapterChanged && m_verse == verse)
         return;
     AbortThread();
     if(m_viewType == BibleView){
-        if(verse.Book() != m_verse.Book() || (m_verse.Book == verse.Book() && m_verse.Chapter() != verse.Chapter())){
+        if( (verse.Book() != m_verse.Book()) || ((m_verse.Book() == verse.Book()) && (m_verse.Chapter() != verse.Chapter()))){
             m_fChapterChanged = true;
             m_verse = verse;
             LoadTextView();
@@ -121,17 +131,34 @@
     if(nVerse == 0)
         nVerse++; // This chapter starts with a heading or some other pretext, so we normalize the verse number here.
 
+    if(m_viewType == CommView && m_verse.Verse() == nVerse)
+        return;
+    
     m_verse.Verse(nVerse);
     if(fScroll)
         ScrollToVerse(m_verse.Verse());
 }
 
+VOID SRModuleView::Show()
+{
+    SRTextView::Show();
+    if(m_fLoadTextDelayed)
+        LoadTextView(FALSE);
+}
+
 VOID SRModuleView::LoadTextView(BOOL fInThread)
 {
 	WCString buf, text, s;
     BOOL done = FALSE;
     char strNum[10];
     
+
+    if(!IsVisible()){
+        m_fLoadTextDelayed = TRUE;
+        return;
+    }else
+        m_fLoadTextDelayed = FALSE;
+    
     if(!m_fSwordInit)
         return;
 
@@ -139,7 +166,7 @@
         AbortThread();
     }
     
-    EnterCriticalSection(&m_csLoadText);
+    //EnterCriticalSection(EnterCriticalSection(&m_csLoadText);m_csLoadText);
     VerseKey keyCur(m_verse);
     
     if(!fInThread){ // This text should still be valid...
@@ -221,7 +248,7 @@
     if(!fInThread || !m_fAbortThread)
         RefreshWindow();
 
-    LeaveCriticalSection(&m_csLoadText);
+    //LeaveCriticalSection(LeaveCriticalSection(&m_csLoadText);m_csLoadText);
     
     if(done){
         ScrollToVerse(m_verse.Verse());
@@ -229,7 +256,6 @@
         m_nLoadedTill = keyCur.Verse();
         CreateLoadTextThread();
     }
-
 }
 
 VOID SRModuleView::DrawLoadingProgress(const VerseKey& keyCur)
@@ -292,9 +318,11 @@
 VOID SRModuleView::CreateLoadTextThread()
 {
     if(m_hLoadTextThread)
-        CloseHandle(m_hLoadTextThread);
+        ::CloseHandle(m_hLoadTextThread);
     m_fThreadRunning = TRUE;
-    m_hLoadTextThread = CreateThread(NULL, 0, LoadTextThread, (LPVOID) this, 0, &m_dwLoadTextThreadID);
+    m_hLoadTextThread = ::CreateThread(NULL, 0, LoadTextThread, (LPVOID) this, 0, &m_dwLoadTextThreadID);
+    if(m_hLoadTextThread)
+        ::SetThreadPriority(m_hLoadTextThread, THREAD_PRIORITY_BELOW_NORMAL);
 }
 
 WCString SRModuleView::GetVerseHeader(VerseKey key) const
@@ -394,7 +422,7 @@
     wchar_t wchapt[16] = {0};
     if(!m_fSwordInit)
         return "";
-    EnterCriticalSection(&m_csLoadText);
+    //EnterCriticalSection(EnterCriticalSection(&m_csLoadText);m_csLoadText);
     
     WCString title =  
         WCString(m_pModule->Name()) + " " + 
@@ -402,7 +430,7 @@
         WCString(_itow(m_verse.Chapter(),wchapt, 10)) + WCString(":") + 
         WCString(_itow(m_verse.Verse(), wverse, 10));
     
-    LeaveCriticalSection(&m_csLoadText);
+    //LeaveCriticalSection(LeaveCriticalSection(&m_csLoadText);m_csLoadText);
 
     return title;
 }

Modified: trunk/src/SwordReader_GUI/SRModuleView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRModuleView.h	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRModuleView.h	2008-09-13 03:22:28 UTC (rev 178)
@@ -32,6 +32,7 @@
     INT         GetChapterMax() { return m_verse.getChapterMax();   }
     INT         GetVerseMax()   { return m_verse.getVerseMax();     }
     VOID        SetSwordReady() { m_fSwordInit = TRUE; }
+    VOID        Show();
 private:
     VOID        LoadTextView(BOOL fInThread = FALSE);
     VOID        CreateLoadTextThread();
@@ -50,6 +51,11 @@
     BOOL        m_fThreadRunning;
     BOOL        m_fAbortThread;
     SRViewType  m_viewType;
+    /*! If set it means there was a request to LoadText but the window 
+        was not visible thus we deferred the LoadText call.
+     */
+    BOOL                        m_fLoadTextDelayed;
+
     friend DWORD WINAPI LoadTextThread(LPVOID arg);
 
 };

Modified: trunk/src/SwordReader_GUI/SRTabbedViews.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.cpp	2008-09-13 03:22:28 UTC (rev 178)
@@ -9,6 +9,7 @@
     m_wcsClassName = "SRTabbedViews";
     m_wcsWindowName = "";
     m_hInstance = SRFramework::SRApp::GetInstanceHandle();
+    m_keyDummy.setText("Gen 1:1", true);
 }
 
 SRTabbedViews::~SRTabbedViews(void)
@@ -126,28 +127,50 @@
 
 const SWModule *SRTabbedViews::GetBibleModule()
 {
+    if(!m_viewBible)
+        return NULL;
     return m_viewBible->GetModule();
 }
 
+const VerseKey &SRTabbedViews::GetBibleVerseKey()
+{
+    if(!m_viewBible)
+        return m_keyDummy;
+    return m_viewBible->GetVerseKey();
+}
+
 VOID SRTabbedViews::SetBibleModule(SWModule *pModule)
 {
-    m_viewBible->SetModule(pModule);
+    if(m_viewBible)
+        m_viewBible->SetModule(pModule);
 }
 
 const SWModule *SRTabbedViews::GetCommModule()
 {
+    if(!m_viewComm)
+        return NULL;
     return m_viewComm->GetModule();
 }
 
+const VerseKey &SRTabbedViews::GetCommVerseKey()
+{
+    if(!m_viewComm)
+        return m_keyDummy;
+    return m_viewComm->GetVerseKey();
+}
+
 VOID SRTabbedViews::SetCommModule(SWModule *pModule)
 {
-    m_viewComm->SetModule(pModule);
+    if(m_viewComm)
+        m_viewComm->SetModule(pModule);
 }
 
 VOID SRTabbedViews::SetSwordReady()
 {
-    m_viewBible->SetSwordReady();
-    m_viewComm->SetSwordReady();
+    if(m_viewBible)
+        m_viewBible->SetSwordReady();
+    if(m_viewComm)
+        m_viewComm->SetSwordReady();
     /* ... */
 }
     
@@ -237,7 +260,10 @@
 void SRTabbedViews::MoveWindow(LPCRECT lpRect,BOOL bRepaint)
 {
     SRWnd::MoveWindow(lpRect, bRepaint);
-    m_viewBible->MoveWindow(lpRect, bRepaint);
+    if(m_viewBible)
+        m_viewBible->MoveWindow(lpRect, bRepaint);
+    if(m_viewComm)
+        m_viewComm->MoveWindow(lpRect, bRepaint);
     /* ... */
 }
 
@@ -309,12 +335,14 @@
 
 VOID SRTabbedViews::SetBibleKey(const VerseKey &verse)
 {
-    m_viewBible->SetKey(verse);
+    if(m_viewBible)
+        m_viewBible->SetKey(verse);
 }
 
 VOID SRTabbedViews::SetCommKey(const VerseKey &verse)
 {
-    m_viewComm->SetKey(verse);
+    if(m_viewComm)
+        m_viewComm->SetKey(verse);
 }
 
 BOOL SRTabbedViews::OnNotify(int idCtrl, LPNMHDR pnmh)
@@ -325,10 +353,11 @@
     case TCN_SELCHANGING:
         if(m_tabs.GetCurSel() < 2) // i.e. this was a tab with a versekey
             m_keyLinked = GetCurrentVerseKey();
-        return FALSE;
+        return FALSE; // If we return TRUE we stop the change
     case TCN_SELCHANGE:
         SwitchToCurrentView();
-        m_pParentWnd->SetFocus(); // Give focus back to the parent.
+        if(m_pParentWnd)
+            m_pParentWnd->SetFocus(); // Give focus back to the parent.
         break;
     default:
         return FALSE;
@@ -336,25 +365,38 @@
     return TRUE;
 }
 
-VOID SRTabbedViews::SwitchToCurrentView()
+INT SRTabbedViews::SwitchToCurrentView()
 {
     switch(m_tabs.GetCurSel())
     {
     case SR_TAB_BIBLE:
-        m_viewBible->SetKey(m_keyLinked);
-        m_viewBible->Show();
-        m_viewComm->Hide();
-        break;
+        if(m_viewBible){
+            m_viewBible->SetKey(m_keyLinked);
+            m_viewBible->Show();
+        }
+        if(m_viewComm){
+            m_viewComm->Hide();
+        }
+        return SR_TAB_BIBLE;
     case SR_TAB_COMM:
-        m_viewComm->SetKey(m_keyLinked);
-        m_viewComm->Show();
-        m_viewBible->Hide();
-        break;
+        if(m_viewComm){
+            m_viewComm->SetKey(m_keyLinked);
+            m_viewComm->Show();
+        }
+        if(m_viewBible){
+            m_viewBible->Hide();
+        }
+        return SR_TAB_COMM;
     case SR_TAB_DICT:
-        m_viewBible->Hide();
-        m_viewComm->Hide();
-        break;
+        if(m_viewBible){
+            m_viewBible->Hide();
+        }
+        if(m_viewComm){
+            m_viewComm->Hide();
+        }
+        return SR_TAB_DICT;
     }
+    return -1;
 }
 
 VOID SRTabbedViews::ManualChangeCurrentTab(INT nNewTab)

Modified: trunk/src/SwordReader_GUI/SRTabbedViews.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.h	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.h	2008-09-13 03:22:28 UTC (rev 178)
@@ -23,6 +23,8 @@
     BOOL UpdateWindow();
     const SWModule *GetBibleModule();
     const SWModule *GetCommModule();
+    const VerseKey &GetBibleVerseKey();
+    const VerseKey &GetCommVerseKey();
     VOID SetBibleModule(SWModule *pModule);
     VOID SetBibleKey(const VerseKey &verse);
     VOID SetCommModule(SWModule *pModule);
@@ -50,7 +52,7 @@
     BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
 
     BOOL OnNotify(int idCtrl, LPNMHDR pnmh);
-    VOID SwitchToCurrentView();
+    INT SwitchToCurrentView();
 private:
     BOOL InitTabs();
     BOOL InitViews();

Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp	2008-09-13 03:22:28 UTC (rev 178)
@@ -80,7 +80,7 @@
     for(DWORD i = 0; i < BTEXT_FONT_CACHE_MAX; i++)
         m_hFontCache[i] = 0;
     
-    InitializeCriticalSection(&m_csLoadText);
+    //InitializeCriticalSection(&m_csLoadText);
 }
 
 SRTextView::~SRTextView()
@@ -88,7 +88,7 @@
     if(m_lpszBuff)
         delete [] m_lpszBuff;
 
-    DeleteCriticalSection(&m_csLoadText);
+    //DeleteCriticalSection(&m_csLoadText);
     DestroyWindow(m_hWnd);
 }
 
@@ -97,7 +97,7 @@
     if(!Register())
         return FALSE;
 
-    if(!SRWnd::Create(m_wcsClassName,m_wcsWindowName,WS_CHILD | WS_VISIBLE, bounds, pParentWnd, NULL, m_hInstance))
+    if(!SRWnd::Create(m_wcsClassName,m_wcsWindowName,WS_CHILD , bounds, pParentWnd, NULL, m_hInstance))
         return FALSE;
 
     return TRUE;
@@ -484,7 +484,7 @@
     if(m_dwBuffEnd == 0)
         return;
 
-    EnterCriticalSection(&m_csLoadText);
+    //EnterCriticalSection(EnterCriticalSection(&m_csLoadText);m_csLoadText);
     if(!m_fAppended){
         memset(&m_rsState, 0, sizeof(m_rsState));
         m_nLineX      = BTEXT_MARGIN;
@@ -609,7 +609,7 @@
     m_dwWordIndex = m_dwWordIndex;
     m_fAppended = FALSE;
     m_fPreRendered = TRUE;
-    DeleteCriticalSection(&m_csLoadText);
+    //DeleteCriticalSection(&m_csLoadText);
 }
 
 // I wanted to use the same font setter for both prerendering and rendering
@@ -714,8 +714,9 @@
     rectDims.left           = 0; 
     rectDims.right          = 0; 
     rectDims.bottom         = 0;
-
+    
     INT nOldBkMode = SetBkMode(hdc, TRANSPARENT);
+    
 
     // *TODO* The next line should not be needed, but for some strange reason its not 
     // erasing the background. I need to look into this more.
@@ -982,9 +983,9 @@
 VOID SRTextView::ScrollToVerse(WORD wVerseNum)
 {
     if(wVerseNum == 1)
-        ScrollToPosition(0, FALSE); // Addresses a problem when a heading exists prior to verse 1. Temp fix (dctrotz)
+        ScrollToPosition(0, TRUE); // Addresses a problem when a heading exists prior to verse 1. Temp fix (dctrotz)
     else
-        ScrollToPosition(m_BTLines.GetVersePosition(wVerseNum), FALSE);
+        ScrollToPosition(m_BTLines.GetVersePosition(wVerseNum), TRUE);
 }
 
 
@@ -1079,10 +1080,14 @@
 }
 BOOL SRTextView::CurrentPageFilled()
 {
+    BOOL fPageFull = FALSE;
     HDC hdc = GetDC(m_hWnd);
     PreRenderBuff(hdc);
     ReleaseDC(m_hWnd, hdc);
-    return (m_BTLines.m_lppLinesLastWord[m_BTLines.m_dwLastLine]->m_lpPrevWord->m_rect.bottom - m_nTop) > (m_rect.bottom - m_rect.top);
+
+    if(m_BTLines.m_lppLinesLastWord && m_BTLines.m_lppLinesLastWord[m_BTLines.m_dwLastLine]->m_lpPrevWord)
+    fPageFull =  (m_BTLines.m_lppLinesLastWord[m_BTLines.m_dwLastLine]->m_lpPrevWord->m_rect.bottom - m_nTop) > (m_rect.bottom - m_rect.top);
+    return fPageFull;
 }
 /*****************************************************************************
  * SRTextWord                                                                 *

Modified: trunk/src/SwordReader_GUI/SRTextView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.h	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SRTextView.h	2008-09-13 03:22:28 UTC (rev 178)
@@ -429,7 +429,7 @@
         @param dwSize the length of the text being added.
         @return TRUE if sucessful FALSE if malformed tags encountered.
      */
-    BOOL    AddText(const TCHAR *szText, DWORD dwSize);
+    virtual BOOL    AddText(const TCHAR *szText, DWORD dwSize);
     //! Scrolls the window a full height in a given direction.
     /*! @param nDirection the direction to scroll 
         \code
@@ -437,7 +437,7 @@
         nDirection <= 0 indicates down.
         \endcode
      */
-    VOID    ScrollFullPage(INT nDirection);
+    virtual VOID    ScrollFullPage(INT nDirection);
     //! Scrolls the window to a given y position.
     /*! @param yPos the y position to scroll to.
         @param fSendMessage if set will send message to update verse.
@@ -445,41 +445,41 @@
                 cases where we asked to scroll to a certain verse in the first 
                 place. i.e. ScrollToVerse
     */
-    VOID    ScrollToPosition(INT yPos, BOOL fSendMessage);
+    virtual VOID    ScrollToPosition(INT yPos, BOOL fSendMessage);
     //! Scrolls the window to a specific verse.
     /*! @param wVerseNum the verse to scroll to.
     */
-    VOID    ScrollToVerse(WORD wVerseNum);
+    virtual VOID    ScrollToVerse(WORD wVerseNum);
     //! Shows the window control.
     //! Calls ShowWindow with the SW_SHOW parameter for the underlying window.
-    VOID    Show();
+    virtual VOID    Show();
     //! Hides the window control.
     //! Calls ::ShowWindow with the SW_HIDE parameter for the underlying window.
-    VOID    Hide();
+    virtual VOID    Hide();
     //! Changes the position and or size of the window.
     //! Calls ::MoveWindow for the underlying window.
-    VOID MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE);
+    virtual VOID MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE);
     //! Changes the position and or size of the window.
     //! Calls ::MoveWindow for the underlying window.
-    VOID MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
+    virtual VOID MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
     //! Clears the text from m_lpszBuff and removes the lines from m_BTLines.
-    VOID    Clear();
+    virtual VOID    Clear();
     //! Redraws the window, including a pre-render stage if neccesarry. 
-    BOOL UpdateWindow();
+    virtual BOOL UpdateWindow();
     //! Calls the low level WinCE API window creation functions and creates a new window.
-    BOOL Create(SRWnd *pParentWnd, RECT bounds);
+    virtual BOOL Create(SRWnd *pParentWnd, RECT bounds);
     //! Gets the verse of the line at the top window.
     /*! @return the verse number of the word at the end of the top line 
         visible in the window.
     */
-    INT GetVerseNum();
+    virtual INT GetVerseNum();
     //! Determines if the current buffer has filled the screen.
     /*! This function is useful for knowing when there is enough text pre-rendered such 
         that it fills the screen. If the screen has been filled, we can load the rest of 
         our text in the background.
         @return true if the current buffer has filled the viewable screen space. 
     */
-    BOOL CurrentPageFilled();
+    virtual BOOL CurrentPageFilled();
 	
     // Friend classes, not needed in Visual Studio 2005
 	// but needed in eVC 3
@@ -761,7 +761,7 @@
         we can redraw over it while scrolling.
      */
     WORD                        m_wStatusBarHeight;
-    
-    CRITICAL_SECTION            m_csLoadText;
 
+    //CRITICAL_SECTION            m_csLoadText;
+
 };

Modified: trunk/src/SwordReader_GUI/SwordReaderResource.h
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderResource.h	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SwordReaderResource.h	2008-09-13 03:22:28 UTC (rev 178)
@@ -70,7 +70,16 @@
 #define BUTTON_NT_FOREGROUND    0x00008888
 
 #define SR_STATUS_BAR_HEIGHT    12
+#ifdef LOGSTUFF
+    #define _LG_(id, txt, type) \
+    { \
+        FILE *tmp = fopen("SR_Log.txt","a"); \
+        fprintf(tmp, "[%d %s-%c %s %d\n", id, txt, type, __FILE__, __LINE__); \
+        fclose(tmp); \
+    }
+#else
+    #define _LG_(id, txt, type)
+#endif
 
 
-
 #endif
\ No newline at end of file

Modified: trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
===================================================================
--- trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj	2008-09-09 16:11:23 UTC (rev 177)
+++ trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj	2008-09-13 03:22:28 UTC (rev 178)
@@ -177,6 +177,7 @@
 				BrowseInformation="1"
 				WarningLevel="3"
 				SuppressStartupBanner="true"
+				DebugInformationFormat="0"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -199,6 +200,7 @@
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="..\STL_eVC"
 				IgnoreDefaultLibraryNames="$(CENoDefaultLib)"
+				GenerateDebugInformation="false"
 				ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)/SwordReader_GUI.pdb"
 				StackReserveSize="65536"
 				StackCommitSize="4096"




More information about the sword-cvs mailing list