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

dtrotzjr at www.crosswire.org dtrotzjr at www.crosswire.org
Sat Mar 15 22:27:57 MST 2008


Author: dtrotzjr
Date: 2008-03-15 22:27:55 -0700 (Sat, 15 Mar 2008)
New Revision: 98

Modified:
   trunk/src/Dll1/winceSword/src/dirent.cpp
   trunk/src/gui/ApplicationInterface.cpp
   trunk/src/gui/ApplicationInterface.h
   trunk/src/gui/NavBooks.cpp
   trunk/src/gui/NavBooks.h
   trunk/src/gui/NavFind.cpp
   trunk/src/gui/NavFind.h
   trunk/src/gui/NavNumbers.cpp
   trunk/src/gui/NavNumbers.h
   trunk/src/gui/NavRenderText.cpp
   trunk/src/gui/NavRenderText.h
   trunk/src/gui/SimpleNavigator.cpp
   trunk/src/gui/SimpleNavigator.h
   trunk/src/gui/SwordIndex.cpp
   trunk/src/gui/SwordIndex.h
   trunk/src/gui/TextControl.cpp
   trunk/src/gui/TextControl.h
   trunk/src/gui/Utils.cpp
   trunk/src/gui/Utils.h
   trunk/src/gui/VerseTextControl.cpp
   trunk/src/gui/VerseTextControl.h
   trunk/src/simplegui/simplegui.vcproj
Log:
Added a new WCString class replaces UString. -- NOT YET IN A WORKING STATE!!! --
-- dctrotz

Modified: trunk/src/Dll1/winceSword/src/dirent.cpp
===================================================================
--- trunk/src/Dll1/winceSword/src/dirent.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/Dll1/winceSword/src/dirent.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -8,6 +8,7 @@
 
 DIR* opendir(const char *pSpec) {
 	DIR *pDir = new DIR;
+    memset(pDir, 0, sizeof(DIR));
 	pDir->dirPath = new SWBuf();
     wchar_t buf[MAX_PATH + 1];
 	*(pDir->dirPath) = windizePath(pSpec);
@@ -19,7 +20,8 @@
 
 void closedir(DIR * pDir) {
 //MessageBox(0,L"closedir",L"STAGE",MB_OK|MB_ICONERROR);
-	FindClose( pDir->hFind );
+    if(pDir->hFind)
+	    FindClose( pDir->hFind );
 	delete pDir->dirPath;
     delete pDir;
 }
@@ -30,8 +32,10 @@
 	if (pDir->hFind) {
 //MessageBox(0,pDir->wfd.cFileName,L"readdir returning",MB_OK|MB_ICONERROR);
 		strcpy(pDir->de.d_name, wstrtostr(buf, pDir->wfd.cFileName, MAX_PATH + 1));
-		if ( !FindNextFile(pDir->hFind, &(pDir->wfd)) )
+        if ( !FindNextFile(pDir->hFind, &(pDir->wfd)) ){
+            FindClose(pDir->hFind);
 			pDir->hFind = NULL;
+        }
 
 		return &pDir->de;
 	}
@@ -43,6 +47,8 @@
 void rewinddir(DIR* dir) {
     wchar_t buf[MAX_PATH + 1];
 //MessageBox(0,L"rewinddir",L"STAGE",MB_OK|MB_ICONERROR);
+    if(dir->hFind)
+        FindClose(dir->hFind);
 	dir->hFind = FindFirstFile(strtowstr(buf, dir->dirPath->c_str(), MAX_PATH + 1), &(dir->wfd));
 }
 

Modified: trunk/src/gui/ApplicationInterface.cpp
===================================================================
--- trunk/src/gui/ApplicationInterface.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/ApplicationInterface.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -36,14 +36,14 @@
 	LoadString(g_hInst, id, buffer, MAX_LOADSTRING);
 }
 
