aboutsummaryrefslogtreecommitdiffstats
path: root/apps/windoze/CBuilder5/BibleCS/mainfrm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'apps/windoze/CBuilder5/BibleCS/mainfrm.cpp')
-rw-r--r--apps/windoze/CBuilder5/BibleCS/mainfrm.cpp431
1 files changed, 53 insertions, 378 deletions
diff --git a/apps/windoze/CBuilder5/BibleCS/mainfrm.cpp b/apps/windoze/CBuilder5/BibleCS/mainfrm.cpp
index 5d883ae..32b4aff 100644
--- a/apps/windoze/CBuilder5/BibleCS/mainfrm.cpp
+++ b/apps/windoze/CBuilder5/BibleCS/mainfrm.cpp
@@ -193,7 +193,7 @@ __fastcall TForm1::~TForm1()
}
//---------------------------------------------------------------------------
-char TForm1::CreateTextPane(SWModule *mod, char *font) {
+char TForm1::CreateTextPane(SWModule *mod) {
TTabSheet *newtab = new TTabSheet(this);
SWDispRTFChap *newrtf = new SWDispRTFChap(this);
char buf[1024];
@@ -222,7 +222,7 @@ char TForm1::CreateTextPane(SWModule *mod, char *font) {
return 0;
}
//---------------------------------------------------------------------------
-char TForm1::CreateCommentPane(SWModule *mod, char* font) {
+char TForm1::CreateCommentPane(SWModule *mod) {
TTabSheet *newtab = new TTabSheet(this);
TWinControl *newrtf;
char buf[1024];
@@ -285,7 +285,7 @@ char TForm1::CreateCommentPane(SWModule *mod, char* font) {
return 0;
}
//---------------------------------------------------------------------------
-char TForm1::CreateLDPane(SWModule *mod, char* font) {
+char TForm1::CreateLDPane(SWModule *mod) {
TTabSheet *newtab = new TTabSheet(this);
SWDispRTF *newrtf = new SWDispRTF(this);
SectionMap::iterator sit;
@@ -307,15 +307,6 @@ char TForm1::CreateLDPane(SWModule *mod, char* font) {
newrtf->module = mod;
newrtf->recalcAppearance();
-/*
- if ((sit = optionsconf->Sections.find("Appearance")) != optionsconf->Sections.end()) {
- if ((*sit).second.find("LDBackColor") != (*sit).second.end()) {
- lbDictKeys->Color = TColor((atoi((*(*sit).second.find("LDBackColor")).second.c_str())));
- }
- if ((*sit).second.find("LDFontColor") != (*sit).second.end())
- lbDictKeys->Font->Color = TColor((atoi((*(*sit).second.find("LDFontColor")).second.c_str())));
- }
-*/
SWDisplay *disp = new RTFDisp(newrtf);
mod->Disp(*displays.insert(displays.begin(), disp));
mod->setKey(*DefaultStrKey);
@@ -339,7 +330,7 @@ void __fastcall TForm1::BookTOCChange(TObject* Sender, TTreeNode* Node) {
}
-char TForm1::CreateBookPane(SWModule *mod, char* font) {
+char TForm1::CreateBookPane(SWModule *mod) {
TTabSheet *newtab = new TTabSheet(this);
TWinControl *newrtf;
char buf[1024];
@@ -579,7 +570,7 @@ void __fastcall TForm1::DictionaryLookup1Click(TObject *Sender)
if (!strncmp(rtf->Name.c_str(), "TextRTFLXX", 10))
feature = "GreekDef";
if (!hasFeature(mainmgr, curLex.c_str(), feature.c_str())) {
- string tmpval = ((eit = optionsconf->Sections["ModDefaults"].find(feature.c_str())) != optionsconf->Sections["ModDefaults"].end())? (*eit).second : (string)"";
+ string tmpval = optionsconf->Sections["ModDefaults"][feature.c_str()];
for (int i = 0; i < LexDictPageControl->PageCount; i++) {
if (!stricmp(LexDictPageControl->Pages[i]->Caption.c_str(), tmpval.c_str())) {
LexDictPageControl->ActivePageIndex = i;
@@ -935,42 +926,20 @@ void __fastcall TForm1::FormShow(TObject *Sender)
if (SWLog::systemlog)
delete SWLog::systemlog;
SWLog::systemlog = new SWWinLog(this->Handle); // set the system logger to our MSWindows specific SWLog class
- tmpval = ((eit = optionsconf->Sections["System"].find("MaxFiles")) != optionsconf->Sections["System"].end())? (*eit).second : (string)"";
+ tmpval = optionsconf->Sections["System"]["MaxFiles"];
if ((maxFiles = atoi(tmpval.c_str()))) {
FileMgr::systemFileMgr.maxFiles = maxFiles;
}
-
- tmpval = ((eit = optionsconf->Sections["Hints"].find("On")) != optionsconf->Sections["Hints"].end())? (*eit).second : (string)"1";
-
- if (atoi(tmpval.c_str()))
- Form1->ShowHint = true;
- else Form1->ShowHint = false;
+ tmpval = optionsconf->Sections["General"]["DevsAsDicts"];
+ showDevos = (stricmp(tmpval.c_str(), "false"));
- tmpval = ((eit = optionsconf->Sections["General"].find("DevsAsDicts")) != optionsconf->Sections["General"].end())? (*eit).second : (string)"";
- showDevos = (!stricmp(tmpval.c_str(), "true"));
-
- tmpval = ((eit = optionsconf->Sections["General"].find("GlosAsDicts")) != optionsconf->Sections["General"].end())? (*eit).second : (string)"";
- showGlos = !(!stricmp(tmpval.c_str(), "false"));
+ tmpval = optionsconf->Sections["General"]["GlosAsDicts"];
+ showGlos = (stricmp(tmpval.c_str(), "false"));
- tmpval = ((eit = optionsconf->Sections["Appearance"].find("locale")) != optionsconf->Sections["Appearance"].end())? (*eit).second : (string)"en_us";
- i12ize(tmpval.c_str());
-
DefaultVSKey = new VerseKey();
DefaultStrKey = new StrKey();
-
-// DefaultVSKey->setLocale(tmpval.c_str());
-
- tmpval = ((eit = optionsconf->Sections["Appearance"].find("TextFontName")) != optionsconf->Sections["Appearance"].end())? (*eit).second : (string)"Times New Roman";
- strcpy(tempTextFont, tmpval.c_str()); // Temporary holding place for text font
-
- tmpval = ((eit = optionsconf->Sections["Appearance"].find("CommentFontName")) != optionsconf->Sections["Appearance"].end())? (*eit).second : (string)"Times New Roman";
- strcpy(tempCommFont, tmpval.c_str());
-
- tmpval = ((eit = optionsconf->Sections["Appearance"].find("LDFontName")) != optionsconf->Sections["Appearance"].end())? (*eit).second : (string)"Times New Roman";
- strcpy(tempLDFont, tmpval.c_str());
-
fillVKeySelector(DefaultVSKey);
cbBook->ItemIndex = cbBook->Items->IndexOf("James");
@@ -1037,43 +1006,19 @@ void __fastcall TForm1::FormShow(TObject *Sender)
}
if (!strcmp((*it).second->Type(), "Biblical Texts")) {
- strcpy(textFont, tempTextFont);
- if ((sit = mainmgr->config->Sections.find((*it).second->Name())) != mainmgr->config->Sections.end()) {
- if ((eit = (*sit).second.find("Font")) != (*sit).second.end()) {
- strcpy(textFont,(char *)(*eit).second.c_str());
- }
- }
- CreateTextPane((*it).second, textFont);
+ CreateTextPane((*it).second);
}
if (!strcmp((*it).second->Type(), "Commentaries")) {
- strcpy(commentFont, tempCommFont);
- if ((sit = mainmgr->config->Sections.find((*it).second->Name())) != mainmgr->config->Sections.end()) {
- if ((eit = (*sit).second.find("Font")) != (*sit).second.end()) {
- strcpy(commentFont,(char *)(*eit).second.c_str());
- }
- }
- CreateCommentPane((*it).second, commentFont);
+ CreateCommentPane((*it).second);
}
if (!strcmp((*it).second->Type(), "Generic Books")) {
- strcpy(commentFont, tempCommFont);
- if ((sit = mainmgr->config->Sections.find((*it).second->Name())) != mainmgr->config->Sections.end()) {
- if ((eit = (*sit).second.find("Font")) != (*sit).second.end()) {
- strcpy(commentFont,(char *)(*eit).second.c_str());
- }
- }
- CreateBookPane((*it).second, commentFont);
+ CreateBookPane((*it).second);
}
if (!strcmp((*it).second->Type(), "Lexicons / Dictionaries")) {
- strcpy(LDFont, tempLDFont);
- if ((sit = mainmgr->config->Sections.find((*it).second->Name())) != mainmgr->config->Sections.end()) {
- if ((eit = (*sit).second.find("Font")) != (*sit).second.end()) {
- strcpy(LDFont,(char *)(*eit).second.c_str());
- }
- }
if ((!devotional && !glossary) ||
- (showDevos && devotional) ||
- (showGlos && glossary))
- CreateLDPane((*it).second, LDFont);
+ (showDevos && devotional) ||
+ (showGlos && glossary))
+ CreateLDPane((*it).second);
}
}
@@ -1096,27 +1041,23 @@ void __fastcall TForm1::FormShow(TObject *Sender)
pnlTextCom->Height = atoi((*eit).second.c_str());
if ((eit = (*sit).second.find("TextWidth")) != (*sit).second.end())
pnlText->Width = atoi((*eit).second.c_str());
- if ((eit = (*sit).second.find("SearchTop")) != (*sit).second.end()){
+
+ if ((eit = (*sit).second.find("SearchTop")) != (*sit).second.end()) {
searchForm->Top = atoi((*eit).second.c_str());
- searchForm->Position = poDesigned;
+ searchForm->Position = poDesigned; // because we've set the values
}
-
if ((eit = (*sit).second.find("SearchLeft")) != (*sit).second.end())
searchForm->Left = atoi((*eit).second.c_str());
if ((eit = (*sit).second.find("SearchHeight")) != (*sit).second.end())
searchForm->Height = atoi((*eit).second.c_str());
if ((eit = (*sit).second.find("SearchWidth")) != (*sit).second.end())
searchForm->Width = atoi((*eit).second.c_str());
-
searchForm->WindowState = (sit->second["SearchMaximized"] == "true") ? wsMaximized : wsNormal;
}
-
for (loop = 0; loop < 10; loop++)
ctrlstates.insert(ctrlstates.begin(), 0);
-
-
// Add options to Options Main Menu choice
sit = layoutconf->Sections.find("ModuleOptions");
OptionsList options = mainmgr->getGlobalOptions();
@@ -1142,18 +1083,6 @@ void __fastcall TForm1::FormShow(TObject *Sender)
Options2->Add(newitem);
}
- if ((sit = optionsconf->Sections.find("Appearance")) != optionsconf->Sections.end()){
- if ((eit = (*sit).second.find("FieldColor")) != (*sit).second.end())
- fieldColor = TColor(atoi((*eit).second.c_str()));
- else fieldColor = clAqua;
- }
-
- cbBook->Color = fieldColor;
- CHBox->Color = fieldColor;
- VSBox->Color = fieldColor;
- freeHandLookup->Color = fieldColor;
- DictKeyEdit->Color = fieldColor;
-
if ((sit = layoutconf->Sections.find("History")) != layoutconf->Sections.end()) {
eitend = (*sit).second.upper_bound("SearchText");
@@ -1203,6 +1132,7 @@ void __fastcall TForm1::FormShow(TObject *Sender)
}
+ // set the correct tabs visible
ConfigEntMap *section;
TPageControl *pc = 0;
for (int pcs = 0; pcs < 3; pcs++) {
@@ -1233,11 +1163,11 @@ void __fastcall TForm1::FormShow(TObject *Sender)
if(!stricmp(tmpval.c_str(), "Devotional")) {
DevOfTheDay2->Show();
}
- RefreshActiveSheet(LexDictPageControl);
- RefreshActiveSheet(CommentaryPageControl);
- RefreshActiveSheet(TextPageControl);
+
+ refreshAppearance();
}
+
bool TForm1::hasFeature(SWMgr *mgr, const char *modName, const char *feature) {
SectionMap::iterator sit;
ConfigEntMap::iterator eit, eitend;
@@ -1517,246 +1447,20 @@ void __fastcall TForm1::Options1Click(TObject *Sender)
int color;
string tmpval;
- //*********************************
- //Initialize Preferences Dialog Box
+ //*********************************
+ //Initialize Preferences Dialog Box
Optionsfrm->LoadDispSettings(optionsconf);
- /*
- if ((sit = optionsconf->Sections.find("Appearance")) != optionsconf->Sections.end()) {
- if ((*sit).second.find("AutoVSColor") != (*sit).second.end())
- Optionsfrm->AutoVSColor->Checked = (((atoi((*(*sit).second.find("AutoVSColor")).second.c_str()))) ? true:false);
- else Optionsfrm->AutoVSColor->Checked = true;
-
- if ((*sit).second.find("TextBackColor") != (*sit).second.end())
- Optionsfrm->FontDialogText->BackColor = TColor(atoi((*(*sit).second.find("TextBackColor")).second.c_str()));
- else Optionsfrm->FontDialogText->BackColor = TColor(clWhite);
-
- if ((*sit).second.find("CommentBackColor") != (*sit).second.end())
- Optionsfrm->FontDialogComment->BackColor = TColor(atoi((*(*sit).second.find("CommentBackColor")).second.c_str()));
- else Optionsfrm->FontDialogComment->BackColor = TColor(clWhite);
-
- if ((*sit).second.find("LDBackColor") != (*sit).second.end())
- Optionsfrm->FontDialogLD->BackColor = TColor(atoi((*(*sit).second.find("LDBackColor")).second.c_str()));
- else Optionsfrm->FontDialogLD->BackColor = TColor(clWhite);
-
- if ((*sit).second.find("PopupBackColor") != (*sit).second.end())
- Optionsfrm->FontDialogPopup->BackColor = TColor(atoi((*(*sit).second.find("PopupBackColor")).second.c_str()));
- else Optionsfrm->FontDialogPopup->BackColor = TColor(clInfoText);
-
- if ((*sit).second.find("TextFontName") != (*sit).second.end())
- Optionsfrm->FontDialogText->Font->Name = ((*(*sit).second.find("TextFontName")).second.c_str());
- else Optionsfrm->FontDialogText->Font->Name = "Times New Roman";
-
- if ((*sit).second.find("CommentFontName") != (*sit).second.end())
- Optionsfrm->FontDialogComment->Font->Name = ((*(*sit).second.find("CommentFontName")).second.c_str());
- else Optionsfrm->FontDialogComment->Font->Name = "Times New Roman";
-
- if ((*sit).second.find("LDFontName") != (*sit).second.end())
- Optionsfrm->FontDialogLD->Font->Name = ((*(*sit).second.find("LDFontName")).second.c_str());
- else Optionsfrm->FontDialogLD->Font->Name = "Times New Roman";
-
- if ((*sit).second.find("PopupFontName") != (*sit).second.end())
- Optionsfrm->FontDialogPopup->Font->Name = ((*(*sit).second.find("PopupFontName")).second.c_str());
- else Optionsfrm->FontDialogPopup->Font->Name = "MS Sans Serif";
-
- if ((*sit).second.find("TextFontSize") != (*sit).second.end())
- Optionsfrm->FontDialogText->Font->Size = (atoi ((*(*sit).second.find("TextFontSize")).second.c_str()));
- else Optionsfrm->FontDialogText->Font->Size = 10;
-
- if ((*sit).second.find("CommentFontSize") != (*sit).second.end())
- Optionsfrm->FontDialogComment->Font->Size = (atoi ((*(*sit).second.find("CommentFontSize")).second.c_str()));
- else Optionsfrm->FontDialogComment->Font->Size = 10;
-
- if ((*sit).second.find("LDFontSize") != (*sit).second.end())
- Optionsfrm->FontDialogLD->Font->Size = (atoi ((*(*sit).second.find("LDFontSize")).second.c_str()));
- else Optionsfrm->FontDialogLD->Font->Size = 10;
-
- if ((*sit).second.find("PopupFontSize") != (*sit).second.end())
- Optionsfrm->FontDialogPopup->Font->Size = (atoi ((*(*sit).second.find("PopupFontSize")).second.c_str()));
- else Optionsfrm->FontDialogPopup->Font->Size = 10;
-
- if ((*sit).second.find("TextFontColor") != (*sit).second.end())
- Optionsfrm->FontDialogText->Font->Color = TColor(atoi ((*(*sit).second.find("TextFontColor")).second.c_str()));
- else Optionsfrm->FontDialogText->Font->Color = clBlack;
-
- if ((*sit).second.find("CommentFontColor") != (*sit).second.end())
- Optionsfrm->FontDialogComment->Font->Color = TColor(atoi ((*(*sit).second.find("CommentFontColor")).second.c_str()));
- else Optionsfrm->FontDialogComment->Font->Color = clBlack;
-
- if ((*sit).second.find("LDFontColor") != (*sit).second.end())
- Optionsfrm->FontDialogLD->Font->Color = TColor(atoi ((*(*sit).second.find("LDFontColor")).second.c_str()));
- else Optionsfrm->FontDialogLD->Font->Color = clBlack;
-
- if ((*sit).second.find("PopupFontColor") != (*sit).second.end())
- Optionsfrm->FontDialogPopup->Font->Color = TColor(atoi ((*(*sit).second.find("PopupFontColor")).second.c_str()));
- else Optionsfrm->FontDialogPopup->Font->Color = clBlack;
- }
- */
- if ((sit = optionsconf->Sections.find("Bookmarks")) != optionsconf->Sections.end()) {
- Optionsfrm->AutoBMPersonal->Checked = ((atoi(sit->second["AutoSavePersonal"].c_str()))?true:false);
- Optionsfrm->AutoBMOther->Checked = ((atoi(sit->second["AutoSaveOther"].c_str()))?true:false);
- }
- if ((sit = optionsconf->Sections.find("Layout")) != optionsconf->Sections.end()) {
- Optionsfrm->AutoLayout->Checked = ((atoi(sit->second["AutoSaveLayout"].c_str()))?true:false);
-
- }
-
- Optionsfrm->HintStrongs->Checked = true;
- tmpval = ((eit = optionsconf->Sections["HintStrongs"].find("On")) != optionsconf->Sections["HintStrongs"].end())? (*eit).second : (string)"1";
- if (!atoi(tmpval.c_str()))
- Optionsfrm->HintStrongs->Checked = false;
-
- Optionsfrm->HintPopups->Checked = true;
- tmpval = ((eit = optionsconf->Sections["Hints"].find("On")) != optionsconf->Sections["Hints"].end())? (*eit).second : (string)"1";
- if (!atoi(tmpval.c_str()))
- Optionsfrm->HintPopups->Checked = false;
-
- Optionsfrm->devsAsDictsCB->Checked = false;
- tmpval = ((eit = optionsconf->Sections["General"].find("DevsAsDicts")) != optionsconf->Sections["General"].end())? (*eit).second : (string)"false";
- if (!stricmp(tmpval.c_str(), "true"))
- Optionsfrm->devsAsDictsCB->Checked = true;
-
- Optionsfrm->glosAsDictsCB->Checked = true;
- tmpval = ((eit = optionsconf->Sections["General"].find("GlosAsDicts")) != optionsconf->Sections["General"].end())? (*eit).second : (string)"true";
- if (stricmp(tmpval.c_str(), "false"))
- Optionsfrm->glosAsDictsCB->Checked = true;
-
- Optionsfrm->devSplashCB->Checked = false;
- tmpval = ((eit = optionsconf->Sections["General"].find("TipOfTheDay")) != optionsconf->Sections["General"].end())? (*eit).second : (string)"";
- if (!stricmp(tmpval.c_str(), "Devotional"))
- Optionsfrm->devSplashCB->Checked = true;
-
- const char *localeName = LocaleMgr::systemLocaleMgr.getDefaultLocaleName();
- SWLocale *defLocale = LocaleMgr::systemLocaleMgr.getLocale(localeName);
- Optionsfrm->localeCB->ItemIndex = Optionsfrm->localeCB->Items->IndexOf((defLocale)?defLocale->getDescription():"English (US)");
-
- tmpval = ((eit = optionsconf->Sections["ModDefaults"].find("GreekDef")) != optionsconf->Sections["ModDefaults"].end())? (*eit).second : (string)"";
- if ((it = mainmgr->Modules.find(tmpval)) != mainmgr->Modules.end()) {
- Optionsfrm->greekDefCB->ItemIndex = Optionsfrm->greekDefCB->Items->IndexOf(it->second->Description());
- }
-
- tmpval = ((eit = optionsconf->Sections["ModDefaults"].find("GreekParse")) != optionsconf->Sections["ModDefaults"].end())? (*eit).second : (string)"";
- if ((it = mainmgr->Modules.find(tmpval)) != mainmgr->Modules.end()) {
- Optionsfrm->greekParseCB->ItemIndex = Optionsfrm->greekParseCB->Items->IndexOf(it->second->Description());
- }
-
- tmpval = ((eit = optionsconf->Sections["ModDefaults"].find("HebrewDef")) != optionsconf->Sections["ModDefaults"].end())? (*eit).second : (string)"";
- if ((it = mainmgr->Modules.find(tmpval)) != mainmgr->Modules.end()) {
- Optionsfrm->hebrewDefCB->ItemIndex = Optionsfrm->hebrewDefCB->Items->IndexOf(it->second->Description());
- }
-
- tmpval = ((eit = optionsconf->Sections["ModDefaults"].find("HebrewParse")) != optionsconf->Sections["ModDefaults"].end())? (*eit).second : (string)"";
- if ((it = mainmgr->Modules.find(tmpval)) != mainmgr->Modules.end()) {
- Optionsfrm->hebrewParseCB->ItemIndex = Optionsfrm->hebrewParseCB->Items->IndexOf(it->second->Description());
- }
-
- tmpval = ((eit = optionsconf->Sections["ModDefaults"].find("DailyDevotion")) != optionsconf->Sections["ModDefaults"].end())? (*eit).second : (string)"";
- if ((it = mainmgr->Modules.find(tmpval)) != mainmgr->Modules.end()) {
- Optionsfrm->dailyDefaultCB->ItemIndex = Optionsfrm->dailyDefaultCB->Items->IndexOf(it->second->Description());
- }
-
- tmpval = ((eit = optionsconf->Sections["ModDefaults"].find("StrongsNumbers")) != optionsconf->Sections["ModDefaults"].end())? (*eit).second : (string)"";
- if ((it = mainmgr->Modules.find(tmpval)) != mainmgr->Modules.end()) {
- Optionsfrm->strongsNumsCB->ItemIndex = Optionsfrm->strongsNumsCB->Items->IndexOf(it->second->Description());
- }
- //*********************************
- // Show Dialog Box
+ Optionsfrm->LoadMiscSettings(optionsconf);
+
+ //*********************************
+ // Show Dialog Box
if (Optionsfrm->ShowModal() == mrOk) {
- // Save Preferences settings :)
- emap = optionsconf->Sections["Appearance"];
- emap.erase("AutoVSColor"); emap.insert(ConfigEntMap::value_type("AutoVSColor", IntToStr((Optionsfrm->AutoVSColor->Checked)?1:0).c_str()));
- emap.erase("CurrentVSColor"); emap.insert(ConfigEntMap::value_type("CurrentVSColor", IntToStr(Optionsfrm->ColorDialogVS->Color).c_str()));
- emap.erase("StrongsColor"); emap.insert(ConfigEntMap::value_type("StrongsColor", IntToStr(Optionsfrm->ColorDialogStrongs->Color).c_str()));
- emap.erase("MorphColor"); emap.insert(ConfigEntMap::value_type("MorphColor", IntToStr(Optionsfrm->ColorDialogMorph->Color).c_str()));
- emap.erase("VSNumberColor"); emap.insert(ConfigEntMap::value_type("VSNumberColor", IntToStr(Optionsfrm->ColorDialogVerseNum->Color).c_str()));
- emap.erase("FieldColor"); emap.insert(ConfigEntMap::value_type("FieldColor", IntToStr(Optionsfrm->ColorDialogField->Color).c_str()));
-
- emap.erase("TextBackColor"); emap.insert(ConfigEntMap::value_type("TextBackColor", IntToStr(Optionsfrm->FontDialogText->BackColor).c_str()));
- emap.erase("CommentBackColor"); emap.insert(ConfigEntMap::value_type("CommentBackColor", IntToStr(Optionsfrm->FontDialogComment->BackColor).c_str()));
- emap.erase("LDBackColor"); emap.insert(ConfigEntMap::value_type("LDBackColor", IntToStr(Optionsfrm->FontDialogLD->BackColor).c_str()));
- emap.erase("PopupBackColor"); emap.insert(ConfigEntMap::value_type("PopupBackColor", IntToStr(Optionsfrm->FontDialogPopup->BackColor).c_str()));
-
- emap.erase("TextFontName"); emap.insert(ConfigEntMap::value_type("TextFontName", (Optionsfrm->FontDialogText->Font->Name).c_str()));
- emap.erase("CommentFontName"); emap.insert(ConfigEntMap::value_type("CommentFontName", (Optionsfrm->FontDialogComment->Font->Name).c_str()));
- emap.erase("LDFontName"); emap.insert(ConfigEntMap::value_type("LDFontName", (Optionsfrm->FontDialogLD->Font->Name).c_str()));
- emap.erase("PopupFontName"); emap.insert(ConfigEntMap::value_type("PopupFontName", (Optionsfrm->FontDialogPopup->Font->Name).c_str()));
-
- emap.erase("TextFontSize"); emap.insert(ConfigEntMap::value_type("TextFontSize", IntToStr(Optionsfrm->FontDialogText->Font->Size).c_str()));
- emap.erase("CommentFontSize"); emap.insert(ConfigEntMap::value_type("CommentFontSize", IntToStr(Optionsfrm->FontDialogComment->Font->Size).c_str()));
- emap.erase("LDFontSize"); emap.insert(ConfigEntMap::value_type("LDFontSize", IntToStr(Optionsfrm->FontDialogLD->Font->Size).c_str()));
- emap.erase("PopupFontSize"); emap.insert(ConfigEntMap::value_type("PopupFontSize", IntToStr(Optionsfrm->FontDialogPopup->Font->Size).c_str()));
-
- emap.erase("TextFontColor"); emap.insert(ConfigEntMap::value_type("TextFontColor", IntToStr(Optionsfrm->FontDialogText->Font->Color).c_str()));
- emap.erase("CommentFontColor"); emap.insert(ConfigEntMap::value_type("CommentFontColor", IntToStr(Optionsfrm->FontDialogComment->Font->Color).c_str()));
- emap.erase("LDFontColor"); emap.insert(ConfigEntMap::value_type("LDFontColor", IntToStr(Optionsfrm->FontDialogLD->Font->Color).c_str()));
- emap.erase("PopupFontColor"); emap.insert(ConfigEntMap::value_type("PopupFontColor", IntToStr(Optionsfrm->FontDialogPopup->Font->Color).c_str()));
-
- emap.erase("locale"); emap.insert(ConfigEntMap::value_type("locale", (const char *)Optionsfrm->localeCB->Items->Objects[Optionsfrm->localeCB->ItemIndex]));
- optionsconf->Sections["Appearance"] = emap;
-
- emap = optionsconf->Sections["ModDefaults"];
-
- if (Optionsfrm->greekDefCB->ItemIndex > -1) {
- emap.erase("GreekDef"); emap.insert(ConfigEntMap::value_type("GreekDef", (const char *)Optionsfrm->greekDefCB->Items->Objects[Optionsfrm->greekDefCB->ItemIndex]));
- }
- if (Optionsfrm->greekParseCB->ItemIndex > -1) {
- emap.erase("GreekParse"); emap.insert(ConfigEntMap::value_type("GreekParse", (const char *)Optionsfrm->greekParseCB->Items->Objects[Optionsfrm->greekParseCB->ItemIndex]));
- }
- if (Optionsfrm->hebrewDefCB->ItemIndex > -1) {
- emap.erase("HebrewDef"); emap.insert(ConfigEntMap::value_type("HebrewDef", (const char *)Optionsfrm->hebrewDefCB->Items->Objects[Optionsfrm->hebrewDefCB->ItemIndex]));
- }
- if (Optionsfrm->hebrewParseCB->ItemIndex > -1) {
- emap.erase("HebrewParse"); emap.insert(ConfigEntMap::value_type("HebrewParse", (const char *)Optionsfrm->hebrewParseCB->Items->Objects[Optionsfrm->hebrewParseCB->ItemIndex]));
- }
- if (Optionsfrm->dailyDefaultCB->ItemIndex > -1) {
- emap.erase("DailyDevotion"); emap.insert(ConfigEntMap::value_type("DailyDevotion", (const char *)Optionsfrm->dailyDefaultCB->Items->Objects[Optionsfrm->dailyDefaultCB->ItemIndex]));
- }
- if (Optionsfrm->strongsNumsCB->ItemIndex > -1) {
- emap.erase("StrongsNumbers"); emap.insert(ConfigEntMap::value_type("StrongsNumbers", (const char *)Optionsfrm->strongsNumsCB->Items->Objects[Optionsfrm->strongsNumsCB->ItemIndex]));
- }
- optionsconf->Sections["ModDefaults"] = emap;
-
-
- emap = optionsconf->Sections["Bookmarks"];
- emap.erase("AutoSavePersonal"); emap.insert(ConfigEntMap::value_type("AutoSavePersonal", IntToStr((Optionsfrm->AutoBMPersonal->Checked)?1:0).c_str()));
- emap.erase("AutoSaveOther"); emap.insert(ConfigEntMap::value_type("AutoSaveOther", IntToStr((Optionsfrm->AutoBMOther->Checked)?1:0).c_str()));
- optionsconf->Sections["Bookmarks"] = emap;
-
- emap = optionsconf->Sections["Layout"];
- emap.erase("AutoSaveLayout"); emap.insert(ConfigEntMap::value_type("AutoSaveLayout", IntToStr((Optionsfrm->AutoLayout->Checked)?1:0).c_str()));
- optionsconf->Sections["Layout"] = emap;
-
- emap = optionsconf->Sections["Hints"];
- emap.erase("On"); emap.insert(ConfigEntMap::value_type("On", IntToStr((Optionsfrm->HintPopups->Checked)?1:0).c_str()));
- optionsconf->Sections["Hints"] = emap;
-
- emap = optionsconf->Sections["HintStrongs"];
- emap.erase("On"); emap.insert(ConfigEntMap::value_type("On", IntToStr((Optionsfrm->HintStrongs->Checked)?1:0).c_str()));
- optionsconf->Sections["HintStrongs"] = emap;
-
- emap = optionsconf->Sections["General"];
- emap.erase("TipOfTheDay"); emap.insert(ConfigEntMap::value_type("TipOfTheDay", (Optionsfrm->devSplashCB->Checked)?"Devotional":""));
- emap.erase("DevsAsDicts"); emap.insert(ConfigEntMap::value_type("DevsAsDicts", (Optionsfrm->devsAsDictsCB->Checked)?"true":"false"));
- emap.erase("GlosAsDicts"); emap.insert(ConfigEntMap::value_type("GlosAsDicts", (Optionsfrm->glosAsDictsCB->Checked)?"true":"false"));
- optionsconf->Sections["General"] = emap;
-
+ // Save Preferences settings :)
+ Optionsfrm->extractSettings(optionsconf);
optionsconf->Save();
- RefRTFHeaders();
+ refreshAppearance();
}
-
- tmpval = ((eit = optionsconf->Sections["Hints"].find("On")) != optionsconf->Sections["Hints"].end())? (*eit).second : (string)"1";
-
- if (atoi(tmpval.c_str()))
- Form1->ShowHint = true;
- else Form1->ShowHint = false;
-
- tmpval = ((eit = optionsconf->Sections["Appearance"].find("locale")) != optionsconf->Sections["Appearance"].end())? (*eit).second : (string)"en_us";
- i12ize(tmpval.c_str());
- DefaultVSKey->setLocale(tmpval.c_str());
- fillVKeySelector(DefaultVSKey);
- TextKeyChanged();
- RefreshActiveSheet(LexDictPageControl);
-
}
//---------------------------------------------------------------------------
void __fastcall TForm1::cbBookChange(TObject *Sender)
@@ -2037,7 +1741,7 @@ void __fastcall TForm1::GlobalOptionChange(TObject *Sender)
if ((!stricmp(option, "Strong's Numbers")) && (!stricmp(value, "On"))) {
string curText = TextPageControl->ActivePage->Caption.c_str();
if (!hasFeature(mainmgr, curText.c_str(), "StrongsNumbers")) {
- string tmpval = ((eit = optionsconf->Sections["ModDefaults"].find("StrongsNumbers")) != optionsconf->Sections["ModDefaults"].end())? (*eit).second : (string)"";
+ string tmpval = optionsconf->Sections["ModDefaults"]["StrongsNumbers"];
for (int i = 0; i < TextPageControl->PageCount; i++) {
if (!stricmp(TextPageControl->Pages[i]->Caption.c_str(), tmpval.c_str())) {
TextPageControl->ActivePageIndex = i;
@@ -2091,12 +1795,7 @@ void __fastcall TForm1::OptionShowVals(TObject *Sender)
void __fastcall TForm1::Contents1Click(TObject *Sender)
{
- string helpDir;
- ConfigEntMap::iterator it = optionsconf->Sections["Help"].find("Directory");
- if (it != optionsconf->Sections["Help"].end())
- helpDir = (*it).second;
- else helpDir = ".\\help";
-
+ string helpDir = optionsconf->Sections["Help"].getWithDefault("Directory", ".\\help");
string helpExe = helpDir + "\\sword.chm";
if ((int)ShellExecute(this->Handle, "open", helpExe.c_str(), NULL, NULL, SW_SHOWNORMAL) < 33) {
@@ -2148,13 +1847,8 @@ void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
// NS_TermEmbedding();
- section = optionsconf->Sections["Layout"];
- entryIt = section.find("AutoSaveLayout");
- if(entryIt != section.end()){
- if(atoi(entryIt->second.c_str()))
- SaveLayout1Click(this);
- }
-
+ if ((*optionsconf)["Layout"]["AutoSaveLayout"] == "1")
+ SaveLayout1Click(this);
}
//---------------------------------------------------------------------------
@@ -2259,59 +1953,40 @@ void __fastcall TForm1::InstallManager1Click(TObject *Sender)
//---------------------------------------------------------------------------
-void TForm1::RefRTFHeaders()
-{
+void TForm1::refreshAppearance() {
ModMap::iterator it;
- SectionMap::iterator sit;
- ConfigEntMap::iterator eit, eitend;
- char textFont[128];
- char commentFont[128];
- char LDFont[128];
- char tempTextFont[128];
- char tempCommFont[128];
- char tempLDFont[128];
- char buf[1024];
- TColor fieldColor;
string tmpval;
- SWDispRTFChap* rtfDispChapter;
- SWDispRTF* rtfDisp;
- // Store fonts here: needed for being able to switch back to original font name if it changes
- tmpval = ((eit = optionsconf->Sections["Appearance"].find("TextFontName")) != optionsconf->Sections["Appearance"].end())? (*eit).second : (string)"Times New Roman";
- strcpy(tempTextFont, tmpval.c_str());
- tmpval = ((eit = optionsconf->Sections["Appearance"].find("CommentFontName")) != optionsconf->Sections["Appearance"].end())? (*eit).second : (string)"Times New Roman";
- strcpy(tempCommFont, tmpval.c_str());
- tmpval = ((eit = optionsconf->Sections["Appearance"].find("LDFontName")) != optionsconf->Sections["Appearance"].end())? (*eit).second : (string)"Times New Roman";
- strcpy(tempLDFont, tmpval.c_str());
+ tmpval = optionsconf->Sections["Appearance"].getWithDefault("locale", "en_us");
+ i12ize(tmpval.c_str());
// Change the panels attributes here
for (it = mainmgr->Modules.begin(); it != mainmgr->Modules.end(); it++) {
SWModule *module = it->second;
RTFDisp *disp = SWDYNAMIC_CAST(RTFDisp, module->Disp());
if (disp) {
- rtfDisp = (SWDispRTF*) disp->editControl();
+ SWDispRTF* rtfDisp = (SWDispRTF*) disp->editControl();
rtfDisp->recalcAppearance();
}
}
- if ((sit = optionsconf->Sections.find("Appearance")) != optionsconf->Sections.end())
- if ((*sit).second.find("LDBackColor") != (*sit).second.end())
- lbDictKeys->Color = TColor((atoi((*(*sit).second.find("LDBackColor")).second.c_str())));
- if ((sit = optionsconf->Sections.find("Appearance")) != optionsconf->Sections.end())
- if ((*sit).second.find("LDFontColor") != (*sit).second.end())
- lbDictKeys->Font->Color = TColor((atoi((*(*sit).second.find("LDFontColor")).second.c_str())));
+ // Change the text entry field color
+ tmpval = optionsconf->Sections["Appearance"]["FieldColor"];
+ TColor fieldColor = tmpval.length() ? TColor(atoi(tmpval.c_str())) : clAqua;
- // Change the text entry field color
- if ((sit = optionsconf->Sections.find("Appearance")) != optionsconf->Sections.end()){
- if ((eit = (*sit).second.find("FieldColor")) != (*sit).second.end())
- fieldColor = TColor(atoi((*eit).second.c_str()));
- else fieldColor = clAqua;
- }
cbBook->Color = fieldColor;
CHBox->Color = fieldColor;
VSBox->Color = fieldColor;
freeHandLookup->Color = fieldColor;
DictKeyEdit->Color = fieldColor;
+
+ Form1->ShowHint = (optionsconf->Sections["Hints"].getWithDefault("On", "1") == "1");
+ DefaultVSKey->setLocale(tmpval.c_str());
+ fillVKeySelector(DefaultVSKey);
+ TextKeyChanged();
+ RefreshActiveSheet(LexDictPageControl);
+ RefreshActiveSheet(CommentaryPageControl);
+ RefreshActiveSheet(TextPageControl);
}
@@ -2350,7 +2025,7 @@ void __fastcall TForm1::ApplicationEvents1ShowHint(AnsiString &HintStr,
return;
ConfigEntMap::iterator eit;
- string tmpval = ((eit = optionsconf->Sections["HintStrongs"].find("On")) != optionsconf->Sections["HintStrongs"].end())? (*eit).second : (string)"1";
+ string tmpval = optionsconf->Sections["HintStrongs"].getWithDefault("On", "1");
SWDispRTF *rtf = 0;
if (atoi(tmpval.c_str())) {
@@ -2486,7 +2161,7 @@ void __fastcall TForm1::ApplicationEvents1ShowHint(AnsiString &HintStr,
feature += (preChar == '(')?"Parse":"Def";
if (!strncmp(HintInfo.HintControl->Name.c_str(), "TextRTFLXX", 10))
feature = "GreekDef";
- string tmpval = ((eit = optionsconf->Sections["ModDefaults"].find(feature.c_str())) != optionsconf->Sections["ModDefaults"].end())? (*eit).second : (string)"";
+ string tmpval = optionsconf->Sections["ModDefaults"][feature.c_str()];
if (tmpval.size()) {
SWModule *defMod = mainmgr->Modules[tmpval];
if (!defMod) {