[sword-cvs] swordreader/src/gui BibleReader.aps, 1.5, 1.6 Main.cpp, 1.8, 1.9 NavBooks.cpp, 1.7, 1.8 NavFind.cpp, 1.7, 1.8 NavFind.h, 1.7, 1.8 NavNumbers.cpp, 1.6, 1.7 TextControl.cpp, 1.2, 1.3 resource.h, 1.4, 1.5

sword at www.crosswire.org sword at www.crosswire.org
Sat Jul 24 12:21:28 MST 2004


Committed by: jgorter

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

Modified Files:
	BibleReader.aps Main.cpp NavBooks.cpp NavFind.cpp NavFind.h 
	NavNumbers.cpp TextControl.cpp resource.h 
Log Message:
Latest changes:
- switched rows/colums for faster browsing
- added some comments
- added about menu

Index: BibleReader.aps
===================================================================
RCS file: /cvs/core/swordreader/src/gui/BibleReader.aps,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
Binary files /tmp/cvsnO2Upq and /tmp/cvsGNbeqQ differ

Index: Main.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/Main.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Main.cpp	15 Mar 2004 10:44:35 -0000	1.8
+++ Main.cpp	24 Jul 2004 19:21:25 -0000	1.9
@@ -4,9 +4,11 @@
 #ifdef SIMPLE
 	#include "SimpleNavigator.h"
 	#define NAVIGATOR SimpleNavigator
+	#include "../simplegui/resource.h"
 #else
 	#include "Navigator.h"
 	#define NAVIGATOR Navigator
+	#include "resource.h"
 #endif
 
 #include <aygshell.h>
@@ -153,6 +155,9 @@
 					SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
 					SendMessage (hWnd, WM_CLOSE, 0, 0);
 					break;
+				case MENU_ABOUT:
+					MessageBox(0, L"Sword reader program for IPAQ\n\nsee: http://www.crosswire.org/sword/swordreader/\n\nGUI by Johan Gorter, 2004\nProverbs 16:3", L"About", MB_OK);
+					break;
 				case MENU_SHUTDOWN:
 					SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
 					SendMessage (hWnd, WM_CLOSE, 0, 0);
@@ -232,7 +237,7 @@
 	HMENU menuMenu = getSubMenu(g_hwndCB,MENU_MENU);
 	
 	HMENU menuTranslations=CreatePopupMenu();
-	InsertMenu(menuMenu,0,MF_POPUP,(UINT)menuTranslations,L"Translation");
+	InsertMenu(menuMenu,0,MF_BYPOSITION | MF_POPUP,(UINT)menuTranslations,L"Translation");
 	g_navigator->fillTranslationsMenu(menuTranslations);
 
 	DrawMenuBar(g_hwndCB);
@@ -242,7 +247,7 @@
 	HMENU menuMenu = getSubMenu(g_hwndCB,MENU_MENU);
 	
 	HMENU menuGlobalOptions=CreatePopupMenu();
