[sword-cvs] swordreader/src/gui Main.cpp,1.2,1.3 NavRenderText.cpp,1.4,1.5 Navigator.cpp,1.2,1.3 Navigator.h,1.2,1.3 gui.vcl,1.11,1.12

sword@www.crosswire.org sword@www.crosswire.org
Sat, 24 Jan 2004 15:30:01 -0700


Update of /cvs/core/swordreader/src/gui
In directory www:/tmp/cvs-serv12620/src/gui

Modified Files:
	Main.cpp NavRenderText.cpp Navigator.cpp Navigator.h gui.vcl 
Log Message:
Finished first pass at option menu

Index: Main.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/Main.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Main.cpp	24 Jan 2004 19:45:52 -0000	1.2
+++ Main.cpp	24 Jan 2004 22:29:59 -0000	1.3
@@ -233,8 +233,8 @@
 	HMENU menuMenu = getSubMenu(g_hwndCB,MENU_MENU);
 	
 	HMENU menuTranslations=CreatePopupMenu();
-	g_navigator->fillTranslationsMenu(menuTranslations);
 	InsertMenu(menuMenu,0,MF_POPUP,(UINT)menuTranslations,L"Translation");
+	g_navigator->fillTranslationsMenu(menuTranslations);
 
 	DrawMenuBar(g_hwndCB);
 }
@@ -243,8 +243,9 @@
 	HMENU menuMenu = getSubMenu(g_hwndCB,MENU_MENU);
 	
 	HMENU menuGlobalOptions=CreatePopupMenu();
-	g_navigator->fillGlobalOptionsMenu(menuGlobalOptions);
 	InsertMenu(menuMenu,0,MF_POPUP,(UINT)menuGlobalOptions,L"Options");
+	g_navigator->fillGlobalOptionsMenu(menuGlobalOptions);
+	g_navigator->toggleOptionMenu(-1);	// get all checked menu choiced correct, but don't change anything
 
 	DrawMenuBar(g_hwndCB);
 }

Index: NavRenderText.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavRenderText.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- NavRenderText.cpp	21 Jan 2004 19:52:25 -0000	1.4
+++ NavRenderText.cpp	24 Jan 2004 22:29:59 -0000	1.5
@@ -10,7 +10,6 @@
 //#define NOHTML
 
 
-
 #ifndef NOHTML
 
 
@@ -161,163 +160,104 @@
 
 
 //simpeler graphical representation not using the HTML component
-
 NavRenderText::NavRenderText(Navigator* navigator) {
-
 	this->navigator=navigator;
-
 }
 
 
-
 NavRenderText::~NavRenderText() {
-
 }
 
 
-
 void NavRenderText::show(bool forceRefresh) {
-
 }
 
 
-
 void NavRenderText::showText(bool forceRefresh) {
-
 }
 
 
-
 void NavRenderText::load() {
-
 }
 
 
-
 void NavRenderText::hide() {
-
 }
 
 