-UString loadString(UINT id) {
+WCString loadString(UINT id) {
 	TCHAR chars[MAX_LOADSTRING];
 	loadString(id,chars);
-	return UString(chars);
+	return WCString(chars);
 }
 
-void setTitle(UString title) {
-	SetWindowText(g_hWnd,title.c_str());
+void setTitle(const WCString &title) {
+	SetWindowText(g_hWnd,title.w_str());
 }
 
 void refreshScreen() {
@@ -51,25 +51,25 @@
 	UpdateWindow(NULL);
 }
 
-void drawText(RECT* rt, UString text) {
-	drawText(rt,text.c_str(), text.length());
+void drawText(RECT* rt, const WCString &text) {
+	drawText(rt,text.w_str(), text.length());
 }
 
-void drawRText(RECT* rt, UString text) {
-	drawRText(rt,text.c_str(), text.length());
+void drawRText(RECT* rt, const WCString &text) {
+	drawRText(rt,text.w_str(), text.length());
 }
 
 #define MARGIN 2
 
-int drawVerseText(RECT* rt, UString text) {
+int drawVerseText(RECT* rt, const WCString &text) {
 	RECT tmp=*rt;
 	tmp.left+=MARGIN;
-	DrawText(hdc, text.c_str(),text.length(),&tmp,DT_LEFT|DT_WORDBREAK|DT_CALCRECT);
+	DrawText(hdc, text.w_str(),text.length(),&tmp,DT_LEFT|DT_WORDBREAK|DT_CALCRECT);
 	tmp.left=rt->left;
 	tmp.right=rt->right;
 	clearRect(&tmp);
 	tmp.left+=MARGIN;
-	DrawText(hdc, text.c_str(),text.length(),&tmp,DT_LEFT|DT_WORDBREAK);
+	DrawText(hdc, text.w_str(),text.length(),&tmp,DT_LEFT|DT_WORDBREAK);
 	return (tmp.bottom)-(tmp.top);
 }
 
@@ -98,8 +98,8 @@
 */
 }
 
-void addMenu(HMENU menu,int flags, int id, UString text) {
-	AppendMenu(menu,flags,USERBUTTONS+id,text.c_str());
+void addMenu(HMENU menu,int flags, int id, const WCString &text) {
+	AppendMenu(menu,flags,USERBUTTONS+id,text.w_str());
 }
 
 
@@ -114,9 +114,9 @@
 }
 
 
-UString getText(HWND edit) {
+WCString getText(HWND edit) {
 	TCHAR chars[MAX_LOADSTRING];
 	SendMessage(edit,WM_GETTEXT,(WPARAM)MAX_LOADSTRING,(LPARAM)chars);
 	chars[MAX_LOADSTRING-1]=0; // in case the buffer was exceeded
-	return UString(chars);
+	return WCString(chars);
 }
\ No newline at end of file

Modified: trunk/src/gui/ApplicationInterface.h
===================================================================
--- trunk/src/gui/ApplicationInterface.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/ApplicationInterface.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -12,6 +12,7 @@
 #include <windows.h>
 
 #include "utils.h"
+#include "WCString.h"
 
 #define setMenuSelected(hWndMB, idButton, checked) SendMessage((hWndMB), TB_CHECKBUTTON,\
 	(WPARAM)idButton, (LPARAM)MAKELONG(checked,0));
@@ -49,10 +50,10 @@
 
 // load string from string table
 void loadString(UINT id, LPTSTR buffer);
-UString loadString(UINT id);
+WCString loadString(UINT id);
 
 // sets the main title
-void setTitle(UString title);
+void setTitle(const WCString &title);
 
 // Refreshes the whole application screen
 void refreshScreen();
@@ -63,7 +64,7 @@
 		rt, text, length, 0);
 }
 
-void drawText(RECT* rt, UString text);
+void drawText(RECT* rt,const WCString &text);
 
 // Draws the text right-aligned inside the rectangle
 inline void drawRText(RECT* rt, const TCHAR* text, int length) {
@@ -73,9 +74,9 @@
 		rt, text, length, 0);
 }
 
-void drawRText(RECT* rt, UString text);
+void drawRText(RECT* rt,const WCString &text);
 
-int drawVerseText(RECT* rt, UString text);
+int drawVerseText(RECT* rt,const WCString &text);
 
 // fill the rectangle with the original background color
 inline void clearRect(RECT* rt) {
@@ -96,13 +97,13 @@
 void selectMenu(std::map<int,int>& menus, int mode);
 //void selectMenu(int mode);
 
-void addMenu(HMENU menu, int flags, int id, UString text);
+void addMenu(HMENU menu, int flags, int id,const WCString& text);
 
 void checkMenu(HMENU menu, int id, bool checked);
 
 // Get an id to give to the CreateWindow as hMenu
 HMENU registerID(int id);
 
-UString getText(HWND edit);
+WCString getText(HWND edit);
 
 #endif

Modified: trunk/src/gui/NavBooks.cpp
===================================================================
--- trunk/src/gui/NavBooks.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/NavBooks.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -22,7 +22,7 @@
 
 NavBooks::NavBooks(SimpleNavigator* navigator): NavPage(navigator) {
 	this->position=&(navigator->position);
-	this->command=UString(L"Select a book from the above:");
+	this->command = "Select a book from the above:";
 	this->maxOTNumber=position->otBookCount();
 	this->maxNumber=position->bookCount();
 }

Modified: trunk/src/gui/NavBooks.h
===================================================================
--- trunk/src/gui/NavBooks.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/NavBooks.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -6,6 +6,7 @@
 #endif // _MSC_VER > 1000
 
 #include "utils.h"
+#include "WCString.h"
 #include "NavPage.h"
 
 class SimpleNavigator;
@@ -26,7 +27,7 @@
 private:
 	int numberAt(int x, int y);
 	SwordIndex* position;
-	UString command;
+	WCString command;
 	int maxNumber, maxOTNumber;
 };
 

Modified: trunk/src/gui/NavFind.cpp
===================================================================
--- trunk/src/gui/NavFind.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/NavFind.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -86,7 +86,7 @@
 	// I haven't bothered changing the height - what is off-screen simply doesn't show.  
 	// There is no test and no error.
 	preview->clearText();
-	preview->addText(UString(L"preview"));
+	preview->addText(L"preview");
 	preview->endOfText();
 	placeWidgets();
 }
