diff --git a/ZRCola/ZRCola.props b/ZRCola/ZRCola.props index 5eebfca..f49f50e 100644 --- a/ZRCola/ZRCola.props +++ b/ZRCola/ZRCola.props @@ -7,7 +7,7 @@ - ..\lib\wxExtend\include;..\lib\libZRCola\include + ..\lib\wxExtend\include;..\lib\stdex\include;..\lib\libZRCola\include diff --git a/ZRCola/stdafx.h b/ZRCola/stdafx.h index c753e27..2c0294a 100644 --- a/ZRCola/stdafx.h +++ b/ZRCola/stdafx.h @@ -30,5 +30,8 @@ #include #include +#include #include #include + +#include diff --git a/ZRCola/zrcolaapp.h b/ZRCola/zrcolaapp.h index 8e4eb31..07ae7e9 100644 --- a/ZRCola/zrcolaapp.h +++ b/ZRCola/zrcolaapp.h @@ -42,3 +42,6 @@ public: /// - false otherwise virtual bool OnInit(); }; + + +wxDECLARE_APP(ZRColaApp); diff --git a/ZRCola/zrcolacomppnl.cpp b/ZRCola/zrcolacomppnl.cpp index 84f1e5f..a06462f 100644 --- a/ZRCola/zrcolacomppnl.cpp +++ b/ZRCola/zrcolacomppnl.cpp @@ -30,6 +30,30 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) : m_selComposed(0, 0), wxZRColaComposerPanelBase(parent) { + wxString sPath(wxPathOnly(wxTheApp->argv[0])); + sPath << wxT("\\..\\data\\ZRCola.zrcdb"); // TODO: Make database file configurable + + std::fstream dat((LPCTSTR)sPath, std::ios_base::in | std::ios_base::binary); + if (dat.good()) { + if (stdex::idrec::find(dat, ZRCOLA_DB_ID, sizeof(ZRCola::recordid_t))) { + ZRCola::recordsize_t size; + dat.read((char*)&size, sizeof(ZRCola::recordsize_t)); + if (dat.good()) { + ZRCola::translation_rec r_rec(m_t_db); + if (r_rec.find(dat, size)) { + dat >> r_rec; + if (!dat.good()) { + wxFAIL_MSG(wxT("Error reading translation data from ZRCola.zrcdb.")); + m_t_db. comp_index.clear(); + m_t_db.decomp_index.clear(); + m_t_db. data.clear(); + } + } else + wxFAIL_MSG(wxT("ZRCola.zrcdb has no translation data.")); + } + } else + wxFAIL_MSG(wxT("ZRCola.zrcdb is not a valid ZRCola database.")); + } } diff --git a/ZRCola/zrcolacomppnl.h b/ZRCola/zrcolacomppnl.h index a7f13b3..7c91caa 100644 --- a/ZRCola/zrcolacomppnl.h +++ b/ZRCola/zrcolacomppnl.h @@ -49,6 +49,7 @@ protected: virtual void OnComposedText(wxCommandEvent& event); protected: + ZRCola::translation_db m_t_db; ///< Translation database bool m_progress; ///< Boolean flag to avoid recursive updates of composed and decomposed text controls ZRCola::mapping_vector m_mapping; ///< Character index mapping vector between composed and decomposed text std::pair diff --git a/lib/stdex b/lib/stdex index 32391e5..f5a2b04 160000 --- a/lib/stdex +++ b/lib/stdex @@ -1 +1 @@ -Subproject commit 32391e55a37dd6f56577f6b761fbe8589f858095 +Subproject commit f5a2b04caa11c846a5414d5c10934723e53aa84b