-
 void NavRenderText::paint() {
-
 	clearRect(&RECT_SCREEN);
-
 	RECT textRect=RECT_SCREEN;
-
 	setFont(FONT_TEXT);
-
 	navigator->position.setMark();
-
 	verseCount=0;
-
 	bool ready=false;
-
-	String* s=new String(); String* heading=new String();//If not a pointer, warnings will occur
+	UString s; 
+	UString heading;
 
 	while ((textRect.top<textRect.bottom)&&(!ready)) {
-
 		__try {
-
-			*s=navigator->position.verseText();
-
-			if (s->length()>0) {
-
-				*heading=getVerseHeader();
-
-				textRect.top+=drawVerseText(&textRect,toUString((*heading)+(*s)));
-
+			s = navigator->position.verseText();
+			if (s.length() > 0) {
+				heading = getVerseHeader();
+				textRect.top += drawVerseText(&textRect,heading+s);
 			}
-
 		}
-
 		__except(EXCEPTION_EXECUTE_HANDLER) {
-
 			drawVerseText(&textRect,UString(L"Not enough memory available"));
-
 			ready=true;
-
 		}			
 
 		navigator->position.next();
-
 		verseCount++;
-
 	}
 
-	delete s;delete heading;
-
 	navigator->position.jumpBack();
-
 	setFont();
 
 }
 
 
-
-String NavRenderText::getVerseHeader() {
-
+UString NavRenderText::getVerseHeader() {
 	String result;
 
 	if (navigator->position.getVerse()==1) {
-
 		result+=toCString(navigator->position.getChap());
-
 		result+=":";
-
 	}
 
 	result+=toCString(navigator->position.getVerse());
-
 	result+=" ";
 
-	return result;
-
+	return toUString(result);
 }
 
 
-
 void NavRenderText::keyDown(WPARAM id, LPARAM lparam) {
-
 	switch (id) {
-
 		case VK_UP:
-
 			navigator->position--;
-
 			navigator->refresh();
-
 			break;
 
 		case VK_DOWN:
-
 			navigator->position++;
-
 			navigator->refresh();
-
 			break;
 
 		case VK_LEFT:
-
 			navigator->position-=verseCount-1;
-
 			navigator->refresh();
-
 			break;
 
 		case VK_RIGHT:
-
 			navigator->position+=verseCount-1;
-
 			navigator->refresh();
-
 			break;
 
 		}
 
 	navigator->updateTitle();
-
 }
 
 

Index: Navigator.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/Navigator.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Navigator.cpp	24 Jan 2004 19:45:52 -0000	1.2
+++ Navigator.cpp	24 Jan 2004 22:29:59 -0000	1.3
@@ -33,12 +33,21 @@
 	numbers=new NavNumbers(this);
 	books=new NavBooks(this);
 	text=new NavRenderText(this);
+	nextID = 1;
+	optStartID = 0;
+	optEndID = 0;
+	transStartID = 0;
+	transEndID = 0;
+	options = 0;
+	opCount = 0;
 }
 
 Navigator::~Navigator() {
 	delete numbers;
 	delete books;
 	delete text;
+	if (options)
+		delete options;
 }
 
 void Navigator::refresh() {
@@ -91,9 +100,16 @@
 
 /* a menu-item is selected (one of the translations) */
 void Navigator::buttonClicked(int id) {
-	setModule(id);
-	checkModuleMenu(id);
-	text->show(true);
+	if ((id >= transStartID) && (id <= transEndID)) {
+		setModule(id);
+		checkModuleMenu(id);
+		text->show(true);
+	}
+	else if ((id >= optStartID) && (id <= optEndID)) {
+		toggleOptionMenu(id);
+		setMode(MODE_TEXT);
+		text->show(true);
+	}
 }
 
 void Navigator::keyDown(WPARAM id, LPARAM lparam) {
@@ -132,41 +148,66 @@
 }
 
 void Navigator::fillTranslationsMenu(HMENU menuTranslations) {
+	transStartID = nextID;
 	this->menuTranslations=menuTranslations;
 	if (menuTranslations) {
-		int modulenr=1;
 		for (ModuleMap::iterator i=position.firstModule();i!=position.lastModule();i++) {
-			addMenu(menuTranslations,modulenr,toUString(String(i->first)));
-			modulenr++;
+			addMenu(menuTranslations, nextID++, toUString(String(i->first)));
 		}
 	}
 	checkModuleMenu(1);
+	transEndID = nextID - 1;
 }
 
 void Navigator::fillGlobalOptionsMenu(HMENU menuOptions) {
-	this->menuOptions=menuOptions;
 	if (menuOptions) {
-		int modulenr=1;
-		StringList options = position.manager->getGlobalOptions();
-		for (StringList::iterator i = options.begin(); i != options.end(); i++) {
-			HMENU menuOption = CreatePopupMenu();
+		if (options)
+			delete options;
+		optStartID = nextID;
+		this->menuOptions=menuOptions;
+		StringList optionNames = position.manager->getGlobalOptions();
+
+		// count options
+		opCount = 0;
+		for (StringList::iterator i = optionNames.begin(); i != optionNames.end(); i++) {
 			StringList values = position.manager->getGlobalOptionValues(*i);
+			bool supported = true;
 			for (StringList::iterator j = values.begin(); j != values.end(); j++) {
-				addMenu(menuOption, modulenr++, toUString(j->c_str()));
+				if ((*j != "On") && (*j != "Off"))
+					supported = false;
+			}
+			if (supported)
+				opCount++;
+		}
+
+		options = new SWBuf[opCount];
+
+		// add options;
+		for (i = optionNames.begin(); i != optionNames.end(); i++) {
+//			HMENU menuOption = CreatePopupMenu();
+//			InsertMenu(menuOptions,0,MF_POPUP,(UINT)menuOption, toUString(i->c_str()).c_str());
+			StringList values = position.manager->getGlobalOptionValues(*i);
+			bool supported = true;
+			for (StringList::iterator j = values.begin(); j != values.end(); j++) {
+//				addMenu(menuOption, nextID++, toUString(j->c_str()));
+				if ((*j != "On") && (*j != "Off"))
+					supported = false;
+			}
+			if (supported) {
+				options[nextID - optStartID] = *i;
+				addMenu(menuOptions, nextID++, toUString(i->c_str()));
 			}
-			InsertMenu(menuOptions,0,MF_POPUP,(UINT)menuOption, strtowstr(i->c_str()));
 		}
 	}
+	optEndID = nextID - 1;
 }
 
 void Navigator::setModule(int id) {
-	int modulenr=1;
+	int modulenr = transStartID;
 	ModuleMap::iterator i;
-	for (
-		i=position.firstModule();
-		(i!=position.lastModule())&&(id!=modulenr);
-		i++
-	) { 
+	for (i=position.firstModule();
+			(i!=position.lastModule())&&(id!=modulenr);
+			i++) { 
 		modulenr++; 
 	};
 	if (i!=position.lastModule()) {
@@ -175,10 +216,25 @@
 	}
 }
 
+
 void Navigator::checkModuleMenu(int id) {
-	int current=1;
+	int current=transStartID;
 	for (ModuleMap::iterator i=position.firstModule();i!=position.lastModule();i++) {
 		checkMenu(menuTranslations,current,(current==id));
 		current++;
+	}
+}
+
+
+void Navigator::toggleOptionMenu(int id) {
+	if (options) {
+		for (int i = optStartID; i <= optEndID; i++) {
+			SWBuf val = position.manager->getGlobalOption(options[i-optStartID]);
+			if (i == id) {
+				val = (val=="On")?"Off":"On";
+				position.manager->setGlobalOption(options[i-optStartID], val);
+			}
+			checkMenu(menuOptions, i, (val == "On"));
+		}
 	}
 }

Index: Navigator.h
===================================================================
RCS file: /cvs/core/swordreader/src/gui/Navigator.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Navigator.h	24 Jan 2004 19:45:52 -0000	1.2
+++ Navigator.h	24 Jan 2004 22:29:59 -0000	1.3
@@ -12,6 +12,9 @@
 
 #include "utils.h"
 #include "SwordIndex.h"
+#include <swbuf.h>
+
+using namespace sword;
 
 #define NUM_MENUS	5
 
@@ -37,6 +40,13 @@
 	HMENU menuTranslations;
 	HMENU menuOptions;
 
+	int nextID;
+	int transStartID;
+	int transEndID;
+	int optStartID;
+	int optEndID;
+	SWBuf *options;
+	int opCount;
 	UString getVerseHeader();
 
 	void showChap();
@@ -44,37 +54,27 @@
 
 	void setModule(int id);
 	void checkModuleMenu(int id);
+
 public:
 	SwordIndex position;
-
 	NavNumbers* numbers;
-
 	NavBooks* books;
-
 	NavRenderText* text;
 
 	Navigator(RECT* screen);
 	virtual ~Navigator();
-	
-	void updateTitle();
 
+	void updateTitle();
 	void fillTranslationsMenu(HMENU menuTranslations);
 	void fillGlobalOptionsMenu(HMENU menuTranslations);
-
+	void toggleOptionMenu(int id);
 	void refresh();
-
 	void setMode(int mode);
-
 	void paint();
-
 	void buttonClicked(int id);
-
 	void keyDown(WPARAM id, LPARAM lparam);
-
 	void mouseDown(int x, int y);
-
 	bool initialized() {return position.initialized();}
-
 };
 
 #endif // !defined(AFX_NAVIGATOR_H__3F8DCC07_29A2_46F6_B31C_897A653319E5__INCLUDED_)

Index: gui.vcl
===================================================================
RCS file: /cvs/core/swordreader/src/gui/gui.vcl,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- gui.vcl	24 Jan 2004 19:45:52 -0000	1.11
+++ gui.vcl	24 Jan 2004 22:29:59 -0000	1.12
@@ -3,13 +3,13 @@
 <pre>
 <h1>Build Log</h1>
 <h3>
---------------------Configuration: gui - Win32 (WCE x86) Debug--------------------
+--------------------Configuration: gui - Win32 (WCE ARM) Release--------------------
 </h3>
 <h3>Command Lines</h3>
-Creating command line "rc.exe /l 0x409 /fo"X86Dbg/BibleReader.res" /i "..\dll1\sword\include" /i "..\dll1\wincesword\include" /d UNDER_CE=300 /d _WIN32_WCE=300 /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "WIN32_PLATFORM_PSPC=310" /d "_X86_" /d "x86" /d "_i386_" /r "D:\src\swordreader\src\gui\BibleReader.rc"" 
-Creating temporary file "C:\DOCUME~1\scribe\LOCALS~1\Temp\RSP5A.tmp" with contents
+Creating command line "rc.exe /l 0x409 /fo"ARMRel/BibleReader.res" /i "..\dll1\sword\include" /i "..\dll1\wincesword\include" /i "..\STL_eVC" /d UNDER_CE=300 /d _WIN32_WCE=300 /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "WIN32_PLATFORM_PSPC=310" /d "ARM" /d "_ARM_" /r "D:\src\swordreader\src\gui\BibleReader.rc"" 
+Creating temporary file "C:\DOCUME~1\scribe\LOCALS~1\Temp\RSPDD.tmp" with contents
 [
-/nologo /W3 /Zi /Od /I "..\STL_eVC" /I "..\..\..\sword\include" /I "..\dll1\wincesword\include" /D "DEBUG" /D "_i386_" /D UNDER_CE=300 /D _WIN32_WCE=300 /D "WIN32_PLATFORM_PSPC=310" /D "i_386_" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /FR"X86Dbg/" /Fp"X86Dbg/gui.pch" /YX /Fo"X86Dbg/" /Fd"X86Dbg/" /Gs8192 /GF /c 
+/nologo /W3 /I "..\STL_eVC" /I "..\..\..\sword\include" /I "..\dll1\wincesword\include" /D _WIN32_WCE=300 /D "WIN32_PLATFORM_PSPC=310" /D "ARM" /D "_ARM_" /D UNDER_CE=300 /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /Fp"ARMRel/gui.pch" /YX /Fo"ARMRel/" /Oxs /MC /c 
 "D:\src\swordreader\src\gui\ApplicationInterface.cpp"
 "D:\src\swordreader\src\gui\Main.cpp"
 "D:\src\swordreader\src\gui\NavBooks.cpp"
@@ -19,21 +19,21 @@
 "D:\src\swordreader\src\gui\SwordIndex.cpp"
 "D:\src\swordreader\src\gui\Utils.cpp"
 ]
-Creating command line "cl.exe @C:\DOCUME~1\scribe\LOCALS~1\Temp\RSP5A.tmp" 
-Creating temporary file "C:\DOCUME~1\scribe\LOCALS~1\Temp\RSP5B.tmp" with contents
+Creating command line "clarm.exe @C:\DOCUME~1\scribe\LOCALS~1\Temp\RSPDD.tmp" 
+Creating temporary file "C:\DOCUME~1\scribe\LOCALS~1\Temp\RSPDE.tmp" with contents
 [
-corelibc.lib ..\Dll1\X86Dbg\sword.lib htmlview.lib oleaut32.lib commctrl.lib coredll.lib aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /incremental:yes /pdb:"X86Dbg/gui.pdb" /debug /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:libc.lib /nodefaultlib:libcd.lib /nodefaultlib:libcmt.lib /nodefaultlib:libcmtd.lib /nodefaultlib:msvcrt.lib /nodefaultlib:msvcrtd.lib /nodefaultlib:oldnames.lib /out:"X86Dbg/gui.exe" /subsystem:windowsce,3.00 /MACHINE:IX86 
-.\X86Dbg\ApplicationInterface.obj
-.\X86Dbg\Main.obj
-.\X86Dbg\NavBooks.obj
-.\X86Dbg\Navigator.obj
-.\X86Dbg\NavNumbers.obj
-.\X86Dbg\NavRenderText.obj
-.\X86Dbg\SwordIndex.obj
-.\X86Dbg\Utils.obj
-.\X86Dbg\BibleReader.res
+..\Dll1\ARMRel\sword.lib htmlview.lib oleaut32.lib commctrl.lib coredll.lib aygshell.lib ..\Dll1\ARMRel\sword.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /incremental:no /pdb:"ARMRel/gui.pdb" /nodefaultlib:"libc.lib /nodefaultlib:libcd.lib /nodefaultlib:libcmt.lib /nodefaultlib:libcmtd.lib /nodefaultlib:msvcrt.lib /nodefaultlib:msvcrtd.lib /nodefaultlib:oldnames.lib" /out:"ARMRel/gui.exe" /libpath:"..\STL_eVC" /libpath:"C:\IpaqProgs\SwordReader\src\STL_eVC\\" /subsystem:windowsce,3.00 /align:"4096" /MACHINE:ARM 
+.\ARMRel\ApplicationInterface.obj
+.\ARMRel\Main.obj
+.\ARMRel\NavBooks.obj
+.\ARMRel\Navigator.obj
+.\ARMRel\NavNumbers.obj
+.\ARMRel\NavRenderText.obj
+.\ARMRel\SwordIndex.obj
+.\ARMRel\Utils.obj
+.\ARMRel\BibleReader.res
 ]
-Creating command line "link.exe @C:\DOCUME~1\scribe\LOCALS~1\Temp\RSP5B.tmp"
+Creating command line "link.exe @C:\DOCUME~1\scribe\LOCALS~1\Temp\RSPDE.tmp"
 <h3>Output Window</h3>
 Compiling resources...
 Compiling...
@@ -53,12 +53,12 @@
 NavRenderText.cpp
 ..\..\..\sword\include\swbuf.h(206) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
 ..\..\..\sword\include\swbuf.h(213) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
-D:\src\swordreader\src\gui\NavRenderText.cpp(115) : warning C4509: nonstandard extension used: 'load' uses SEH and 'heading' has destructor
-        D:\src\swordreader\src\gui\NavRenderText.cpp(88) : see declaration of 'heading'
-D:\src\swordreader\src\gui\NavRenderText.cpp(115) : warning C4509: nonstandard extension used: 'load' uses SEH and 's' has destructor
-        D:\src\swordreader\src\gui\NavRenderText.cpp(87) : see declaration of 's'
-D:\src\swordreader\src\gui\NavRenderText.cpp(115) : warning C4509: nonstandard extension used: 'load' uses SEH and 'text' has destructor
-        D:\src\swordreader\src\gui\NavRenderText.cpp(81) : see declaration of 'text'
+D:\src\swordreader\src\gui\NavRenderText.cpp(114) : warning C4509: nonstandard extension used: 'load' uses SEH and 'heading' has destructor
+        D:\src\swordreader\src\gui\NavRenderText.cpp(87) : see declaration of 'heading'
+D:\src\swordreader\src\gui\NavRenderText.cpp(114) : warning C4509: nonstandard extension used: 'load' uses SEH and 's' has destructor
+        D:\src\swordreader\src\gui\NavRenderText.cpp(86) : see declaration of 's'
+D:\src\swordreader\src\gui\NavRenderText.cpp(114) : warning C4509: nonstandard extension used: 'load' uses SEH and 'text' has destructor
+        D:\src\swordreader\src\gui\NavRenderText.cpp(80) : see declaration of 'text'
 SwordIndex.cpp
 ..\..\..\sword\include\swbuf.h(206) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
 ..\..\..\sword\include\swbuf.h(213) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)