[sword-svn] r147 - trunk/src/SwordReader_GUI
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Thu Jul 10 22:08:24 MST 2008
Author: dtrotzjr
Date: 2008-07-10 22:08:23 -0700 (Thu, 10 Jul 2008)
New Revision: 147
Modified:
trunk/src/SwordReader_GUI/SRMainFrame.cpp
trunk/src/SwordReader_GUI/SRTextView.cpp
Log:
Fixed verse header being off by one verse.
Fixed the bug that would allow two instances of the app. Now a single instance is always enforced.
Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-07-07 04:41:03 UTC (rev 146)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-07-11 05:08:23 UTC (rev 147)
@@ -104,6 +104,17 @@
BOOL SRMainFrame::Create()
{
+ //If it is already running, then focus on the window, and exit.
+ HWND hWnd = FindWindow(this->m_wcsClassName.w_str(), NULL);
+ if (hWnd)
+ {
+ // set focus to foremost child window
+ // The "| 0x01" is used to bring any owned windows to the foreground and
+ // activate them.
+ SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001));
+ return FALSE;
+ }
+
RECT bounds = {CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT};
if(!Register())
return FALSE;
@@ -221,6 +232,7 @@
}
void SRMainFrame::LoadTextView() {
+ WCString buf, text, s;
/*
::SendMessage(g_hwndCB, TB_ENABLEBUTTON, MENU_BOOK, false);
::SendMessage(g_hwndCB, TB_ENABLEBUTTON, MENU_CHAP, false);
@@ -240,42 +252,33 @@
m_viewText->Clear();
VerseKey keyCur(m_keyCurVerse);
- //m_keyCurVerse->Verse(1);
keyCur.Verse(1);
- WCString buf = "";//"<html><head><meta name=\"MobileOptimized\" content=\"240\"><title></title></head><body>";
m_viewText->AddText(buf.w_str(), buf.length()); // a <style> section presumably gets skipped
- WCString s;
- WCString heading;
char strNum[10];
while (true) {
m_modCurText->SetKey(keyCur);
int pvHeading = 0;
+ text = (TCHAR *)m_modCurText->RenderText();
+ s = "";
do {
sprintf(strNum, "%i", pvHeading++);
SWBuf preverseHeading = m_modCurText->getEntryAttributes()["Heading"]["Preverse"][strNum].c_str();
if (preverseHeading.length()) {
- buf = "<br /><br /><b>";
- buf += (TCHAR *)m_modCurText->RenderText(preverseHeading);
- buf += "</b><br /><br />";
- m_viewText->AddText(buf.w_str(), buf.length());
+ if(keyCur.Verse() != 1)
+ s += "<br /><br /><b>";
+ else
+ s += "<b>";
+ s += (TCHAR *)m_modCurText->RenderText(preverseHeading);
+ s += "</b><br /><br />";
}
else break;
} while (true);
- s = GetVerseHeader(keyCur);
- s += (TCHAR *)m_modCurText->RenderText();
- s += " "; // Many verses do not have a space after them.
- if (s.length() > 0) {
- // If the following failed it was due to a bad tag in this verse.
- // Use the stripped version instead.
- if(!m_viewText->AddText(s.w_str(), s.length())){
- s = GetVerseHeader(keyCur);
- s += (TCHAR *)m_modCurText->StripText();
- s += " "; // Many verses do not have a space after them.
- m_viewText->AddText(s.w_str(), s.length());
- }
+ s += GetVerseHeader(keyCur);
+ s += text + " ";
+
+ m_viewText->AddText(s.w_str(), s.length());
- }
if (keyCur.Verse() == GetMaxVerses())
break;
else
Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp 2008-07-07 04:41:03 UTC (rev 146)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp 2008-07-11 05:08:23 UTC (rev 147)
@@ -913,7 +913,10 @@
VOID SRTextView::ScrollToVerse(WORD wVerseNum)
{
- ScrollToPosition(m_BTLines.GetVersePosition(wVerseNum), FALSE);
+ if(wVerseNum == 1)
+ ScrollToPosition(0, FALSE); // Addresses a problem when a heading exists prior to verse 1. Temp fix (dctrotz)
+ else
+ ScrollToPosition(m_BTLines.GetVersePosition(wVerseNum), FALSE);
}
More information about the sword-cvs
mailing list