[sword-svn] r76 - in trunk/src: . Dll1/winceSword/src gui
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Sun Dec 23 20:26:12 MST 2007
Author: dtrotzjr
Date: 2007-12-23 20:26:11 -0700 (Sun, 23 Dec 2007)
New Revision: 76
Modified:
trunk/src/Dll1/winceSword/src/unistd.cpp
trunk/src/SwRd.vcb
trunk/src/SwRd.vco
trunk/src/gui/ApplicationInterface.cpp
trunk/src/gui/ApplicationInterface.h
trunk/src/gui/Main.cpp
trunk/src/gui/SimpleNavigator.cpp
trunk/src/gui/SimpleNavigator.h
trunk/src/gui/SwordIndex.cpp
trunk/src/gui/SwordIndex.h
Log:
Added options.conf support. I also started saving and retrieving the last passage viewed and the last version used in this file. Fixed small bug in unistd.cpp open function that was not handling the O_CREAT flag correctly.
Modified: trunk/src/Dll1/winceSword/src/unistd.cpp
===================================================================
--- trunk/src/Dll1/winceSword/src/unistd.cpp 2007-12-23 23:04:36 UTC (rev 75)
+++ trunk/src/Dll1/winceSword/src/unistd.cpp 2007-12-24 03:26:11 UTC (rev 76)
@@ -23,6 +23,7 @@
int open(const char *path, int mode) {
//MessageBox(0,strtowstr(path),L"open",MB_OK|MB_ICONERROR);
+ bool exists = false;
const char *winPath = windizePath(path);
DWORD access = 0;
DWORD create = OPEN_EXISTING;
@@ -37,10 +38,20 @@
if (mode & O_RDWR) {
access |= GENERIC_READ | GENERIC_WRITE;
}
+
+ // Quick test to see if file exists, if it does not exist this call fails.
+
+ HANDLE hEx = CreateFile(strtowstr(winPath), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if(hEx != INVALID_HANDLE_VALUE){
+ CloseHandle(hEx);
+ exists = true;
+ }else{
+ exists = false;
+ }
- if (mode & O_CREAT)
+ if(!exists && mode & O_CREAT)
create = OPEN_ALWAYS;
- if (mode & O_TRUNC)
+ if(exists && mode & O_TRUNC)
create = TRUNCATE_EXISTING;
// if (!(access & GENERIC_WRITE))
Modified: trunk/src/SwRd.vcb
===================================================================
(Binary files differ)
Modified: trunk/src/SwRd.vco
===================================================================
(Binary files differ)
Modified: trunk/src/gui/ApplicationInterface.cpp
===================================================================
--- trunk/src/gui/ApplicationInterface.cpp 2007-12-23 23:04:36 UTC (rev 75)
+++ trunk/src/gui/ApplicationInterface.cpp 2007-12-24 03:26:11 UTC (rev 76)
@@ -98,12 +98,11 @@
*/
}
-void addMenu(HMENU menu, int id, UString text) {
- AppendMenu(menu,0,USERBUTTONS+id,text.c_str());
+void addMenu(HMENU menu,int flags, int id, UString text) {
+ AppendMenu(menu,flags,USERBUTTONS+id,text.c_str());
}
-
HMENU registerID(int id) {
return (HMENU) (USERBUTTONS+id);
}
Modified: trunk/src/gui/ApplicationInterface.h
===================================================================
--- trunk/src/gui/ApplicationInterface.h 2007-12-23 23:04:36 UTC (rev 75)
+++ trunk/src/gui/ApplicationInterface.h 2007-12-24 03:26:11 UTC (rev 76)
@@ -96,7 +96,7 @@
void selectMenu(std::map<int,int>& menus, int mode);
//void selectMenu(int mode);
-void addMenu(HMENU menu, int id, UString text);
+void addMenu(HMENU menu, int flags, int id, UString text);
void checkMenu(HMENU menu, int id, bool checked);
Modified: trunk/src/gui/Main.cpp
===================================================================
--- trunk/src/gui/Main.cpp 2007-12-23 23:04:36 UTC (rev 75)
+++ trunk/src/gui/Main.cpp 2007-12-24 03:26:11 UTC (rev 76)
@@ -1,5 +1,6 @@
#include "ApplicationInterface.h"
#include "Main.h"
+#include "swordce.h"
#ifdef SIMPLE
#include "SimpleNavigator.h"
@@ -15,6 +16,7 @@
#include <htmlctrl.h>
NAVIGATOR* g_navigator;
+SWConfig *g_swordConf;
static SHACTIVATEINFO s_sai;
int WINAPI WinMain( HINSTANCE hInstance,
@@ -89,6 +91,18 @@
TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name
g_hInst = hInstance; // Store instance handle in our global variable
+
+ // Create a general options file for storing options
+ // and navigaiton history
+ const char *cwd = getWorkingDirectory();
+ char confFName[MAX_PATH];
+ _snprintf(confFName, MAX_PATH, "%s\\options.conf", cwd);
+ FILE *fp = fopen("Storage Card\\Program Files\\sword\\log.txt", "w");
+ fprintf(fp, "%s\n%s\n", cwd, confFName);
+ fclose(fp);
+ g_swordConf = new SWConfig(confFName);
+ g_swordConf->Load();
+
// Initialize global strings
LoadString(hInstance, IDC_BIBLEREADER, szWindowClass, MAX_LOADSTRING);
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
@@ -219,6 +233,8 @@
CommandBar_Destroy(g_hwndCB);
delete g_navigator;
PostQuitMessage(0);
+ g_swordConf->Save();
+ delete g_swordConf;
break;
case WM_ACTIVATE:
// Notify shell of our activate message
Modified: trunk/src/gui/SimpleNavigator.cpp
===================================================================
--- trunk/src/gui/SimpleNavigator.cpp 2007-12-23 23:04:36 UTC (rev 75)
+++ trunk/src/gui/SimpleNavigator.cpp 2007-12-24 03:26:11 UTC (rev 76)
@@ -13,6 +13,8 @@
using namespace sword;
+extern SWConfig *g_swordConf;
+
#define WIDTH 240
#define HEIGHT 294
@@ -46,6 +48,10 @@
transEndID = 0;
options = 0;
opCount = 0;
+
+ sword::VerseKey key = sword::VerseKey((*g_swordConf)["History"].getWithDefault("LastPassage", "Gen 1:1"));
+ position.setModule(SwordIndex::manager->getModule((*g_swordConf)["History"].getWithDefault("LastVersion", "KJV")));
+ position.setVerseKey(&key);
}
SimpleNavigator::~SimpleNavigator() {
@@ -57,12 +63,22 @@
if (options){
delete [] options;
}
+ saveState();
}
+void SimpleNavigator::saveState(){
+ (*g_swordConf)["History"]["LastPassage"] = toCString(position.verseToString()).c_str();
+ (*g_swordConf)["History"]["LastVersion"] = position.getModName();
+}
+
void SimpleNavigator::refresh() {
refreshScreen();
}
+void SimpleNavigator::setModule(const char *module){
+ position.setModule(SwordIndex::manager->getModule(module));
+}
+
void SimpleNavigator::setMode(int mode) {
if (this->mode>=0) pages[this->mode]->hide();
this->mode=mode;
@@ -135,10 +151,14 @@
this->menuTranslations=menuTranslations;
if (menuTranslations) {
for (ModuleMap::iterator i=position.firstModule();i!=position.lastModule();i++) {
- addMenu(menuTranslations, nextID++, toUString(String(i->first)));
+ if(strcmp(i->first, position.getModName()) == 0)
+ addMenu(menuTranslations, MF_CHECKED, nextID++, toUString(String(i->first)));
+ else
+ addMenu(menuTranslations, 0, nextID++, toUString(String(i->first)));
}
}
- checkModuleMenu(transStartID);
+ // The following line is now handled above. -- dctrotz
+ //checkModuleMenu(transStartID);
transEndID = nextID - 1;
}
@@ -178,7 +198,7 @@
}
if (supported) {
options[nextID - optStartID] = *i;
- addMenu(menuOptions, nextID++, toUString(i->c_str()));
+ addMenu(menuOptions, 0, nextID++, toUString(i->c_str()));
}
}
}
Modified: trunk/src/gui/SimpleNavigator.h
===================================================================
--- trunk/src/gui/SimpleNavigator.h 2007-12-23 23:04:36 UTC (rev 75)
+++ trunk/src/gui/SimpleNavigator.h 2007-12-24 03:26:11 UTC (rev 76)
@@ -62,10 +62,13 @@
SimpleNavigator(RECT* screen);
virtual ~SimpleNavigator();
+ void saveState();
+
// Navigation
void setBook(int number);
void setChap(int number);
void setVerse(int number);
+ void setModule(const char *module);
int getBook() {return position.getBook();};
int getChap() {return position.verse->Chapter();};
Modified: trunk/src/gui/SwordIndex.cpp
===================================================================
--- trunk/src/gui/SwordIndex.cpp 2007-12-23 23:04:36 UTC (rev 75)
+++ trunk/src/gui/SwordIndex.cpp 2007-12-24 03:26:11 UTC (rev 76)
@@ -20,6 +20,12 @@
+ toUString(verse->Verse());
}
+UString SwordIndex::verseToString() {
+ return UString(defBookNames[(verse->Book()-1)+otBookCount()*(verse->Testament()-1)]) + L" "
+ + toUString(verse->Chapter()) + L":"
+ + toUString(verse->Verse());
+}
+
SWMgr* SwordIndex::manager;
SWModule *SwordIndex::greekLex = 0;
SWModule *SwordIndex::hebrewLex = 0;
@@ -126,6 +132,10 @@
}
+char *SwordIndex::getModName(){
+ return bible->Name();
+}
+
int SwordIndex::chapCount() {
return getBook(book).chapmax;
}
Modified: trunk/src/gui/SwordIndex.h
===================================================================
--- trunk/src/gui/SwordIndex.h 2007-12-23 23:04:36 UTC (rev 75)
+++ trunk/src/gui/SwordIndex.h 2007-12-24 03:26:11 UTC (rev 76)
@@ -63,7 +63,7 @@
UString verseText();
UString verseText(sword::VerseKey* anyVerse);
-
+ char *SwordIndex::getModName();
ModuleMap::iterator firstModule() {return texts->begin();};
ModuleMap::iterator lastModule() {return texts->end();};
void setModule(Module m);
@@ -88,6 +88,7 @@
TCHAR** getBookNames() {return bookNames;};
static UString verseToString(Verse* verse);
+ UString verseToString();
static int otBookCount() {return 39;};
static int bookCount() {return 66;};
More information about the sword-cvs
mailing list