@@ -207,12 +207,12 @@
 		uncheck(methodMultiword);
 		methodMode=METHODEXACTPHRASE;
 	} else if (id==resultsID) {
-		int pos= SendMessage (results, LB_GETCURSEL, 0, 0);
+		unsigned int pos= SendMessage (results, LB_GETCURSEL, 0, 0);
 		if ((pos!=LB_ERR)&&(pos<verses.size())) {
 			previewVerse(&verses[pos]);
 		}
 	} else if (id==goID) {
-		int pos= SendMessage (results, LB_GETCURSEL, 0, 0);
+		unsigned int pos= SendMessage (results, LB_GETCURSEL, 0, 0);
 		if ((pos!=LB_ERR)&&(pos<verses.size())) {
 			navigateToVerse(&verses[pos]);
 		}
@@ -238,7 +238,7 @@
 void NavFind::clearResults() {
 	SendMessage (results, LB_RESETCONTENT,0,0);
 	preview->clearText();
-	preview->addText(UString(L"preview"));
+	preview->addText(L"preview");
 	preview->endOfText();
 	verses.clear();
 }
@@ -247,14 +247,14 @@
 	SendMessage(progressBar,PBM_SETPOS, percent, 0);
 }
 
-void NavFind::addResult(UString verseStr) {
-	Verse* verse=new Verse(toCString(verseStr).c_str());
+void NavFind::addResult(const WCString &verseStr) {
+	Verse* verse=new Verse(verseStr.c_str());
 	verses.push_back(*verse);
-	UString verseString=SwordIndex::verseToString(verse);
-	SendMessage (results, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)verseString.c_str());
+	WCString verseString = SwordIndex::verseToString(verse);
+	SendMessage (results, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)verseString.w_str());
 }
 