-	InsertMenu(menuMenu,0,MF_POPUP,(UINT)menuGlobalOptions,L"Options");
+	InsertMenu(menuMenu,0,MF_BYPOSITION | 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
 

Index: NavBooks.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavBooks.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- NavBooks.cpp	17 Apr 2004 18:51:47 -0000	1.7
+++ NavBooks.cpp	24 Jul 2004 19:21:25 -0000	1.8
@@ -11,13 +11,11 @@
 #define PADDING_WIDTH 3
 #define PADDING_HEIGHT 3
 
-#define MAXHORIZONTAL 8
+#define MAXVERTICAL 10
 
 #define ROW0 15
 #define ROW1 30
 #define ROW2 45
-#define STARTNTROW 160
-#define LASTROW 240
 
 NavBooks::NavBooks(SimpleNavigator* navigator): NavPage(navigator) {
 	this->position=&(navigator->position);
@@ -34,13 +32,12 @@
 	memset(&rt,0,sizeof(rt));
 	rt.right=RECT_SCREEN.right;
 
-	//to see if the whole screen gets filled
+	// to see if the whole screen gets filled
 	//rt.bottom=RECT_SCREEN.bottom;
 	//setBackground(0x00000000);
 	//drawText(&rt,UString(L"test"));
 	//setBackground();
-	//
-
+	
 	rt.bottom=ROW0;
 	clearRect(&rt);
 
@@ -50,46 +47,46 @@
 	rt.top=ROW1; rt.bottom=ROW2;
 	clearRect(&rt);
 
-	//TCHAR buttonText[4];
-	//buttonText[3]=L'\0';
 	setBackground(BUTTON_BACKGROUND);
 	setFont(FONT_NAVIGATION);
 	TCHAR** bookNames=position->getBookNames();
 	int current=1;
 	int maxTNumber=maxOTNumber;
+	//padding left of books
+	rt.top=rt.bottom; rt.bottom=RECT_SCREEN.bottom;
+	rt.right=PADDING_WIDTH;
+	clearRect(&rt);
 	while (current<=maxNumber) {
 		//Paint one testament
 		while (current<=maxTNumber) {
-			int rowStart=current;
-			rt.top=rt.bottom; rt.bottom=rt.top+BUTTON_HEIGHT; rt.right=0;
-			while ((current<=maxTNumber)&&(current-rowStart<MAXHORIZONTAL)) {
-				//padding left of button
-				rt.left=rt.right;rt.right=rt.left+PADDING_WIDTH;
+			int colStart=current;
+			rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW2;
+			while ((current<=maxTNumber)&&(current-colStart<MAXVERTICAL)) {
+				//padding top of button
+				rt.top=rt.bottom;rt.bottom=rt.top+PADDING_HEIGHT;
 				clearRect(&rt);
 				//button
-				rt.left=rt.right;rt.right=rt.left+BUTTON_WIDTH;
-				//_itow(current,buttonText,10);
-				//wcsncpy(buttonText,(position->bookName(current)).c_str(),3);
+				rt.top=rt.bottom;rt.bottom=rt.top+BUTTON_HEIGHT;
 				drawText(&rt,bookNames[current-1],3);
 				current++;
 			}
-			//padding right of buttons
-			rt.left=rt.right;rt.right=RECT_SCREEN.right;
+			//	padding below buttons
+			rt.top=rt.bottom;rt.bottom=RECT_SCREEN.bottom;
 			clearRect(&rt);
-			//padding below buttons
-			rt.left=0; rt.top=rt.bottom; rt.bottom=rt.top+PADDING_HEIGHT;
+			// padding right of buttons
+			rt.top=ROW2; rt.left=rt.right; rt.right=rt.left+PADDING_WIDTH;
 			clearRect(&rt);
 		}
 		if (current<maxNumber) {
 			//space between testaments
 			maxTNumber=maxNumber;
-			rt.bottom=STARTNTROW;
+			rt.right=rt.left+BUTTON_WIDTH+PADDING_WIDTH;
 			clearRect(&rt);
 		}
 
 	}
-	//space below the buttons
-	rt.top=rt.bottom; rt.bottom=RECT_SCREEN.bottom;
+	//space right of the buttons
+	rt.left=rt.right; rt.right=RECT_SCREEN.right; rt.bottom=RECT_SCREEN.bottom;
 	clearRect(&rt);
 
 	setBackground();
@@ -97,31 +94,34 @@
 }
 
 int NavBooks::numberAt(int x, int y) {
-	if ((y>=ROW2)&&(y<STARTNTROW)) {
+	if ((y>=ROW2)&&(y<ROW2+MAXVERTICAL*(PADDING_HEIGHT+BUTTON_HEIGHT))) {
 		y=y-ROW2;
-		int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT));
-		y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
-		int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
-		if (horizontal<MAXHORIZONTAL) {
+		if ((x>=PADDING_WIDTH)&&(x<PADDING_WIDTH+4*(BUTTON_WIDTH+PADDING_WIDTH))) {
+			x=x-PADDING_WIDTH;
+			int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
 			x=x-horizontal*(PADDING_WIDTH+BUTTON_WIDTH);
-			//button is in upper right corner
-			if ((x>=PADDING_WIDTH)&&(y<=BUTTON_HEIGHT)) {
-				int current=vertical*MAXHORIZONTAL+horizontal+1;
-				if (current<=maxOTNumber) return current;
+			int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT));
+			if (vertical<MAXVERTICAL) {
+				y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
+				//button is in bottom left corner
+				if ((x<BUTTON_WIDTH)&&(y>=PADDING_HEIGHT)) {
+					int current=horizontal*MAXVERTICAL+vertical+1;
+					if (current<=maxOTNumber) return current;
+				}
 			}
 		}
-	}
-	else if (y>=STARTNTROW) {
-		y=y-STARTNTROW;
-		int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT));
-		y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
-		int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
-		if (horizontal<MAXHORIZONTAL) {
+		else if (x>=PADDING_WIDTH+5*(BUTTON_WIDTH+PADDING_WIDTH)) {
+			x=x-(PADDING_WIDTH+5*(BUTTON_WIDTH+PADDING_WIDTH));
+			int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
 			x=x-horizontal*(PADDING_WIDTH+BUTTON_WIDTH);
-			//button is in upper right corner
-			if ((x>=PADDING_WIDTH)&&(y<=BUTTON_HEIGHT)) {
-				int current=vertical*MAXHORIZONTAL+horizontal+maxOTNumber+1;
-				if (current<=maxNumber) return current;
+			int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT));
+			if (vertical<MAXVERTICAL) {
+				y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
+				//button is in bottom left corner
+				if ((x<BUTTON_WIDTH)&&(y>=PADDING_HEIGHT)) {
+					int current=horizontal*MAXVERTICAL+vertical+maxOTNumber+1;
+					if (current<=maxNumber) return current;
+				}
 			}
 		}
 	}

