[sword-svn] r43 - in trunk/src: Dll1/winceSword/src gui
bdrake at www.crosswire.org
bdrake at www.crosswire.org
Sun Nov 25 10:57:39 MST 2007
Author: bdrake
Date: 2007-11-25 10:57:37 -0700 (Sun, 25 Nov 2007)
New Revision: 43
Modified:
trunk/src/Dll1/winceSword/src/swordce.cpp
trunk/src/gui/NavBooks.cpp
trunk/src/gui/NavFind.cpp
trunk/src/gui/NavNumbers.cpp
trunk/src/gui/SwordIndex.cpp
Log:
Modified: trunk/src/Dll1/winceSword/src/swordce.cpp
===================================================================
--- trunk/src/Dll1/winceSword/src/swordce.cpp 2007-11-06 06:09:09 UTC (rev 42)
+++ trunk/src/Dll1/winceSword/src/swordce.cpp 2007-11-25 17:57:37 UTC (rev 43)
@@ -4,10 +4,25 @@
using sword::SWBuf;
// TODO: from the DLL entry point, figure out the path
-// to the dll file and use that for cwd
-const char *getWorkingDirectory() {
- static const char *cwd = "\\Program Files\\sword";
- return cwd;
+// to the dll file and use that for cwd ........ done BD - see below
+const char *getWorkingDirectory() {
+
+ // static const char *cwd = "\\Program Files\\sword";
+
+ // November 2007 - this code added BD to get current directory rather than use the
+ // string above.
+
+ static char buf[MAX_PATH+1];
+ char *cwd;
+ TCHAR ThisName[MAX_PATH+1];
+ int thatChar = -1;
+ cwd=buf;
+ 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;
+ return cwd;
}
@@ -37,6 +52,7 @@
const char *windizePath(const char *path) {
static SWBuf retVal = "";
retVal = "";
+
if ((*path != '/') && (*path != '\\'))
retVal = getWorkingDirectory();
retVal += "/";
@@ -46,6 +62,7 @@
retVal += tmp;
for (int pos = 0; retVal[pos]; pos++) {
+
switch (retVal[pos]) {
case '/':
retVal[pos] = '\\';
Modified: trunk/src/gui/NavBooks.cpp
===================================================================
--- trunk/src/gui/NavBooks.cpp 2007-11-06 06:09:09 UTC (rev 42)
+++ trunk/src/gui/NavBooks.cpp 2007-11-25 17:57:37 UTC (rev 43)
@@ -11,12 +11,19 @@
#define PADDING_WIDTH 3
#define PADDING_HEIGHT 3
-#define MAXVERTICAL 10
+// #define MAXVERTICAL 10 // altered BD Nov 07 to make OK in landscape
+#define MAXVERTICAL 9
+#define MAX_OT_COLS 5
-#define ROW0 15
-#define ROW1 30
-#define ROW2 45
+// #define ROW0 15
+// #define ROW1 30
+// #define ROW2 45
+
+// all uses of ROW1 and ROW2 removed BD Nov 2007 to make buttons fit on landscape
+// the message "Select a book:" does not now display but may not really be important
+#define ROW0 5
+
NavBooks::NavBooks(SimpleNavigator* navigator): NavPage(navigator) {
this->position=&(navigator->position);
this->command=UString(L"Select a book:");
@@ -38,15 +45,16 @@
//drawText(&rt,UString(L"test"));
//setBackground();
- rt.bottom=ROW0;
- clearRect(&rt);
+ // below simply padded the top of the screen downwards and displayed the string
+ // rt.bottom=ROW0;
+ // clearRect(&rt);
+ // rt.top=ROW0; rt.bottom=ROW1;
+ // drawText(&rt,command);
+ // rt.top=ROW1; rt.bottom=ROW2;
+ // clearRect(&rt);
- rt.top=ROW0; rt.bottom=ROW1;
- drawText(&rt,command);
+ // all references below to ROW0 were formerly ROW2 - amended BD Nov 07
- rt.top=ROW1; rt.bottom=ROW2;
- clearRect(&rt);
-
setBackground(BUTTON_BACKGROUND);
setFont(FONT_NAVIGATION);
TCHAR** bookNames=position->getBookNames();
@@ -60,7 +68,8 @@
//Paint one testament
while (current<=maxTNumber) {
int colStart=current;
- rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW2;
+ rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW0;
+ // rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW0;
while ((current<=maxTNumber)&&(current-colStart<MAXVERTICAL)) {
//padding top of button
rt.top=rt.bottom;rt.bottom=rt.top+PADDING_HEIGHT;
@@ -74,13 +83,15 @@
rt.top=rt.bottom;rt.bottom=RECT_SCREEN.bottom;
clearRect(&rt);
// padding right of buttons
- rt.top=ROW2; rt.left=rt.right; rt.right=rt.left+PADDING_WIDTH;
+ // rt.top=ROW2; rt.left=rt.right; rt.right=rt.left+PADDING_WIDTH;
+ rt.top=ROW0; rt.left=rt.right; rt.right=rt.left+PADDING_WIDTH;
clearRect(&rt);
}
if (current<maxNumber) {
//space between testaments
maxTNumber=maxNumber;
- rt.right=rt.left+BUTTON_WIDTH+PADDING_WIDTH;
+ rt.right=rt.left+PADDING_WIDTH+PADDING_WIDTH;
+ // rt.right=rt.left+BUTTON_WIDTH+PADDING_WIDTH;
clearRect(&rt);
}
@@ -94,9 +105,16 @@
}
int NavBooks::numberAt(int x, int y) {
- if ((y>=ROW2)&&(y<ROW2+MAXVERTICAL*(PADDING_HEIGHT+BUTTON_HEIGHT))) {
- y=y-ROW2;
- if ((x>=PADDING_WIDTH)&&(x<PADDING_WIDTH+4*(BUTTON_WIDTH+PADDING_WIDTH))) {
+ // if ((y>=ROW2)&&(y<ROW2+MAXVERTICAL*(PADDING_HEIGHT+BUTTON_HEIGHT))) {
+ // y=y-ROW2;
+if ((y>=ROW0)&&(y<ROW0+MAXVERTICAL*(PADDING_HEIGHT+BUTTON_HEIGHT))) {
+ y=y-ROW0;
+
+ // if ((x>=PADDING_WIDTH)&&(x<PADDING_WIDTH+4*(BUTTON_WIDTH+PADDING_WIDTH))) {
+
+// change below needed to make the 'tap' read the 'fifth' column (MAX_OT_COLS = 5)
+
+ if ((x>=PADDING_WIDTH)&&(x<PADDING_WIDTH+MAX_OT_COLS*(BUTTON_WIDTH+PADDING_WIDTH))) {
x=x-PADDING_WIDTH;
int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
x=x-horizontal*(PADDING_WIDTH+BUTTON_WIDTH);
@@ -106,11 +124,12 @@
//button is in bottom left corner
if ((x<BUTTON_WIDTH)&&(y>=PADDING_HEIGHT)) {
int current=horizontal*MAXVERTICAL+vertical+1;
- if (current<=maxOTNumber) return current;
+ if (current<=maxOTNumber) return current; // it was a valid OT book
}
}
}
- else if (x>=PADDING_WIDTH+5*(BUTTON_WIDTH+PADDING_WIDTH)) {
+ // it wasn't an old testament book, so try for NT book
+ else if (x>=PADDING_WIDTH+MAX_OT_COLS*(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);
Modified: trunk/src/gui/NavFind.cpp
===================================================================
--- trunk/src/gui/NavFind.cpp 2007-11-06 06:09:09 UTC (rev 42)
+++ trunk/src/gui/NavFind.cpp 2007-11-25 17:57:37 UTC (rev 43)
@@ -1,13 +1,20 @@
#include "ApplicationInterface.h"
#include "NavFind.h"
#include "SimpleNavigator.h"
-#include <winuser.h>
-#include <commctrl.h>
+#include <aygshell.h>
+
#define check(checkButtonHWND) SendMessage(checkButtonHWND,BM_SETCHECK,BST_CHECKED,0);
#define uncheck(checkButtonHWND) SendMessage(checkButtonHWND,BM_SETCHECK,BST_UNCHECKED,0);
+// added Nov 2007 to check mode before painting find listbox - BD
+// this was written as a separate function in case we want to call it from elsewhere
+int IsPortrait() {
+ if (GetSystemMetrics(SM_CYSCREEN) > GetSystemMetrics(SM_CXSCREEN)) return(100);
+ return(0);
+}
+
NavFind::NavFind(SimpleNavigator* navigator) : NavPage(navigator) {
// register ID's so we get feedback
searchID=navigator->getID();
@@ -18,6 +25,16 @@
methodExactphraseID=navigator->getID();
goID=navigator->getID();
resultsID=navigator->getID();
+
+ // test if display is portrait or landscape, and adjust 'preview' and hits
+ // listbox window size and other controls accordingly.
+ int scrHeight = 100; // if landscape mode height of search lisbox
+ int extrawidth = 65; // if mode = landscape, make controls and preview extrawide
+ if (IsPortrait()) {
+ scrHeight = 173; // height of search lisbox in portrait mode
+ extrawidth = 0; // controls and preview don't need to be extrawide
+ }
+
// create windows ce managed controls
queryEdit = CreateWindow(_T("edit"), NULL,
WS_CHILD | ES_AUTOHSCROLL | ES_LEFT | WS_TABSTOP | WS_BORDER,
@@ -25,7 +42,7 @@
g_hWnd, NULL, g_hInst, NULL);
search = CreateWindow(_T("button"), L"Search",
WS_CHILD | BS_PUSHBUTTON,
- 180, 0, 60, 24,
+ 180, 0, 60+extrawidth, 24,
g_hWnd, registerID(searchID), g_hInst, NULL);
rangeBible = CreateWindow(_T("button"), L"Whole bible",
WS_CHILD | BS_RADIOBUTTON,
@@ -35,33 +52,46 @@
0,48,120,24, g_hWnd, registerID(rangeTestamentID),g_hInst, NULL);
rangeBook = CreateWindow(_T("button"), L"This book",
WS_CHILD | BS_RADIOBUTTON,
- 0,72,120,24, g_hWnd, registerID(rangeBookID),g_hInst, NULL);
+ 0,72,120+extrawidth,24, g_hWnd, registerID(rangeBookID),g_hInst, NULL);
methodMultiword = CreateWindow(_T("button"), L"Multi-word",
WS_CHILD | BS_RADIOBUTTON,
- 120,24,120,24, g_hWnd, registerID(methodMultiwordID),g_hInst, NULL);
+ 120,24,120+extrawidth,24, g_hWnd, registerID(methodMultiwordID),g_hInst, NULL);
methodExactphrase = CreateWindow(_T("button"), L"Exact phrase",
WS_CHILD | BS_RADIOBUTTON,
- 120,48,120,24, g_hWnd, registerID(methodExactphraseID),g_hInst, NULL);
+ 120,48,120+extrawidth,24, g_hWnd, registerID(methodExactphraseID),g_hInst, NULL);
title = CreateWindow(_T("static"),L"",
WS_CHILD,
- 120,72,120,24, g_hWnd, NULL, g_hInst, NULL);
+ 120,72,120+extrawidth,24, g_hWnd, NULL, g_hInst, NULL);
check(rangeBook);
rangeMode=RANGEBOOK;
check(methodMultiword);
methodMode=METHODMULTIWORD;
+
+
results = CreateWindow(_T("listbox"),NULL,
WS_CHILD | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_NOTIFY | WS_BORDER | LBS_NOINTEGRALHEIGHT,
- 0,96,80,173, g_hWnd, registerID(resultsID), g_hInst, NULL); //bottom row off screen
+ // 0,96,80,173, g_hWnd, registerID(resultsID), g_hInst, NULL); //bottom row of screen
+ // above was original setting for portrait mode
+ 0,96,80,scrHeight, g_hWnd, registerID(resultsID), g_hInst, NULL); //bottom row of screen
+ // the last figure in above line needs to be 100 for landscape or 173 for portrait
+
progressBar = CreateWindow(PROGRESS_CLASS, L"",
WS_CHILD | WS_BORDER | PBS_SMOOTH,
80,96,100,24, g_hWnd, NULL, g_hInst, NULL);
go = CreateWindow(_T("button"), L"Go to",
WS_CHILD | BS_PUSHBUTTON,
- 180,96,60,24,
+ 180,96,60+extrawidth,24,
g_hWnd, registerID(goID), g_hInst, NULL);
// HTML control
- preview=new TextControl(80,120,160,148);
+ // preview=new TextControl(80,120,160,148); // this is OK for portrait
+ // we now change the preview size for landscape. Note, however that
+ // preview window does not have scroll bars. Are long verses going to
+ // become a problem? Maybe it's not that important. If it is, then add scrollbars.
+
+ preview=new TextControl(80,120,160+extrawidth,148); // the last figure is the height
+ // 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->endOfText();
@@ -159,7 +189,9 @@
void NavFind::previewVerse(Verse* verse) {
preview->clearText();
- //preview->addText(SwordIndex::verseToString(verse));
+ // next line was commented out
+// preview->addText(SwordIndex::verseToString(verse));
+ // and the line below left in
preview->addText(navigator->position.verseText(verse));
preview->endOfText();
}
Modified: trunk/src/gui/NavNumbers.cpp
===================================================================
--- trunk/src/gui/NavNumbers.cpp 2007-11-06 06:09:09 UTC (rev 42)
+++ trunk/src/gui/NavNumbers.cpp 2007-11-25 17:57:37 UTC (rev 43)
@@ -12,14 +12,20 @@
#define PADDING_HEIGHT 3
#define MAXHORIZONTAL 10
-#define MAXVERTICAL 10
+// #define MAXVERTICAL 10 // altered BD Nov 07 to make OK in landscape
+#define MAXVERTICAL 9
#define MAXNUMBERS (MAXVERTICAL*MAXHORIZONTAL)
-#define ROW0 15
-#define ROW1 30
-#define ROW2 45
-#define LASTROW ROW2+MAXVERTICAL*(BUTTON_HEIGHT+PADDING_HEIGHT)
+// #define ROW0 15
+// #define ROW1 30
+// #define ROW2 45
+#define ROW0 5
+// all uses of ROW1 and ROW2 removed BD Nov 2007 to make buttons fit on landscape
+// the message "Select a [whatever]:" does not now display but may not really be important
+// #define LASTROW ROW2+MAXVERTICAL*(BUTTON_HEIGHT+PADDING_HEIGHT)
+#define LASTROW ROW0+MAXVERTICAL*(BUTTON_HEIGHT+PADDING_HEIGHT)
+
NavNumbers::NavNumbers(SimpleNavigator* navigator):NavPage(navigator) {
}
@@ -41,14 +47,18 @@
//drawText(&rt,UString(L"test"));
//setBackground();
- rt.bottom=ROW0;
- clearRect(&rt);
+ // below simply padded the top of the screen downwards and displayed the string
+
+ // rt.bottom=ROW0;
+ // clearRect(&rt);
+ // rt.bottom=ROW0;
+ // clearRect(&rt);
- rt.top=ROW0; rt.bottom=ROW1;
- drawText(&rt,command);
+ // rt.top=ROW0; rt.bottom=ROW1;
+ // drawText(&rt,command);
- rt.top=ROW1; rt.bottom=ROW2;
- clearRect(&rt);
+ // rt.top=ROW1; rt.bottom=ROW2;
+ // clearRect(&rt);
TCHAR buttonText[4];
setBackground(BUTTON_BACKGROUND);
@@ -61,7 +71,8 @@
while ((current<=maxNumber)&&(current<start+MAXNUMBERS)) {
int colStart=current;
- rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW2;
+ rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW0;
+ // 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;
@@ -76,7 +87,8 @@
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;
+ // rt.top=ROW2; rt.left=rt.right; rt.right=rt.left+PADDING_WIDTH;
+ rt.top=ROW0; rt.left=rt.right; rt.right=rt.left+PADDING_WIDTH;
clearRect(&rt);
}
//area right of buttons
@@ -105,7 +117,8 @@
}
int NavNumbers::numberAt(int x, int y) {
- y=y-ROW2;
+ // y=y-ROW2;
+ y=y-ROW0;
if (x>0) {
int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
if (horizontal<MAXHORIZONTAL) {
Modified: trunk/src/gui/SwordIndex.cpp
===================================================================
--- trunk/src/gui/SwordIndex.cpp 2007-11-06 06:09:09 UTC (rev 42)
+++ trunk/src/gui/SwordIndex.cpp 2007-11-25 17:57:37 UTC (rev 43)
@@ -63,6 +63,10 @@
if (!strcmp(curMod->Type(), "Biblical Texts")) {
(*texts)[curMod->Name()]=curMod;
}
+ // next section added BD - Nov 07
+ if (!strcmp(curMod->Type(), "Commentaries")) {
+ (*texts)[curMod->Name()]=curMod;
+ } // end of added code
if (curMod->getConfig().has("Feature", "GreekDef")) {
greekLex = curMod;
}
@@ -196,18 +200,30 @@
searcher->addResult(verseToString(&from));
searcher->addResult(verseToString(&to));
*/
+
Verse verses(from,to);
sword::ListKey results;
searcher->setProgress(20);
+// this next code block carries out the search - the call is to SWModule::search
results=bible->search(
toCString(text).c_str(),
(method==METHODMULTIWORD)?-2:-1,
2 /* case insensitive */,
&verses
);
+// end of search - returns a SWModule::ListKey variable (results)
searcher->setProgress(90);
- for (int i=0;i<results.Count();i++) {
- searcher->addResult(toUString(String(results.getElement(i)->getText())));
- }
+
+// 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())));
+ }
+// thanks to Troy for the above
+
+// below was the original code from Johan Gorter
+// for (int i=0;i<results.Count();i++) {
+// searcher->addResult(toUString(String(results.getElement(i)->getText())));
+// }
searcher->setProgress(100);
}
More information about the sword-cvs
mailing list