-void NavFind::searchFor(UString query) {
+void NavFind::searchFor(const WCString &query) {
 	clearResults();
 	setProgress(5);
 	navigator->position.search(query,rangeMode,methodMode,this);

Modified: trunk/src/gui/NavFind.h
===================================================================
--- trunk/src/gui/NavFind.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/NavFind.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -20,9 +20,9 @@
 	void paint();
 	void hide();
 	void buttonClicked(int id);
-	void searchFor(UString query);
+	void searchFor(const WCString &query);
 	virtual void setProgress(int percent);
-	virtual void addResult(UString verse);
+	virtual void addResult(const WCString &verse);
 	void placeWidgets();
 private:
 	//Navigator* navigator;

Modified: trunk/src/gui/NavNumbers.cpp
===================================================================
--- trunk/src/gui/NavNumbers.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/NavNumbers.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -92,7 +92,7 @@
 		rt.right=(RECT_SCREEN.right/3);
 		clearRect(&rt);
 		rt.left=rt.right;rt.right=RECT_SCREEN.right-rt.left;
-		drawText(&rt,UString(L"More..."));
+		drawText(&rt,"More...");
 		rt.left=rt.right;rt.right=RECT_SCREEN.right;
 		clearRect(&rt);
 		rt.left=RECT_SCREEN.left;

Modified: trunk/src/gui/NavNumbers.h
===================================================================
--- trunk/src/gui/NavNumbers.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/NavNumbers.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -28,7 +28,7 @@
 	};
 protected:
 	int maxNumber;
-	UString command;
+	WCString command;
 	int start;
 };
 

Modified: trunk/src/gui/NavRenderText.cpp
===================================================================
--- trunk/src/gui/NavRenderText.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/NavRenderText.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -57,9 +57,9 @@
 	
 	navigator->position.setMark();
 	navigator->position.setVerse(1);
-	textControl->addText(UString(L"<html><head><meta name=\"MobileOptimized\" content=\"240\"><title></title></head><body>")); // a <style> section presumably gets skipped
-	UString s;
-	UString heading;
+	textControl->addText("<html><head><meta name=\"MobileOptimized\" content=\"240\"><title></title></head><body>"); // a <style> section presumably gets skipped
+	WCString s;
+	WCString heading;
 	char buf[10];
 	while (true) {
 		int pvHeading = 0;
@@ -83,7 +83,7 @@
 		else
 			navigator->position.next();
 	}
-	textControl->addText(UString(L"</body></html>"));
+	textControl->addText("</body></html>");
 	navigator->position.jumpBack();
 
 	textControl->endOfText();
@@ -111,18 +111,23 @@
 	textControl->paint();
 }
 
-UString NavRenderText::getVerseHeader() {
-	String result="\n<b><a name=\"";
-	result+=toCString(navigator->position.getVerse());
-	result+="\">";
-	if (navigator->position.getVerse()==1) {
-		result+=toCString(navigator->position.getChap());
-		result+=":";
+WCString NavRenderText::getVerseHeader() {
+    wchar_t wverse[16] = {0};
+    wchar_t wchap[16] = {0};
+    _itow(navigator->position.getVerse(), wverse, 10);
+    _itow(navigator->position.getChap(), wchap, 10);
+
+	WCString result = "\n<b><a name=\"";
+	result += wverse;
+	result += "\">";
+	if (navigator->position.getVerse() == 1) {
+		result += wchap;
+		result += ":";
 	}
-	result+=toCString(navigator->position.getVerse());
-	result+="</a></b>&nbsp;";
+	result += wverse;
+	result += "</a></b>&nbsp;";
 
-	return toUString(result);
+	return result;
 }
 
 void NavRenderText::keyDown(WPARAM id, LPARAM lparam) {

Modified: trunk/src/gui/NavRenderText.h
===================================================================
--- trunk/src/gui/NavRenderText.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/NavRenderText.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -27,7 +27,7 @@
 	VerseTextControl* textControl;
 	void load();
 	void showText();
-	UString getVerseHeader();
+	WCString getVerseHeader();
 };
 
 #endif // !defined(NAVRENDERTEXT_H)

Modified: trunk/src/gui/SimpleNavigator.cpp
===================================================================
--- trunk/src/gui/SimpleNavigator.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/SimpleNavigator.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -71,7 +71,7 @@
 }
 
 void SimpleNavigator::saveState(){
-	(*g_swordConf)["History"]["LastPassage"] = toCString(position.verseToString()).c_str();
+	(*g_swordConf)["History"]["LastPassage"] = position.verseToString().c_str();
 	(*g_swordConf)["History"]["LastVersion"] = position.getModName();
 }
 
@@ -97,7 +97,7 @@
 }
 
 void SimpleNavigator::updateTitle() {
-	UString title=position.toString()+L" - SwRd";
+	WCString title = position.toString() + " - SwRd";
 	setTitle(title);
 }
 