Index: NavFind.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavFind.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- NavFind.cpp	24 Jul 2004 15:28:01 -0000	1.7
+++ NavFind.cpp	24 Jul 2004 19:21:25 -0000	1.8
@@ -9,6 +9,7 @@
 
 
 NavFind::NavFind(SimpleNavigator* navigator) : NavPage(navigator) {
+	// register ID's so we get feedback
 	searchID=navigator->getID();
 	rangeBibleID=navigator->getID();
 	rangeTestamentID=navigator->getID();
@@ -17,8 +18,7 @@
 	methodExactphraseID=navigator->getID();
 	goID=navigator->getID();
 	resultsID=navigator->getID();
-	query=L"Busy implementing, id=";
-	query+=toUString(searchID);
+	// create windows ce managed controls
 	queryEdit = CreateWindow(_T("edit"), NULL, 
 		WS_CHILD | ES_AUTOHSCROLL | ES_LEFT | WS_TABSTOP | WS_BORDER,
 		0, 0, 180, 24,
@@ -60,6 +60,7 @@
 		WS_CHILD | BS_PUSHBUTTON, 
 		180,96,60,24,
 		g_hWnd,	registerID(goID), g_hInst, NULL);
+	// HTML control
 	preview=new TextControl(80,120,160,148);
 	preview->clearText();
 	preview->addText(UString(L"preview"));
@@ -71,6 +72,7 @@
 }
 
 void NavFind::show() {
+	// set our controls to visible
 	ShowWindow(queryEdit,SW_SHOW);
 	ShowWindow(search,SW_SHOW);
 
@@ -84,10 +86,13 @@
 	ShowWindow(results,SW_SHOW);
 	ShowWindow(progressBar,SW_SHOW);
 	ShowWindow(go,SW_SHOW);
+
+	// propagate to HTML control
 	preview->show();
 }
 
 void NavFind::hide() {
+	// set our controls to visible
 	ShowWindow(queryEdit,SW_HIDE);
 	ShowWindow(search,SW_HIDE);
 
@@ -101,16 +106,19 @@
 	ShowWindow(results,SW_HIDE);
 	ShowWindow(progressBar,SW_HIDE);
 	ShowWindow(go,SW_HIDE);
+	// propagate to HTML control
 	preview->hide();
 }
 
 void NavFind::paint() {
+	// this method can be used to do custom painting, for an example, see NavBooks::paint()
+	// propagate to HTML control
 	preview->paint();
 }
 
 void NavFind::buttonClicked(int id) {
+	// is it one of our registered ID's?
 	if (id==searchID) {
-		query=L"Search not implemented";
 		searchFor(getText(queryEdit));
 		refreshScreen();
 	} else if (id==rangeBibleID) {

Index: NavFind.h
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavFind.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- NavFind.h	24 Jul 2004 15:28:01 -0000	1.7
+++ NavFind.h	24 Jul 2004 19:21:25 -0000	1.8
@@ -35,7 +35,6 @@
 	int rangeBibleID, rangeTestamentID, rangeBookID;
 	int methodMultiwordID, methodExactphraseID;
 	int goID, resultsID;
-	UString query;
 	void clearResults();
 	void previewVerse(Verse* verse);
 	void navigateToVerse(Verse* verse);

Index: NavNumbers.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavNumbers.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- NavNumbers.cpp	17 Apr 2004 18:51:47 -0000	1.6
+++ NavNumbers.cpp	24 Jul 2004 19:21:25 -0000	1.7
@@ -18,7 +18,7 @@
 #define ROW0 15
 #define ROW1 30
 #define ROW2 45
-#define LASTROW 240
+#define LASTROW ROW2+MAXVERTICAL*(BUTTON_HEIGHT+PADDING_HEIGHT)
 
 NavNumbers::NavNumbers(SimpleNavigator* navigator):NavPage(navigator) {
 }
@@ -35,12 +35,11 @@
 	memset(&rt,0,sizeof(rt));
 	rt.right=RECT_SCREEN.right;
 
-	//to see if the whole screen gets filled
-	//rt.bottom=RECT_SCREEN.bottom;
-	//setBackground(0x00000000);
-	//drawText(&rt,UString(L"test"));
-	//resetBackground();
-	//
+	// to see if the whole screen gets filled
+	rt.bottom=RECT_SCREEN.bottom;
+	setBackground(0x00000000);
+	drawText(&rt,UString(L"test"));
+	setBackground();
 
 	rt.bottom=ROW0;
 	clearRect(&rt);
@@ -55,38 +54,47 @@
 	setBackground(BUTTON_BACKGROUND);
 	setFont(FONT_NAVIGATION);
 	int current=start;
+	// left of first buttons
+	rt.right=rt.left+PADDING_WIDTH;
+	rt.top=rt.bottom; rt.bottom=LASTROW;
+	clearRect(&rt);
+
 	while ((current<=maxNumber)&&(current<start+MAXNUMBERS)) {
-		int rowStart=current;
-		rt.top=rt.bottom; rt.bottom=rt.top+BUTTON_HEIGHT; rt.right=0;
-		while ((current<=maxNumber)&&(current-rowStart<MAXHORIZONTAL)) {
-			//padding left of button
-			rt.left=rt.right;rt.right=rt.left+PADDING_WIDTH;
+		int colStart=current;
+		rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW2;
+		while ((current<=maxNumber)&&(current-colStart<MAXVERTICAL)) {
+			//padding above button
+			rt.top=rt.bottom;rt.bottom=rt.top+PADDING_HEIGHT;
 			clearRect(&rt);
 			//button
-			rt.left=rt.right;rt.right=rt.left+BUTTON_WIDTH;
+			rt.top=rt.bottom;rt.bottom=rt.top+BUTTON_HEIGHT;
 			_itow(current,buttonText,10);
 			drawRText(&rt,buttonText,wcslen(buttonText));
 			current++;
 		}
-		//padding right of buttons
-		rt.left=rt.right;rt.right=RECT_SCREEN.right;
-		clearRect(&rt);
 		//padding below buttons
-		rt.left=0; rt.top=rt.bottom; rt.bottom=rt.top+PADDING_HEIGHT;
+		rt.top=rt.bottom;rt.bottom=LASTROW;
+		clearRect(&rt);
+		//padding right of buttons
+		rt.top=ROW2; rt.left=rt.right; rt.right=rt.left+PADDING_WIDTH;
 		clearRect(&rt);
 	}
+	//area right of buttons
+	rt.left=rt.right; rt.right=RECT_SCREEN.right;
+	clearRect(&rt);
+	rt.left=RECT_SCREEN.left;rt.right=RECT_SCREEN.right; //rt.bottom is still LASTROW
 	//optional 'more' button
 	if ((start!=1)||(current<maxNumber)) {
-		rt.top=rt.bottom; rt.bottom=ROW2+MAXVERTICAL*(BUTTON_HEIGHT+PADDING_HEIGHT);
+		rt.top=rt.bottom;rt.bottom=rt.top+PADDING_HEIGHT;
 		clearRect(&rt);
 		rt.top=rt.bottom; rt.bottom=rt.top+BUTTON_HEIGHT;
 		rt.right=(RECT_SCREEN.right/3);
 		clearRect(&rt);
 		rt.left=rt.right;rt.right=RECT_SCREEN.right-rt.left;
-		drawText(&rt,L"More...",7);
+		drawText(&rt,UString(L"More..."));
 		rt.left=rt.right;rt.right=RECT_SCREEN.right;
 		clearRect(&rt);
-		rt.left=0;
+		rt.left=RECT_SCREEN.left;
 	}
 	//space below the buttons
 	rt.top=rt.bottom; rt.bottom=RECT_SCREEN.bottom;
@@ -98,29 +106,30 @@
 
 int NavNumbers::numberAt(int x, int y) {
 	y=y-ROW2;
-	if (y>0) {
-		int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT));
-		if (vertical<MAXVERTICAL) {
-			y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
-			int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
-			if (horizontal<MAXHORIZONTAL) {
-				x=x-horizontal*(PADDING_WIDTH+BUTTON_WIDTH);
-				//button is in upper right corner
-				if ((x>=PADDING_WIDTH)&&(y<=BUTTON_HEIGHT)) {
-					int current=vertical*MAXHORIZONTAL+horizontal+start;
+	if (x>0) {
+		int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
+		if (horizontal<MAXHORIZONTAL) {
+			x=x-horizontal*(PADDING_HEIGHT+BUTTON_HEIGHT);
+			int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT));
+			if (vertical<MAXVERTICAL) {
+				y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
+				//button is in bottom right corner
+				if ((x>=PADDING_WIDTH)&&(y>=PADDING_HEIGHT)) {
+					int current=horizontal*MAXVERTICAL+vertical+start;
 					if (current<=maxNumber) return current;
 				}
 			}
-		}
-		else if (vertical==MAXVERTICAL) { // The 'more' button is here
-			y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
-			if (y<=BUTTON_HEIGHT) {
-				if (((2*x)>=(RECT_SCREEN.right-x))&&((2*(RECT_SCREEN.right-x))>=x)) {
-					if ((start+MAXNUMBERS)>maxNumber)
-						start=1;
-					else
-						start=start+MAXNUMBERS;
-					refreshScreen();
+			else if (vertical==MAXVERTICAL) { // The 'more' button is here
+				y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
+				if (y>=PADDING_HEIGHT) {
+					x=x+horizontal*(PADDING_HEIGHT+BUTTON_HEIGHT); //undo
+					if (((2*x)>=(RECT_SCREEN.right-x))&&((2*(RECT_SCREEN.right-x))>=x)) {
+						if ((start+MAXNUMBERS)>maxNumber)
+							start=1;
+						else
+							start=start+MAXNUMBERS;
+						refreshScreen();
+					}
 				}
 			}
 		}

Index: TextControl.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/TextControl.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- TextControl.cpp	24 Jul 2004 15:28:01 -0000	1.2
+++ TextControl.cpp	24 Jul 2004 19:21:25 -0000	1.3
@@ -52,16 +52,19 @@
 
 void TextControl::clearText() {
 	clearHtml(htmlControl);
-#ifdef debugfile
-	file=fopen("\\chapter.html","w+");
-#endif
+	buffer.clear();
 }
 
 void TextControl::addText(UString text) {
-	addHtml(htmlControl,text.c_str());
+	buffer+=text;
+	//addHtml(htmlControl,text.c_str());
 }
 
 void TextControl::endOfText() {
+#ifdef debugfile
+	file=fopen("\\chapter.html","w+");
+#endif
+	addHtml(htmlControl,buffer.c_str());
 	endHtml(htmlControl);
 #ifdef debugfile
 	fclose(file);

Index: resource.h
===================================================================
RCS file: /cvs/core/swordreader/src/gui/resource.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- resource.h	15 Mar 2004 10:44:35 -0000	1.4
+++ resource.h	24 Jul 2004 19:21:25 -0000	1.5
@@ -2,7 +2,6 @@
 // Microsoft Developer Studio generated include file.
 // Used by BibleReader.rc
 //
-#define MENU_ABOUT                      0
 #define IDS_APP_TITLE                   1
 #define IDS_HELLO                       2
 #define IDC_BIBLEREADER                 3



More information about the sword-cvs mailing list