//--------------------------------------------------------------------------- #include #pragma hdrstop #include "mainfrm.h" #include #include #include #include #include #include #include using namespace sword; const char *defaultLocaleName = "en_us"; const char *defaultLocaleDescription = "English (US)"; ErrorCheckLog *errorCheckLog = 0; //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { errorCheckLog = new ErrorCheckLog(this); SWLog::setSystemLog(errorCheckLog); } __fastcall TForm1::~TForm1() { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { verseList = new TTntListBox(this); verseList->Parent = vList->Parent; verseList->Align = vList->Align; vList->Hide(); verseText = new TTntEdit(this); verseText->Parent = vText->Parent; verseText->Align = vText->Align; verseText->OnChange = vText->OnChange; vText->Hide(); errorText = new TTntMemo(this); errorText->Parent = errText->Parent; errorText->Align = errText->Align; errText->Hide(); LocaleMgr *localeMgr = LocaleMgr::getSystemLocaleMgr(); StringList locales = localeMgr->getAvailableLocales(); localesCB->Clear(); localesCB->Items->AddObject(defaultLocaleDescription, (TObject *)defaultLocaleName); for (StringList::const_iterator it = locales.begin(); it != locales.end(); it++) { const char *name = LocaleMgr::getSystemLocaleMgr()->getLocale(it->c_str())->getName(); const char *description = LocaleMgr::getSystemLocaleMgr()->getLocale(it->c_str())->getDescription(); localesCB->Items->AddObject(description, (TObject *)name); } localesCB->ItemIndex = 0; } //--------------------------------------------------------------------------- void __fastcall TForm1::vTextChange(TObject *Sender) { VerseKey parser; verseList->Clear(); ListKey verses = parser.ParseVerseList(UTF8Encode(verseText->Text).c_str(), parser, true); for (int i = 0; i < verses.Count(); i++) { VerseKey *element = SWDYNAMIC_CAST(VerseKey, verses.GetElement(i)); if (element) { verseList->Items->Add(UTF8Decode((SWBuf(element->LowerBound()) + " - " + SWBuf(element->UpperBound())).c_str())); } else verseList->Items->Add(UTF8Decode((const char *)*verses.GetElement(i))); } } //--------------------------------------------------------------------------- void __fastcall TForm1::localesCBChange(TObject *Sender) { const char *selectedLocale = (const char *)localesCB->Items->Objects[localesCB->ItemIndex]; LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(selectedLocale); vTextChange(0); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { const char *selectedLocale = (const char *)localesCB->Items->Objects[localesCB->ItemIndex]; LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(""); // force a verse locale check VerseKey parser; // clear log errorCheckLog->getCumulitiveLog(); LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(selectedLocale); // force a verse locale check VerseKey parser2; SWBuf errorString = errorCheckLog->getCumulitiveLog(); errorText->Text = UTF8Decode(errorString.c_str()); } //---------------------------------------------------------------------------