[sword-svn] r45 - in trunk/src: Dll1/winceSword/src gui

bdrake at www.crosswire.org bdrake at www.crosswire.org
Tue Dec 4 04:01:23 MST 2007


Author: bdrake
Date: 2007-12-04 04:01:22 -0700 (Tue, 04 Dec 2007)
New Revision: 45

Modified:
   trunk/src/Dll1/winceSword/src/swordce.cpp
   trunk/src/gui/SimpleNavigator.cpp
Log:


Modified: trunk/src/Dll1/winceSword/src/swordce.cpp
===================================================================
--- trunk/src/Dll1/winceSword/src/swordce.cpp	2007-11-26 15:19:14 UTC (rev 44)
+++ trunk/src/Dll1/winceSword/src/swordce.cpp	2007-12-04 11:01:22 UTC (rev 45)
@@ -20,8 +20,8 @@
 	GetModuleFileName(NULL, ThisName, MAX_PATH);   
 	// NULL as first parameter returns full path and filename of running executable
 	while (ThisName[thatChar++]) buf[thatChar] = ThisName[thatChar];
-	while (buf[thatChar--] != '\\');
-	buf[++thatChar] = NULL;
+	while (buf[thatChar--] != '\\');  // string copied from TCHAR to char - find path end
+	buf[++thatChar] = NULL; // NULL terminate the c string
   	return cwd;
 }
 
@@ -34,10 +34,12 @@
   while (*str)
     *c++ = (wchar_t)*str++;
   *c = 0;
+//  MessageBox(0, buffer, L"I'm leaving strtowstr()", MB_OK);
   return buffer;
 }
 
 char *wstrtostr(const wchar_t *str) {
+//  MessageBox(0, str, L"I'm in wstrtostr()", MB_OK);
   static char *c, *buffer = 0;
   if (buffer)
     delete [] buffer;

Modified: trunk/src/gui/SimpleNavigator.cpp
===================================================================
--- trunk/src/gui/SimpleNavigator.cpp	2007-11-26 15:19:14 UTC (rev 44)
+++ trunk/src/gui/SimpleNavigator.cpp	2007-12-04 11:01:22 UTC (rev 45)
@@ -9,6 +9,8 @@
 #include <swordce.h>
 #include <swmgr.h>
 
+#include <url.h>
+
 using namespace sword;
 
 #define WIDTH 240
@@ -218,81 +220,57 @@
 	}
 }
 
-void SimpleNavigator::urlClicked(const WCHAR *target) {
-	const char * t = wstrtostr(target);
-	if (strstr(t, "type=morph")) {
-		const char *val = strstr(t, "value=");
-		if ((val) && (strlen(val) > 6)) {
-			val += 6;
-			SWModule *mod = (position.verse->Testament() == 1) ? position.hebrewMorph : position.greekMorph;
-			if (mod) {
-				mod->SetKey(val);
-				MessageBox(0, strtowstr(mod->StripText()), L"Morphology", MB_OK);
-			}
-		}
-	}
-	else if (strstr(t, "type=Strongs")) {
-		const char *val = strstr(t, "value=G");
-		if ((val) && (strlen(val) > 7)) {
-			val += 7;
-			if (position.greekLex) {
-				position.greekLex->SetKey(val);
-				MessageBox(0, strtowstr(position.greekLex->StripText()), L"Greek Strong's", MB_OK);
-			}
-		}
-		val = strstr(t, "value=H");
-		if ((val) && (strlen(val) > 7)) {
-			val += 7;
-			if (position.hebrewLex) {
-				position.hebrewLex->SetKey(val);
-				MessageBox(0, strtowstr(position.hebrewLex->StripText()), L"Hebrew Strong's", MB_OK);
-			}
-		}
-	}
-	else if (strstr(t, "noteID=")) {
-		const char *val = strstr(t, "noteID=");
-		if ((val) && (strlen(val) > 7)) {
-			val += 7;
-			SWBuf buf = val;
-			const char *tmp = buf.c_str();
-			val = strstr(tmp, ".n.");
-			if (val) {
-				buf.setSize(val - tmp);
-				SWBuf saveKey = position.verse->getText();
-				position.verse->setText(buf.c_str());
-				position.bible->StripText();	// force lookup
-				const char *n = strstr(t, ".n.");
-				if (n) {
-					SWBuf body = position.bible->getEntryAttributes()["Footnote"][n+3]["body"];
-					body = position.bible->StripText(body.c_str());
-					MessageBox(0, strtowstr(body), L"Footnote", MB_OK);
-				}
-				position.verse->setText(saveKey);
-			}
-			else {
-				val = strstr(tmp, ".x.");
-				if (val) {
-					buf.setSize(val - tmp);
-					SWBuf saveKey = position.verse->getText();
-					position.verse->setText(buf.c_str());
-					position.bible->StripText();	// force lookup
-					const char *n = strstr(t, ".x.");
-					if (n) {
-						SWBuf body = position.bible->getEntryAttributes()["Footnote"][n+3]["body"];
-						body = position.bible->StripText(body.c_str());
-						MessageBox(0, strtowstr(body), L"CrossReference", MB_OK);
+int GetModIdx(const char* ModName) {
+	//I regard this as a kludge ........ it is only helpful on footnotes, and is there
+	//because of the limitations of the SwordIndex class
+	// setting module, book chapter and verse in SwordIndex seem to need numbers
+	// this is a pain ........  needs re-thinking ........
+	int modnum = -1;
+	sword::ModMap::iterator it;
+	sword::SWModule* curMod = 0;
+	for (it = SwordIndex::manager->Modules.begin(); it != SwordIndex::manager->Modules.end(); it++) {
+				curMod = (*it).second;
+				++modnum; 
+				if (strstr(curMod->Name(), ModName)) {
+					return(modnum); // at this point, modnum is the index into the translations menu that we want
+					// MessageBox(0, strtowstr(footnote.getParameterValue("module")), L"This is the module", MB_OK);
 					}
-					position.verse->setText(saveKey);
-				}
-			}
-		}
-	}
-	else MessageBox(0, target, L"url clicked", MB_OK);
+		}  
+return(0); // it can't really get here, can it?
+}
 
+void SimpleNavigator::urlClicked(const WCHAR *target) {
+	const char * t = wstrtostr(target);
+	// MessageBox(0, strtowstr(t), L"This is 't'", MB_OK);
+	// SWMgr swmanager; // don't create new manager - use SwordIndex::manager
+	if (strstr(t, "showNote")) { // we don't do anything unless we have a footnote
+		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
+		// problem caused by this - we get a permanent setting here
+		mod->setKey(key.c_str());  // this line of code makes all future verses become 'key'
+		// force a parse of the entry
+		mod->RenderText(); 
+		MessageBox(0, strtowstr(mod->getEntryAttributes()["Footnote"][footnoteNumber]["body"]), L"Footnote", MB_OK);
+		// now we have to get rid of the 'permanent' setKey verse setting
+		// this gets correct module re-initialised with chap & Vs
+		// by 'pretending' that the appropriate translation has been selected
+		// as this is the footnote's translation it is OK, but this method won't do for cross refs
+		// add to which, it's very slow
+		SimpleNavigator::buttonClicked (GetModIdx(footnote.getParameterValue("module"))+transStartID); 
+		}  // </> if (strstr(t, "showNote"))
+	//comment next line out in release version
+	else MessageBox(0, strtowstr("Unable to show reference"), L"url clicked", MB_OK); // catch all
 }
-int SimpleNavigator::getID() {
 
-	return nextID++;
 
+int SimpleNavigator::getID() {
+	return nextID++;
 }
 




More information about the sword-cvs mailing list