[sword-svn] r193 - in trunk/src/SwordReader_GUI: . SRFramework
dtrotzjr at crosswire.org
dtrotzjr at crosswire.org
Sun Jan 4 18:01:57 MST 2009
Author: dtrotzjr
Date: 2009-01-04 18:01:57 -0700 (Sun, 04 Jan 2009)
New Revision: 193
Modified:
trunk/src/SwordReader_GUI/SRBibleWidget.cpp
trunk/src/SwordReader_GUI/SRFramework/WCString.cpp
trunk/src/SwordReader_GUI/SRFramework/WCString.h
trunk/src/SwordReader_GUI/SRLexiView.cpp
trunk/src/SwordReader_GUI/SRMainFrame.cpp
trunk/src/SwordReader_GUI/SRMainFrame.h
trunk/src/SwordReader_GUI/SRModuleView.cpp
trunk/src/SwordReader_GUI/SRTextView.cpp
trunk/src/SwordReader_GUI/SwordReaderResource.h
Log:
More footnote and strongs support. About 30% done. Builds doesn't do much yet.
Modified: trunk/src/SwordReader_GUI/SRBibleWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRBibleWidget.cpp 2009-01-04 22:41:13 UTC (rev 192)
+++ trunk/src/SwordReader_GUI/SRBibleWidget.cpp 2009-01-05 01:01:57 UTC (rev 193)
@@ -223,14 +223,24 @@
{
RECT clientRect;
RECT mainRect, subRect;
+ int i,j,tmp;
+ if(!m_viewLexi || !m_viewBible)
+ return;
+
GetClientRect(m_hWnd, &clientRect);
mainRect = clientRect;
subRect = clientRect;
- mainRect.bottom -= 80;
- subRect.top = mainRect.bottom;
- if(m_viewBible && m_viewLexi){
+
+ m_viewLexi->Show();
+ for(int i = 0, j = 1; i < 80;){
+ Sleep(5);
+ tmp = 20 - j++;
+ i += tmp;
+ mainRect.bottom -= tmp;
+ subRect.top = mainRect.bottom;
m_viewBible->MoveWindow(&mainRect);
- m_viewLexi->Show();
m_viewLexi->MoveWindow(&subRect);
+ m_viewBible->RefreshWindow();
+ m_viewLexi->RefreshWindow();
}
}
\ No newline at end of file
Modified: trunk/src/SwordReader_GUI/SRFramework/WCString.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/WCString.cpp 2009-01-04 22:41:13 UTC (rev 192)
+++ trunk/src/SwordReader_GUI/SRFramework/WCString.cpp 2009-01-05 01:01:57 UTC (rev 193)
@@ -51,6 +51,11 @@
data[i] = rhs[i];
}
}
+
+BOOL WCString::contains(const WCString &rhs) const
+{
+ return wcsstr(this->w_str(), rhs.w_str()) != NULL;
+}
WCString::WCString(const std::string &rhs)
: char_copy(NULL)
Modified: trunk/src/SwordReader_GUI/SRFramework/WCString.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/WCString.h 2009-01-04 22:41:13 UTC (rev 192)
+++ trunk/src/SwordReader_GUI/SRFramework/WCString.h 2009-01-05 01:01:57 UTC (rev 193)
@@ -37,6 +37,8 @@
WCString operator+(const wchar_t *rhs);
WCString operator+(const char *rhs);
+ BOOL contains(const WCString &rhs) const;
+
protected:
std::basic_string<wchar_t> data;
mutable char *char_copy;
Modified: trunk/src/SwordReader_GUI/SRLexiView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiView.cpp 2009-01-04 22:41:13 UTC (rev 192)
+++ trunk/src/SwordReader_GUI/SRLexiView.cpp 2009-01-05 01:01:57 UTC (rev 193)
@@ -65,13 +65,13 @@
if(!m_pModule){
buf += "<b>No Lexicon/Dictionary selected; nothing to load.</b></body></html>";
+ Clear();
AddText(buf.w_str(), buf.length());
return;
}
if(!m_fSwordInit || !m_fEntryChanged)
return;
- Clear();
tmp = (TCHAR *)m_pModule->RenderText();
if(tmp.length() == 0){
@@ -85,6 +85,7 @@
}
buf += tmp;
buf += "</body></html>";
+ Clear();
AddText(buf.w_str(), buf.length());
m_fEntryChanged = false;
Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp 2009-01-04 22:41:13 UTC (rev 192)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp 2009-01-05 01:01:57 UTC (rev 193)
@@ -1,5 +1,6 @@
#include "SRMainFrame.h"
#include <swordce.h>
+#include <url.h>
using namespace sword;
@@ -343,7 +344,8 @@
break;
case SR_HYPERLINK_CLICKED:
pszWordFound = (TCHAR*)hWndCtl;
- m_tabViews->HyperLinkClicked();
+ HandleClickedURL(pszWordFound);
+ //m_tabViews->HyperLinkClicked();
break;
default:
// Check the custom made menu items...
@@ -373,32 +375,165 @@
return FALSE;
}
+BOOL SRMainFrame::HandleClickedURL(const WCString &wcsURL)
+{
+ URL url(wcsURL.c_str());
+ SWModule *mod = NULL;
+ SWKey *modKey = NULL;
+
+ if(wcsURL.contains("showNote")){
+ WCString wcsModule = url.getParameterValue("module");
+ WCString wcsKey = url.getParameterValue("passage");
+ WCString wcsValue = url.getParameterValue("value");
+ mod = m_swmgr->getModule(wcsModule.c_str());
+ modKey = mod->getKey();
+ modKey->setText(wcsKey.c_str());
+ mod->RenderText();
+ WCString wcsBody = mod->getEntryAttributes()["Footnote"][wcsValue.c_str()]["body"];
+ WCString wcsBodyR = mod->RenderText(wcsBody.c_str());
+ // Send this somewhere and show it...
+ return TRUE;
+ }else if(wcsURL.contains("showStrongs")){
+ return TRUE;
+ }else if(wcsURL.contains("showMorph")){
+ return TRUE;
+ }else if(wcsURL.contains("scriptRef")){
+ 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};
const SWModule *pModule = NULL;
- if(!m_fInit)
+ if(!m_fInit || !m_confOptions || !m_tabViews)
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();
- sprintf(buff, "%d", m_tabViews->GetCurTabSel());
- (*m_confOptions)["History"]["LastTabViewed"] = buff;
- }
+ 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();
+ 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]);
}
@@ -436,7 +571,8 @@
VOID SRMainFrame::SetVerse(INT nVerse, BOOL fScroll)
{
- m_tabViews->SetCurrentVerse(nVerse, fScroll);
+ if(m_tabViews)
+ m_tabViews->SetCurrentVerse(nVerse, fScroll);
SaveOptions();
UpdateWindowTitle();
}
@@ -622,7 +758,8 @@
void SRMainFrame::UpdateWindowTitle()
{
- SetWindowText(m_hWnd,m_tabViews->GetCurrentWindowTitle().w_str());
+ if(m_tabViews)
+ SetWindowText(m_hWnd,m_tabViews->GetCurrentWindowTitle().w_str());
}
Modified: trunk/src/SwordReader_GUI/SRMainFrame.h
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.h 2009-01-04 22:41:13 UTC (rev 192)
+++ trunk/src/SwordReader_GUI/SRMainFrame.h 2009-01-05 01:01:57 UTC (rev 193)
@@ -40,10 +40,12 @@
void SetFocus();
void UpdateWindowTitle();
void SetWindowTitle(const WCString &wcsTitle);
+ BOOL HandleClickedURL(const WCString &wcsURL);
// Sword related
BOOL InitSword();
+
// Do these belong here?... dctrotz
static const WCString *GetBookNames() { return s_wcsBookNames; }
Modified: trunk/src/SwordReader_GUI/SRModuleView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRModuleView.cpp 2009-01-04 22:41:13 UTC (rev 192)
+++ trunk/src/SwordReader_GUI/SRModuleView.cpp 2009-01-05 01:01:57 UTC (rev 193)
@@ -30,6 +30,7 @@
, m_fThreadRunning(FALSE)
, m_fAbortThread(FALSE)
, m_viewType(viewType)
+, m_verse("Gen 1:1")
{
}
Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp 2009-01-04 22:41:13 UTC (rev 192)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp 2009-01-05 01:01:57 UTC (rev 193)
@@ -826,7 +826,7 @@
POINT pt = {xPos, yPos};
SRTextWord *pbtWord;
DWORD dwLineNum = 0;
- static TCHAR szWordFound[4096] = {0};
+ static TCHAR szWordFound[SR_MAX_MISC_STRING_LEN] = {0};
while(dwLineNum <= m_BTLines.m_dwLastLine && (m_BTLines.m_lpLines[dwLineNum].m_rect.bottom + m_nTop) < pt.y)
dwLineNum++;
Modified: trunk/src/SwordReader_GUI/SwordReaderResource.h
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderResource.h 2009-01-04 22:41:13 UTC (rev 192)
+++ trunk/src/SwordReader_GUI/SwordReaderResource.h 2009-01-05 01:01:57 UTC (rev 193)
@@ -29,6 +29,8 @@
typedef std::map<const char*, sword::SWModule*, ltstr> ModuleMap;
+#define SR_MAX_MISC_STRING_LEN 4096
+
#define SR_MAX_MODULE_PAGES 4
#define SWORD_OLD_TESTAMENT 1
More information about the sword-cvs
mailing list