@@ -156,9 +156,9 @@
 	if (menuTranslations) {
 		for (ModuleMap::iterator i=position.firstModule();i!=position.lastModule();i++) {
 			if(strcmp(i->first, position.getModName()) == 0)
-				addMenu(menuTranslations, MF_CHECKED, nextID++, toUString(String(i->first)));
+				addMenu(menuTranslations, MF_CHECKED, nextID++, i->first);
 			else
-				addMenu(menuTranslations, 0, nextID++, toUString(String(i->first)));
+				addMenu(menuTranslations, 0, nextID++, i->first);
 		}
 	}
 	// The following line is now handled above. -- dctrotz 
@@ -204,7 +204,7 @@
 			}
 			if (supported) {
 				options[nextID - optStartID] = *i;
-				addMenu(menuOptions, 0, nextID++, toUString(i->c_str()));
+				addMenu(menuOptions, 0, nextID++, i->c_str());
 			}
 		}
 	}
@@ -268,7 +268,7 @@
 	// MessageBox(0, strtowstr(t), L"This is 't'", MB_OK);
 	// SWMgr swmanager; // don't create new manager - use SwordIndex::manager
 	// Footnote MessageBox
-	UString oldPos = position.verseToString(); // information to restore the persistent key
+	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");

Modified: trunk/src/gui/SimpleNavigator.h
===================================================================
--- trunk/src/gui/SimpleNavigator.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/SimpleNavigator.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -46,7 +46,7 @@
 	int optEndID;
 	SWBuf *options;
 	int opCount;
-	UString getVerseHeader();
+	WCString getVerseHeader();
 
 	void setModule(int id);
 	void checkModuleMenu(int id);

Modified: trunk/src/gui/SwordIndex.cpp
===================================================================
--- trunk/src/gui/SwordIndex.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/SwordIndex.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -14,16 +14,22 @@
 L"1Th",L"2Th",L"1Ti",L"2Ti",L"Tit",L"Phi",L"Heb",L"Jas",L"1Pe",L"2Pe",L"1Jo",L"2Jo",L"3Jo",L"Jud",L"Rev",
 };
 
-UString SwordIndex::verseToString(Verse* verse) {
-	return UString(defBookNames[(verse->Book()-1)+otBookCount()*(verse->Testament()-1)]) + L" " 
-		+ toUString(verse->Chapter()) + L":" 
-		+ toUString(verse->Verse());
+WCString SwordIndex::verseToString(Verse* verse) {
+    wchar_t wverse[16] = {0};
+    wchar_t wchapt[16] = {0};
+    
+	return WCString(defBookNames[(verse->Book()-1)+otBookCount()*(verse->Testament()-1)]) + WCString(" ") 
+		+ WCString(_itow(verse->Chapter(),wchapt, 10)) + WCString(":") 
+		+ WCString(_itow(verse->Verse(), wverse, 10));
 }
 
-UString SwordIndex::verseToString() {
-	return UString(defBookNames[(verse->Book()-1)+otBookCount()*(verse->Testament()-1)]) + L" " 
-		+ toUString(verse->Chapter()) + L":" 
-		+ toUString(verse->Verse());
+WCString SwordIndex::verseToString() {
+    wchar_t wverse[16] = {0};
+    wchar_t wchapt[16] = {0};
+    
+	return WCString(defBookNames[(verse->Book()-1)+otBookCount()*(verse->Testament()-1)]) + WCString(" ") 
+		+ WCString(_itow(verse->Chapter(),wchapt, 10)) + WCString(":") 
+		+ WCString(_itow(verse->Verse(), wverse, 10));
 }
 
 SWMgr* SwordIndex::manager;
@@ -98,12 +104,12 @@
 	}
 }
 
