//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include #include #include #include #include #include "TModuleFonts.h" #include "optionfrm.h" #include "mainfrm.h" //--------------------------------------------------------------------------- #pragma resource "*.dfm" TOptionsfrm *Optionsfrm; const char *TOptionsfrm::defaultLocaleName = "en_us"; const char *TOptionsfrm::defaultLocaleDescription = "English (US)"; //--------------------------------------------------------------------------- __fastcall TOptionsfrm::TOptionsfrm(TComponent* Owner) : TForm(Owner) { FontDialogText = new TFontSelFrm(this); FontDialogComment = new TFontSelFrm(this); FontDialogLD = new TFontSelFrm(this); FontDialogPopup = new TFontSelFrm(this); FontDialogSearch = new TFontSelFrm(this); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::btnCurrVerseClick(TObject *Sender) { ColorDialogVS->Execute(); shpCurrVSClr->Brush->Color = ColorDialogVS->Color; UpdatePreview(); } //--------------------------------------------------------------------------- //DONE -oDavid 1 -cOptions: add per module font size selection //TODO 1 -cOptions: add 'general' dictionary besides strongs for lookups of words //TODO 1 -cOptions: add per module 'general' dictionary void __fastcall TOptionsfrm::FormCreate(TObject *Sender) { list locales; localeCB->Clear(); localeCB->Items->AddObject(defaultLocaleDescription, (TObject *)defaultLocaleName); locales = LocaleMgr::systemLocaleMgr.getAvailableLocales(); for (list::iterator it = locales.begin(); it != locales.end(); it++) { const char *name = LocaleMgr::systemLocaleMgr.getLocale(it->c_str())->getName(); const char *description = LocaleMgr::systemLocaleMgr.getLocale(it->c_str())->getDescription(); localeCB->Items->AddObject(description, (TObject *)name); } localeCB->ItemIndex = 0; } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::FormShow(TObject *Sender) { PageControl1->ActivePage = TabSheet1; FindSchemeNames(); cmbTextSelect->ItemIndex = 0; UpdatePreview(); } void __fastcall TOptionsfrm::btnFontClick(TObject *Sender) { TFontSelFrm* tempFrm = new TFontSelFrm(this); switch (cmbTextSelect->ItemIndex) { case 0: CopyFontDlg(tempFrm, FontDialogText); if(FontDialogText->ShowModal() == mrOk){ CopyFontDlg(FontDialogComment, FontDialogText); CopyFontDlg(FontDialogLD, FontDialogText); CopyFontDlg(FontDialogPopup, FontDialogText); UpdatePreview(); }else CopyFontDlg(FontDialogText, tempFrm); break; case 1: CopyFontDlg(tempFrm, FontDialogText); if(FontDialogText->ShowModal() == mrOk) UpdatePreview(); else CopyFontDlg(FontDialogText, tempFrm); break; case 2: CopyFontDlg(tempFrm, FontDialogComment); if(FontDialogComment->ShowModal() == mrOk) UpdatePreview(); else CopyFontDlg(FontDialogComment, tempFrm); break; case 3: CopyFontDlg(tempFrm, FontDialogLD); if(FontDialogLD->ShowModal() == mrOk) UpdatePreview(); else CopyFontDlg(FontDialogLD, tempFrm); break; case 4: CopyFontDlg(tempFrm, FontDialogPopup); if(FontDialogPopup->ShowModal() == mrOk) UpdatePreview(); else CopyFontDlg(FontDialogPopup, tempFrm); break; case 5: CopyFontDlg(tempFrm, FontDialogSearch); if(FontDialogSearch->ShowModal() == mrOk) UpdatePreview(); else CopyFontDlg(FontDialogSearch, tempFrm); break; } delete tempFrm; } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::shpCurrVSClrMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { btnCurrVerseClick(Sender); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::btnNumClrClick(TObject *Sender) { ColorDialogVerseNum->Execute(); shpNumClr->Brush->Color = ColorDialogVerseNum->Color; UpdatePreview(); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::btnFieldClrClick(TObject *Sender) { ColorDialogField->Execute(); shpFieldClr->Brush->Color = ColorDialogField->Color; UpdatePreview(); } //--------------------------------------------------------------------------- // DONE 1 -oDavid -cOptions: add new category, Search Results void __fastcall TOptionsfrm::cmbTextSelectChange(TObject *Sender) { UpdatePreview(); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::cmbSchemeSelectChange(TObject *Sender) { AnsiString tempName = ExtractFilePath(Application->ExeName) + COLOR_DIR + cmbSchemeSelect->Text + COLOR_EXT; SWConfig schemesconf(tempName.c_str()); LoadDispSettings(&schemesconf); UpdatePreview(); } //--------------------------------------------------------------------------- // TODO 1 -cOptions: Change preview to use RxRichEditX, so we're consistent with look and feel of real control void TOptionsfrm::UpdatePreview() { char buffTemp[512], buffFinal[512], font[64]; char* verse = "Why, my beloved brothers, let every man be swift to hear, slow to speak, slow to wrath"; int vsColorRed, vsColorGreen, vsColorBlue, numColorRed, numColorGreen, numColorBlue; int fontSize; TMemoryStream * RTFStream = new TMemoryStream; strcpy(buffFinal, "{\\rtf1\\ansi"); switch (cmbTextSelect->ItemIndex) { case 2: // Commentary Windows TRxRichEditX::TColorToRGB(FontDialogComment->Font->Color, vsColorRed, vsColorGreen, vsColorBlue); TRxRichEditX::TColorToRGB(ColorDialogVerseNum->Color, numColorRed, numColorGreen, numColorBlue); strcpy(font, FontDialogComment->Font->Name.c_str()); fontSize = FontDialogComment->Font->Size; RTFPreview->Color = FontDialogComment->BackColor; break; case 3: // Lexicon/Dictionary Windows TRxRichEditX::TColorToRGB(FontDialogLD->Font->Color, vsColorRed, vsColorGreen, vsColorBlue); TRxRichEditX::TColorToRGB(ColorDialogVerseNum->Color, numColorRed, numColorGreen, numColorBlue); strcpy(font, FontDialogLD->Font->Name.c_str()); fontSize = FontDialogLD->Font->Size; RTFPreview->Color = FontDialogLD->BackColor; break; case 4: // Popup Windows TRxRichEditX::TColorToRGB(FontDialogPopup->Font->Color, vsColorRed, vsColorGreen, vsColorBlue); TRxRichEditX::TColorToRGB(ColorDialogVerseNum->Color, numColorRed, numColorGreen, numColorBlue); strcpy(font, FontDialogPopup->Font->Name.c_str()); fontSize = FontDialogPopup->Font->Size; RTFPreview->Color = FontDialogPopup->BackColor; break; case 5: // Search Result Windows TRxRichEditX::TColorToRGB(FontDialogSearch->Font->Color, vsColorRed, vsColorGreen, vsColorBlue); TRxRichEditX::TColorToRGB(ColorDialogVerseNum->Color, numColorRed, numColorGreen, numColorBlue); strcpy(font, FontDialogSearch->Font->Name.c_str()); fontSize = FontDialogSearch->Font->Size; RTFPreview->Color = FontDialogSearch->BackColor; break; default: // Bible Windows TRxRichEditX::TColorToRGB(FontDialogText->Font->Color, vsColorRed, vsColorGreen, vsColorBlue); TRxRichEditX::TColorToRGB(ColorDialogVerseNum->Color, numColorRed, numColorGreen, numColorBlue); strcpy(font, FontDialogText->Font->Name.c_str()); fontSize = FontDialogText->Font->Size; RTFPreview->Color = FontDialogText->BackColor; } // This is a strange way to deal with font size but I can't think of a different way to do it. // So for now I will use the current system. fontSize -= 12; sprintf(buffTemp, "{\\fonttbl{\\f0\\fdecor\\fprq2 %s;}}" , font); strcat(buffFinal, buffTemp); sprintf(buffTemp, "{\\colortbl;\\red%d\\green%d\\blue%d;\\red%d\\green%d\\blue%d;}" , vsColorRed, vsColorGreen, vsColorBlue, numColorRed, numColorGreen, numColorBlue); strcat(buffFinal, buffTemp); sprintf(buffTemp, "\\pard \\qc\\nowidctlpar{\\f1\\fs%d\\cf1\\b Chapter 1 ", (30 + fontSize)); strcat(buffFinal, buffTemp); sprintf(buffTemp, "\\par\\fs%d\\par}", (10 + fontSize)); strcat(buffFinal, buffTemp); sprintf(buffTemp, "{\\fs%d\\cf2\\super 19}", (10 + fontSize)); strcat(buffFinal, buffTemp); sprintf(buffTemp, "\\ql\\nowidctlpar \\cf1\\f0\\fs%d ", (24 + fontSize)); strcat(buffFinal, buffTemp); strcat(buffFinal, verse); strcat(buffFinal, " }"); RTFStream->WriteBuffer(buffFinal, 512); RTFStream->Position = 0; RTFPreview->Lines->LoadFromStream(RTFStream); GetCurrentScheme(); } TOptionsfrm::CopyFontDlg(TFontSelFrm* lhs, const TFontSelFrm* rhs) { lhs->BackColor = rhs->BackColor; lhs->Font->Color = rhs->Font->Color; lhs->Font->Size = rhs->Font->Size; lhs->Font->Name = rhs->Font->Name; } void __fastcall TOptionsfrm::btnSaveScheme(TObject *Sender) { TPoint menup, point; point.x = 0; point.y = btnSave->Height; menup = btnSave->ClientToScreen(point); SavePopup->Popup(menup.x, menup.y); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::SaveSchemeClick(TObject *Sender) { ConfigEntMap emap; AnsiString strName = cmbSchemeSelect->Text; if(strName != "" && !strName.Pos("/") && !strName.Pos("\\") && !strName.Pos(":") && !strName.Pos("*") && !strName.Pos("?") && !strName.Pos("\"") && !strName.Pos("<") && !strName.Pos(">") && !strName.Pos("|")) { AnsiString strName = COLOR_DIR + cmbSchemeSelect->Text + COLOR_EXT; SWConfig schemeconf(strName.c_str()); emap = schemeconf.Sections["Appearance"]; emap.erase("AutoVSColor"); emap.insert(ConfigEntMap::value_type("AutoVSColor", IntToStr((AutoVSColor->Checked)?1:0).c_str())); emap.erase("CurrentVSColor"); emap.insert(ConfigEntMap::value_type("CurrentVSColor", IntToStr(shpCurrVSClr->Brush->Color).c_str())); emap.erase("VSNumberColor"); emap.insert(ConfigEntMap::value_type("VSNumberColor", IntToStr(ColorDialogVerseNum->Color).c_str())); emap.erase("FieldColor"); emap.insert(ConfigEntMap::value_type("FieldColor", IntToStr(ColorDialogField->Color).c_str())); emap.erase("StrongsColor"); emap.insert(ConfigEntMap::value_type("StrongsColor", IntToStr(ColorDialogStrongs->Color).c_str())); emap.erase("MorphColor"); emap.insert(ConfigEntMap::value_type("MorphColor", IntToStr(ColorDialogMorph->Color).c_str())); emap.erase("TextBackColor"); emap.insert(ConfigEntMap::value_type("TextBackColor", IntToStr(FontDialogText->BackColor).c_str())); emap.erase("CommentBackColor"); emap.insert(ConfigEntMap::value_type("CommentBackColor", IntToStr(FontDialogComment->BackColor).c_str())); emap.erase("LDBackColor"); emap.insert(ConfigEntMap::value_type("LDBackColor", IntToStr(FontDialogLD->BackColor).c_str())); emap.erase("PopupBackColor"); emap.insert(ConfigEntMap::value_type("PopupBackColor", IntToStr(FontDialogPopup->BackColor).c_str())); emap.erase("SearchBackColor"); emap.insert(ConfigEntMap::value_type("SearchBackColor", IntToStr(FontDialogSearch->BackColor).c_str())); emap.erase("TextFontName"); emap.insert(ConfigEntMap::value_type("TextFontName", (FontDialogText->Font->Name).c_str())); emap.erase("CommentFontName"); emap.insert(ConfigEntMap::value_type("CommentFontName", (FontDialogComment->Font->Name).c_str())); emap.erase("LDFontName"); emap.insert(ConfigEntMap::value_type("LDFontName", (FontDialogLD->Font->Name).c_str())); emap.erase("PopupFontName"); emap.insert(ConfigEntMap::value_type("PopupFontName", (FontDialogPopup->Font->Name).c_str())); emap.erase("SearchFontName"); emap.insert(ConfigEntMap::value_type("SearchFontName", (FontDialogSearch->Font->Name).c_str())); emap.erase("TextFontSize"); emap.insert(ConfigEntMap::value_type("TextFontSize", IntToStr(FontDialogText->Font->Size).c_str())); emap.erase("CommentFontSize"); emap.insert(ConfigEntMap::value_type("CommentFontSize", IntToStr(FontDialogComment->Font->Size).c_str())); emap.erase("LDFontSize"); emap.insert(ConfigEntMap::value_type("LDFontSize", IntToStr(FontDialogLD->Font->Size).c_str())); emap.erase("PopupFontSize"); emap.insert(ConfigEntMap::value_type("PopupFontSize", IntToStr(FontDialogPopup->Font->Size).c_str())); emap.erase("SearchFontSize"); emap.insert(ConfigEntMap::value_type("SearchFontSize", IntToStr(FontDialogSearch->Font->Size).c_str())); emap.erase("TextFontColor"); emap.insert(ConfigEntMap::value_type("TextFontColor", IntToStr(FontDialogText->Font->Color).c_str())); emap.erase("CommentFontColor"); emap.insert(ConfigEntMap::value_type("CommentFontColor", IntToStr(FontDialogComment->Font->Color).c_str())); emap.erase("LDFontColor"); emap.insert(ConfigEntMap::value_type("LDFontColor", IntToStr(FontDialogLD->Font->Color).c_str())); emap.erase("PopupFontColor"); emap.insert(ConfigEntMap::value_type("PopupFontColor", IntToStr(FontDialogPopup->Font->Color).c_str())); emap.erase("SearchFontColor"); emap.insert(ConfigEntMap::value_type("SearchFontColor", IntToStr(FontDialogSearch->Font->Color).c_str())); schemeconf.Sections["Appearance"] = emap; schemeconf.Save(); }else{ Application->MessageBox("Scheme name missing or invalid.","Oops", MB_OK); } SetCurrentDir(ExtractFilePath(Application->ExeName)); FindSchemeNames(); } //--------------------------------------------------------------------------- void TOptionsfrm::FindSchemeNames() { DIR *dir; struct dirent *ent; string conffile; AnsiString strName; AnsiString strPath = COLOR_DIR; TStringList *schemeNames = new TStringList; cmbSchemeSelect->Clear(); if (access(strPath.c_str(), 0)) { // directory does not exist _mkdir(strPath.c_str()); } if (dir = opendir(strPath.c_str())) { rewinddir(dir); while ((ent = readdir(dir))) { if ((strcmp(ent->d_name, "."))&& (strcmp(ent->d_name, "..")) && !strcmp(ExtractFileExt(ent->d_name).c_str(), COLOR_EXT.c_str())) { strName = ent->d_name; schemeNames->Add(strName.SubString(1, strName.Length() - 4).c_str()); } } closedir(dir); cmbSchemeSelect->Items = schemeNames; } delete schemeNames; } void __fastcall TOptionsfrm::ExportClick(TObject *Sender) { AnsiString name = cmbSchemeSelect->Text; AnsiString newFileName; AnsiString exName; AnsiString subdir = ExtractFilePath(Application->ExeName) + COLOR_DIR; if(name != ""){ SaveSchDlg->FileName = name; if(SaveSchDlg->Execute()){ exName = subdir + name + COLOR_EXT; newFileName = SaveSchDlg->FileName.c_str(); if(!CopyFileA(exName.c_str(), newFileName.c_str(),1)) Application->MessageBox("Export Failed." , "Oops", MB_OK); } }else{ Application->MessageBox("No Scheme Selected to Export. Please Select a Scheme and Retry" , "Oops", MB_OK); } SetCurrentDir(ExtractFilePath(Application->ExeName)); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::ImportClick(TObject *Sender) { AnsiString newFileName; AnsiString exName, newPath; AnsiString subdir = ExtractFilePath(Application->ExeName) + COLOR_DIR; if(OpenSchDlg->Execute()){ exName = OpenSchDlg->FileName.c_str(); newFileName = ExtractFileName(exName); newPath = subdir + newFileName; if(!CopyFileA(exName.c_str(), newPath.c_str(),1)) MessageBox(this, "Import Failed." , "Oops", MB_OK); } SetCurrentDir(ExtractFilePath(Application->ExeName)); FindSchemeNames(); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::DeleteClick(TObject *Sender) { AnsiString name = cmbSchemeSelect->Text; AnsiString fullName = ExtractFilePath(Application->ExeName) + COLOR_DIR + name + COLOR_EXT; if(name != ""){ DeleteFile(fullName); }else{ Application->MessageBox("No Scheme Selected to Delete. Please Select a Scheme and Retry" , "Oops", MB_OK); } SetCurrentDir(ExtractFilePath(Application->ExeName)); FindSchemeNames(); } //--------------------------------------------------------------------------- void TOptionsfrm::GetCurrentScheme() { AnsiString tempName; SWConfig *schemesconf; SectionMap::iterator sit, oit; SWConfig *optionsconf = dynamic_cast(Application->MainForm)->optionsconf; for(int count = 0; count < cmbSchemeSelect->Items->Count; count++) { tempName = ExtractFilePath(Application->ExeName) + COLOR_DIR + cmbSchemeSelect->Items->Strings[count] + COLOR_EXT; schemesconf = new SWConfig(tempName.c_str()); if( schemesconf->Sections["Appearance"]["CurrentVSColor"] == optionsconf->Sections["Appearance"]["CurrentVSColor"] && schemesconf->Sections["Appearance"]["VSNumberColor"] == optionsconf->Sections["Appearance"]["VSNumberColor"] && schemesconf->Sections["Appearance"]["StrongsColor"] == optionsconf->Sections["Appearance"]["StrongsColor"] && schemesconf->Sections["Appearance"]["MorphColor"] == optionsconf->Sections["Appearance"]["MorphColor"] && schemesconf->Sections["Appearance"]["FieldColor"] == optionsconf->Sections["Appearance"]["FieldColor"] && schemesconf->Sections["Appearance"]["TextBackColor"] == optionsconf->Sections["Appearance"]["TextBackColor"] && schemesconf->Sections["Appearance"]["CommentBackColor"] == optionsconf->Sections["Appearance"]["CommentBackColor"] && schemesconf->Sections["Appearance"]["LDBackColor"] == optionsconf->Sections["Appearance"]["LDBackColor"] && schemesconf->Sections["Appearance"]["PopupBackColor"] == optionsconf->Sections["Appearance"]["PopupBackColor"] && schemesconf->Sections["Appearance"]["TextFontName"] == optionsconf->Sections["Appearance"]["TextFontName"] && schemesconf->Sections["Appearance"]["CommentFontName"] == optionsconf->Sections["Appearance"]["CommentFontName"] && schemesconf->Sections["Appearance"]["LDFontName"] == optionsconf->Sections["Appearance"]["LDFontName"] && schemesconf->Sections["Appearance"]["PopupFontName"] == optionsconf->Sections["Appearance"]["PopupFontName"] && schemesconf->Sections["Appearance"]["TextFontSize"] == optionsconf->Sections["Appearance"]["TextFontSize"] && schemesconf->Sections["Appearance"]["CommentFontSize"] == optionsconf->Sections["Appearance"]["CommentFontSize"] && schemesconf->Sections["Appearance"]["LDFontSize"] == optionsconf->Sections["Appearance"]["LDFontSize"] && schemesconf->Sections["Appearance"]["PopupFontSize"] == optionsconf->Sections["Appearance"]["PopupFontSize"] && schemesconf->Sections["Appearance"]["TextFontColor"] == optionsconf->Sections["Appearance"]["TextFontColor"] && schemesconf->Sections["Appearance"]["CommentFontColor"] == optionsconf->Sections["Appearance"]["CommentFontColor"] && schemesconf->Sections["Appearance"]["LDFontColor"] == optionsconf->Sections["Appearance"]["LDFontColor"] && schemesconf->Sections["Appearance"]["PopupFontColor"] == optionsconf->Sections["Appearance"]["PopupFontColor"]){ cmbSchemeSelect->ItemIndex = count; count = cmbSchemeSelect->Items->Count; // Basically we are done and can move on :) } delete schemesconf; } } void __fastcall TOptionsfrm::btnModFontsClick(TObject *Sender) { TModuleFonts *pDlg = new TModuleFonts(this); pDlg->ShowModal(); delete pDlg; } //--------------------------------------------------------------------------- // TODO 1 -cOptions: add hint verselist preview toggle void __fastcall TOptionsfrm::HintStrongsClick(TObject *Sender) { //In order for HintStrongs to work HintPopups has to be on if(HintStrongs->Checked){ HintPopups->Checked = true; } } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::HintPopupsClick(TObject *Sender) { // If we turn off HintPopups we have to turn off HintStrongs // because HintStrongs will not work if hints are off if(!HintPopups->Checked) HintStrongs->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::btnStrongClrClick(TObject *Sender) { ColorDialogStrongs->Execute(); shpStrongClr->Brush->Color = ColorDialogStrongs->Color; UpdatePreview(); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::btnMorphClrClick(TObject *Sender) { ColorDialogMorph->Execute(); shpMorphClr->Brush->Color = ColorDialogMorph->Color; UpdatePreview(); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::shpFieldClrMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { btnFieldClrClick(Sender); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::shpStrongClrMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { btnStrongClrClick(Sender); } //--------------------------------------------------------------------------- void __fastcall TOptionsfrm::shpMorphClrMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { btnMorphClrClick(Sender); } //--------------------------------------------------------------------------- void TOptionsfrm::LoadDispSettings(SWConfig* config) { SectionMap::iterator sit; if ((sit = config->Sections.find("Appearance")) != config->Sections.end()) { if ((*sit).second.find("CurrentVSColor") != (*sit).second.end()){ shpCurrVSClr->Brush->Color = TColor(atoi((*(*sit).second.find("CurrentVSColor")).second.c_str())); ColorDialogVS->Color = TColor(atoi((*(*sit).second.find("CurrentVSColor")).second.c_str())); } else { shpCurrVSClr->Brush->Color = TColor(clBlue); ColorDialogVS->Color = TColor(clBlue); } if ((*sit).second.find("AutoVSColor") != (*sit).second.end()) { AutoVSColor->Checked = (atoi((*(*sit).second.find("AutoVSColor")).second.c_str()) == 0) ? false : true; } else { AutoVSColor->Checked = true; } if ((*sit).second.find("StrongsColor") != (*sit).second.end()){ shpStrongClr->Brush->Color = TColor(atoi((*(*sit).second.find("StrongsColor")).second.c_str())); ColorDialogStrongs->Color = TColor(atoi((*(*sit).second.find("StrongsColor")).second.c_str())); } else{ shpStrongClr->Brush->Color = TColor(16711935); // Magenta ColorDialogStrongs->Color = TColor(16711935); } if ((*sit).second.find("MorphColor") != (*sit).second.end()){ shpMorphClr->Brush->Color = TColor(atoi((*(*sit).second.find("MorphColor")).second.c_str())); ColorDialogMorph->Color = TColor(atoi((*(*sit).second.find("MorphColor")).second.c_str())); } else{ shpMorphClr->Brush->Color = TColor(60534); // Light Green ColorDialogMorph->Color = TColor(60534); } if ((*sit).second.find("VSNumberColor") != (*sit).second.end()){ shpNumClr->Brush->Color = TColor(atoi((*(*sit).second.find("VSNumberColor")).second.c_str())); ColorDialogVerseNum->Color = TColor(atoi((*(*sit).second.find("VSNumberColor")).second.c_str())); } else{ shpNumClr->Brush->Color = TColor(clBlue); ColorDialogVerseNum->Color = TColor(clBlue); } if ((*sit).second.find("FieldColor") != (*sit).second.end()){ shpFieldClr->Brush->Color = TColor(atoi((*(*sit).second.find("FieldColor")).second.c_str())); ColorDialogField->Color = TColor(atoi((*(*sit).second.find("FieldColor")).second.c_str())); } else{ shpFieldClr->Brush->Color = TColor(clAqua); ColorDialogField->Color = TColor(clAqua); } if ((*sit).second.find("VSNumberColor") != (*sit).second.end()) ColorDialogVerseNum->Color = TColor(atoi ((*(*sit).second.find("VSNumberColor")).second.c_str())); else ColorDialogVerseNum->Color = clBlue; //**** Font BackColor ****// if ((*sit).second.find("TextBackColor") != (*sit).second.end()) FontDialogText->BackColor = TColor(atoi((*(*sit).second.find("TextBackColor")).second.c_str())); else FontDialogText->BackColor = TColor(clWhite); if ((*sit).second.find("CommentBackColor") != (*sit).second.end()) FontDialogComment->BackColor = TColor(atoi((*(*sit).second.find("CommentBackColor")).second.c_str())); else FontDialogComment->BackColor = TColor(clWhite); if ((*sit).second.find("LDBackColor") != (*sit).second.end()) FontDialogLD->BackColor = TColor(atoi((*(*sit).second.find("LDBackColor")).second.c_str())); else FontDialogLD->BackColor = TColor(clWhite); if ((*sit).second.find("PopupBackColor") != (*sit).second.end()) FontDialogPopup->BackColor = TColor(atoi((*(*sit).second.find("PopupBackColor")).second.c_str())); else FontDialogSearch->BackColor = TColor(14680063); // 13434879 == cream color if ((*sit).second.find("SearchBackColor") != (*sit).second.end()) FontDialogSearch->BackColor = TColor(atoi((*(*sit).second.find("SearchBackColor")).second.c_str())); else FontDialogSearch->BackColor = TColor(clWhite); //**** Font Face Name ****// if ((*sit).second.find("TextFontName") != (*sit).second.end()) FontDialogText->Font->Name = ((*(*sit).second.find("TextFontName")).second.c_str()); else FontDialogText->Font->Name = "Times New Roman"; if ((*sit).second.find("CommentFontName") != (*sit).second.end()) FontDialogComment->Font->Name = ((*(*sit).second.find("CommentFontName")).second.c_str()); else FontDialogComment->Font->Name = "Times New Roman"; if ((*sit).second.find("LDFontName") != (*sit).second.end()) FontDialogLD->Font->Name = ((*(*sit).second.find("LDFontName")).second.c_str()); else FontDialogLD->Font->Name = "Times New Roman"; if ((*sit).second.find("PopupFontName") != (*sit).second.end()) FontDialogPopup->Font->Name = ((*(*sit).second.find("PopupFontName")).second.c_str()); else FontDialogPopup->Font->Name = "Times New Roman"; if ((*sit).second.find("SearchFontName") != (*sit).second.end()) FontDialogSearch->Font->Name = ((*(*sit).second.find("SearchFontName")).second.c_str()); else FontDialogSearch->Font->Name = "Times New Roman"; //**** Font Size ****// if ((*sit).second.find("TextFontSize") != (*sit).second.end()) FontDialogText->Font->Size = (atoi ((*(*sit).second.find("TextFontSize")).second.c_str())); else FontDialogText->Font->Size = 10; if ((*sit).second.find("CommentFontSize") != (*sit).second.end()) FontDialogComment->Font->Size = (atoi ((*(*sit).second.find("CommentFontSize")).second.c_str())); else FontDialogComment->Font->Size = 10; if ((*sit).second.find("LDFontSize") != (*sit).second.end()) FontDialogLD->Font->Size = (atoi ((*(*sit).second.find("LDFontSize")).second.c_str())); else FontDialogLD->Font->Size = 10; if ((*sit).second.find("PopupFontSize") != (*sit).second.end()) FontDialogPopup->Font->Size = (atoi ((*(*sit).second.find("PopupFontSize")).second.c_str())); else FontDialogPopup->Font->Size = 10; if ((*sit).second.find("SearchFontSize") != (*sit).second.end()) FontDialogSearch->Font->Size = (atoi ((*(*sit).second.find("SearchFontSize")).second.c_str())); else FontDialogSearch->Font->Size = 10; //**** Font ForeColor ****// if ((*sit).second.find("TextFontColor") != (*sit).second.end()) FontDialogText->Font->Color = TColor(atoi ((*(*sit).second.find("TextFontColor")).second.c_str())); else FontDialogText->Font->Color = clBlack; if ((*sit).second.find("CommentFontColor") != (*sit).second.end()) FontDialogComment->Font->Color = TColor(atoi ((*(*sit).second.find("CommentFontColor")).second.c_str())); else FontDialogComment->Font->Color = clBlack; if ((*sit).second.find("LDFontColor") != (*sit).second.end()) FontDialogLD->Font->Color = TColor(atoi ((*(*sit).second.find("LDFontColor")).second.c_str())); else FontDialogLD->Font->Color = clBlack; if ((*sit).second.find("PopupFontColor") != (*sit).second.end()) FontDialogPopup->Font->Color = TColor(atoi ((*(*sit).second.find("PopupFontColor")).second.c_str())); else FontDialogPopup->Font->Color = clBlack; if ((*sit).second.find("SearchFontColor") != (*sit).second.end()) FontDialogSearch->Font->Color = TColor(atoi ((*(*sit).second.find("SearchFontColor")).second.c_str())); else FontDialogSearch->Font->Color = clBlack; } } void TOptionsfrm::LoadMiscSettings(SWConfig* config) { ModMap::iterator it; SectionMap::iterator sit; ConfigEntMap::iterator eit; ConfigEntMap emap; int color; string tmpval; if ((sit = config->Sections.find("Bookmarks")) != config->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 = config->Sections.find("Layout")) != config->Sections.end()) { Optionsfrm->AutoLayout->Checked = ((atoi(sit->second["AutoSaveLayout"].c_str()))?true:false); } Optionsfrm->HintStrongs->Checked = true; tmpval = ((eit = config->Sections["HintStrongs"].find("On")) != config->Sections["HintStrongs"].end())? (*eit).second : (string)"1"; if (!atoi(tmpval.c_str())) Optionsfrm->HintStrongs->Checked = false; Optionsfrm->HintPopups->Checked = true; tmpval = ((eit = config->Sections["Hints"].find("On")) != config->Sections["Hints"].end())? (*eit).second : (string)"1"; if (!atoi(tmpval.c_str())) Optionsfrm->HintPopups->Checked = false; Optionsfrm->devsAsDictsCB->Checked = false; tmpval = ((eit = config->Sections["General"].find("DevsAsDicts")) != config->Sections["General"].end())? (*eit).second : (string)"false"; if (!stricmp(tmpval.c_str(), "true")) Optionsfrm->devsAsDictsCB->Checked = true; Optionsfrm->glosAsDictsCB->Checked = true; tmpval = ((eit = config->Sections["General"].find("GlosAsDicts")) != config->Sections["General"].end())? (*eit).second : (string)"true"; if (stricmp(tmpval.c_str(), "false")) Optionsfrm->glosAsDictsCB->Checked = true; Optionsfrm->devSplashCB->Checked = false; tmpval = ((eit = config->Sections["General"].find("TipOfTheDay")) != config->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 = config->Sections["ModDefaults"].find("GreekDef")) != config->Sections["ModDefaults"].end())? (*eit).second : (string)""; if ((it = Form1->mainmgr->Modules.find(tmpval)) != Form1->mainmgr->Modules.end()) { Optionsfrm->greekDefCB->ItemIndex = Optionsfrm->greekDefCB->Items->IndexOf(it->second->Description()); } tmpval = ((eit = config->Sections["ModDefaults"].find("GreekParse")) != config->Sections["ModDefaults"].end())? (*eit).second : (string)""; if ((it = Form1->mainmgr->Modules.find(tmpval)) != Form1->mainmgr->Modules.end()) { Optionsfrm->greekParseCB->ItemIndex = Optionsfrm->greekParseCB->Items->IndexOf(it->second->Description()); } tmpval = ((eit = config->Sections["ModDefaults"].find("HebrewDef")) != config->Sections["ModDefaults"].end())? (*eit).second : (string)""; if ((it = Form1->mainmgr->Modules.find(tmpval)) != Form1->mainmgr->Modules.end()) { Optionsfrm->hebrewDefCB->ItemIndex = Optionsfrm->hebrewDefCB->Items->IndexOf(it->second->Description()); } tmpval = ((eit = config->Sections["ModDefaults"].find("HebrewParse")) != config->Sections["ModDefaults"].end())? (*eit).second : (string)""; if ((it = Form1->mainmgr->Modules.find(tmpval)) != Form1->mainmgr->Modules.end()) { Optionsfrm->hebrewParseCB->ItemIndex = Optionsfrm->hebrewParseCB->Items->IndexOf(it->second->Description()); } tmpval = ((eit = config->Sections["ModDefaults"].find("DailyDevotion")) != config->Sections["ModDefaults"].end())? (*eit).second : (string)""; if ((it = Form1->mainmgr->Modules.find(tmpval)) != Form1->mainmgr->Modules.end()) { Optionsfrm->dailyDefaultCB->ItemIndex = Optionsfrm->dailyDefaultCB->Items->IndexOf(it->second->Description()); } tmpval = ((eit = config->Sections["ModDefaults"].find("StrongsNumbers")) != config->Sections["ModDefaults"].end())? (*eit).second : (string)""; if ((it = Form1->mainmgr->Modules.find(tmpval)) != Form1->mainmgr->Modules.end()) { Optionsfrm->strongsNumsCB->ItemIndex = Optionsfrm->strongsNumsCB->Items->IndexOf(it->second->Description()); } } void TOptionsfrm::extractSettings(SWConfig* config) { ModMap::iterator it; SectionMap::iterator sit; ConfigEntMap::iterator eit; ConfigEntMap emap; int color; string tmpval; emap = config->Sections["Appearance"]; emap["AutoVSColor"] = IntToStr((Optionsfrm->AutoVSColor->Checked)?1:0).c_str(); emap["CurrentVSColor"] = IntToStr(Optionsfrm->ColorDialogVS->Color).c_str(); emap["StrongsColor"] = IntToStr(Optionsfrm->ColorDialogStrongs->Color).c_str(); emap["MorphColor"] = IntToStr(Optionsfrm->ColorDialogMorph->Color).c_str(); emap["VSNumberColor"] = IntToStr(Optionsfrm->ColorDialogVerseNum->Color).c_str(); emap["FieldColor"] = IntToStr(Optionsfrm->ColorDialogField->Color).c_str(); emap["TextBackColor"] = IntToStr(Optionsfrm->FontDialogText->BackColor).c_str(); emap["CommentBackColor"] = IntToStr(Optionsfrm->FontDialogComment->BackColor).c_str(); emap["LDBackColor"] = IntToStr(Optionsfrm->FontDialogLD->BackColor).c_str(); emap["PopupBackColor"] = IntToStr(Optionsfrm->FontDialogPopup->BackColor).c_str(); emap["SearchBackColor"] = IntToStr(Optionsfrm->FontDialogSearch->BackColor).c_str(); emap["TextFontName"] = (Optionsfrm->FontDialogText->Font->Name).c_str(); emap["CommentFontName"] = (Optionsfrm->FontDialogComment->Font->Name).c_str(); emap["LDFontName"] = (Optionsfrm->FontDialogLD->Font->Name).c_str(); emap["PopupFontName"] = (Optionsfrm->FontDialogPopup->Font->Name).c_str(); emap["SearchFontName"] = (Optionsfrm->FontDialogSearch->Font->Name).c_str(); emap["TextFontSize"] = IntToStr(Optionsfrm->FontDialogText->Font->Size).c_str(); emap["CommentFontSize"] = IntToStr(Optionsfrm->FontDialogComment->Font->Size).c_str(); emap["LDFontSize"] = IntToStr(Optionsfrm->FontDialogLD->Font->Size).c_str(); emap["PopupFontSize"] = IntToStr(Optionsfrm->FontDialogPopup->Font->Size).c_str(); emap["SearchFontSize"] = IntToStr(Optionsfrm->FontDialogSearch->Font->Size).c_str(); emap["TextFontColor"] = IntToStr(Optionsfrm->FontDialogText->Font->Color).c_str(); emap["CommentFontColor"] = IntToStr(Optionsfrm->FontDialogComment->Font->Color).c_str(); emap["LDFontColor"] = IntToStr(Optionsfrm->FontDialogLD->Font->Color).c_str(); emap["PopupFontColor"] = IntToStr(Optionsfrm->FontDialogPopup->Font->Color).c_str(); emap["SearchFontColor"] = IntToStr(Optionsfrm->FontDialogSearch->Font->Color).c_str(); emap["locale"] = (const char *)Optionsfrm->localeCB->Items->Objects[Optionsfrm->localeCB->ItemIndex]; config->Sections["Appearance"] = emap; emap = config->Sections["ModDefaults"]; if (Optionsfrm->greekDefCB->ItemIndex > -1) { emap["GreekDef"] = (const char *)Optionsfrm->greekDefCB->Items->Objects[Optionsfrm->greekDefCB->ItemIndex]; } if (Optionsfrm->greekParseCB->ItemIndex > -1) { emap["GreekParse"] = (const char *)Optionsfrm->greekParseCB->Items->Objects[Optionsfrm->greekParseCB->ItemIndex]; } if (Optionsfrm->hebrewDefCB->ItemIndex > -1) { emap["HebrewDef"] = (const char *)Optionsfrm->hebrewDefCB->Items->Objects[Optionsfrm->hebrewDefCB->ItemIndex]; } if (Optionsfrm->hebrewParseCB->ItemIndex > -1) { emap["HebrewParse"] = (const char *)Optionsfrm->hebrewParseCB->Items->Objects[Optionsfrm->hebrewParseCB->ItemIndex]; } if (Optionsfrm->dailyDefaultCB->ItemIndex > -1) { emap["DailyDevotion"] = (const char *)Optionsfrm->dailyDefaultCB->Items->Objects[Optionsfrm->dailyDefaultCB->ItemIndex]; } if (Optionsfrm->strongsNumsCB->ItemIndex > -1) { emap["StrongsNumbers"] = (const char *)Optionsfrm->strongsNumsCB->Items->Objects[Optionsfrm->strongsNumsCB->ItemIndex]; } config->Sections["ModDefaults"] = emap; emap = config->Sections["Bookmarks"]; emap["AutoSavePersonal"] = IntToStr((Optionsfrm->AutoBMPersonal->Checked)?1:0).c_str(); emap["AutoSaveOther"] = IntToStr((Optionsfrm->AutoBMOther->Checked)?1:0).c_str(); config->Sections["Bookmarks"] = emap; config->Sections["Layout"]["AutoSaveLayout"] = IntToStr((Optionsfrm->AutoLayout->Checked)?1:0).c_str(); config->Sections["Hints"]["On"] = IntToStr((Optionsfrm->HintPopups->Checked)?1:0).c_str(); config->Sections["HintStrongs"]["On"] = IntToStr((Optionsfrm->HintStrongs->Checked)?1:0).c_str(); emap = config->Sections["General"]; emap["TipOfTheDay"] = (Optionsfrm->devSplashCB->Checked)?"Devotional":""; emap["DevsAsDicts"] = (Optionsfrm->devsAsDictsCB->Checked)?"true":"false"; emap["GlosAsDicts"] = (Optionsfrm->glosAsDictsCB->Checked)?"true":"false"; config->Sections["General"] = emap; } void __fastcall TOptionsfrm::shpNumClrMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { btnNumClrClick(Sender); } //---------------------------------------------------------------------------