-UString SwordIndex::toString() {
+WCString SwordIndex::toString() {
 	return verseToString(verse);
 }
 
-UString SwordIndex::bookName(int book) {
-	return UString(defBookNames[book-1]);
+WCString SwordIndex::bookName(int book) {
+	return WCString(defBookNames[book-1]);
 }
 
 void SwordIndex::setBook(int book) {
@@ -156,15 +162,15 @@
 	return verse->Verse();
 }
 
-UString SwordIndex::verseText() {
-	UString utf16 = (WCHAR *)bible->RenderText();
+WCString SwordIndex::verseText() {
+	WCString utf16 = (WCHAR *)bible->RenderText();
 	return utf16;
 }
 
-UString SwordIndex::verseText(sword::VerseKey* anyVerse) {
+WCString SwordIndex::verseText(sword::VerseKey* anyVerse) {
 	setMark();
 	verse->copyFrom(anyVerse);
-	UString temp=verseText();
+	WCString temp = verseText();
 	jumpBack();
 	return temp;
 }
@@ -186,11 +192,11 @@
 }
 
 void SwordIndex::setModule(Module m) {
-	bible=m;
+	bible = m;
 	bible->setKey(verse);
 }
 
-void SwordIndex::search(UString text, int range, int method, Searcher* searcher) {
+void SwordIndex::search(const WCString &text, int range, int method, Searcher* searcher) {
 	searcher->setProgress(10);
 	Verse from=verse->clone();
 	Verse to=verse->clone();
@@ -212,7 +218,7 @@
 	searcher->setProgress(20);
 // this next code block carries out the search - the call is to SWModule::search
 	results=bible->search(
-		toCString(text).c_str(), 
+		text.c_str(), 
 		(method==METHODMULTIWORD)?-2:-1, 
 		2 /* case insensitive */, 
 		&verses
@@ -223,7 +229,7 @@
 // the 'for' loop copies the results into the display window
 	for (results = TOP; !results.Error(); results++) {
 //		searcher->addResult(toUString(String(results.getText())));
-		searcher->addResult(toUString((std::string)(results.getText())));
+		searcher->addResult(results.getText());
 		}
 // thanks to Troy for the above
 

Modified: trunk/src/gui/SwordIndex.h
===================================================================
--- trunk/src/gui/SwordIndex.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/SwordIndex.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -32,7 +32,7 @@
 class Searcher {
 public:
 	virtual void setProgress(int percent)=0;
-	virtual void addResult(UString verse)=0;
+	virtual void addResult(const WCString &verse)=0;
 };
 
 #define RANGEBIBLE 0
@@ -59,10 +59,10 @@
 public:
 	SwordIndex();
 	virtual ~SwordIndex();
-	UString toString();
+	WCString toString();
 
-	UString verseText();
-	UString verseText(sword::VerseKey* anyVerse);
+	WCString verseText();
+	WCString verseText(sword::VerseKey* anyVerse);
 	char *SwordIndex::getModName();
 	ModuleMap::iterator firstModule() {return texts->begin();};
 	ModuleMap::iterator lastModule() {return texts->end();};
@@ -72,7 +72,7 @@
 	void jumpBack();
 	void next();
 
-	void search(UString text, int range, int method, Searcher* searcher);
+	void search(const WCString &text, int range, int method, Searcher* searcher);
 
 	static sword::SWMgr* manager;
 	static SWModule *greekLex;
@@ -83,12 +83,12 @@
 	VerseKey* verse;
 	bool initialized() { return (bible!=0);};
 
-	UString bookName(int book);
+	WCString bookName(int book);
 
 	TCHAR** getBookNames() {return bookNames;};
 
-	static UString verseToString(Verse* verse);	
-	UString verseToString();
+	static WCString verseToString(Verse* verse);	
+	WCString verseToString();
 
 	static int otBookCount() {return 39;};
 	static int bookCount() {return 66;};

Modified: trunk/src/gui/TextControl.cpp
===================================================================
--- trunk/src/gui/TextControl.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/TextControl.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -108,13 +108,13 @@
 	buffer.clear();
 }
 
-void TextControl::addText(UString text) {
+void TextControl::addText(const WCString &text) {
 	buffer+=text;
 	
 	if(!preview && !primed && buffer.length() > 1500){
 		clearHtml(htmlPrimed);
 		addHtml(htmlPrimed,buffer.c_str());
-		addHtml(htmlPrimed, UString(L"</body></html>").c_str());
+		addHtml(htmlPrimed, L"</body></html>");
 		endHtml(htmlPrimed);
 		ShowWindow(htmlPrimed,SW_SHOW);
 		ShowWindow(htmlFull,SW_HIDE);

Modified: trunk/src/gui/TextControl.h
===================================================================
--- trunk/src/gui/TextControl.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/TextControl.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -19,12 +19,12 @@
 	virtual void paint();
 
 	virtual void clearText();
-	void addText(UString text);
+	void addText(const WCString &text);
 	void endOfText();
 protected:
 	HWND htmlPrimed;
 	HWND htmlFull;
-	UString buffer;
+	WCString buffer;
 	RECT area;
 	bool portrait;
 	bool preview;

Modified: trunk/src/gui/Utils.cpp
===================================================================
--- trunk/src/gui/Utils.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/Utils.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -1,6 +1,7 @@
 #include "Utils.h"
 #include "ApplicationInterface.h"
 
+/*
 WCHAR CharToUchar(const char in){
 	WCHAR result;
 	mbstowcs(&result,&in,1);
@@ -24,12 +25,12 @@
 	return String(_itoa(i, buffer, 10));
 }
 
-UString toUString(std::string s) {
-	UString result(s.length(),L' ');
-    for(int i = 0; i < result.length(); i++){
-        result[i] = CharToUchar(s[i]);
+UString *toUString(UString& dst,const std::string src) {
+    dst.resize(src.length());
+    for(unsigned int i = 0; i < dst.length(); i++){
+        dst[i] = CharToUchar(src[i]);
     }
-	return result;
+	return &dst;
 }
 
 std::string toCString(UString s) {
@@ -54,7 +55,7 @@
 	}
 	return result;
 }
-
+*/
 bool inPortraitMode(){
 	return GetSystemMetrics(SM_CXSCREEN) <= GetSystemMetrics(SM_CYSCREEN);
 }

Modified: trunk/src/gui/Utils.h
===================================================================
--- trunk/src/gui/Utils.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/Utils.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -12,6 +12,8 @@
 
 // This file is a library containing several utilities that can be used throughout the program
 
+/*
+
 typedef std::basic_string<WCHAR> UString;
 typedef std::string String;
 
@@ -19,12 +21,12 @@
 
 String toCString(int i);
 
-UString toUString(String s);
+UString *toUString(UString& dst,const std::string src);
 
 String toCString(UString s);
 
 UString noMarkup(UString in);
-
+*/
 bool inPortraitMode();
 
 void LOGIT(const char *msg, int i);

Modified: trunk/src/gui/VerseTextControl.cpp
===================================================================
--- trunk/src/gui/VerseTextControl.cpp	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/VerseTextControl.cpp	2008-03-16 05:27:55 UTC (rev 98)
@@ -9,21 +9,23 @@
 
 #include <htmlctrl.h>
 
-#define controlToVerse(window,versenr) SendMessage(window, DTM_ANCHORW, FALSE, (LPARAM)(toUString(versenr).c_str()))
+#define controlToVerse(window,versenr) SendMessage(window, DTM_ANCHORW, FALSE, (LPARAM)(versenr))
 
 VerseTextControl::VerseTextControl(int x, int y, int width, int height) 
 		: TextControl(x,y,width,height) {}
 
-void VerseTextControl::addAnchoredText(UString text, int anchor) {
+void VerseTextControl::addAnchoredText(const WCString &text, int anchor) {
 	// anchor is assumed to be embedded in the text
 	addText(text);
 }
 
 void VerseTextControl::gotoAnchor(int anchor) {
+    wchar_t wanchor[16];
+    _itow(anchor, wanchor, 10);
 	if(!primed || preview)
-		controlToVerse(htmlPrimed,anchor);
+		controlToVerse(htmlPrimed,wanchor);
 	else
-		controlToVerse(htmlFull,anchor);
+		controlToVerse(htmlFull,wanchor);
 }
 
 void VerseTextControl::paint() {

Modified: trunk/src/gui/VerseTextControl.h
===================================================================
--- trunk/src/gui/VerseTextControl.h	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/gui/VerseTextControl.h	2008-03-16 05:27:55 UTC (rev 98)
@@ -10,7 +10,7 @@
 class VerseTextControl: public TextControl {
 public:
 	VerseTextControl(int x, int y, int width, int height);
-	void addAnchoredText(UString text, int anchor); 
+	void addAnchoredText(const WCString &text, int anchor); 
 	// we are able to scroll back to this point using the anchor
 	void gotoAnchor(int anchor);
 

Modified: trunk/src/simplegui/simplegui.vcproj
===================================================================
--- trunk/src/simplegui/simplegui.vcproj	2008-03-15 21:21:57 UTC (rev 97)
+++ trunk/src/simplegui/simplegui.vcproj	2008-03-16 05:27:55 UTC (rev 98)
@@ -189,7 +189,7 @@
 				Name="VCLinkerTool"
 				AdditionalOptions="/ALIGN:4096 /subsystem:$(CESubsystem)  "
 				AdditionalDependencies="..\Dll1\&quot;$(PlatformName)\$(ConfigurationName)&quot;\sword.lib htmlview.lib commctrl.lib coredll.lib aygshell.lib"
-				OutputFile="$(PlatformName)\$(ConfigurationName)/simplegui.exe"
+				OutputFile="$(PlatformName)\$(ConfigurationName)/SwordReader.exe"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="..\STL_eVC"
@@ -292,7 +292,7 @@
 				Name="VCLinkerTool"
 				AdditionalOptions="/ALIGN:4096 /subsystem:$(CESubsystem) /MACHINE:ARM "
 				AdditionalDependencies="..\Dll1\&quot;$(PlatformName)\$(ConfigurationName)&quot;\sword.lib htmlview.lib commctrl.lib coredll.lib aygshell.lib secchk.lib ccrtrtti.lib"
-				OutputFile="$(PlatformName)\$(ConfigurationName)/simplegui.exe"
+				OutputFile="$(PlatformName)\$(ConfigurationName)/SwordReader.exe"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="..\STL_eVC"
@@ -491,7 +491,7 @@
 				Name="VCLinkerTool"
 				AdditionalOptions="/ALIGN:4096 /subsystem:$(CESubsystem)  "
 				AdditionalDependencies="..\Dll1\&quot;$(PlatformName)\$(ConfigurationName)&quot;\sword.lib htmlview.lib commctrl.lib coredll.lib aygshell.lib"
-				OutputFile="$(PlatformName)\$(ConfigurationName)/simplegui.exe"
+				OutputFile="$(PlatformName)\$(ConfigurationName)/SwordReader.exe"
 				LinkIncremental="2"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="..\STL_eVC"
@@ -591,7 +591,7 @@
 				Name="VCLinkerTool"
 				AdditionalOptions="/ALIGN:4096 /subsystem:$(CESubsystem) /MACHINE:ARM "
 				AdditionalDependencies="..\Dll1\&quot;$(PlatformName)\$(ConfigurationName)&quot;\sword.lib htmlview.lib commctrl.lib coredll.lib aygshell.lib secchk.lib ccrtrtti.lib"
-				OutputFile="$(PlatformName)\$(ConfigurationName)/simplegui.exe"
+				OutputFile="$(PlatformName)\$(ConfigurationName)/SwordReader.exe"
 				LinkIncremental="2"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="..\STL_eVC"
@@ -1391,6 +1391,10 @@
 					/>
 				</FileConfiguration>
 			</File>
+			<File
+				RelativePath="..\gui\WCString.cpp"
+				>
+			</File>
 		</Filter>
 		<Filter
 			Name="Header Files"
@@ -1452,6 +1456,10 @@
 				RelativePath="..\gui\VerseTextControl.h"
 				>
 			</File>
+			<File
+				RelativePath="..\gui\WCString.h"
+				>
+			</File>
 		</Filter>
 		<Filter
 			Name="Resource Files"




More information about the sword-cvs mailing list