From: <kkk...@us...> - 2009-11-22 15:29:56
|
Revision: 802 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=802&view=rev Author: kkkvadim Date: 2009-11-22 15:29:49 +0000 (Sun, 22 Nov 2009) Log Message: ----------- new Added Paths: ----------- trunk/mmex/src/constants.cpp trunk/mmex/src/constants.h Added: trunk/mmex/src/constants.cpp =================================================================== --- trunk/mmex/src/constants.cpp (rev 0) +++ trunk/mmex/src/constants.cpp 2009-11-22 15:29:49 UTC (rev 802) @@ -0,0 +1,33 @@ +/******************************************************* +Copyright (C) 2009 VaDiM + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + ********************************************************/ + +#include "constants.h" +#include <wx/string.h> +//---------------------------------------------------------------------------- + +wxString mmex::getProgramName() +{ + return wxString(wxT("MoneyManagerEx")); +} +//---------------------------------------------------------------------------- + +wxString mmex::getProgramVersion() +{ + return wxString(wxT("0.9.6.0")); +} +//---------------------------------------------------------------------------- Property changes on: trunk/mmex/src/constants.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/mmex/src/constants.h =================================================================== --- trunk/mmex/src/constants.h (rev 0) +++ trunk/mmex/src/constants.h 2009-11-22 15:29:49 UTC (rev 802) @@ -0,0 +1,40 @@ +/******************************************************* +Copyright (C) 2009 VaDiM + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + ********************************************************/ + +#ifndef _MM_EX_CONSTANTS_H_ +#define _MM_EX_CONSTANTS_H_ +//---------------------------------------------------------------------------- +class wxString; +//---------------------------------------------------------------------------- + +namespace mmex +{ + +/* + Uses for titles, reports, etc. + Do not use mmex::GetAppName() for such things. +*/ +wxString getProgramName(); + +wxString getProgramVersion(); + +} // namespace mmex + +//---------------------------------------------------------------------------- +#endif // _MM_EX_CONSTANTS_H_ +//---------------------------------------------------------------------------- Property changes on: trunk/mmex/src/constants.h ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:31:50
|
Revision: 803 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=803&view=rev Author: kkkvadim Date: 2009-11-22 15:31:37 +0000 (Sun, 22 Nov 2009) Log Message: ----------- new Added Paths: ----------- trunk/mmex/src/paths.cpp trunk/mmex/src/paths.h Added: trunk/mmex/src/paths.cpp =================================================================== --- trunk/mmex/src/paths.cpp (rev 0) +++ trunk/mmex/src/paths.cpp 2009-11-22 15:31:37 UTC (rev 803) @@ -0,0 +1,121 @@ +/******************************************************* +Copyright (C) 2009 VaDiM + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + ********************************************************/ + +//---------------------------------------------------------------------------- +#include "paths.h" +#include "platfdep.h" +//---------------------------------------------------------------------------- +#include <wx/filename.h> +#include <wx/stdpaths.h> +#include <wx/icon.h> +//---------------------------------------------------------------------------- + +/* + This routine is platform-independent. +*/ +wxFileName mmex::GetUserDir(bool create) +{ + static wxFileName fname(wxFileName::DirName(wxStandardPaths::Get().GetUserDataDir())); + + if (create && !fname.DirExists()) { + bool ok = fname.Mkdir(777, wxPATH_MKDIR_FULL); + wxASSERT(ok); + } + + return fname; +} +//---------------------------------------------------------------------------- + +wxString mmex::getPathDoc(EDocFile f) +{ + static const wxChar* files[DOC_FILES_MAX] = { + wxT("README.TXT"), + wxT("contrib.txt"), + wxT("license.txt"), + wxT("version.txt"), + wxT("help/index.html") + }; + + wxASSERT(sizeof(files)/sizeof(*files) == DOC_FILES_MAX); + wxASSERT(f >= 0 && f < DOC_FILES_MAX); + + wxString path = GetDocDir().GetPath(); + path += wxFileName::GetPathSeparator(); + path += files[f]; + + return path; +} +//---------------------------------------------------------------------------- + +wxString mmex::getPathResource(EResFile f) +{ + static const wxChar* files[RES_FILES_MAX] = { + wxT("mmex.ico"), + wxT("splash.png"), + wxT("kaching.wav") + }; + + wxASSERT(sizeof(files)/sizeof(*files) == RES_FILES_MAX); + wxASSERT(f >= 0 && f < RES_FILES_MAX); + + wxFileName fname = GetResourceDir(); + fname.SetFullName(files[f]); + + return fname.GetFullPath(); +} +//---------------------------------------------------------------------------- + +wxString mmex::getPathShared(ESharedFile f) +{ + static const wxChar* files[SHARED_FILES_MAX] = { + wxT("currency_seed.db3"), + wxT("i18n") + }; + + wxASSERT(sizeof(files)/sizeof(*files) == SHARED_FILES_MAX); + wxASSERT(f >= 0 && f < SHARED_FILES_MAX); + + wxFileName fname = GetSharedDir(); + fname.SetFullName(files[f]); + + return fname.GetFullPath(); +} +//---------------------------------------------------------------------------- + +wxString mmex::getPathUser(EUserFile f) +{ + static const wxChar* files[USER_FILES_MAX] = { + wxT("mmexini.db3") + }; + + wxASSERT(sizeof(files)/sizeof(*files) == USER_FILES_MAX); + wxASSERT(f >= 0 && f < USER_FILES_MAX); + + wxFileName fname = GetUserDir(true); + fname.SetFullName(files[f]); + + return fname.GetFullPath(); +} +//---------------------------------------------------------------------------- + +const wxIcon& mmex::getProgramIcon() +{ + static wxIcon icon(getPathResource(PROGRAM_ICON), wxBITMAP_TYPE_ICO, 32, 32); + return icon; +} +//---------------------------------------------------------------------------- Property changes on: trunk/mmex/src/paths.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/mmex/src/paths.h =================================================================== --- trunk/mmex/src/paths.h (rev 0) +++ trunk/mmex/src/paths.h 2009-11-22 15:31:37 UTC (rev 803) @@ -0,0 +1,53 @@ +/******************************************************* +Copyright (C) 2009 VaDiM + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + ********************************************************/ + +#ifndef _MM_EX_PATHS_H_ +#define _MM_EX_PATHS_H_ +//---------------------------------------------------------------------------- +/* + mmex's files and dirs locations. + All functions return absolute paths. +*/ +//---------------------------------------------------------------------------- +class wxString; +class wxIcon; +//---------------------------------------------------------------------------- + +namespace mmex +{ + +enum EDocFile { F_README, F_CONTRIB, F_LICENSE, F_VERSION, HTML_INDEX, DOC_FILES_MAX }; +wxString getPathDoc(EDocFile f); + +enum EResFile { PROGRAM_ICON, SPLASH_ICON, TRANS_SOUND, RES_FILES_MAX }; +wxString getPathResource(EResFile f); + +// use instead of getPathResource(PROGRAM_ICON) +const wxIcon& getProgramIcon(); + +enum ESharedFile { CURRENCY_DB_SEED, LANG_DIR, SHARED_FILES_MAX }; +wxString getPathShared(ESharedFile f); + +enum EUserFile { SETTINGS, USER_FILES_MAX }; +wxString getPathUser(EUserFile f); + +} // namespace mmex + +//---------------------------------------------------------------------------- +#endif // _MM_EX_PATHS_H_ +//---------------------------------------------------------------------------- Property changes on: trunk/mmex/src/paths.h ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:33:28
|
Revision: 804 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=804&view=rev Author: kkkvadim Date: 2009-11-22 15:33:22 +0000 (Sun, 22 Nov 2009) Log Message: ----------- new Added Paths: ----------- trunk/mmex/src/mmgraphpie.cpp trunk/mmex/src/platfdep.h Added: trunk/mmex/src/mmgraphpie.cpp =================================================================== --- trunk/mmex/src/mmgraphpie.cpp (rev 0) +++ trunk/mmex/src/mmgraphpie.cpp 2009-11-22 15:33:22 UTC (rev 804) @@ -0,0 +1,36 @@ +#include "mmgraphpie.h" +#include "chart.h" +#include "util.h" + +bool sortValueList(const ValuePair& elem1, const ValuePair& elem2) +{ + return fabs(elem1.amount) > fabs(elem2.amount); +} + +mmGraphPie::mmGraphPie() : chart(new PieChart(480, 320)) +{ +} + +mmGraphPie::~mmGraphPie() +{ +} + +void mmGraphPie::init(std::vector<ValuePair>& valueList) +{ + std::vector<ChartData> pieData; + std::sort(valueList.begin(), valueList.end(), sortValueList); + + for (size_t i = 0; i < valueList.size(); ++i) { + if (i < 15) + pieData.push_back(ChartData(valueList[i].label, valueList[i].amount)); + } + + chart->SetData(pieData); + chart->Init(240, CHART_LEGEND_FIXED, PIE_CHART_ABSOLUT); +} + +bool mmGraphPie::Generate(const wxString& chartTitle) +{ + chart->Render(chartTitle); + return chart->Save(GetOutputFileName()); +} Property changes on: trunk/mmex/src/mmgraphpie.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/mmex/src/platfdep.h =================================================================== --- trunk/mmex/src/platfdep.h (rev 0) +++ trunk/mmex/src/platfdep.h 2009-11-22 15:33:22 UTC (rev 804) @@ -0,0 +1,51 @@ +/******************************************************* +Copyright (C) 2009 VaDiM + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + ********************************************************/ + +#ifndef _MM_EX_PLATFDEP_H_ +#define _MM_EX_PLATFDEP_H_ +//---------------------------------------------------------------------------- +/* + Platform-dependent API. +*/ +//---------------------------------------------------------------------------- + +class wxFileName; +class wxString; + + +namespace mmex +{ + +wxFileName GetDocDir(); +wxFileName GetResourceDir(); +wxFileName GetSharedDir(); +wxFileName GetUserDir(bool create); + +/* + wxStandardPaths uses wxApp::GetAppName(), so you should + call wxApp::SetAppName(mmex::GetAppName()) in wxApp::OnInit(). + + Use mmex::getProgramName() for others purposes. +*/ +wxString GetAppName(); + +} // namespace mmex + +//---------------------------------------------------------------------------- +#endif // _MM_EX_PLATFDEP_H_ +//---------------------------------------------------------------------------- Property changes on: trunk/mmex/src/platfdep.h ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:40:59
|
Revision: 807 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=807&view=rev Author: kkkvadim Date: 2009-11-22 15:40:53 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/dbwrapper.cpp trunk/mmex/src/dbwrapper.h trunk/mmex/src/util.cpp trunk/mmex/src/util.h Modified: trunk/mmex/src/dbwrapper.cpp =================================================================== --- trunk/mmex/src/dbwrapper.cpp 2009-11-22 15:39:32 UTC (rev 806) +++ trunk/mmex/src/dbwrapper.cpp 2009-11-22 15:40:53 UTC (rev 807) @@ -20,6 +20,8 @@ #include "wx/datetime.h" #include "util.h" #include "guiid.h" +#include "paths.h" +#include "constants.h" //---------------------------------------------------------------------------- #include <boost/scoped_ptr.hpp> #include <string> @@ -52,6 +54,67 @@ } //---------------------------------------------------------------------------- +void loadCurrencies(wxSQLite3Database* db) +{ + static const char sql[] = + "select CURRENCYNAME, " + "PFX_SYMBOL, " + "SFX_SYMBOL, " + "DECIMAL_POINT, " + "GROUP_SEPARATOR, " + "UNIT_NAME, " + "CENT_NAME, " + "SCALE, " + "BASECONVRATE " // CURRENCY_SYMBOL not exists in this table + "from CURRENCYFORMATS_V1"; + + static const char sql2[] = + "insert into CURRENCYFORMATS_V1 (" + "CURRENCYNAME, PFX_SYMBOL, SFX_SYMBOL, DECIMAL_POINT, GROUP_SEPARATOR, " + "UNIT_NAME, CENT_NAME, SCALE, BASECONVRATE, CURRENCY_SYMBOL " + " ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, '' )"; + + wxString fName = mmex::getPathShared(mmex::CURRENCY_DB_SEED); + wxASSERT(wxFileName::FileExists(fName)); + + wxSQLite3Database currencies; + currencies.Open(fName); + + { + bool ok = currencies.TableExists(wxT("CURRENCYFORMATS_V1")); + wxASSERT(ok); + ok = ok; // removes compiler's warning + } + + wxSQLite3ResultSet rs = currencies.ExecuteQuery(sql); + wxSQLite3Statement st = db->PrepareStatement(sql2); + + while(rs.NextRow()) + { + int i = 0; + st.Bind(++i, rs.GetString(wxT("CURRENCYNAME"))); + st.Bind(++i, rs.GetString(wxT("PFX_SYMBOL"))); + st.Bind(++i, rs.GetString(wxT("SFX_SYMBOL"))); + st.Bind(++i, rs.GetString(wxT("DECIMAL_POINT"))); + st.Bind(++i, rs.GetString(wxT("GROUP_SEPARATOR"))); + st.Bind(++i, rs.GetString(wxT("UNIT_NAME"))); + st.Bind(++i, rs.GetString(wxT("CENT_NAME"))); + st.Bind(++i, rs.GetDouble(wxT("SCALE"))); + st.Bind(++i, rs.GetDouble(wxT("BASECONVRATE"), g_defBASECONVRATE)); + + wxASSERT(st.GetParamCount() == i); + + st.ExecuteUpdate(); + st.Reset(); + } + + st.Finalize(); + rs.Finalize(); + + currencies.Close(); +} +//---------------------------------------------------------------------------- + void insertCategoryTree(wxSQLite3Database* db, wxSQLite3Statement &cat, @@ -293,7 +356,7 @@ const Rec data[] = { - { "MMEXVERSION", mmex::getVersion()}, + { "MMEXVERSION", mmex::getProgramVersion()}, { "DATAVERSION", mmex::DATAVERSION }, { "CREATEDATE", wxDateTime::Now().FormatISODate() }, { "DATEFORMAT", mmex::DEFDATEFORMAT }, @@ -318,18 +381,30 @@ } } -void mmDBWrapper::createCurrencyV1Table(wxSQLite3Database* db, const wxString& fpath) +void mmDBWrapper::createCurrencyV1Table(wxSQLite3Database* db) { - bool valid = db->TableExists(wxT("CURRENCYFORMATS_V1")); - if (!valid) - { + bool exists = db->TableExists(wxT("CURRENCYFORMATS_V1")); + + if (exists) { + + /* Check whether the column "CURRENCY_SYMBOL" exists or not */ + wxSQLite3ResultSet q1 = db->ExecuteQuery(wxT("select * from CURRENCYFORMATS_V1 limit 1")); + + if(q1.GetColumnCount() < 11) { + /* not exist, create the column */ + db->ExecuteUpdate(wxT("alter table CURRENCYFORMATS_V1 add CURRENCY_SYMBOL TEXT")); + } + + } else { + db->ExecuteUpdate(wxT("create table CURRENCYFORMATS_V1(CURRENCYID integer primary key, \ CURRENCYNAME TEXT NOT NULL, PFX_SYMBOL TEXT, SFX_SYMBOL TEXT, \ DECIMAL_POINT TEXT, GROUP_SEPARATOR TEXT, \ UNIT_NAME TEXT, CENT_NAME TEXT, SCALE numeric, BASECONVRATE numeric, CURRENCY_SYMBOL TEXT);")); - valid = db->TableExists(wxT("CURRENCYFORMATS_V1")); - wxASSERT(valid); + exists = db->TableExists(wxT("CURRENCYFORMATS_V1")); + wxASSERT(exists); + /* Load Default US Currency */ static const char sql[] = @@ -341,17 +416,7 @@ ")"; db->ExecuteUpdate(sql); - - /* Load Currencies from iniDB */ - loadCurrencies(db, fpath); - } else { - /* Check whether the column "CURRENCY_SYMBOL" exists or not */ - wxSQLite3ResultSet q1 = db->ExecuteQuery(wxT("select * from CURRENCYFORMATS_V1")); - - if(q1.GetColumnCount() < 11) { - /* not exist, create the column */ - db->ExecuteUpdate(wxT("alter table CURRENCYFORMATS_V1 add CURRENCY_SYMBOL TEXT;")); - } + loadCurrencies(db); } } @@ -444,66 +509,6 @@ return ok; } -void mmDBWrapper::loadCurrencies(wxSQLite3Database* db, const wxString& fpath) -{ - static const char sql[] = - "select CURRENCYNAME, " - "PFX_SYMBOL, " - "SFX_SYMBOL, " - "DECIMAL_POINT, " - "GROUP_SEPARATOR, " - "UNIT_NAME, " - "CENT_NAME, " - "SCALE, " - "BASECONVRATE " // CURRENCY_SYMBOL not exists in this table - "from CURRENCYFORMATS_V1"; - - static const char sql2[] = - "insert into CURRENCYFORMATS_V1 (" - "CURRENCYNAME, PFX_SYMBOL, SFX_SYMBOL, DECIMAL_POINT, GROUP_SEPARATOR, " - "UNIT_NAME, CENT_NAME, SCALE, BASECONVRATE, CURRENCY_SYMBOL " - " ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, '' )"; - - boost::scoped_ptr<wxSQLite3Database> inidb(new wxSQLite3Database()); - - wxString fName = fpath + mmex::CURRENCYDB_FNAME; - wxASSERT(wxFileName::FileExists(fName)); - - inidb->Open(fName); - { - bool ok = inidb->TableExists(wxT("CURRENCYFORMATS_V1")); - wxASSERT(ok); - ok = ok; // removes compiler's warning - } - - wxSQLite3Statement st = db->PrepareStatement(sql2); - wxSQLite3ResultSet q1 = inidb->ExecuteQuery(sql); - - while(q1.NextRow()) - { - int i = 0; - st.Bind(++i, q1.GetString(wxT("CURRENCYNAME"))); - st.Bind(++i, q1.GetString(wxT("PFX_SYMBOL"))); - st.Bind(++i, q1.GetString(wxT("SFX_SYMBOL"))); - st.Bind(++i, q1.GetString(wxT("DECIMAL_POINT"))); - st.Bind(++i, q1.GetString(wxT("GROUP_SEPARATOR"))); - st.Bind(++i, q1.GetString(wxT("UNIT_NAME"))); - st.Bind(++i, q1.GetString(wxT("CENT_NAME"))); - st.Bind(++i, q1.GetDouble(wxT("SCALE"))); - st.Bind(++i, q1.GetDouble(wxT("BASECONVRATE"), g_defBASECONVRATE)); - - wxASSERT(st.GetParamCount() == i); - - st.ExecuteUpdate(); - st.Reset(); - } - - q1.Finalize(); - st.Finalize(); - - inidb->Close(); -} - void mmDBWrapper::createAccountListV1Table(wxSQLite3Database* db) { bool exists = db->TableExists(wxT("ACCOUNTLIST_V1")); @@ -785,7 +790,7 @@ This routine sets up a new DB as well as update an old one */ -void mmDBWrapper::initDB(wxSQLite3Database* db, wxProgressDialog* pgd, const wxString& fpath) +void mmDBWrapper::initDB(wxSQLite3Database* db, wxProgressDialog* pgd) { /* Create INFOTABLE_V1 Tables */ createInfoV1Table(db); @@ -793,7 +798,7 @@ pgd->Update(10); /* Create Currency Settings */ - createCurrencyV1Table(db, fpath); + createCurrencyV1Table(db); if (pgd) pgd->Update(20); Modified: trunk/mmex/src/dbwrapper.h =================================================================== --- trunk/mmex/src/dbwrapper.h 2009-11-22 15:39:32 UTC (rev 806) +++ trunk/mmex/src/dbwrapper.h 2009-11-22 15:40:53 UTC (rev 807) @@ -29,10 +29,9 @@ bool ViewExists(wxSQLite3Database* db, const char *viewName); /* Creating new DBs */ -void initDB(wxSQLite3Database* db, wxProgressDialog* pgd, const wxString& path); -void loadCurrencies(wxSQLite3Database* db, const wxString& fpath); +void initDB(wxSQLite3Database* db, wxProgressDialog* pgd); void createInfoV1Table(wxSQLite3Database* db); -void createCurrencyV1Table(wxSQLite3Database* db, const wxString& fpath); +void createCurrencyV1Table(wxSQLite3Database* db); void createAccountListV1Table(wxSQLite3Database* db); void createCheckingAccountV1Table(wxSQLite3Database* db); void createPayeeV1Table(wxSQLite3Database* db); Modified: trunk/mmex/src/util.cpp =================================================================== --- trunk/mmex/src/util.cpp 2009-11-22 15:39:32 UTC (rev 806) +++ trunk/mmex/src/util.cpp 2009-11-22 15:40:53 UTC (rev 807) @@ -23,9 +23,11 @@ #include "mmex.h" #include "univcsvdialog.h" #include "mmcoredb.h" -#include <wx/sound.h> +#include "paths.h" #include "wxautocombobox.h" +#include <wx/sound.h> + //---------------------------------------------------------------------------- namespace @@ -113,7 +115,6 @@ wxString mmIniOptions::logoName_ = wxT("bma_small.jpg"); bool mmIniOptions::enableAddAccount_ = false; bool mmIniOptions::enableRepeatingTransactions_ = true; - wxString mmIniOptions::appName_ = wxT("Hotel Manager"); bool mmIniOptions::enableImportMMNETCSV_ = false; bool mmIniOptions::enableImportMMCSV_ = false; bool mmIniOptions::enableCheckForUpdates_ = false; @@ -136,7 +137,6 @@ wxString mmIniOptions::logoName_ = wxT(""); bool mmIniOptions::enableAddAccount_ = true; bool mmIniOptions::enableRepeatingTransactions_ = true; - wxString mmIniOptions::appName_ = wxT("Money Manager Ex - CodeLathe"); bool mmIniOptions::enableImportMMNETCSV_ = true; bool mmIniOptions::enableImportMMCSV_ = true; bool mmIniOptions::enableCheckForUpdates_ = true; @@ -184,22 +184,13 @@ // --------------------------------------------------------------------------- void mmPlayTransactionSound(wxSQLite3Database* db_) { - wxString useSound = mmDBWrapper::getINISettingValue(db_, - wxT("USETRANSSOUND"), wxT("TRUE")); - if (useSound != wxT("TRUE")) - return; - wxString soundPath = mmGetBaseWorkingPath()+wxT("\\kaching.wav"); - - // Added path for mac app bundles -#if defined (__WXMAC__) || defined(__WXOSX__) - soundPath = wxT("MMEX.app/Contents/Resources/kaching.wav"); -#elif defined (__WXGTK__) - soundPath = mmGetBaseWorkingPath()+wxT("//kaching.wav"); -#endif - - wxSound registerSound(soundPath); - if (registerSound.IsOk()) - registerSound.Play(wxSOUND_ASYNC); + wxString useSound = mmDBWrapper::getINISettingValue(db_, wxT("USETRANSSOUND"), wxT("TRUE")); + + if (useSound == wxT("TRUE")) { + wxSound registerSound(mmex::getPathResource(mmex::TRANS_SOUND)); + if (registerSound.IsOk()) + registerSound.Play(wxSOUND_ASYNC); + } } wxString mmGetBaseWorkingPath(bool ignoreCommandLine) @@ -228,7 +219,7 @@ { wxString lang; - const wxString langPath = mmGetBaseWorkingPath() + wxT("/i18n"); + const wxString langPath = mmex::getPathShared(mmex::LANG_DIR); wxLocale &locale = wxGetApp().getLocale(); bool verbose = forced_show_dlg; @@ -1284,14 +1275,15 @@ /* -------------------------------------------- */ // setup the defaults for US Dollar -wxString mmCurrencyFormatter::pfx_symbol = wxT("$"); -wxString mmCurrencyFormatter::sfx_symbol = wxT(""); -wxChar mmCurrencyFormatter::decimal_point = wxT('.'); +wxString mmCurrencyFormatter::pfx_symbol = wxT("$"); +wxString mmCurrencyFormatter::sfx_symbol; +wxChar mmCurrencyFormatter::decimal_point = wxT('.'); wxChar mmCurrencyFormatter::group_separator = wxT(','); -wxString mmCurrencyFormatter::unit_name = wxT("dollar"); -wxString mmCurrencyFormatter::cent_name = wxT("cent"); -double mmCurrencyFormatter::scale = 100; +wxString mmCurrencyFormatter::unit_name = wxT("dollar"); +wxString mmCurrencyFormatter::cent_name = wxT("cent"); +double mmCurrencyFormatter::scale = 100; + double mmRound(const double x) { double dummy; @@ -1312,49 +1304,46 @@ void mmCurrencyFormatter::loadSettings(wxString pfx, wxString sfx, wxChar dec, wxChar grp, wxString unit, wxString cent, double scale) { - mmCurrencyFormatter::pfx_symbol = pfx; - mmCurrencyFormatter::sfx_symbol = sfx; - mmCurrencyFormatter::decimal_point = dec; - mmCurrencyFormatter::group_separator = grp; - mmCurrencyFormatter::unit_name = unit; - mmCurrencyFormatter::cent_name = cent; - mmCurrencyFormatter::scale = scale; + pfx_symbol = pfx; + sfx_symbol = sfx; + decimal_point = dec; + group_separator = grp; + unit_name = unit; + cent_name = cent; + scale = scale; } void mmCurrencyFormatter::loadSettings(boost::shared_ptr<mmCurrency> pCurrencyPtr) { - mmCurrencyFormatter::pfx_symbol = pCurrencyPtr->pfxSymbol_; - mmCurrencyFormatter::sfx_symbol = pCurrencyPtr->sfxSymbol_; + pfx_symbol = pCurrencyPtr->pfxSymbol_; + sfx_symbol = pCurrencyPtr->sfxSymbol_; - if (!pCurrencyPtr->dec_.IsEmpty()) - { - mmCurrencyFormatter::decimal_point = pCurrencyPtr->dec_.GetChar(0); + if (!pCurrencyPtr->dec_.IsEmpty()) { + decimal_point = pCurrencyPtr->dec_.GetChar(0); + } else { + decimal_point = 0; } - else - mmCurrencyFormatter::decimal_point = 0; - if (!pCurrencyPtr->grp_.IsEmpty()) - { - mmCurrencyFormatter::group_separator = pCurrencyPtr->grp_.GetChar(0); + if (!pCurrencyPtr->grp_.IsEmpty()) { + group_separator = pCurrencyPtr->grp_.GetChar(0); + } else { + group_separator = 0; } - else - mmCurrencyFormatter::group_separator = 0; - - mmCurrencyFormatter::unit_name = pCurrencyPtr->unit_; - mmCurrencyFormatter::cent_name = pCurrencyPtr->cent_; - mmCurrencyFormatter::scale = pCurrencyPtr->scaleDl_; + unit_name = pCurrencyPtr->unit_; + cent_name = pCurrencyPtr->cent_; + scale = pCurrencyPtr->scaleDl_; } void mmCurrencyFormatter::loadDefaultSettings() { - mmCurrencyFormatter::pfx_symbol = wxT("$"); - mmCurrencyFormatter::sfx_symbol = wxT(""); - mmCurrencyFormatter::decimal_point = wxT('.'); - mmCurrencyFormatter::group_separator = wxT(','); - mmCurrencyFormatter::unit_name = wxT("dollar"); - mmCurrencyFormatter::cent_name = wxT("cent"); - mmCurrencyFormatter::scale = 100; + pfx_symbol = wxT("$"); + sfx_symbol.clear(); + decimal_point = wxT('.'); + group_separator = wxT(','); + unit_name = wxT("dollar"); + cent_name = wxT("cent"); + scale = 100; } bool mmCurrencyFormatter::formatDoubleToCurrencyEdit(double val, wxString& rdata) @@ -1450,15 +1439,15 @@ bool mmCurrencyFormatter::formatDoubleToCurrency(double val, wxString& rdata) { - wxString data = wxT(""); - double value = mmRound(val * mmCurrencyFormatter::scale); + wxString data; + double value = mmRound(val * scale); double absx = value > 0 ? value : - value; // Get magnitude of argument double whole = mmMoneyInt(absx); // Isolate whole monetary units short cents = mmCents(absx); // Isolate fractional units //double remdr = absx - ((whole * 100 + cents) / 100); - data = data + pfx_symbol; // insert prefix - data = data + wxT(' '); // insert space + data += pfx_symbol; // insert prefix + data += wxT(' '); // insert space if (value < 0) data += '-'; // print prefix minus, if needed @@ -1569,21 +1558,12 @@ EVT_KEY_UP(wxAutoComboBox::OnKeyUp) END_EVENT_TABLE() -wxAutoComboBox::wxAutoComboBox() -{ - -} - wxAutoComboBox::wxAutoComboBox(wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, const wxArrayString& choices, long style, const wxValidator& validator, const wxString& name) : wxComboBox(parent, id, value, pos, size, choices, style, validator, name) { } -wxAutoComboBox::~wxAutoComboBox(void) -{ -} - void wxAutoComboBox::OnKeyUp(wxKeyEvent &event) { int nKeyCode = event.GetKeyCode(); Modified: trunk/mmex/src/util.h =================================================================== --- trunk/mmex/src/util.h 2009-11-22 15:39:32 UTC (rev 806) +++ trunk/mmex/src/util.h 2009-11-22 15:40:53 UTC (rev 807) @@ -100,7 +100,6 @@ static bool enableBeNotifiedForNewReleases_; static bool enableVisitWebsite_; static wxString logoName_; - static wxString appName_; static wxString fontSize_; static bool enableImportMMNETCSV_; static bool enableImportMMCSV_; @@ -124,27 +123,28 @@ static wxColour listFutureDateColor; }; + class mmCurrencyFormatter { - public: mmCurrencyFormatter() {} - public: ~mmCurrencyFormatter() {} +public: - public: static void loadSettings(wxString pfx, wxString sfx, wxChar dec, wxChar grp, - wxString unit, wxString cent, double scale); - public: static void loadDefaultSettings(); - public: static bool formatDoubleToCurrency(double val, wxString& data); - public: static bool formatCurrencyToDouble(const wxString& str, double& val); - public: static bool formatDoubleToCurrencyEdit(double val, wxString& rdata); - public: static void loadSettings(boost::shared_ptr<mmCurrency> pCurrencyPtr); +static void loadSettings(wxString pfx, wxString sfx, wxChar dec, wxChar grp, wxString unit, wxString cent, double scale); +static void loadDefaultSettings(); - public: - static wxString pfx_symbol; // Leading currency symbol (U.S.: '$') - static wxString sfx_symbol; // Trailing currency symbol - static wxChar decimal_point; // Character for 100ths (U.S.: period) - static wxChar group_separator;// Character for 1000nds (U.S.: comma) - static wxString unit_name; // Name of monetary unit (U.S.: "dollar") - static wxString cent_name; // Name of fraction unit (U.S.: "cent") - static double scale; // Scale 100 +static bool formatDoubleToCurrency(double val, wxString& data); +static bool formatCurrencyToDouble(const wxString& str, double& val); +static bool formatDoubleToCurrencyEdit(double val, wxString& rdata); +static void loadSettings(boost::shared_ptr<mmCurrency> pCurrencyPtr); + +static wxString pfx_symbol; // Leading currency symbol (U.S.: '$') +static wxString sfx_symbol; // Trailing currency symbol +static wxChar decimal_point; // Character for 100ths (U.S.: period) +static wxChar group_separator;// Character for 1000nds (U.S.: comma) +static wxString unit_name; // Name of monetary unit (U.S.: "dollar") +static wxString cent_name; // Name of fraction unit (U.S.: "cent") +static double scale; // Scale 100 + }; + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:42:53
|
Revision: 808 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=808&view=rev Author: kkkvadim Date: 2009-11-22 15:42:39 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/aboutdialog.cpp trunk/mmex/src/aboutdialog.h trunk/mmex/src/appstartdialog.cpp trunk/mmex/src/appstartdialog.h trunk/mmex/src/mmex.cpp Modified: trunk/mmex/src/aboutdialog.cpp =================================================================== --- trunk/mmex/src/aboutdialog.cpp 2009-11-22 15:40:53 UTC (rev 807) +++ trunk/mmex/src/aboutdialog.cpp 2009-11-22 15:42:39 UTC (rev 808) @@ -20,82 +20,64 @@ #include "defs.h" #include "dbwrapper.h" #include "util.h" - +#include "paths.h" +#include "constants.h" /*******************************************************/ /* Include XPM Support */ #include "../resources/money.xpm" -#ifdef MMEX_CUSTOM_BUILD -#include "../resources/bma.xpm" -#endif /*******************************************************/ -#define MMEX_SPLASH_FNAME wxT("/splash.png") -#define MMEX_ICON_FNAME wxT("/mmex.ico") -/*******************************************************/ -IMPLEMENT_DYNAMIC_CLASS( mmAboutDialog, wxDialog ) -BEGIN_EVENT_TABLE( mmAboutDialog, wxDialog ) +IMPLEMENT_DYNAMIC_CLASS(mmAboutDialog, wxDialog) + + +BEGIN_EVENT_TABLE(mmAboutDialog, wxDialog) EVT_BUTTON(ID_DIALOG_BUTTON_ABOUT_VERSION_HISTORY, mmAboutDialog::OnVersionHistory) EVT_BUTTON(ID_DIALOG_BUTTON_ABOUT_CONTRIBUTERS, mmAboutDialog::OnContributerList) END_EVENT_TABLE() -mmAboutDialog::mmAboutDialog() -{ -} -mmAboutDialog::mmAboutDialog( wxSQLite3Database* inidb, wxWindow* parent, wxWindowID id, - const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +mmAboutDialog::mmAboutDialog( wxSQLite3Database* inidb, wxWindow* parent) : + inidb_(inidb) { - inidb_ = inidb; - Create(parent, id, caption, pos, size, style); + wxString caption = _("About ") + mmex::getProgramName(); + Create(parent, ID_DIALOG_ABOUT, caption, wxDefaultPosition, wxSize(500, 220), wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX); } -bool mmAboutDialog::Create( wxWindow* parent, wxWindowID id, - const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +bool mmAboutDialog::Create(wxWindow* parent, + wxWindowID id, + const wxString& caption, + const wxPoint& pos, + const wxSize& size, + long style + ) { - SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); - wxDialog::Create( parent, id, caption, pos, size, style ); + SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS); - CreateControls(); - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + bool ok = wxDialog::Create(parent, id, caption, pos, size, style); - wxIcon icon(mmGetBaseWorkingPath() + MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + if (ok) { + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + SetIcon(mmex::getProgramIcon()); + Centre(); + } - Centre(); - return TRUE; + return ok; } void mmAboutDialog::OnVersionHistory(wxCommandEvent& /*event*/) { - wxFileName fname(wxTheApp->argv[0]); - wxString filePath = fname.GetPath(wxPATH_GET_VOLUME) - + wxFileName::GetPathSeparator() - + wxT("version.txt"); -#if defined (__WXMAC__) || defined (__WXOSX__) - filePath = wxT("MMEX.app/Contents/Resources/version.txt"); -#endif - fileviewer* dlg = new fileviewer(filePath, this); - if ( dlg->ShowModal() == wxID_OK ) - { - } - dlg->Destroy(); + wxString filePath = mmex::getPathDoc(mmex::F_VERSION); + fileviewer dlg(filePath, this); + dlg.ShowModal(); } void mmAboutDialog::OnContributerList(wxCommandEvent& /*event*/) { - wxFileName fname(wxTheApp->argv[0]); - wxString filePath = fname.GetPath(wxPATH_GET_VOLUME) - + wxFileName::GetPathSeparator() - + wxT("contrib.txt"); -#if defined (__WXMAC__) || defined (__WXOSX__) - filePath = wxT("MMEX.app/Contents/Resources/contrib.txt"); -#endif - fileviewer* dlg = new fileviewer(filePath, this); - if ( dlg->ShowModal() == wxID_OK ) - { - } - dlg->Destroy(); + wxString filePath = mmex::getPathDoc(mmex::F_CONTRIB); + fileviewer dlg(filePath, this); + dlg.ShowModal(); } void mmAboutDialog::CreateControls() @@ -109,7 +91,7 @@ itemBoxSizer2->Add(itemBoxSizerN, 1, wxGROW|wxALL, 5); wxBitmap itemStaticBitmap3Bitmap; - itemStaticBitmap3Bitmap.LoadFile(mmGetBaseWorkingPath() + MMEX_SPLASH_FNAME, wxBITMAP_TYPE_PNG); + itemStaticBitmap3Bitmap.LoadFile(mmex::getPathResource(mmex::SPLASH_ICON), wxBITMAP_TYPE_PNG); wxStaticBitmap* itemStaticBitmap3 = 0; if (!mmIniOptions::enableCustomLogo_) @@ -117,14 +99,6 @@ itemStaticBitmap3 = new wxStaticBitmap( itemDialog1, wxID_STATIC, itemStaticBitmap3Bitmap, wxDefaultPosition); } - else - { -#ifdef MMEX_CUSTOM_BUILD - wxBitmap itemStaticCustomBitmap(bma_xpm); - itemStaticBitmap3 = new wxStaticBitmap( itemDialog1, wxID_STATIC, - itemStaticCustomBitmap, wxDefaultPosition, wxSize(235, 157), 0 ); -#endif - } if (itemStaticBitmap3) { itemBoxSizerN->Add(itemStaticBitmap3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); @@ -133,17 +107,8 @@ wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); itemBoxSizer2->Add(itemBoxSizer4, 1, wxGROW|wxALL, 5); -#if 0 - wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, - mmIniOptions::appName_, - wxDefaultPosition, wxDefaultSize, 0 ); - itemStaticText5->SetFont(wxFont(16, - wxSWISS, wxNORMAL, wxBOLD, FALSE, wxT(""))); - itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxADJUST_MINSIZE, 5); -#endif - wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, - wxString(_("Version: ")) + mmex::getVersion(), wxDefaultPosition, wxDefaultSize, 0 ); + wxString(_("Version: ")) + mmex::getProgramVersion(), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer4->Add(itemStaticText6, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxADJUST_MINSIZE, 5); if (!mmIniOptions::enableCustomAboutDialog_) @@ -154,7 +119,7 @@ itemBoxSizer4->Add(itemStaticText8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxADJUST_MINSIZE, 5); wxStaticText* itemStaticText91 = new wxStaticText( itemDialog1, - wxID_STATIC, _(" and contributors from around the world."), + wxID_STATIC, _(" and contributors from around the world"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer4->Add(itemStaticText91, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxADJUST_MINSIZE, 5); @@ -171,7 +136,7 @@ itemBoxSizer4->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxStaticText* itemStaticText12 = new wxStaticText( itemDialog1, - wxID_STATIC, _("Powered by wxWidgets, SQLite, wxSQLite(by Ulrich Telle)"), wxDefaultPosition, wxDefaultSize, 0 ); + wxID_STATIC, _("Powered by wxWidgets, SQLite, wxSQLite(by Ulrich Telle), Boost C++"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer4->Add(itemStaticText12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxADJUST_MINSIZE, 5); wxButton* itemButton14 = new wxButton( itemDialog1, ID_DIALOG_BUTTON_ABOUT_VERSION_HISTORY, @@ -184,8 +149,7 @@ wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer4->Add(itemButton18, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); - wxString langStr = mmDBWrapper::getINISettingValue(inidb_, - wxT("LANGUAGE"), wxT("")); + wxString langStr = mmDBWrapper::getINISettingValue(inidb_, wxT("LANGUAGE")); wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Using Language : ") + langStr, wxDefaultPosition, wxDefaultSize, 0 ); Modified: trunk/mmex/src/aboutdialog.h =================================================================== --- trunk/mmex/src/aboutdialog.h 2009-11-22 15:40:53 UTC (rev 807) +++ trunk/mmex/src/aboutdialog.h 2009-11-22 15:42:39 UTC (rev 808) @@ -19,41 +19,29 @@ #ifndef _MM_EX_ABOUTDIALOG_H_ #define _MM_EX_ABOUTDIALOG_H_ -#include "guiid.h" -#include "util.h" +#include <wx/dialog.h> -#define SYMBOL_ABOUTDIALOG_STYLE wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX -#define SYMBOL_ABOUTDIALOG_TITLE _("About ") + mmIniOptions::appName_ -#define SYMBOL_ABOUTDIALOG_IDNAME ID_DIALOG_ABOUT -#define SYMBOL_ABOUTDIALOG_SIZE wxSize(500, 220) -#define SYMBOL_ABOUTDIALOG_POSITION wxDefaultPosition +class wxSQLite3Database; + + class mmAboutDialog : public wxDialog { - DECLARE_DYNAMIC_CLASS( mmTransDialog ) + DECLARE_DYNAMIC_CLASS(mmAboutDialog) DECLARE_EVENT_TABLE() public: - mmAboutDialog(); - mmAboutDialog(wxSQLite3Database* inidb, wxWindow* parent, - wxWindowID id = SYMBOL_ABOUTDIALOG_IDNAME, - const wxString& caption = SYMBOL_ABOUTDIALOG_TITLE, - const wxPoint& pos = SYMBOL_ABOUTDIALOG_POSITION, - const wxSize& size = SYMBOL_ABOUTDIALOG_SIZE, - long style = SYMBOL_ABOUTDIALOG_STYLE ); + mmAboutDialog() : inidb_() {} + mmAboutDialog(wxSQLite3Database* inidb, wxWindow* parent); - bool Create(wxWindow* parent, wxWindowID id = SYMBOL_ABOUTDIALOG_IDNAME, - const wxString& caption = SYMBOL_ABOUTDIALOG_TITLE, - const wxPoint& pos = SYMBOL_ABOUTDIALOG_POSITION, - const wxSize& size = SYMBOL_ABOUTDIALOG_SIZE, - long style = SYMBOL_ABOUTDIALOG_STYLE ); +private: + wxSQLite3Database* inidb_; + bool Create(wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style); void CreateControls(); void OnVersionHistory(wxCommandEvent& event); void OnContributerList(wxCommandEvent& event); - -private: - wxSQLite3Database* inidb_; }; -#endif +#endif // _MM_EX_ABOUTDIALOG_H_ + Modified: trunk/mmex/src/appstartdialog.cpp =================================================================== --- trunk/mmex/src/appstartdialog.cpp 2009-11-22 15:40:53 UTC (rev 807) +++ trunk/mmex/src/appstartdialog.cpp 2009-11-22 15:42:39 UTC (rev 808) @@ -20,16 +20,15 @@ #include "appstartdialog.h" #include "guiid.h" #include "dbwrapper.h" +#include "paths.h" +#include "constants.h" +#include "util.h" /*******************************************************/ /* Include XPM Support */ #include "../resources/money.xpm" -#ifdef MMEX_CUSTOM_BUILD -#include "../resources/bma.xpm" -#endif /*******************************************************/ - IMPLEMENT_DYNAMIC_CLASS( mmAppStartDialog, wxDialog ) BEGIN_EVENT_TABLE( mmAppStartDialog, wxDialog ) @@ -40,46 +39,52 @@ EVT_BUTTON( ID_BUTTON_APPSTART_LAST_DATABASE, mmAppStartDialog::OnButtonAppstartLastDatabaseClick ) END_EVENT_TABLE() -mmAppStartDialog::mmAppStartDialog( ) + +mmAppStartDialog::mmAppStartDialog() : + inidb_(), + itemCheckBox(), + retCode_(-1) { - retCode_ = -1; } -mmAppStartDialog::~mmAppStartDialog() -{ - wxString showBeginApp = wxT("FALSE"); - if (itemCheckBox->GetValue() == true) - showBeginApp = wxT("TRUE"); - mmDBWrapper::setINISettingValue(inidb_, - wxT("SHOWBEGINAPP"), showBeginApp); -} - -mmAppStartDialog::mmAppStartDialog( wxSQLite3Database* inidb, wxWindow* parent, wxWindowID id, - const wxString& caption, const wxPoint& pos, - const wxSize& size, long style ) +mmAppStartDialog::mmAppStartDialog(wxSQLite3Database* inidb, wxWindow* parent) : + inidb_(inidb), + itemCheckBox(), + retCode_(-1) { - retCode_ = -1; - inidb_ = inidb; - Create(parent, id, caption, pos, size, style); + wxString caption = mmex::getProgramName() + _(" Start Page"); + Create(parent, ID_DIALOG_APPSTART, caption, wxDefaultPosition, wxSize(400, 300), wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX); } bool mmAppStartDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); - wxDialog::Create( parent, id, caption, pos, size, style ); + bool ok = wxDialog::Create( parent, id, caption, pos, size, style ); - wxIcon icon(mmGetBaseWorkingPath() + wxT("/mmex.ico"), wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + if (ok) { + SetIcon(mmex::getProgramIcon()); + CreateControls(); + GetSizer()->Fit(this); + GetSizer()->SetSizeHints(this); + CentreOnScreen(); + } - CreateControls(); - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); - CentreOnScreen(); - return TRUE; + return ok; } +mmAppStartDialog::~mmAppStartDialog() +{ + try { + wxString showBeginApp = itemCheckBox->GetValue() ? wxT("TRUE") : wxT("FALSE"); + mmDBWrapper::setINISettingValue(inidb_, wxT("SHOWBEGINAPP"), showBeginApp); + } catch (...) { + wxASSERT(false); + } +} + + void mmAppStartDialog::CreateControls() { mmAppStartDialog* itemDialog1 = this; @@ -91,7 +96,7 @@ itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxBitmap itemStaticBitmap4Bitmap; - itemStaticBitmap4Bitmap.LoadFile(mmGetBaseWorkingPath() + wxT("/splash.png"), wxBITMAP_TYPE_PNG); + itemStaticBitmap4Bitmap.LoadFile(mmex::getPathResource(mmex::SPLASH_ICON), wxBITMAP_TYPE_PNG); wxStaticBitmap* itemStaticBitmap4 = 0; if (!mmIniOptions::enableCustomLogo_) @@ -99,14 +104,6 @@ itemStaticBitmap4 = new wxStaticBitmap( itemDialog1, wxID_STATIC, itemStaticBitmap4Bitmap, wxDefaultPosition, wxSize(400, 209), 0 ); } - else - { -#ifdef MMEX_CUSTOM_BUILD - wxBitmap itemStaticCustomBitmap(bma_xpm); - itemStaticBitmap4 = new wxStaticBitmap( itemDialog1, wxID_STATIC, - itemStaticCustomBitmap, wxDefaultPosition, wxSize(181, 200), 0 ); -#endif - } if (itemStaticBitmap4) { itemBoxSizer3->Add(itemStaticBitmap4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); @@ -154,16 +151,22 @@ { wxButton* itemButton9 = new wxButton( itemDialog1, ID_BUTTON_APPSTART_WEBSITE, _("Visit Website for more information"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton9->SetToolTip(_("Open the Money Manager Ex website for latest news, updates etc")); + + wxString s = _("Open the "); + s += mmex::getProgramName(); + s += _(" website for latest news, updates etc"); + + itemButton9->SetToolTip(s); itemBoxSizer5->Add(itemButton9, 0, wxGROW|wxALL, 5); } wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer10, 0, wxALIGN_LEFT|wxALL, 5); - wxString showAppStartString = _("Show this window next time ") + - mmIniOptions::appName_ + - _(" starts"); + wxString showAppStartString = _("Show this window next time "); + showAppStartString += mmex::getProgramName(); + showAppStartString += _(" starts"); + itemCheckBox = new wxCheckBox( itemDialog1, ID_CHECKBOX_APPSTART_SHOWAPPSTART, showAppStartString, wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); Modified: trunk/mmex/src/appstartdialog.h =================================================================== --- trunk/mmex/src/appstartdialog.h 2009-11-22 15:40:53 UTC (rev 807) +++ trunk/mmex/src/appstartdialog.h 2009-11-22 15:42:39 UTC (rev 808) @@ -19,51 +19,37 @@ #ifndef _MM_EX_APPSTARTDIALOG_H_ #define _MM_EX_APPSTARTDIALOG_H_ -#include "defs.h" -#include "guiid.h" -#include "util.h" +#include <wx/dialog.h> -#define SYMBOL_MMAPPSTARTDIALOG_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX -#define SYMBOL_MMAPPSTARTDIALOG_TITLE mmIniOptions::appName_ + _(" Start Page") -#define SYMBOL_MMAPPSTARTDIALOG_IDNAME ID_DIALOG_APPSTART -#define SYMBOL_MMAPPSTARTDIALOG_SIZE wxSize(400, 300) -#define SYMBOL_MMAPPSTARTDIALOG_POSITION wxDefaultPosition +class wxCheckBox; +class wxSQLite3Database; + class mmAppStartDialog: public wxDialog { - DECLARE_DYNAMIC_CLASS( mmAppStartDialog ) + DECLARE_DYNAMIC_CLASS(mmAppStartDialog) DECLARE_EVENT_TABLE() public: - mmAppStartDialog( ); - mmAppStartDialog( wxSQLite3Database* inidb, wxWindow* parent, - wxWindowID id = SYMBOL_MMAPPSTARTDIALOG_IDNAME, - const wxString& caption = SYMBOL_MMAPPSTARTDIALOG_TITLE, - const wxPoint& pos = SYMBOL_MMAPPSTARTDIALOG_POSITION, - const wxSize& size = SYMBOL_MMAPPSTARTDIALOG_SIZE, - long style = SYMBOL_MMAPPSTARTDIALOG_STYLE ); - ~mmAppStartDialog(); + mmAppStartDialog(); + mmAppStartDialog(wxSQLite3Database* inidb, wxWindow* parent); + ~mmAppStartDialog(); - bool Create( wxWindow* parent, - wxWindowID id = SYMBOL_MMAPPSTARTDIALOG_IDNAME, - const wxString& caption = SYMBOL_MMAPPSTARTDIALOG_TITLE, - const wxPoint& pos = SYMBOL_MMAPPSTARTDIALOG_POSITION, - const wxSize& size = SYMBOL_MMAPPSTARTDIALOG_SIZE, - long style = SYMBOL_MMAPPSTARTDIALOG_STYLE ); + int getReturnCode() const { return retCode_; } - void CreateControls(); +private: + wxSQLite3Database* inidb_; + wxCheckBox* itemCheckBox; + int retCode_; - int getReturnCode() { return retCode_; } + bool Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style); + void CreateControls(); void OnButtonAppstartOpenDatabaseClick( wxCommandEvent& event ); void OnButtonAppstartNewDatabaseClick( wxCommandEvent& event ); void OnButtonAppstartHelpClick( wxCommandEvent& event ); void OnButtonAppstartWebsiteClick( wxCommandEvent& event ); void OnButtonAppstartLastDatabaseClick( wxCommandEvent& event ); - -private: - int retCode_; - wxSQLite3Database* inidb_; - wxCheckBox* itemCheckBox; }; -#endif +#endif // _MM_EX_APPSTARTDIALOG_H_ + Modified: trunk/mmex/src/mmex.cpp =================================================================== --- trunk/mmex/src/mmex.cpp 2009-11-22 15:40:53 UTC (rev 807) +++ trunk/mmex/src/mmex.cpp 2009-11-22 15:42:39 UTC (rev 808) @@ -57,6 +57,9 @@ #include "billsdepositsdialog.h" #include "util.h" #include "dbwrapper.h" +#include "paths.h" +#include "constants.h" +#include "platfdep.h" //---------------------------------------------------------------------------- /* Include XPM Support */ @@ -120,9 +123,6 @@ namespace { -const wxChar *MMEX_INIDB_FNAME = wxT("/mmexini.db3"); -//---------------------------------------------------------------------------- - class mmNewDatabaseWizard : public wxWizard { public: @@ -197,18 +197,6 @@ }; //---------------------------------------------------------------------------- -wxString getMMEXIconPath() -{ - wxString path; - - - path = mmGetBaseWorkingPath() + wxT("/mmex.ico"); - - - return path; -} -//---------------------------------------------------------------------------- - inline bool sortCategs(const CategInfo &elem1, const CategInfo &elem2) { return elem1.amount < elem2.amount; @@ -224,7 +212,7 @@ if (!rep.IsOk()) { - wxSafeShowMessage(mmIniOptions::appName_, _("Fatal error occured.\nApplication will be terminated.")); + wxSafeShowMessage(mmex::getProgramName(), _("Fatal error occured.\nApplication will be terminated.")); return; } @@ -240,7 +228,7 @@ bool OnInitImpl(mmGUIApp &app) { - app.SetAppName(mmIniOptions::appName_); // FIXME: read from version resource + app.SetAppName(mmex::GetAppName()); /* Setting Locale causes unexpected problems, so default to English Locale */ app.getLocale().Init(wxLANGUAGE_ENGLISH); @@ -251,32 +239,30 @@ wxImage::AddHandler(new wxPNGHandler()); /* Get INI DB for loading settings */ - boost::scoped_ptr<wxSQLite3Database> inidb(new wxSQLite3Database); + wxSQLite3Database inidb; + inidb.Open(mmex::getPathUser(mmex::SETTINGS)); - wxString cfgPath = mmGetBaseWorkingPath() + MMEX_INIDB_FNAME; - inidb->Open(cfgPath); + mmDBWrapper::verifyINIDB(&inidb); - mmDBWrapper::verifyINIDB(inidb.get()); - /* Load Colors from Database */ - mmLoadColorsFromDatabase(inidb.get()); + mmLoadColorsFromDatabase(&inidb); /* Load MMEX Custom Settings */ - mmIniOptions::loadOptions(inidb.get()); + mmIniOptions::loadOptions(&inidb); /* Was App Maximized? */ wxString isMaxStrDef = wxT("FALSE"); - wxString isMaxStr = mmDBWrapper::getINISettingValue(inidb.get(), wxT("ISMAXIMIZED"), isMaxStrDef); + wxString isMaxStr = mmDBWrapper::getINISettingValue(&inidb, wxT("ISMAXIMIZED"), isMaxStrDef); /* Load Dimensions of Window */ wxString originX = wxT("50"); wxString originY = wxT("50"); wxString sizeW = wxT("800"); wxString sizeH = wxT("600"); - wxString valxStr = mmDBWrapper::getINISettingValue(inidb.get(), wxT("ORIGINX"), originX); - wxString valyStr = mmDBWrapper::getINISettingValue(inidb.get(), wxT("ORIGINY"), originY); - wxString valWStr = mmDBWrapper::getINISettingValue(inidb.get(), wxT("SIZEW"), sizeW); - wxString valHStr = mmDBWrapper::getINISettingValue(inidb.get(), wxT("SIZEH"), sizeH); + wxString valxStr = mmDBWrapper::getINISettingValue(&inidb, wxT("ORIGINX"), originX); + wxString valyStr = mmDBWrapper::getINISettingValue(&inidb, wxT("ORIGINY"), originY); + wxString valWStr = mmDBWrapper::getINISettingValue(&inidb, wxT("SIZEW"), sizeW); + wxString valHStr = mmDBWrapper::getINISettingValue(&inidb, wxT("SIZEH"), sizeH); long valx = 0; long valy = 0; @@ -288,15 +274,15 @@ valWStr.ToLong(&valw); valHStr.ToLong(&valh); - mmSelectLanguage(0, inidb.get(), false); + mmSelectLanguage(0, &inidb, false); - inidb->Close(); + inidb.Close(); #if defined (__WXMAC__) || defined (__WXOSX__) wxSystemOptions::SetOption(wxMAC_ALWAYS_USE_GENERIC_LISTCTRL,1); #endif - mmGUIFrame *frame = new mmGUIFrame(mmIniOptions::appName_, wxPoint(valx, valy), wxSize(valw, valh)); + mmGUIFrame *frame = new mmGUIFrame(mmex::getProgramName(), wxPoint(valx, valy), wxSize(valw, valh)); bool ok = frame->Show(); wxASSERT(ok); @@ -462,7 +448,7 @@ // a wizard page may be either an object of predefined class page1 = new wxWizardPageSimple(this); - wxString noteString = mmIniOptions::appName_ + + wxString noteString = mmex::getProgramName() + _(" models all transactions as belonging to accounts.\n\n The next pages will help you create a new account.\n\nTo help you get started, begin by making a list of all\nfinancial institutions where you hold an account."); new wxStaticText(page1, wxID_ANY, noteString); @@ -557,13 +543,11 @@ // tell wxAuiManager to manage this frame m_mgr.SetManagedWindow(this); - /* Set Icon for Frame */ - wxIcon icon(getMMEXIconPath(), wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); /* Setup Printer */ - printer_.reset(new wxHtmlEasyPrinting(mmIniOptions::appName_, this)); - wxString printHeaderBase = mmIniOptions::appName_; + printer_.reset(new wxHtmlEasyPrinting(mmex::getProgramName(), this)); + wxString printHeaderBase = mmex::getProgramName(); printer_-> SetHeader( printHeaderBase + wxT("(@PAGENUM@/@PAGESCNT@)<hr>"), wxPAGE_ALL); /* Load from Settings DB */ @@ -678,17 +662,6 @@ /* Delete the GUI */ cleanupHomePanel(false); - /* Delete any temp *.png files left behind */ - if (wxFile::Exists(wxT("inc_expenses_month.png"))) - ::wxRemoveFile(wxT("inc_expenses_month.png")); - - if (wxFile::Exists(wxT("pie_chart.png"))) - ::wxRemoveFile(wxT("pie_chart.png")); - - if (wxFile::Exists(wxT("top_categories.png"))) - ::wxRemoveFile(wxT("top_categories.png")); - - if (core_) { core_.reset(); } @@ -754,8 +727,7 @@ void mmGUIFrame::loadConfigFile() { inidb_.reset(new wxSQLite3Database); - wxString iniDBPath = mmGetBaseWorkingPath() + MMEX_INIDB_FNAME; - inidb_->Open(iniDBPath); + inidb_->Open(mmex::getPathUser(mmex::SETTINGS)); } //---------------------------------------------------------------------------- @@ -2555,7 +2527,7 @@ // we need to check the db whether it is the right version if (!mmDBWrapper::checkDBVersion(db_.get())) { - wxString note = mmIniOptions::appName_ + _(" - No File opened "); + wxString note = mmex::getProgramName() + _(" - No File opened "); this->SetTitle(note); mmShowErrorMessage(this, _("Sorry. The Database version is too old or Database password is incorrect"), @@ -2608,7 +2580,7 @@ } else // open of existing database failed { - wxString note = mmIniOptions::appName_ + _(" - No File opened "); + wxString note = mmex::getProgramName() + _(" - No File opened "); this->SetTitle(note); wxMessageDialog msgDlg(this, _("Cannot locate previously opened database.\nDo you want to browse to locate the file?"), @@ -2629,32 +2601,26 @@ void mmGUIFrame::openDataBase(const wxString& fileName) { - wxString appPath = mmGetBaseWorkingPath(); - - wxProgressDialog* pgd = new wxProgressDialog(_("Please Wait"), + wxProgressDialog dlg(_("Please Wait"), _("Opening Database File && Verifying Integrity"), 100, this, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH ); - mmDBWrapper::initDB(db_.get(), pgd, appPath); - pgd->Update(100); - pgd->Destroy(); - wxFileName fName(fileName); - wxString title = mmIniOptions::appName_ + wxT(" : ") - + fileName; - this->SetTitle(title); + mmDBWrapper::initDB(db_.get(), &dlg); + dlg.Update(100); + dlg.Destroy(); + wxString title = mmex::getProgramName() + wxT(" : ") + fileName; + SetTitle(title); + m_topCategories.Clear(); mmIniOptions::loadInfoOptions(db_.get()); - if (db_.get()) - { + if (db_) { fileName_ = fileName; - } - else - { + } else { fileName_.Clear(); password_.Clear(); - } + } } //---------------------------------------------------------------------------- @@ -3275,7 +3241,7 @@ wxString build = tkz.GetNextToken(); // get current version - wxString currentV = mmex::getVersion(); + wxString currentV = mmex::getProgramVersion(); wxStringTokenizer tkz1(currentV, wxT('.'), wxTOKEN_RET_EMPTY_ALL); numTokens = (int)tkz1.CountTokens(); @@ -3511,7 +3477,7 @@ } else if (hp) { - printer_ ->PrintFile(wxT("help/index.html")); + printer_ ->PrintFile(mmex::getPathDoc(mmex::HTML_INDEX)); } } //---------------------------------------------------------------------------- @@ -3529,7 +3495,7 @@ } else if (hp) { - printer_ ->PreviewFile(wxT("help/index.html")); + printer_ ->PreviewFile(mmex::getPathDoc(mmex::HTML_INDEX)); } } //---------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:44:43
|
Revision: 809 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=809&view=rev Author: kkkvadim Date: 2009-11-22 15:44:34 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/budgetyeardialog.cpp trunk/mmex/src/mmgraphpie.h trunk/mmex/src/transdialog.cpp trunk/mmex/src/univcsvdialog.cpp Modified: trunk/mmex/src/budgetyeardialog.cpp =================================================================== --- trunk/mmex/src/budgetyeardialog.cpp 2009-11-22 15:42:39 UTC (rev 808) +++ trunk/mmex/src/budgetyeardialog.cpp 2009-11-22 15:44:34 UTC (rev 809) @@ -20,12 +20,9 @@ #include "budgetyearentrydialog.h" #include "util.h" #include "defs.h" +#include "paths.h" -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - - IMPLEMENT_DYNAMIC_CLASS( mmBudgetYearDialog, wxDialog ) BEGIN_EVENT_TABLE( mmBudgetYearDialog, wxDialog ) @@ -61,8 +58,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); Modified: trunk/mmex/src/mmgraphpie.h =================================================================== --- trunk/mmex/src/mmgraphpie.h 2009-11-22 15:42:39 UTC (rev 808) +++ trunk/mmex/src/mmgraphpie.h 2009-11-22 15:44:34 UTC (rev 809) @@ -1,51 +1,28 @@ -#include "mmgraphgenerator.h" -#include "chart.h" -#include "mmex.h" - #ifndef _MM_EX_GRAPHPIE_H_ #define _MM_EX_GRAPHPIE_H_ -bool sortValueList(const ValuePair& elem1, const ValuePair& elem2) -{ - return fabs(elem1.amount) > fabs(elem2.amount); -} +#include "mmgraphgenerator.h" -class mmGraphPie : public mmGraphGenerator -{ -public: - mmGraphPie() : mmGraphGenerator(wxT("pie_chart.png")) - { - chart = new PieChart(480, 320); - }; +#include <boost/scoped_ptr.hpp> +#include <vector> - ~mmGraphPie() - { - delete chart; - }; +struct ValuePair; - virtual void init(std::vector<ValuePair>& valueList) - { - std::vector<ChartData> pieData; - std::sort(valueList.begin(), valueList.end(), sortValueList); - for(unsigned int i=0; i<valueList.size(); i++) - { - if (i < 15) - pieData.push_back(ChartData(valueList[i].label, valueList[i].amount)); - } +class PieChart; - chart->SetData(pieData); - chart->Init(240, CHART_LEGEND_FIXED, PIE_CHART_ABSOLUT); - } +class mmGraphPie : public mmGraphGenerator +{ +public: + mmGraphPie(); + ~mmGraphPie(); - bool Generate(const wxString& chartTitle) - { - chart->Render(chartTitle); - return chart->Save(GetOutputFileName()); - }; + void init(std::vector<ValuePair>& valueList); + bool Generate(const wxString& chartTitle); private: - PieChart* chart; + boost::scoped_ptr<PieChart> chart; }; -#endif +#endif // _MM_EX_GRAPHPIE_H_ + Modified: trunk/mmex/src/transdialog.cpp =================================================================== --- trunk/mmex/src/transdialog.cpp 2009-11-22 15:42:39 UTC (rev 808) +++ trunk/mmex/src/transdialog.cpp 2009-11-22 15:44:34 UTC (rev 809) @@ -24,25 +24,17 @@ #include "dbwrapper.h" #include "splittransactionsdialog.h" #include "defs.h" +#include "paths.h" -#include "sstream" +#include <sstream> // Defines for Transaction Type -#define DEF_WITHDRAWAL 0 -#define DEF_DEPOSIT 1 -#define DEF_TRANSFER 2 +enum { DEF_WITHDRAWAL, DEF_DEPOSIT, DEF_TRANSFER }; // Defines for Transaction Status -#define DEF_STATUS_NONE 0 -#define DEF_STATUS_RECONCILED 1 -#define DEF_STATUS_VOID 2 -#define DEF_STATUS_FOLLOWUP 3 -#define DEF_STATUS_DUPLICATE 4 +enum { DEF_STATUS_NONE, DEF_STATUS_RECONCILED, DEF_STATUS_VOID, DEF_STATUS_FOLLOWUP, DEF_STATUS_DUPLICATE }; -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - IMPLEMENT_DYNAMIC_CLASS( mmTransDialog, wxDialog ) BEGIN_EVENT_TABLE( mmTransDialog, wxDialog ) @@ -93,8 +85,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); Modified: trunk/mmex/src/univcsvdialog.cpp =================================================================== --- trunk/mmex/src/univcsvdialog.cpp 2009-11-22 15:42:39 UTC (rev 808) +++ trunk/mmex/src/univcsvdialog.cpp 2009-11-22 15:44:34 UTC (rev 809) @@ -20,11 +20,8 @@ #include "util.h" #include "fileviewerdialog.h" #include "defs.h" +#include "paths.h" - -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - IMPLEMENT_DYNAMIC_CLASS( mmUnivCSVImportDialog, wxDialog ) @@ -102,8 +99,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); Centre(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:46:25
|
Revision: 810 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=810&view=rev Author: kkkvadim Date: 2009-11-22 15:46:17 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/assetdialog.cpp trunk/mmex/src/filtertransdialog.cpp trunk/mmex/src/guiid.cpp trunk/mmex/src/mmcurrency.cpp Modified: trunk/mmex/src/assetdialog.cpp =================================================================== --- trunk/mmex/src/assetdialog.cpp 2009-11-22 15:44:34 UTC (rev 809) +++ trunk/mmex/src/assetdialog.cpp 2009-11-22 15:46:17 UTC (rev 810) @@ -20,24 +20,13 @@ #include "dbwrapper.h" #include "currencydialog.h" #include "defs.h" +#include "paths.h" -#define DEF_CHANGE_NONE 0 -#define DEF_CHANGE_APPRECIATE 1 -#define DEF_CHANGE_DEPRECIATE 2 -#define DEF_ASSET_PROPERTY 0 -#define DEF_ASSET_AUTO 1 -#define DEF_ASSET_HOUSE 2 -#define DEF_ASSET_ART 3 -#define DEF_ASSET_JEWELLERY 4 -#define DEF_ASSET_CASH 5 -#define DEF_ASSET_OTHER 6 +enum { DEF_CHANGE_NONE, DEF_CHANGE_APPRECIATE, DEF_CHANGE_DEPRECIATE }; +enum { DEF_ASSET_PROPERTY, DEF_ASSET_AUTO, DEF_ASSET_HOUSE, DEF_ASSET_ART, DEF_ASSET_JEWELLERY, DEF_ASSET_CASH, DEF_ASSET_OTHER }; -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") -#define MMEX_SPLASH_FNAME mmGetBaseWorkingPath() + wxT("/splash.png") - - IMPLEMENT_DYNAMIC_CLASS( mmAssetDialog, wxDialog ) BEGIN_EVENT_TABLE( mmAssetDialog, wxDialog ) @@ -72,8 +61,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); @@ -435,7 +423,7 @@ EndModal(wxID_OK); } -void mmAssetDialog::OnChangeAppreciationType(wxCommandEvent& event) +void mmAssetDialog::OnChangeAppreciationType(wxCommandEvent& /*event*/) { int selection = valueChange_->GetSelection(); // Disable for "None", Enable for "Appreciates" or "Depreciates" Modified: trunk/mmex/src/filtertransdialog.cpp =================================================================== --- trunk/mmex/src/filtertransdialog.cpp 2009-11-22 15:44:34 UTC (rev 809) +++ trunk/mmex/src/filtertransdialog.cpp 2009-11-22 15:46:17 UTC (rev 810) @@ -36,6 +36,7 @@ #include "dbwrapper.h" #include "categdialog.h" #include "payeedialog.h" +#include "paths.h" #include <algorithm> #include <vector> @@ -55,10 +56,6 @@ #define DEF_STATUS_DUPLICATE 4 -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - - bool sortTransactionsByDate1( boost::shared_ptr<mmBankTransaction> elem1, boost::shared_ptr<mmBankTransaction> elem2 ) { @@ -170,11 +167,10 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); Centre(); - return TRUE; + return true; } /*! Modified: trunk/mmex/src/guiid.cpp =================================================================== --- trunk/mmex/src/guiid.cpp 2009-11-22 15:44:34 UTC (rev 809) +++ trunk/mmex/src/guiid.cpp 2009-11-22 15:46:17 UTC (rev 810) @@ -18,21 +18,10 @@ //---------------------------------------------------------------------------- #include "guiid.h" -#include <wx/string.h> //---------------------------------------------------------------------------- const int mmex::MIN_DATAVERSION = 2; const wxChar * const mmex::DATAVERSION = wxT("2"); -//---------------------------------------------------------------------------- const wxChar *const mmex::DEFDATEFORMAT = wxT("%m/%d/%y"); const wxChar *const mmex::DEFDELIMTER = wxT(","); -const wxChar *const mmex::CURRENCYDB_FNAME = wxT("/currency.db3"); const wxChar *const mmex::DEFSTOCKURL = wxT("http://www.google.com/finance?q=%s"); //---------------------------------------------------------------------------- - -wxString mmex::getVersion() -{ - static const wxString version(wxT("0.9.6.0")); // FIXME! get from version resource of exe - return version; - -} -//---------------------------------------------------------------------------- Modified: trunk/mmex/src/mmcurrency.cpp =================================================================== --- trunk/mmex/src/mmcurrency.cpp 2009-11-22 15:44:34 UTC (rev 809) +++ trunk/mmex/src/mmcurrency.cpp 2009-11-22 15:46:17 UTC (rev 810) @@ -16,6 +16,7 @@ #include "mmcurrency.h" #include "util.h" +#include "dbwrapper.h" mmCurrency::mmCurrency(boost::shared_ptr<wxSQLite3Database> db, wxSQLite3ResultSet& q1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:47:21
|
Revision: 811 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=811&view=rev Author: kkkvadim Date: 2009-11-22 15:47:15 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/billsdepositsdialog.cpp trunk/mmex/src/budgetyearentrydialog.cpp trunk/mmex/src/htmlbuilder.cpp trunk/mmex/src/mmhelppanel.cpp Modified: trunk/mmex/src/billsdepositsdialog.cpp =================================================================== --- trunk/mmex/src/billsdepositsdialog.cpp 2009-11-22 15:46:17 UTC (rev 810) +++ trunk/mmex/src/billsdepositsdialog.cpp 2009-11-22 15:47:15 UTC (rev 811) @@ -24,13 +24,11 @@ #include "dbwrapper.h" #include "splittransactionsdialog.h" #include "defs.h" +#include "paths.h" + #include <limits> -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - - IMPLEMENT_DYNAMIC_CLASS( mmBDDialog, wxDialog ) BEGIN_EVENT_TABLE( mmBDDialog, wxDialog ) @@ -91,8 +89,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); boost::shared_ptr<mmSplitTransactionEntries> split(new mmSplitTransactionEntries()); Modified: trunk/mmex/src/budgetyearentrydialog.cpp =================================================================== --- trunk/mmex/src/budgetyearentrydialog.cpp 2009-11-22 15:46:17 UTC (rev 810) +++ trunk/mmex/src/budgetyearentrydialog.cpp 2009-11-22 15:47:15 UTC (rev 811) @@ -19,33 +19,23 @@ #include "budgetyearentrydialog.h" #include "util.h" #include "defs.h" +#include "paths.h" - -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - - IMPLEMENT_DYNAMIC_CLASS( mmBudgetYearEntryDialog, wxDialog ) BEGIN_EVENT_TABLE( mmBudgetYearEntryDialog, wxDialog ) EVT_BUTTON(ID_DIALOG_BUDGETYEARENTRY_BUTTON_OK, mmBudgetYearEntryDialog::OnOk) END_EVENT_TABLE() -mmBudgetYearEntryDialog::mmBudgetYearEntryDialog( ) +mmBudgetYearEntryDialog::mmBudgetYearEntryDialog() : db_() { - db_ = 0; - budgetYear_ = wxT(""); - yearToCopy_ = wxT(""); } mmBudgetYearEntryDialog::mmBudgetYearEntryDialog( wxSQLite3Database* db, wxWindow* parent, wxWindowID id, const wxString& caption, - const wxPoint& pos, const wxSize& size, long style ) + const wxPoint& pos, const wxSize& size, long style ) : db_(db) { - db_ = db; - budgetYear_ = wxT(""); - yearToCopy_ = wxT(""); Create(parent, id, caption, pos, size, style); } @@ -60,8 +50,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); Modified: trunk/mmex/src/htmlbuilder.cpp =================================================================== --- trunk/mmex/src/htmlbuilder.cpp 2009-11-22 15:46:17 UTC (rev 810) +++ trunk/mmex/src/htmlbuilder.cpp 2009-11-22 15:47:15 UTC (rev 811) @@ -18,6 +18,7 @@ #include "htmlbuilder.h" #include "util.h" +#include "constants.h" mmHTMLBuilder::mmHTMLBuilder() { // init colors from config @@ -35,7 +36,7 @@ void mmHTMLBuilder::init() { html += wxT("<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=UTF-8\"><title>"); - html += mmIniOptions::appName_; + html += mmex::getProgramName(); html += wxT(" - "); html += _("Report"); html += wxT("</title></head><body bgcolor=\"#ffffff\" text=\"#000000\" link=\"#0000cc\" vlink=\"#551a8b\" alink=\"#ff0000\">"); Modified: trunk/mmex/src/mmhelppanel.cpp =================================================================== --- trunk/mmex/src/mmhelppanel.cpp 2009-11-22 15:46:17 UTC (rev 810) +++ trunk/mmex/src/mmhelppanel.cpp 2009-11-22 15:47:15 UTC (rev 811) @@ -20,10 +20,13 @@ #include "util.h" #include "dbwrapper.h" #include "htmlbuilder.h" -#include <algorithm> -#include <vector> #include "reportbase.h" +#include "paths.h" +#include "constants.h" + #include <wx/app.h> +#include <vector> +#include <algorithm> BEGIN_EVENT_TABLE(mmHelpPanel, wxPanel) END_EVENT_TABLE() @@ -75,7 +78,7 @@ wxBoxSizer* itemBoxSizerVHeader = new wxBoxSizer(wxVERTICAL); itemPanel3->SetSizer(itemBoxSizerVHeader); - wxString helpHeader = mmIniOptions::appName_ + _(" Help"); + wxString helpHeader = mmex::getProgramName() + _(" Help"); wxStaticText* itemStaticText9 = new wxStaticText( itemPanel3, ID_PANEL_REPORTS_STATIC_HEADER, helpHeader, wxDefaultPosition, wxDefaultSize, 0 ); itemStaticText9->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD, FALSE, @@ -87,10 +90,6 @@ wxHW_SCROLLBAR_AUTO|wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); itemBoxSizer2->Add(htmlWindow_, 1, wxGROW|wxALL, 1); - wxString helpPath = mmGetBaseWorkingPath(true) - + wxT("\\help\\index.html"); - - - htmlWindow_ ->LoadPage(helpPath); + htmlWindow_ ->LoadPage(mmex::getPathDoc(mmex::HTML_INDEX)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:48:55
|
Revision: 812 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=812&view=rev Author: kkkvadim Date: 2009-11-22 15:48:47 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/mmpayee.cpp trunk/mmex/src/payeedialog.cpp trunk/mmex/src/stockdialog.cpp Modified: trunk/mmex/src/mmpayee.cpp =================================================================== --- trunk/mmex/src/mmpayee.cpp 2009-11-22 15:47:15 UTC (rev 811) +++ trunk/mmex/src/mmpayee.cpp 2009-11-22 15:48:47 UTC (rev 812) @@ -18,6 +18,7 @@ #include "mmpayee.h" #include "util.h" +#include "dbwrapper.h" mmPayee::mmPayee(int payeeID, const wxString& payeeString, Modified: trunk/mmex/src/payeedialog.cpp =================================================================== --- trunk/mmex/src/payeedialog.cpp 2009-11-22 15:47:15 UTC (rev 811) +++ trunk/mmex/src/payeedialog.cpp 2009-11-22 15:48:47 UTC (rev 812) @@ -19,12 +19,11 @@ #include "payeedialog.h" #include "util.h" #include "defs.h" +#include "paths.h" + #include <wx/event.h> -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - IMPLEMENT_DYNAMIC_CLASS( mmPayeeDialog, wxDialog ) BEGIN_EVENT_TABLE( mmPayeeDialog, wxDialog ) @@ -96,8 +95,7 @@ selectButton->Disable(); } - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); Modified: trunk/mmex/src/stockdialog.cpp =================================================================== --- trunk/mmex/src/stockdialog.cpp 2009-11-22 15:47:15 UTC (rev 811) +++ trunk/mmex/src/stockdialog.cpp 2009-11-22 15:48:47 UTC (rev 812) @@ -22,11 +22,8 @@ #include "dbwrapper.h" #include "currencydialog.h" #include "defs.h" +#include "paths.h" - -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - IMPLEMENT_DYNAMIC_CLASS( mmStockDialog, wxDialog ) BEGIN_EVENT_TABLE( mmStockDialog, wxDialog ) @@ -63,8 +60,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:50:03
|
Revision: 813 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=813&view=rev Author: kkkvadim Date: 2009-11-22 15:49:56 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/budgetentrydialog.cpp trunk/mmex/src/categdialog.cpp trunk/mmex/src/mmgraphtopcategories.h Modified: trunk/mmex/src/budgetentrydialog.cpp =================================================================== --- trunk/mmex/src/budgetentrydialog.cpp 2009-11-22 15:48:47 UTC (rev 812) +++ trunk/mmex/src/budgetentrydialog.cpp 2009-11-22 15:49:56 UTC (rev 813) @@ -19,23 +19,12 @@ #include "budgetentrydialog.h" #include "util.h" #include "defs.h" +#include "paths.h" -#define DEF_TYPE_EXPENSE 0 -#define DEF_TYPE_INCOME 1 +enum { DEF_TYPE_EXPENSE, DEF_TYPE_INCOME }; +enum { DEF_FREQ_NONE, DEF_FREQ_WEEKLY, DEF_FREQ_BIWEEKLY, DEF_FREQ_MONTHLY, DEF_FREQ_BIMONTHLY, DEF_FREQ_QUARTERLY, DEF_FREQ_HALFYEARLY, DEF_FREQ_YEARLY }; -#define DEF_FREQ_NONE 0 -#define DEF_FREQ_WEEKLY 1 -#define DEF_FREQ_BIWEEKLY 2 -#define DEF_FREQ_MONTHLY 3 -#define DEF_FREQ_BIMONTHLY 4 -#define DEF_FREQ_QUARTERLY 5 -#define DEF_FREQ_HALFYEARLY 6 -#define DEF_FREQ_YEARLY 7 - -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - IMPLEMENT_DYNAMIC_CLASS( mmBudgetEntryDialog, wxDialog ) BEGIN_EVENT_TABLE( mmBudgetEntryDialog, wxDialog ) @@ -74,8 +63,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); Modified: trunk/mmex/src/categdialog.cpp =================================================================== --- trunk/mmex/src/categdialog.cpp 2009-11-22 15:48:47 UTC (rev 812) +++ trunk/mmex/src/categdialog.cpp 2009-11-22 15:49:56 UTC (rev 813) @@ -19,10 +19,8 @@ #include "categdialog.h" #include "util.h" #include "defs.h" +#include "paths.h" -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - IMPLEMENT_DYNAMIC_CLASS( mmCategDialog, wxDialog ) BEGIN_EVENT_TABLE( mmCategDialog, wxDialog ) @@ -66,8 +64,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); Modified: trunk/mmex/src/mmgraphtopcategories.h =================================================================== --- trunk/mmex/src/mmgraphtopcategories.h 2009-11-22 15:48:47 UTC (rev 812) +++ trunk/mmex/src/mmgraphtopcategories.h 2009-11-22 15:49:56 UTC (rev 813) @@ -4,6 +4,7 @@ //---------------------------------------------------------------------------- #include "mmgraphgenerator.h" //---------------------------------------------------------------------------- +#include <vector> #include <boost/scoped_ptr.hpp> //---------------------------------------------------------------------------- class BarChart; @@ -14,6 +15,7 @@ { public: mmGraphTopCategories(); + ~mmGraphTopCategories(); void init(const std::vector<CategInfo> &categList); bool Generate(const wxString& chartTitle); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:51:05
|
Revision: 814 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=814&view=rev Author: kkkvadim Date: 2009-11-22 15:50:57 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/currencydialog.cpp trunk/mmex/src/guiid.h trunk/mmex/src/mmgraphgenerator.cpp Modified: trunk/mmex/src/currencydialog.cpp =================================================================== --- trunk/mmex/src/currencydialog.cpp 2009-11-22 15:49:56 UTC (rev 813) +++ trunk/mmex/src/currencydialog.cpp 2009-11-22 15:50:57 UTC (rev 814) @@ -19,6 +19,7 @@ #include "currencydialog.h" #include "util.h" #include "defs.h" +#include "paths.h" #include <wx/combobox.h> @@ -27,10 +28,6 @@ #endif -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - - IMPLEMENT_DYNAMIC_CLASS( mmCurrencyDialog, wxDialog ) BEGIN_EVENT_TABLE( mmCurrencyDialog, wxDialog ) @@ -79,8 +76,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); Modified: trunk/mmex/src/guiid.h =================================================================== --- trunk/mmex/src/guiid.h 2009-11-22 15:49:56 UTC (rev 813) +++ trunk/mmex/src/guiid.h 2009-11-22 15:50:57 UTC (rev 814) @@ -22,8 +22,6 @@ //---------------------------------------------------------------------------- #include <wx/defs.h> // wxID_HIGHEST //---------------------------------------------------------------------------- -class wxString; -//---------------------------------------------------------------------------- namespace mmex { @@ -33,11 +31,8 @@ //---------------------------------------------------------------------------- extern const wxChar *const DEFDATEFORMAT; extern const wxChar *const DEFDELIMTER; -extern const wxChar *const CURRENCYDB_FNAME; extern const wxChar *const DEFSTOCKURL; -wxString getVersion(); - } // mmex //---------------------------------------------------------------------------- @@ -426,4 +421,3 @@ //---------------------------------------------------------------------------- #endif // _MM_EX_GUIID_H_ //---------------------------------------------------------------------------- - Modified: trunk/mmex/src/mmgraphgenerator.cpp =================================================================== --- trunk/mmex/src/mmgraphgenerator.cpp 2009-11-22 15:49:56 UTC (rev 813) +++ trunk/mmex/src/mmgraphgenerator.cpp 2009-11-22 15:50:57 UTC (rev 814) @@ -17,15 +17,57 @@ ********************************************************/ #include "mmgraphgenerator.h" -#include "util.h" +//---------------------------------------------------------------------------- +#include <vector> +#include <algorithm> +#include <wx/filename.h> +//---------------------------------------------------------------------------- -mmGraphGenerator::mmGraphGenerator(const wxString& outFileName) +namespace { - // for systems without the graphs directory this would assert an error! - htmlString_ = /* wxT("graphs\\") + */ outFileName; + +class Deleter +{ +public: + Deleter() : files(64) {} + ~Deleter(); + + void add(const wxString &f) { files.push_back(f); } + void delete_all(); + +private: + std::vector<wxString> files; +}; +//---------------------------------------------------------------------------- +Deleter g_deleter; +//---------------------------------------------------------------------------- + +Deleter::~Deleter() +{ + try { + delete_all(); + } catch (...) { + wxASSERT(false); + } } +//---------------------------------------------------------------------------- -const wxString& mmGraphGenerator::GetOutputFileName() -{ - return htmlString_; +void Deleter::delete_all() +{ + for_each(files.begin(), files.end(), wxRemoveFile); } +//---------------------------------------------------------------------------- + +} // namespace + +//---------------------------------------------------------------------------- + +/* + FIXME: do not create temp files in public temporary directory. +*/ +mmGraphGenerator::mmGraphGenerator() : + m_htmlString(wxFileName::CreateTempFileName(wxGetEmptyString())) +{ + g_deleter.add(m_htmlString); +} +//---------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:52:52
|
Revision: 815 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=815&view=rev Author: kkkvadim Date: 2009-11-22 15:52:39 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/maincurrencydialog.cpp trunk/mmex/src/mmcheckingpanel.cpp trunk/mmex/src/mmcurrency.h Modified: trunk/mmex/src/maincurrencydialog.cpp =================================================================== --- trunk/mmex/src/maincurrencydialog.cpp 2009-11-22 15:50:57 UTC (rev 814) +++ trunk/mmex/src/maincurrencydialog.cpp 2009-11-22 15:52:39 UTC (rev 815) @@ -20,13 +20,8 @@ #include "currencydialog.h" #include "util.h" #include "defs.h" - +#include "paths.h" -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - -using namespace std; - IMPLEMENT_DYNAMIC_CLASS( mmMainCurrencyDialog, wxDialog ) BEGIN_EVENT_TABLE( mmMainCurrencyDialog, wxDialog ) @@ -72,8 +67,7 @@ //GetSizer()->Fit(this); //GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); fillControls(); Modified: trunk/mmex/src/mmcheckingpanel.cpp =================================================================== --- trunk/mmex/src/mmcheckingpanel.cpp 2009-11-22 15:50:57 UTC (rev 814) +++ trunk/mmex/src/mmcheckingpanel.cpp 2009-11-22 15:52:39 UTC (rev 815) @@ -1197,7 +1197,7 @@ } //---------------------------------------------------------------------------- -void MyListCtrl::OnListItemDeselected(wxListEvent& event) +void MyListCtrl::OnListItemDeselected(wxListEvent& /*event*/) { m_selectedIndex = -1; m_cp->updateExtraTransactionData(m_selectedIndex); Modified: trunk/mmex/src/mmcurrency.h =================================================================== --- trunk/mmex/src/mmcurrency.h 2009-11-22 15:50:57 UTC (rev 814) +++ trunk/mmex/src/mmcurrency.h 2009-11-22 15:52:39 UTC (rev 815) @@ -17,9 +17,14 @@ #ifndef _MM_EX_MMCURRENCY_H_ #define _MM_EX_MMCURRENCY_H_ -#include "mmdbinterface.h" -#include "boost/shared_ptr.hpp" +#include <vector> +#include <boost/shared_ptr.hpp> +#include <wx/string.h> +class wxSQLite3Database; +class wxSQLite3ResultSet; + + class mmCurrency { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:54:08
|
Revision: 816 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=816&view=rev Author: kkkvadim Date: 2009-11-22 15:53:54 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/mmgraphgenerator.h trunk/mmex/src/mmgraphincexpensesmonth.h trunk/mmex/src/mmpayee.h trunk/mmex/src/newacctdialog.cpp Modified: trunk/mmex/src/mmgraphgenerator.h =================================================================== --- trunk/mmex/src/mmgraphgenerator.h 2009-11-22 15:52:39 UTC (rev 815) +++ trunk/mmex/src/mmgraphgenerator.h 2009-11-22 15:53:54 UTC (rev 816) @@ -19,19 +19,19 @@ #ifndef _MM_EX_GRAPHGENERATOR_H_ #define _MM_EX_GRAPHGENERATOR_H_ -#include "defs.h" +#include <wx/string.h> class mmGraphGenerator { public: - mmGraphGenerator(const wxString& outFileName); + mmGraphGenerator(); + virtual ~mmGraphGenerator() {} -public: - const wxString& GetOutputFileName(); - virtual bool Generate(const wxString& chartTitle) = 0; + virtual bool Generate(const wxString& chartTitle) = 0; + const wxString& GetOutputFileName() const { return m_htmlString; } private: - wxString htmlString_; + wxString m_htmlString; }; #endif Modified: trunk/mmex/src/mmgraphincexpensesmonth.h =================================================================== --- trunk/mmex/src/mmgraphincexpensesmonth.h 2009-11-22 15:52:39 UTC (rev 815) +++ trunk/mmex/src/mmgraphincexpensesmonth.h 2009-11-22 15:53:54 UTC (rev 816) @@ -1,42 +1,23 @@ +#ifndef _MM_EX_GRAPHINCEXPENSESMONTH_H_ +#define _MM_EX_GRAPHINCEXPENSESMONTH_H_ + #include "mmgraphgenerator.h" -#include "chart.h" +#include <boost/scoped_ptr.hpp> +class BarChart; -#ifndef _MM_EX_GRAPHINCEXPENSESMONTH_H_ -#define _MM_EX_GRAPHINCEXPENSESMONTH_H_ class mmGraphIncExpensesMonth : public mmGraphGenerator { public: - mmGraphIncExpensesMonth() : mmGraphGenerator(wxT("inc_expenses_month.png")) - { - chart = new BarChart(200, 240); - } + mmGraphIncExpensesMonth(); + ~mmGraphIncExpensesMonth(); - ~mmGraphIncExpensesMonth() - { - delete chart; - } + void init(double income, double expenses); + bool Generate(const wxString& chartTitle); - virtual void init(double income, double expenses) - { - std::vector<ChartData> barData; - - barData.push_back(ChartData(_("Income"), income)); - barData.push_back(ChartData(_("Expenses"), expenses)); - - chart->SetData(barData); - chart->Init(140, CHART_LEGEND_FLOAT, BAR_CHART_SIMPLE); - } - - bool Generate(const wxString& chartTitle) - { - chart->Render(chartTitle); - return chart->Save(GetOutputFileName()); - }; - private: - BarChart* chart; + boost::scoped_ptr<BarChart> chart; }; -#endif +#endif // _MM_EX_GRAPHINCEXPENSESMONTH_H_ Modified: trunk/mmex/src/mmpayee.h =================================================================== --- trunk/mmex/src/mmpayee.h 2009-11-22 15:52:39 UTC (rev 815) +++ trunk/mmex/src/mmpayee.h 2009-11-22 15:53:54 UTC (rev 816) @@ -17,7 +17,6 @@ #ifndef _MM_EX_MMPAYEE_H_ #define _MM_EX_MMPAYEE_H_ -#include "mmdbinterface.h" #include "mmcategory.h" #include "boost/shared_ptr.hpp" Modified: trunk/mmex/src/newacctdialog.cpp =================================================================== --- trunk/mmex/src/newacctdialog.cpp 2009-11-22 15:52:39 UTC (rev 815) +++ trunk/mmex/src/newacctdialog.cpp 2009-11-22 15:53:54 UTC (rev 816) @@ -20,18 +20,13 @@ #include "dbwrapper.h" #include "maincurrencydialog.h" #include "defs.h" - #include "util.h" +#include "paths.h" -#define ACCT_TYPE_CHECKING 0 -#define ACCT_TYPE_INVESTMENT 1 +enum { ACCT_TYPE_CHECKING, ACCT_TYPE_INVESTMENT }; +enum { ACCT_STATUS_OPEN, ACCT_STATUS_CLOSED }; -#define ACCT_STATUS_OPEN 0 -#define ACCT_STATUS_CLOSED 1 -#define MMEX_ICON_FNAME mmGetBaseWorkingPath() + wxT("/mmex.ico") - - IMPLEMENT_DYNAMIC_CLASS( mmNewAcctDialog, wxDialog ) BEGIN_EVENT_TABLE( mmNewAcctDialog, wxDialog ) @@ -66,8 +61,7 @@ GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); - wxIcon icon(MMEX_ICON_FNAME, wxBITMAP_TYPE_ICO, 32, 32); - SetIcon(icon); + SetIcon(mmex::getProgramIcon()); Centre(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-22 15:54:57
|
Revision: 817 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=817&view=rev Author: kkkvadim Date: 2009-11-22 15:54:50 +0000 (Sun, 22 Nov 2009) Log Message: ----------- changes Modified Paths: -------------- trunk/mmex/src/assetspanel.cpp trunk/mmex/src/mmgraphtopcategories.cpp Removed Paths: ------------- trunk/mmex/src/mmdbinterface.h Modified: trunk/mmex/src/assetspanel.cpp =================================================================== --- trunk/mmex/src/assetspanel.cpp 2009-11-22 15:53:54 UTC (rev 816) +++ trunk/mmex/src/assetspanel.cpp 2009-11-22 15:54:50 UTC (rev 817) @@ -298,7 +298,7 @@ cp_->enableEditDeleteButtons(true); } -void assetsListCtrl::OnListItemDeselected(wxListEvent& event) +void assetsListCtrl::OnListItemDeselected(wxListEvent& /*event*/) { selectedIndex_ = -1; cp_->enableEditDeleteButtons(false); Deleted: trunk/mmex/src/mmdbinterface.h =================================================================== --- trunk/mmex/src/mmdbinterface.h 2009-11-22 15:53:54 UTC (rev 816) +++ trunk/mmex/src/mmdbinterface.h 2009-11-22 15:54:50 UTC (rev 817) @@ -1,40 +0,0 @@ -/******************************************************* - Copyright (C) 2006 Madhan Kanagavel - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - ********************************************************/ - -#ifndef _MM_EX_MMDBINTERFACE_H_ -#define _MM_EX_MMDBINTERFACE_H_ - -#include "dbwrapper.h" -#include "boost/shared_ptr.hpp" - -class mmDBInterface -{ -public: - mmDBInterface(boost::shared_ptr<wxSQLite3Database>& db) - : db_(db) {} - virtual ~mmDBInterface() {} - - virtual void addDBRecord() = 0; - //virtual void updateDBRecord(); - //virtual void deleteDBRecord(); - //virtual void loadDBRecord(); -protected: - boost::shared_ptr<wxSQLite3Database> db_; -}; - -#endif Modified: trunk/mmex/src/mmgraphtopcategories.cpp =================================================================== --- trunk/mmex/src/mmgraphtopcategories.cpp 2009-11-22 15:53:54 UTC (rev 816) +++ trunk/mmex/src/mmgraphtopcategories.cpp 2009-11-22 15:54:50 UTC (rev 817) @@ -5,12 +5,16 @@ //---------------------------------------------------------------------------- mmGraphTopCategories::mmGraphTopCategories() : - mmGraphGenerator(wxT("top_categories.png")), - m_chart(new BarChart(320, 240)) + m_chart(new BarChart(320, 240)) { } //---------------------------------------------------------------------------- +mmGraphTopCategories::~mmGraphTopCategories() +{ +} +//---------------------------------------------------------------------------- + void mmGraphTopCategories::init(const std::vector<CategInfo> &categList) { std::vector<ChartData> barData; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oma...@us...> - 2009-11-25 16:41:28
|
Revision: 821 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=821&view=rev Author: omalleypat Date: 2009-11-25 16:41:20 +0000 (Wed, 25 Nov 2009) Log Message: ----------- Updates to the payee dialog. Now there is only one text entry area that handles search and add/edit. A new function to filter payees using SQLite LIKE operator has been added to facilitate search. Also, the add and edit buttons pop dialogs instead of directly operating on the selected entry to make it more clear exactly what is happening. The add dialog is prepopulated with whatever is in the search field in case the user was searching for a payee and did not find it. The edit dialog tells the user the name of the payee being edited so it is clear what the program is doing. Modified Paths: -------------- trunk/mmex/src/dbwrapper.cpp trunk/mmex/src/dbwrapper.h trunk/mmex/src/payeedialog.cpp trunk/mmex/src/payeedialog.h Modified: trunk/mmex/src/dbwrapper.cpp =================================================================== --- trunk/mmex/src/dbwrapper.cpp 2009-11-22 19:55:45 UTC (rev 820) +++ trunk/mmex/src/dbwrapper.cpp 2009-11-25 16:41:20 UTC (rev 821) @@ -2133,7 +2133,23 @@ return amt; } +wxArrayString mmDBWrapper::filterPayees(wxSQLite3Database* db, const wxString& patt) +{ + wxArrayString flist; + wxString sql; + sql.Printf(wxT("select PAYEENAME from PAYEE_V1 where PAYEENAME LIKE '%s%%' ORDER BY PAYEENAME"),patt.c_str()); + + wxSQLite3Statement st = db->PrepareStatement(sql); + wxSQLite3ResultSet q1 = st.ExecuteQuery(); + while (q1.NextRow()) + { + flist.Add(q1.GetString(wxT("PAYEENAME"))); + } + st.Finalize(); + return flist; +} + void mmDBWrapper::addBudgetYear(wxSQLite3Database* db, const wxString &year) { wxSQLite3Statement st = db->PrepareStatement("insert into BUDGETYEAR_V1 (BUDGETYEARNAME) values (?)"); Modified: trunk/mmex/src/dbwrapper.h =================================================================== --- trunk/mmex/src/dbwrapper.h 2009-11-22 19:55:45 UTC (rev 820) +++ trunk/mmex/src/dbwrapper.h 2009-11-25 16:41:20 UTC (rev 821) @@ -79,7 +79,8 @@ bool updatePayee(wxSQLite3Database* db, const wxString& payeeName, int payeeID, int categID, int subcategID); bool deletePayeeWithConstraints(wxSQLite3Database* db, int payeeID); double getAmountForPayee(wxSQLite3Database* db, int payeeID, bool ignoreDate, wxDateTime dtbegin, wxDateTime dtEnd); - +wxArrayString filterPayees(wxSQLite3Database* db, const wxString& patt); + /* Category Table API */ bool deleteCategoryWithConstraints(wxSQLite3Database* db, int categID); bool deleteSubCategoryWithConstraints(wxSQLite3Database* db, int categID, int subcategID); Modified: trunk/mmex/src/payeedialog.cpp =================================================================== --- trunk/mmex/src/payeedialog.cpp 2009-11-22 19:55:45 UTC (rev 820) +++ trunk/mmex/src/payeedialog.cpp 2009-11-25 16:41:20 UTC (rev 821) @@ -33,9 +33,9 @@ EVT_BUTTON(ID_DIALOG_PAYEE_BUTTON_SELECT, mmPayeeDialog::OnBSelect) EVT_BUTTON(ID_DIALOG_PAYEE_BUTTON_EDIT, mmPayeeDialog::OnEdit) EVT_LISTBOX(ID_DIALOG_PAYEE_LISTBOX_PAYEES, mmPayeeDialog::OnSelChanged) - EVT_COMBOBOX(ID_DIALOG_TRANS_PAYEECOMBO, mmPayeeDialog::OnComboSelected) EVT_LISTBOX_DCLICK(ID_DIALOG_PAYEE_LISTBOX_PAYEES, mmPayeeDialog::OnDoubleClicked) EVT_CHAR_HOOK(mmPayeeDialog::OnListKeyDown) + EVT_TEXT(ID_DIALOG_PAYEE_TEXTCTRL_PAYEENAME, mmPayeeDialog::OnTextCtrlChanged) END_EVENT_TABLE() @@ -51,7 +51,7 @@ { long keycode = event.GetKeyCode(); - if(keycode == 13) + if(keycode == 13 && showSelectButton_) { wxCommandEvent event; OnBSelect(event); @@ -105,18 +105,12 @@ void mmPayeeDialog::fillControls() { - core_->payeeList_.sortPayeeList(); - - int numPayees = (int)core_->payeeList_.payees_.size(); - for (int idx = 0; idx < numPayees; idx++) - { - listBox_->Insert(core_->payeeList_.payees_[idx]->payeeName_, idx, - new mmPayeeListBoxItem(core_->payeeList_.payees_[idx]->payeeID_)); - payeeComboBox_->Insert(core_->payeeList_.payees_[idx]->payeeName_, idx, new mmPayeeListBoxItem(core_->payeeList_.payees_[idx]->payeeID_)); - } - payeeComboBox_->Connect(ID_DIALOG_TRANS_PAYEECOMBO, wxEVT_SET_FOCUS, wxFocusEventHandler(mmPayeeDialog::OnSetFocus), NULL, this); - payeeComboBox_->Connect(ID_DIALOG_TRANS_PAYEECOMBO, wxEVT_KILL_FOCUS, wxFocusEventHandler(mmPayeeDialog::OnFocus), NULL, this); - payeeComboBox_->SetFocus(); + listBox_->Clear(); + wxArrayString filtd = mmDBWrapper::filterPayees(core_->db_.get(),textCtrl->GetValue()); + for (int i=0; i < filtd.GetCount(); i++) + { + listBox_->Append(filtd.Item(i)); + } } void mmPayeeDialog::CreateControls() @@ -131,10 +125,6 @@ itemBoxSizer2->Add(itemStaticTextName, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - payeeComboBox_ = new wxAutoComboBox(itemDialog1, - ID_DIALOG_TRANS_PAYEECOMBO, wxT(""), wxDefaultPosition, wxSize(250, -1), wxCB_READONLY); - itemBoxSizer2->Add(payeeComboBox_, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - payeeComboBox_->SetToolTip(_("Enter the payee name to be added or make edits to an existing payee name")); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5); @@ -143,23 +133,15 @@ wxDefaultPosition, wxSize(100, 200), wxArrayString(), wxLB_SINGLE); itemBoxSizer3->Add(listBox_, 1, wxGROW|wxALL, 1); - //wxBoxSizer* itemBoxSizerPayee = new wxBoxSizer(wxHORIZONTAL); - //itemBoxSizer2->Add(itemBoxSizerPayee, 1, wxGROW|wxALL, 5); - - //wxStaticText* itemStaticTextName = new wxStaticText( itemDialog1, wxID_STATIC, - // _("Payee Name"), wxDefaultPosition, wxDefaultSize, 0 ); - //itemBoxSizerPayee->Add(itemStaticTextName, 0, - // wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticTextName2 = new wxStaticText( itemDialog1, wxID_STATIC, - _("Add/Edit Payee: "), wxDefaultPosition, wxDefaultSize, 0 ); + _("Filter Payees: "), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer2->Add(itemStaticTextName2, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); textCtrl = new wxTextCtrl( itemDialog1, ID_DIALOG_PAYEE_TEXTCTRL_PAYEENAME, wxT(""), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer2->Add(textCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); - textCtrl->SetToolTip(_("Enter the payee name to be added or make edits to an existing payee name")); + textCtrl->SetToolTip(_("Enter a search string. You can use % as a wildcard to match zero or more characters or _ to match a single character.")); wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer5, 0, wxGROW|wxALL, 5); @@ -168,17 +150,20 @@ _("&Add"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer5->Add(addButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); addButton->SetToolTip(_("Add a new payee name")); + addButton->Disable(); editButton = new wxButton( itemDialog1, ID_DIALOG_PAYEE_BUTTON_EDIT, _("&Edit"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer5->Add(editButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); editButton->SetToolTip(_("Change the name of an existing payee")); - + editButton->Disable(); + deleteButton = new wxButton( itemDialog1, ID_DIALOG_PAYEE_BUTTON_DELETE, _("&Delete"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer5->Add(deleteButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); deleteButton->SetToolTip(_("Delete the selected payee. The payee cannot be used by an existing transaction.")); - + deleteButton->Disable(); + wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer9, 0, wxGROW|wxALL, 5); @@ -186,17 +171,33 @@ _("&Select"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer9->Add(selectButton, 1, wxALIGN_CENTER_VERTICAL|wxALL, 1); selectButton->SetToolTip(_("Select the currently selected payee as the selected payee for the transaction")); + selectButton->Disable(); +} - // this->Connect(ID_DIALOG_TRANS_PAYEECOMBO, wxEVT_SET_FOCUS, wxFocusEventHandler(mmPayeeDialog::OnFocus)); +void mmPayeeDialog::OnTextCtrlChanged(wxCommandEvent& event) +{ + wxString payeeString = listBox_->GetStringSelection(); + fillControls(); + if (textCtrl->GetValue() != wxGetEmptyString()) + { + addButton->Enable(); + listBox_->SetSelection(0); + } + else + { + addButton->Disable(); + listBox_->SetStringSelection(payeeString); + } + OnSelChanged(event); } -void mmPayeeDialog::OnAdd(wxCommandEvent& /*event*/) + +void mmPayeeDialog::OnAdd(wxCommandEvent& event) { - wxTextCtrl* payeeText = (wxTextCtrl*)FindWindow(ID_DIALOG_PAYEE_TEXTCTRL_PAYEENAME); - wxString text = payeeText->GetValue(); - if (text.Trim().IsEmpty()) + wxString text = wxGetTextFromUser(_("Enter the name of the payee to add:"), _("Add Payee"), textCtrl->GetValue()); + if (text == wxGetEmptyString()) { - mmShowErrorMessage(this, _("Type a Payee Name in the Text Box and then press Add."), _("Error")); + //mmShowErrorMessage(this, _("Type a Payee Name in the Text Box and then press Add."), _("Error")); return; } if (core_->payeeList_.payeeExists(text)) @@ -206,60 +207,36 @@ else { core_->payeeList_.addPayee(text); - listBox_->Clear(); + textCtrl->SetValue(wxGetEmptyString()); fillControls(); listBox_->SetStringSelection(text); - wxString payeeString = listBox_->GetStringSelection(); - payeeID_ = core_->payeeList_.getPayeeID(payeeString); - textCtrl->SetValue(payeeString); + + // SetStringSelection does not emit event, so we need to do it manually. + // This is important because it is where payeeID_ gets set + OnSelChanged(event); } } -void mmPayeeDialog::OnDelete(wxCommandEvent& /*event*/) +void mmPayeeDialog::OnDelete(wxCommandEvent& event) { if (!core_->payeeList_.deletePayee(payeeID_)) { mmShowErrorMessage(this, _("Payee is in use"), _("Error")); return; } - payeeComboBox_->SetValue(wxT("")); - listBox_->Clear(); + textCtrl->SetValue(wxGetEmptyString()); fillControls(); + OnSelChanged(event); } void mmPayeeDialog::OnBSelect(wxCommandEvent& /*event*/) { - //wxString payeeString = listBox_->GetStringSelection(); if (payeeID_ != -1) { EndModal(wxID_OK); return; } - - int sel = listBox_->GetSelection(); - if (sel != -1) - { - mmPayeeListBoxItem* lbitem = (mmPayeeListBoxItem*)listBox_->GetClientObject(sel); - payeeID_ = lbitem->getPayeeID(); - EndModal(wxID_OK); - } -#if 0 - else - { - wxString payeeString = payeeComboBox_->GetValue(); - if (listBox_->SetStringSelection(payeeString, true)) - { - wxString payeeString = listBox_->GetStringSelection(); - int selInd = listBox_->GetSelection(); - if (selInd == -1) - return; - mmPayeeListBoxItem* lbitem = (mmPayeeListBoxItem*)listBox_->GetClientObject(selInd); - payeeID_ = lbitem->getPayeeID(); - EndModal(wxID_OK); - } - } -#endif } void mmPayeeDialog::OnOk(wxCommandEvent& /*event*/) @@ -270,90 +247,44 @@ void mmPayeeDialog::OnSelChanged(wxCommandEvent& /*event*/) { wxString payeeString = listBox_->GetStringSelection(); - int selInd = listBox_->GetSelection(); - if (selInd == -1) + if (payeeString==wxGetEmptyString()) + { + editButton->Disable(); + deleteButton->Disable(); + selectButton->Disable(); + payeeID_ = -1; return; - mmPayeeListBoxItem* lbitem = (mmPayeeListBoxItem*)listBox_->GetClientObject(selInd); - payeeID_ = lbitem->getPayeeID(); - textCtrl->SetValue(payeeString); - //payeeComboBox_->SetValue(payeeString); + } + if (showSelectButton_) + selectButton->Enable(); + editButton->Enable(); + deleteButton->Enable(); + payeeID_ = core_->payeeList_.getPayeeID(payeeString); + } -void mmPayeeDialog::OnComboSelected(wxCommandEvent& /*event*/) -{ - wxString payeeString = payeeComboBox_->GetValue(); - int selInd = payeeComboBox_->GetSelection(); - if (selInd == -1) - return; - - mmPayeeListBoxItem* lbitem = (mmPayeeListBoxItem*)payeeComboBox_->GetClientObject(selInd); - payeeID_ = lbitem->getPayeeID(); - textCtrl->SetValue(payeeString); - //payeeComboBox_->SetFocus(); -#if 0 - if (listBox_->SetStringSelection(payeeString, true)) - { - wxString payeeString = listBox_->GetStringSelection(); - int selInd = listBox_->GetSelection(); - if (selInd == -1) - return; - mmPayeeListBoxItem* lbitem = (mmPayeeListBoxItem*)listBox_->GetClientObject(selInd); - payeeID_ = lbitem->getPayeeID(); - textCtrl->SetValue(payeeString); - payeeComboBox_->SetFocus(); - } -#endif - //int selInd = payeeComboBox_->GetCurrentSelection(); - //if (selInd == -1) - // return; - //mmPayeeListBoxItem* lbitem = (mmPayeeListBoxItem*)listBox_->GetClientObject(selInd); - //payeeID_ = lbitem->getPayeeID(); - - //textCtrl->SetValue(payeeString); - // payeeComboBox_->SetValue(payeeString); -} - - -void mmPayeeDialog::OnSetFocus(wxFocusEvent& /*event*/) -{ -} - -void mmPayeeDialog::OnFocus(wxFocusEvent& /*event*/) -{ - wxString payeeString = payeeComboBox_->GetValue(); - int selInd = payeeComboBox_->GetSelection(); - if (selInd == -1) - return; - - mmPayeeListBoxItem* lbitem = (mmPayeeListBoxItem*)payeeComboBox_->GetClientObject(selInd); - payeeID_ = lbitem->getPayeeID(); - textCtrl->SetValue(payeeString); -#if 0 - wxString payeeString = payeeComboBox_->GetValue(); - if (listBox_->SetStringSelection(payeeString, true)) - { - wxString payeeString = listBox_->GetStringSelection(); - int selInd = listBox_->GetSelection(); - if (selInd == -1) - return; - mmPayeeListBoxItem* lbitem = (mmPayeeListBoxItem*)listBox_->GetClientObject(selInd); - payeeID_ = lbitem->getPayeeID(); - textCtrl->SetValue(payeeString); - //payeeComboBox_->SetFocus(); - } -#endif -} - void mmPayeeDialog::OnDoubleClicked(wxCommandEvent& event) { OnBSelect(event); } -void mmPayeeDialog::OnEdit(wxCommandEvent& /*event*/) +void mmPayeeDialog::OnEdit(wxCommandEvent& event) { - wxString text = textCtrl->GetValue(); - core_->payeeList_.updatePayee(payeeID_, text); - core_->bTransactionList_.updateAllTransactionsForPayee(core_, payeeID_); - listBox_->Clear(); - fillControls(); + wxString oldname = listBox_->GetStringSelection(); + + wxString mesg; + mesg.Printf(_("Enter a new name for %s"),oldname.c_str()); + wxString newName = wxGetTextFromUser(mesg, _("Edit Payee Name"), oldname); + if (newName != wxGetEmptyString()) + { + core_->payeeList_.updatePayee(payeeID_, newName); + core_->bTransactionList_.updateAllTransactionsForPayee(core_, payeeID_); + editButton->Disable(); + fillControls(); + + // Now we need to make sure that the edited name is selected after the dialog is closed + textCtrl->SetValue(wxGetEmptyString()); + listBox_->SetStringSelection(newName); + OnSelChanged(event); + } } Modified: trunk/mmex/src/payeedialog.h =================================================================== --- trunk/mmex/src/payeedialog.h 2009-11-22 19:55:45 UTC (rev 820) +++ trunk/mmex/src/payeedialog.h 2009-11-25 16:41:20 UTC (rev 821) @@ -76,6 +76,7 @@ void OnListKeyDown(wxKeyEvent &event); void fillControls(); + void OnTextCtrlChanged(wxCommandEvent& event); void OnSelChanged(wxCommandEvent& event); void OnComboSelected(wxCommandEvent& event); void OnDoubleClicked(wxCommandEvent& event); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-28 13:12:40
|
Revision: 827 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=827&view=rev Author: kkkvadim Date: 2009-11-28 13:12:30 +0000 (Sat, 28 Nov 2009) Log Message: ----------- moved Removed Paths: ------------- trunk/mmex/src/tinystr.cpp trunk/mmex/src/tinyxml.cpp trunk/mmex/src/tinyxmlerror.cpp trunk/mmex/src/tinyxmlparser.cpp trunk/mmex/src/wxsqlite3.cpp trunk/mmex/src/wxtinyxml.cpp Deleted: trunk/mmex/src/tinystr.cpp =================================================================== --- trunk/mmex/src/tinystr.cpp 2009-11-28 13:10:55 UTC (rev 826) +++ trunk/mmex/src/tinystr.cpp 2009-11-28 13:12:30 UTC (rev 827) @@ -1,116 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original file by Yves Berquin. - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -/* - * THIS FILE WAS ALTERED BY Tyge L\xF8vset, 7. April 2005. - */ - - -#ifndef TIXML_USE_STL - -#include "tinystr.h" - -// Error value for find primitive -const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); - - -// Null rep. -TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; - - -void TiXmlString::reserve (size_type cap) -{ - if (cap > capacity()) - { - TiXmlString tmp; - tmp.init(length(), cap); - memcpy(tmp.start(), data(), length()); - swap(tmp); - } -} - - -TiXmlString& TiXmlString::assign(const char* str, size_type len) -{ - size_type cap = capacity(); - if (len > cap || cap > 3*(len + 8)) - { - TiXmlString tmp; - tmp.init(len); - memcpy(tmp.start(), str, len); - swap(tmp); - } - else - { - memmove(start(), str, len); - set_size(len); - } - return *this; -} - - -TiXmlString& TiXmlString::append(const char* str, size_type len) -{ - size_type newsize = length() + len; - if (newsize > capacity()) - { - reserve (newsize + capacity()); - } - memmove(finish(), str, len); - set_size(newsize); - return *this; -} - - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) -{ - TiXmlString tmp; - tmp.reserve(a.length() + b.length()); - tmp += a; - tmp += b; - return tmp; -} - -TiXmlString operator + (const TiXmlString & a, const char* b) -{ - TiXmlString tmp; - TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) ); - tmp.reserve(a.length() + b_len); - tmp += a; - tmp.append(b, b_len); - return tmp; -} - -TiXmlString operator + (const char* a, const TiXmlString & b) -{ - TiXmlString tmp; - TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) ); - tmp.reserve(a_len + b.length()); - tmp.append(a, a_len); - tmp += b; - return tmp; -} - - -#endif // TIXML_USE_STL Deleted: trunk/mmex/src/tinyxml.cpp =================================================================== --- trunk/mmex/src/tinyxml.cpp 2009-11-28 13:10:55 UTC (rev 826) +++ trunk/mmex/src/tinyxml.cpp 2009-11-28 13:12:30 UTC (rev 827) @@ -1,1888 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include <ctype.h> - -#ifdef TIXML_USE_STL -#include <sstream> -#include <iostream> -#endif - -#include "tinyxml.h" - - -bool TiXmlBase::condenseWhiteSpace = true; - -// Microsoft compiler security -FILE* TiXmlFOpen( const char* filename, const char* mode ) -{ - #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - FILE* fp = 0; - errno_t err = fopen_s( &fp, filename, mode ); - if ( !err && fp ) - return fp; - return 0; - #else - return fopen( filename, mode ); - #endif -} - -void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) -{ - int i=0; - - while( i<(int)str.length() ) - { - unsigned char c = (unsigned char) str[i]; - - if ( c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - // - // The -1 is a bug fix from Rob Laveaux. It keeps - // an overflow from happening if there is no ';'. - // There are actually 2 ways to exit this loop - - // while fails (error case) and break (semicolon found). - // However, there is no mechanism (currently) for - // this function to return an error. - while ( i<(int)str.length()-1 ) - { - outString->append( str.c_str() + i, 1 ); - ++i; - if ( str[i] == ';' ) - break; - } - } - else if ( c == '&' ) - { - outString->append( entity[0].str, entity[0].strLength ); - ++i; - } - else if ( c == '<' ) - { - outString->append( entity[1].str, entity[1].strLength ); - ++i; - } - else if ( c == '>' ) - { - outString->append( entity[2].str, entity[2].strLength ); - ++i; - } - else if ( c == '\"' ) - { - outString->append( entity[3].str, entity[3].strLength ); - ++i; - } - else if ( c == '\'' ) - { - outString->append( entity[4].str, entity[4].strLength ); - ++i; - } - else if ( c < 32 ) - { - // Easy pass at non-alpha/numeric/symbol - // Below 32 is symbolic. - char buf[ 32 ]; - - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); - #else - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - #endif - - //*ME: warning C4267: convert 'size_t' to 'int' - //*ME: Int-Cast to make compiler happy ... - outString->append( buf, (int)strlen( buf ) ); - ++i; - } - else - { - //char realc = (char) c; - //outString->append( &realc, 1 ); - *outString += (char) c; // somewhat more efficient function call. - ++i; - } - } -} - - -TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() -{ - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; -} - - -TiXmlNode::~TiXmlNode() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } -} - - -void TiXmlNode::CopyTo( TiXmlNode* target ) const -{ - target->SetValue (value.c_str() ); - target->userData = userData; -} - - -void TiXmlNode::Clear() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } - - firstChild = 0; - lastChild = 0; -} - - -TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) -{ - assert( node->parent == 0 || node->parent == this ); - assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); - - if ( node->Type() == TiXmlNode::DOCUMENT ) - { - delete node; - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - node->parent = this; - - node->prev = lastChild; - node->next = 0; - - if ( lastChild ) - lastChild->next = node; - else - firstChild = node; // it was an empty list. - - lastChild = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) -{ - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - - return LinkEndChild( node ); -} - - -TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) -{ - if ( !beforeThis || beforeThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if ( beforeThis->prev ) - { - beforeThis->prev->next = node; - } - else - { - assert( firstChild == beforeThis ); - firstChild = node; - } - beforeThis->prev = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) -{ - if ( !afterThis || afterThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if ( afterThis->next ) - { - afterThis->next->prev = node; - } - else - { - assert( lastChild == afterThis ); - lastChild = node; - } - afterThis->next = node; - return node; -} - - -TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) -{ - if ( replaceThis->parent != this ) - return 0; - - TiXmlNode* node = withThis.Clone(); - if ( !node ) - return 0; - - node->next = replaceThis->next; - node->prev = replaceThis->prev; - - if ( replaceThis->next ) - replaceThis->next->prev = node; - else - lastChild = node; - - if ( replaceThis->prev ) - replaceThis->prev->next = node; - else - firstChild = node; - - delete replaceThis; - node->parent = this; - return node; -} - - -bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) -{ - if ( removeThis->parent != this ) - { - assert( 0 ); - return false; - } - - if ( removeThis->next ) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; - - if ( removeThis->prev ) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; - - delete removeThis; - return true; -} - -const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = firstChild; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = lastChild; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild(); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling(); - } -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild( val ); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling( val ); - } -} - - -const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = next; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = prev; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -void TiXmlElement::RemoveAttribute( const char * name ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING str( name ); - TiXmlAttribute* node = attributeSet.Find( str ); - #else - TiXmlAttribute* node = attributeSet.Find( name ); - #endif - if ( node ) - { - attributeSet.Remove( node ); - delete node; - } -} - -const TiXmlElement* TiXmlNode::FirstChildElement() const -{ - const TiXmlNode* node; - - for ( node = FirstChild(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = FirstChild( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement() const -{ - const TiXmlNode* node; - - for ( node = NextSibling(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = NextSibling( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlDocument* TiXmlNode::GetDocument() const -{ - const TiXmlNode* node; - - for( node = this; node; node = node->parent ) - { - if ( node->ToDocument() ) - return node->ToDocument(); - } - return 0; -} - - -TiXmlElement::TiXmlElement (const char * _value) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} - - -#ifdef TIXML_USE_STL -TiXmlElement::TiXmlElement( const std::string& _value ) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} -#endif - - -TiXmlElement::TiXmlElement( const TiXmlElement& copy) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - copy.CopyTo( this ); -} - - -void TiXmlElement::operator=( const TiXmlElement& base ) -{ - ClearThis(); - base.CopyTo( this ); -} - - -TiXmlElement::~TiXmlElement() -{ - ClearThis(); -} - - -void TiXmlElement::ClearThis() -{ - Clear(); - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } -} - - -const char* TiXmlElement::Attribute( const char* name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return node->Value(); - return 0; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return &node->ValueStr(); - return 0; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, int* i ) const -{ - const char* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s ); - } - else { - *i = 0; - } - } - return s; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const -{ - const std::string* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s->c_str() ); - } - else { - *i = 0; - } - } - return s; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, double* d ) const -{ - const char* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s ); - } - else { - *d = 0; - } - } - return s; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const -{ - const std::string* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s->c_str() ); - } - else { - *d = 0; - } - } - return s; -} -#endif - - -int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); -} -#endif - - -int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); -} -#endif - - -void TiXmlElement::SetAttribute( const char * name, int val ) -{ - char buf[64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); - #else - sprintf( buf, "%d", val ); - #endif - SetAttribute( name, buf ); -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, int val ) -{ - std::ostringstream oss; - oss << val; - SetAttribute( name, oss.str() ); -} -#endif - - -void TiXmlElement::SetDoubleAttribute( const char * name, double val ) -{ - char buf[256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); - #else - sprintf( buf, "%f", val ); - #endif - SetAttribute( name, buf ); -} - - -void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING _name( cname ); - TIXML_STRING _value( cvalue ); - #else - const char* _name = cname; - const char* _value = cvalue; - #endif - - TiXmlAttribute* node = attributeSet.Find( _name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value ) -{ - TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( name, _value ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } -} -#endif - - -void TiXmlElement::Print( FILE* cfile, int depth ) const -{ - int i; - assert( cfile ); - for ( i=0; i<depth; i++ ) { - fprintf( cfile, " " ); - } - - fprintf( cfile, "<%s", value.c_str() ); - - const TiXmlAttribute* attrib; - for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) - { - fprintf( cfile, " " ); - attrib->Print( cfile, depth ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a <foo /> node - // 2) An element with only a text child is printed as <foo> text </foo> - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if ( !firstChild ) - { - fprintf( cfile, " />" ); - } - else if ( firstChild == lastChild && firstChild->ToText() ) - { - fprintf( cfile, ">" ); - firstChild->Print( cfile, depth + 1 ); - fprintf( cfile, "</%s>", value.c_str() ); - } - else - { - fprintf( cfile, ">" ); - - for ( node = firstChild; node; node=node->NextSibling() ) - { - if ( !node->ToText() ) - { - fprintf( cfile, "\n" ); - } - node->Print( cfile, depth+1 ); - } - fprintf( cfile, "\n" ); - for( i=0; i<depth; ++i ) { - fprintf( cfile, " " ); - } - fprintf( cfile, "</%s>", value.c_str() ); - } -} - - -void TiXmlElement::CopyTo( TiXmlElement* target ) const -{ - // superclass: - TiXmlNode::CopyTo( target ); - - // Element class: - // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; - for( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next() ) - { - target->SetAttribute( attribute->Name(), attribute->Value() ); - } - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - -bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this, attributeSet.First() ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -TiXmlNode* TiXmlElement::Clone() const -{ - TiXmlElement* clone = new TiXmlElement( Value() ); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -const char* TiXmlElement::GetText() const -{ - const TiXmlNode* child = this->FirstChild(); - if ( child ) { - const TiXmlText* childText = child->ToText(); - if ( childText ) { - return childText->Value(); - } - } - return 0; -} - - -TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - ClearError(); -} - -TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} - - -#ifdef TIXML_USE_STL -TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} -#endif - - -TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDocument::operator=( const TiXmlDocument& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) -{ - // See STL_STRING_BUG below. - //StringToBuffer buf( value ); - - return LoadFile( Value(), encoding ); -} - - -bool TiXmlDocument::SaveFile() const -{ - // See STL_STRING_BUG below. -// StringToBuffer buf( value ); -// -// if ( buf.buffer && SaveFile( buf.buffer ) ) -// return true; -// -// return false; - return SaveFile( Value() ); -} - -bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) -{ - // There was a really terrifying little bug here. The code: - // value = filename - // in the STL case, cause the assignment method of the std::string to - // be called. What is strange, is that the std::string had the same - // address as it's c_str() method, and so bad things happen. Looks - // like a bug in the Microsoft STL implementation. - // Add an extra string to avoid the crash. - TIXML_STRING filename( _filename ); - value = filename; - - // reading in binary mode so that tinyxml can normalize the EOL - FILE* file = TiXmlFOpen( value.c_str (), "rb" ); - - if ( file ) - { - bool result = LoadFile( file, encoding ); - fclose( file ); - return result; - } - else - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } -} - -bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) -{ - if ( !file ) - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Delete the existing data: - Clear(); - location.Clear(); - - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek( file, 0, SEEK_END ); - length = ftell( file ); - fseek( file, 0, SEEK_SET ); - - // Strange case, but good to handle up front. - if ( length <= 0 ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // If we have a file, assume it is all one big XML file, and read it in. - // The document parser may decide the document ends sooner than the entire file, however. - TIXML_STRING data; - data.reserve( length ); - - // Subtle bug here. TinyXml did use fgets. But from the XML spec: - // 2.11 End-of-Line Handling - // <snip> - // <quote> - // ...the XML processor MUST behave as if it normalized all line breaks in external - // parsed entities (including the document entity) on input, before parsing, by translating - // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to - // a single #xA character. - // </quote> - // - // It is not clear fgets does that, and certainly isn't clear it works cross platform. - // Generally, you expect fgets to translate from the convention of the OS to the c/unix - // convention, and not work generally. - - /* - while( fgets( buf, sizeof(buf), file ) ) - { - data += buf; - } - */ - - char* buf = new char[ length+1 ]; - buf[0] = 0; - - if ( fread( buf, length, 1, file ) != 1 ) { - delete [] buf; - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - const char* lastPos = buf; - const char* p = buf; - - buf[length] = 0; - while( *p ) { - assert( p < (buf+length) ); - if ( *p == 0xa ) { - // Newline character. No special rules for this. Append all the characters - // since the last string, and include the newline. - data.append( lastPos, (p-lastPos+1) ); // append, include the newline - ++p; // move past the newline - lastPos = p; // and point to the new buffer (may be 0) - assert( p <= (buf+length) ); - } - else if ( *p == 0xd ) { - // Carriage return. Append what we have so far, then - // handle moving forward in the buffer. - if ( (p-lastPos) > 0 ) { - data.append( lastPos, p-lastPos ); // do not add the CR - } - data += (char)0xa; // a proper newline - - if ( *(p+1) == 0xa ) { - // Carriage return - new line sequence - p += 2; - lastPos = p; - assert( p <= (buf+length) ); - } - else { - // it was followed by something else...that is presumably characters again. - ++p; - lastPos = p; - assert( p <= (buf+length) ); - } - } - else { - ++p; - } - } - // Handle any left over characters. - if ( p-lastPos ) { - data.append( lastPos, p-lastPos ); - } - delete [] buf; - buf = 0; - - Parse( data.c_str(), 0, encoding ); - - if ( Error() ) - return false; - else - return true; -} - - -bool TiXmlDocument::SaveFile( const char * filename ) const -{ - // The old c stuff lives on... - FILE* fp = TiXmlFOpen( filename, "w" ); - if ( fp ) - { - bool result = SaveFile( fp ); - fclose( fp ); - return result; - } - return false; -} - - -bool TiXmlDocument::SaveFile( FILE* fp ) const -{ - if ( useMicrosoftBOM ) - { - const unsigned char TIXML_UTF_LEAD_0 = 0xefU; - const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; - const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - - fputc( TIXML_UTF_LEAD_0, fp ); - fputc( TIXML_UTF_LEAD_1, fp ); - fputc( TIXML_UTF_LEAD_2, fp ); - } - Print( fp, 0 ); - return (ferror(fp) == 0); -} - - -void TiXmlDocument::CopyTo( TiXmlDocument* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->error = error; - target->errorId = errorId; - target->errorDesc = errorDesc; - target->tabsize = tabsize; - target->errorLocation = errorLocation; - target->useMicrosoftBOM = useMicrosoftBOM; - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - - -TiXmlNode* TiXmlDocument::Clone() const -{ - TiXmlDocument* clone = new TiXmlDocument(); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlDocument::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - node->Print( cfile, depth ); - fprintf( cfile, "\n" ); - } -} - - -bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -const TiXmlAttribute* TiXmlAttribute::Next() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} - -/* -TiXmlAttribute* TiXmlAttribute::Next() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} -*/ - -const TiXmlAttribute* TiXmlAttribute::Previous() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} - -/* -TiXmlAttribute* TiXmlAttribute::Previous() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} -*/ - -void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - TIXML_STRING n, v; - - EncodeString( name, &n ); - EncodeString( value, &v ); - - if (value.find ('\"') == TIXML_STRING::npos) { - if ( cfile ) { - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; - } - } - else { - if ( cfile ) { - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; - } - } -} - - -int TiXmlAttribute::QueryIntValue( int* ival ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -int TiXmlAttribute::QueryDoubleValue( double* dval ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -void TiXmlAttribute::SetIntValue( int _value ) -{ - char buf [64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); - #else - sprintf (buf, "%d", _value); - #endif - SetValue (buf); -} - -void TiXmlAttribute::SetDoubleValue( double _value ) -{ - char buf [256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value); - #else - sprintf (buf, "%lf", _value); - #endif - SetValue (buf); -} - -int TiXmlAttribute::IntValue() const -{ - return atoi (value.c_str ()); -} - -double TiXmlAttribute::DoubleValue() const -{ - return atof (value.c_str ()); -} - - -TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlComment::operator=( const TiXmlComment& base ) -{ - Clear(); - base.CopyTo( this ); -} - - -void TiXmlComment::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( int i=0; i<depth; i++ ) - { - fprintf( cfile, " " ); - } - fprintf( cfile, "<!--%s-->", value.c_str() ); -} - - -void TiXmlComment::CopyTo( TiXmlComment* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlComment::Clone() const -{ - TiXmlComment* clone = new TiXmlComment(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlText::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - if ( cdata ) - { - int i; - fprintf( cfile, "\n" ); - for ( i=0; i<depth; i++ ) { - fprintf( cfile, " " ); - } - fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() ); // unformatted output - } - else - { - TIXML_STRING buffer; - EncodeString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); - } -} - - -void TiXmlText::CopyTo( TiXmlText* target ) const -{ - TiXmlNode::CopyTo( target ); - target->cdata = cdata; -} - - -bool TiXmlText::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlText::Clone() const -{ - TiXmlText* clone = 0; - clone = new TiXmlText( "" ); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlDeclaration::TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} - - -#ifdef TIXML_USE_STL -TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} -#endif - - -TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - if ( cfile ) fprintf( cfile, "<?xml " ); - if ( str ) (*str) += "<?xml "; - - if ( !version.empty() ) { - if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ()); - if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; } - } - if ( !encoding.empty() ) { - if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ()); - if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; } - } - if ( !standalone.empty() ) { - if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ()); - if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; } - } - if ( cfile ) fprintf( cfile, "?>" ); - if ( str ) (*str) += "?>"; -} - - -void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->version = version; - target->encoding = encoding; - target->standalone = standalone; -} - - -bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlDeclaration::Clone() const -{ - TiXmlDeclaration* clone = new TiXmlDeclaration(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlUnknown::Print( FILE* cfile, int depth ) const -{ - for ( int i=0; i<depth; i++ ) - fprintf( cfile, " " ); - fprintf( cfile, "<%s>", value.c_str() ); -} - - -void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlUnknown::Clone() const -{ - TiXmlUnknown* clone = new TiXmlUnknown(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlAttributeSet::TiXmlAttributeSet() -{ - sentinel.next = &sentinel; - sentinel.prev = &sentinel; -} - - -TiXmlAttributeSet::~TiXmlAttributeSet() -{ - assert( sentinel.next == &sentinel ); - assert( sentinel.prev == &sentinel ); -} - - -void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) -{ - #ifdef TIXML_USE_STL - assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. - #else - assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. - #endif - - addMe->next = &sentinel; - addMe->prev = sentinel.prev; - - sentinel.prev->next = addMe; - sentinel.prev = addMe; -} - -void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) -{ - TiXmlAttribute* node; - - for( node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node == removeMe ) - { - node->prev->next = node->next; - node->next->prev = node->prev; - node->next = 0; - node->prev = 0; - return; - } - } - assert( 0 ); // we tried to remove a non-linked attribute. -} - - -#ifdef TIXML_USE_STL -const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const -{ - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} - -/* -TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} -*/ -#endif - - -const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const -{ - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} - -/* -TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} -*/ - -#ifdef TIXML_USE_STL -std::istream& operator>> (std::istream & in, TiXmlNode & base) -{ - TIXML_STRING tag; - tag.reserve( 8 * 1000 ); - base.StreamIn( &in, &tag ); - - base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); - return in; -} -#endif - - -#ifdef TIXML_USE_STL -std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out << printer.Str(); - - return out; -} - - -std::string& operator<< (std::string& out, const TiXmlNode& base ) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out.append( printer.Str() ); - - return out; -} -#endif - - -TiXmlHandle TiXmlHandle::FirstChild() const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement() const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild(); - for ( i=0; - child && i<count; - child = child->NextSibling(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild( value ); - for ( i=0; - child && i<count; - child = child->NextSibling( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement(); - for ( i=0; - child && i<count; - child = child->NextSiblingElement(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement( value ); - for ( i=0; - child && i<count; - child = child->NextSiblingElement( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) -{ - DoIndent(); - buffer += "<"; - buffer += element.Value(); - - for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) - { - buffer += " "; - attrib->Print( 0, 0, &buffer ); - } - - if ( !element.FirstChild() ) - { - buffer += " />"; - DoLineBreak(); - } - else - { - buffer += ">"; - if ( element.FirstChild()->ToText() - && element.LastChild() == element.FirstChild() - && element.FirstChild()->ToText()->CDATA() == false ) - { - simpleTextPrint = true; - // no DoLineBreak()! - } - else - { - DoLineBreak(); - } - } - ++depth; - return true; -} - - -bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) -{ - --depth; - if ( !element.FirstChild() ) - { - // nothing. - } - else - { - if ( simpleTextPrint ) - { - simpleTextPrint = false; - } - else - { - DoIndent(); - } - buffer += "</"; - buffer += element.Value(); - buffer += ">"; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlText& text ) -{ - if ( text.CDATA() ) - { - DoIndent(); - buffer += "<![CDATA["; - buffer += text.Value(); - buffer += "]]>"; - DoLineBreak(); - } - else if ( simpleTextPrint ) - { - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - } - else - { - DoIndent(); - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) -{ - DoIndent(); - declaration.Print( 0, 0, &buffer ); - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlComment& comment ) -{ - DoIndent(); - buffer += "<!--"; - buffer += comment.Value(); - buffer += "-->"; - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) -{ - DoIndent(); - buffer += "<"; - buffer += unknown.Value(); - buffer += ">"; - DoLineBreak(); - return true; -} - Deleted: trunk/mmex/src/tinyxmlerror.cpp =================================================================== --- trunk/mmex/src/tinyxmlerror.cpp 2009-11-28 13:10:55 UTC (rev 826) +++ trunk/mmex/src/tinyxmlerror.cpp 2009-11-28 13:12:30 UTC (rev 827) @@ -1,53 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include "tinyxml.h" - -// The goal of the seperate error file is to make the first -// step towards localization. tinyxml (currently) only supports -// english error messages, but the could now be translated. -// -// It also cleans up the code a bit. -// - -const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = -{ - "No error", - "Error", - "Failed to open file", - "Memory allocation failed.", - "Error parsing Element.", - "Failed to read Element name", - "Error reading Element value.", - "Error reading Attributes.", - "Error: empty tag.", - "Error reading end tag.", - "Error parsing Unknown.", - "Error parsing Comment.", - "Error parsing Declaration.", - "Error document empty.", - "Error null (0) or unexpected EOF found in input stream.", - "Error parsing CDATA.", - "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", -}; Deleted: trunk/mmex/src/tinyxmlparser.cpp =================================================================== --- trunk/mmex/src/tinyxmlparser.cpp 2009-11-28 13:10:55 UTC (rev 826) +++ trunk/mmex/src/tinyxmlparser.cpp 2009-11-28 13:12:30 UTC (rev 827) @@ -1,1638 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include <ctype.h> -#include <stddef.h> - -#include "tinyxml.h" - -//#define DEBUG_PARSER -#if defined( DEBUG_PARSER ) -# if defined( DEBUG ) && defined( _MSC_VER ) -# include <windows.h> -# define TIXML_LOG OutputDebugString -# else -# define TIXML_LOG printf -# endif -#endif - -// Note tha "PutString" hardcodes the same list. This -// is less flexible than it appears. Changing the entries -// or order will break putstring. -TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = -{ - { "&", 5, '&' }, - { "<", 4, '<' }, - { ">", 4, '>' }, - { """, 6, '\"' }, - { "'", 6, '\'' } -}; - -// Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html -// Including the basic of this table, which determines the #bytes in the -// sequence from the lead byte. 1 placed for invalid sequences -- -// although the result will be junk, pass it through as much as possible. -// Beware of the non-characters in UTF-8: -// ef bb bf (Microsoft "lead bytes") -// ef bf be -// ef bf bf - -const unsigned char TIXML_UTF_LEAD_0 = 0xefU; -const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; -const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - -const int TiXmlBase::utf8ByteTable[256] = -{ - // 0 1 2 3 4 5 6 7 8 9 a b c d e f - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte - 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid -}; - - -void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) -{ - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) - *length = 1; - else if ( input < 0x800 ) - *length = 2; - else if ( input < 0x10000 ) - *length = 3; - else if ( input < 0x200000 ) - *length = 4; - else - { *length = 0; return; } // This code won't covert this correctly anyway. - - output += *length; - - // Scary scary fall throughs. - switch (*length) - { - case 4: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 3: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 2: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 1: - --output; - *output = (char)(input | FIRST_BYTE_MARK[*length]); - } -} - - -/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalpha( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalpha( anyByte ); -// } -} - - -/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalnum( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalnum( anyByte ); -// } -} - - -class TiXmlParsingData -{ - friend class TiXmlDocument; - public: - void Stamp( const char* now, TiXmlEncoding encoding ); - - const TiXmlCursor& Cursor() { return cursor; } - - private: - // Only used by the document! - TiXmlParsingData( const char* start, int _tabsize, int row, int col ) - { - assert( start ); - stamp = start; - tabsize = _tabsize; - cursor.row = row; - cursor.col = col; - } - - TiXmlCursor cursor; - const char* stamp; - int tabsize; -}; - - -void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) -{ - assert( now ); - - // Do nothing if the tabsize is 0. - if ( tabsize < 1 ) - { - return; - } - - // Get the current row, column. - int row = cursor.row; - int col = cursor.col; - const char* p = stamp; - assert( p ); - - while ( p < now ) - { - // Treat p as unsigned, so we have a happy compiler. - const unsigned char* pU = (const unsigned char*)p; - - // Code contributed by Fletcher Dunn: (modified by lee) - switch (*pU) { - case 0: - // We *should* never get here, but in case we do, don't - // advance past the terminating null character, ever - return; - - case '\r': - // bump down to the next line - ++row; - col = 0; - // Eat the character - ++p; - - // Check for \r\n sequence, and treat this as a single character - if (*p == '\n') { - ++p; - } - break; - - case '\n': - // bump down to the next line - ++row; - col = 0; - - // Eat the character - ++p; - - // Check for \n\r sequence, and treat this as a single - // character. (Yes, this bizarre thing does occur still - // on some arcane platforms...) - if (*p == '\r') { - ++p; - } - break; - - case '\t': - // Eat the character - ++p; - - // Skip to next tab stop - col = (col / tabsize + 1) * tabsize; - break; - - case TIXML_UTF_LEAD_0: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( *(p+1) && *(p+2) ) - { - // In these cases, don't advance the column. These are - // 0-width spaces. - if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) - p += 3; - else - { p +=3; ++col; } // A normal character. - } - } - else - { - ++p; - ++col; - } - break; - - default: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // Eat the 1 to 4 byte utf8 character. - int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; - if ( step == 0 ) - step = 1; // Error case from bad encoding, but handle gracefully. - p += step; - - // Just advance one column, of course. - ++col; - } - else - { - ++p; - ++col; - } - break; - } - } - cursor.row = row; - cursor.col = col; - assert( cursor.row >= -1 ); - assert( cursor.col >= -1 ); - stamp = p; - assert( stamp ); -} - - -const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) -{ - if ( !p || !*p ) - { - return 0; - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - while ( *p ) - { - const unsigned char* pU = (const unsigned char*)p; - - // Skip the stupid Microsoft UTF-8 Byte order marks - if ( *(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==TIXML_UTF_LEAD_1 - && *(pU+2)==TIXML_UTF_LEAD_2 ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbeU ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbfU ) - { - p += 3; - continue; - } - - if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. - ++p; - else - break; - } - } - else - { - while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) - ++p; - } - - return p; -} - -#ifdef TIXML_USE_STL -/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) -{ - for( ;; ) - { - if ( !in->good() ) return false; - - int c = in->peek(); - // At this scope, we can't get to a document. So fail silently. - if ( !IsWhiteSpace( c ) || c <= 0 ) - return true; - - *tag += (char) in->get(); - } -} - -/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) -{ - //assert( character > 0 && character < 128 ); // else it won't work in utf-8 - while ( in->good() ) - { - int c = in->peek(); - if ( c == character ) - return true; - if ( c <= 0 ) // Silent failure: can't get document at this scope - return false; - - in->get(); - *tag += (char) c; - } - return false; -} -#endif - -// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The -// "assign" optimization removes over 10% of the execution time. -// -const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) -{ - // Oddly, not supported on some comilers, - //name->clear(); - // So use this: - *name = ""; - assert( p ); - - // Names start with letters or underscores. - // Of course, in unicode, tinyxml has no idea what a letter *is*. The - // algorithm is generous. - // - // After that, they can be letters, underscores, numbers, - // hyphens, or colons. (Colons are valid ony for namespaces, - // but tinyxml can't tell namespaces from names.) - if ( p && *p - && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) - { - const char* start = p; - while( p && *p - && ( IsAlphaNum( (unsigned char ) *p, encoding ) - || *p == '_' - || *p == '-' - || *p == '.' - || *p == ':' ) ) - { - //(*name) += *p; // expensive - ++p; - } - if ( p-start > 0 ) { - name->assign( start, p-start ); - } - return p; - } - return 0; -} - -const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) -{ - // Presume an entity, and pull it out. - TIXML_STRING ent; - int i; - *length = 0; - - if ( *(p+1) && *(p+1) == '#' && *(p+2) ) - { - unsigned long ucs = 0; - ptrdiff_t delta = 0; - unsigned mult = 1; - - if ( *(p+2) == 'x' ) - { - // Hexadecimal. - if ( !*(p+3) ) return 0; - - const char* q = p+3; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != 'x' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else if ( *q >= 'a' && *q <= 'f' ) - ucs += mult * (*q - 'a' + 10); - else if ( *q >= 'A' && *q <= 'F' ) - ucs += mult * (*q - 'A' + 10 ); - else - return 0; - mult *= 16; - --q; - } - } - else - { - // Decimal. - if ( !*(p+2) ) return 0; - - const char* q = p+2; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != '#' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else - return 0; - mult *= 10; - --q; - } - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - } - else - { - *value = (char)ucs; - *length = 1; - } - return p + delta + 1; - } - - // Now try to match it. - for( i=0; i<NUM_ENTITY; ++i ) - { - if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 ) - { - assert( strlen( entity[i].str ) == entity[i].strLength ); - *value = entity[i].chr; - *length = 1; - return ( p + entity[i].strLength ); - } - } - - // So it wasn't an entity, its unrecognized, or something like that. - *value = *p; // Don't put back the last one, since we return it! - //*length = 1; // Leave unrecognized entities - this doesn't really work. - // Just writes strange XML. - return p+1; -} - - -bool TiXmlBase::StringEqual( const char* p, - const char* tag, - bool ignoreCase, - TiXmlEncoding encoding ) -{ - assert( p ); - assert( tag ); - if ( !p || !*p ) - { - assert( 0 ); - return false; - } - - const char* q = p; - - if ( ignoreCase ) - { - while ( *q && *tag && ToLower( *q, encoding ) == ToLower( *tag, encoding ) ) - { - ++q; - ++tag; - } - - if ( *tag == 0 ) - return true; - } - else - { - while ( *q && *tag && *q == *tag ) - { - ++q; - ++tag; - } - - if ( *tag == 0 ) // Have we found the end of the tag, and everything equal? - return true; - } - return false; -} - -const char* TiXmlBase::ReadText( const char* p, - TIXML_STRING * text, - bool trimWhiteSpace, - const char* endTag, - bool caseInsensitive, - TiXmlEncoding encoding ) -{ - *text = ""; - if ( !trimWhiteSpace // certain tags always keep whitespace - || !condenseWhiteSpace ) // if true, whitespace is always kept - { - // Keep all the white space. - while ( p && *p - && !StringEqual( p, endTag, caseInsensitive, encoding ) - ) - { - int len; - char cArr[4] = { 0, 0, 0, 0 }; - p = GetChar( p, cArr, &len, encoding ); - text->append( cArr, len ); - } - } - else - { - bool whitespace = false; - - // Remove leading white space: - p = SkipWhiteSpace( p, encoding ); - while ( p && *p - && !StringEqual( p, endTag, caseInsensitive, encoding ) ) - { - if ( *p == '\r' || *p == '\n' ) - { - whitespace = true; - ++p; - } - else if ( IsWhiteSpace( *p ) ) - { - whitespace = true; - ++p; - } - else - { - // If we've found whitespace, add it before the - // new character. Any whitespace just becomes a space. - if ( whitespace ) - { - (*text) += ' '; - whitespace = false; - } - int len; - char cArr[4] = { 0, 0, 0, 0 }; - p = GetChar( p, cArr, &len, encoding ); - if ( len == 1 ) - (*text) += cArr[0]; // more efficient - else - text->append( cArr, len ); - } - } - } - if ( p ) - p += strlen( endTag ); - return p; -} - -#ifdef TIXML_USE_STL - -void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - // The basic issue with a document is that we don't know what we're - // streaming. Read something presumed to be a tag (and hope), then - // identify it, and call the appropriate stream method on the tag. - // - // This "pre-streaming" will ne... [truncated message content] |
From: <kkk...@us...> - 2009-11-29 13:06:42
|
Revision: 837 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=837&view=rev Author: kkkvadim Date: 2009-11-29 13:06:32 +0000 (Sun, 29 Nov 2009) Log Message: ----------- +wxFileName GetLogDir(bool create); Modified Paths: -------------- trunk/mmex/src/paths.cpp trunk/mmex/src/platfdep.h Modified: trunk/mmex/src/paths.cpp =================================================================== --- trunk/mmex/src/paths.cpp 2009-11-29 11:43:41 UTC (rev 836) +++ trunk/mmex/src/paths.cpp 2009-11-29 13:06:32 UTC (rev 837) @@ -41,6 +41,19 @@ } //---------------------------------------------------------------------------- +wxFileName mmex::GetLogDir(bool create) +{ + static wxFileName fname; + + if (!fname.IsOk()) { + fname = GetUserDir(create); + fname.AppendDir(wxT("logs")); + } + + return fname; +} +//---------------------------------------------------------------------------- + wxString mmex::getPathDoc(EDocFile f) { static const wxChar* files[DOC_FILES_MAX] = { Modified: trunk/mmex/src/platfdep.h =================================================================== --- trunk/mmex/src/platfdep.h 2009-11-29 11:43:41 UTC (rev 836) +++ trunk/mmex/src/platfdep.h 2009-11-29 13:06:32 UTC (rev 837) @@ -35,7 +35,9 @@ wxFileName GetResourceDir(); wxFileName GetSharedDir(); wxFileName GetUserDir(bool create); +wxFileName GetLogDir(bool create); + /* wxStandardPaths uses wxApp::GetAppName(), so you should call wxApp::SetAppName(mmex::GetAppName()) in wxApp::OnInit(). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-29 13:08:48
|
Revision: 838 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=838&view=rev Author: kkkvadim Date: 2009-11-29 13:08:40 +0000 (Sun, 29 Nov 2009) Log Message: ----------- -wxString mmGetBaseWorkingPath(bool ignoreCommandLine = false); Modified Paths: -------------- trunk/mmex/src/mmex.cpp trunk/mmex/src/qifimport.cpp trunk/mmex/src/univcsvdialog.cpp trunk/mmex/src/util.cpp trunk/mmex/src/util.h Modified: trunk/mmex/src/mmex.cpp =================================================================== --- trunk/mmex/src/mmex.cpp 2009-11-29 13:06:32 UTC (rev 837) +++ trunk/mmex/src/mmex.cpp 2009-11-29 13:08:40 UTC (rev 838) @@ -589,53 +589,22 @@ menuItemOnlineUpdateCurRate_->Enable(false); } - /* Decide if we need to show app start dialog */ - wxString showBeginApp = mmDBWrapper::getINISettingValue(inidb_.get(), - wxT("SHOWBEGINAPP"), wxT("TRUE")); - if (showBeginApp == wxT("TRUE")) - { - /* No Previous File */ + // decide if we need to show app start dialog + wxString showBeginApp = mmDBWrapper::getINISettingValue(inidb_.get(), wxT("SHOWBEGINAPP"), wxT("TRUE")); + bool from_scratch = showBeginApp == wxT("TRUE"); + + wxFileName dbpath = from_scratch ? wxGetEmptyString() : + mmDBWrapper::getINISettingValue(inidb_.get(), wxT("LASTFILENAME")); + + + if (from_scratch || !dbpath.IsOk()) { menuEnableItems(false); createHomePage(); updateNavTreeControl(); - - /* Show Begin App Dialog */ showBeginAppDialog(); + } else { + openFile(dbpath.GetFullPath(), false); } - else - { - /* Try loading last db if it exists */ - wxString val = mmDBWrapper::getINISettingValue(inidb_.get(), - wxT("LASTFILENAME"), wxGetEmptyString()); - if (!val.IsEmpty()) - { - /* Try Opening the file */ - wxFileName fName(val); - wxString absName; - - /* Relative paths don't work well in Linux, so using it only - for Windows */ -#if defined (__WXGTK__) || defined (__WXMAC__) - absName = fName.GetFullPath(); -#else - wxFileName appPath(mmGetBaseWorkingPath(true)); - fName.Normalize( wxPATH_NORM_ALL, appPath.GetPath()); - absName = fName.GetFullPath(); -#endif - - openFile(absName, false); - } - else - { - /* No Previous File */ - menuEnableItems(false); - createHomePage(); - updateNavTreeControl(); - - /* Show Begin App Dialog */ - showBeginAppDialog(); - } - } } //---------------------------------------------------------------------------- @@ -680,44 +649,38 @@ } //---------------------------------------------------------------------------- +/* + Save our settings to ini db. +*/ void mmGUIFrame::saveConfigFile() { - /* Save our settings to ini db */ - wxFileName appPath(mmGetBaseWorkingPath(true)); wxFileName fname(fileName_); + mmDBWrapper::setINISettingValue(inidb_.get(), wxT("LASTFILENAME"), fname.GetFullPath()); -#if defined (__WXGTK__) || defined (__WXMAC__) - -#else - /*bool makeRelative = */fname.MakeRelativeTo(appPath.GetPath()); -#endif - mmDBWrapper::setINISettingValue(inidb_.get(), - wxT("LASTFILENAME"), fname.GetFullPath()); - mmSaveColorsToDatabase(inidb_.get()); - bool isMax = this->IsMaximized(); - wxString isMaxStr = wxT("FALSE"); - if (isMax) - isMaxStr = wxT("TRUE"); - /* Aui Settings */ m_perspective = m_mgr.SavePerspective(); - mmDBWrapper::setINISettingValue(inidb_.get(), - wxT("AUIPERSPECTIVE"), m_perspective); + mmDBWrapper::setINISettingValue(inidb_.get(), wxT("AUIPERSPECTIVE"), m_perspective); - int valx, valy, valw, valh; + int valx = 0; + int valy = 0; + int valw = 0; + int valh = 0; + this->GetPosition(&valx, &valy); this->GetSize(&valw, &valh); + wxString valxs = wxString::Format(wxT("%d"), valx); wxString valys = wxString::Format(wxT("%d"), valy); wxString valws = wxString::Format(wxT("%d"), valw); wxString valhs = wxString::Format(wxT("%d"), valh); + mmDBWrapper::setINISettingValue(inidb_.get(), wxT("ORIGINX"), valxs); mmDBWrapper::setINISettingValue(inidb_.get(), wxT("ORIGINY"), valys); mmDBWrapper::setINISettingValue(inidb_.get(), wxT("SIZEW"), valws); mmDBWrapper::setINISettingValue(inidb_.get(), wxT("SIZEH"), valhs); - mmDBWrapper::setINISettingValue(inidb_.get(), wxT("ISMAXIMIZED"), isMaxStr); + mmDBWrapper::setINISettingValue(inidb_.get(), wxT("ISMAXIMIZED"), this->IsMaximized() ? wxT("TRUE") : wxT("FALSE")); } //---------------------------------------------------------------------------- @@ -3428,43 +3391,36 @@ { mmAppStartDialog *dlg = new mmAppStartDialog(inidb_.get(), this); dlg->ShowModal(); - - if (dlg->getReturnCode() == 0) + int rc = dlg->getReturnCode(); + + if (rc == 0) { wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_NEW); AddPendingEvent(evt); } - else if (dlg->getReturnCode() == 1) + else if (rc == 1) { wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_OPEN); AddPendingEvent(evt); } - else if (dlg->getReturnCode() == 2) + else if (rc == 2) { wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, wxID_HELP); AddPendingEvent(evt); } - else if (dlg->getReturnCode() == 3) + else if (rc == 3) { wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_REPORTISSUES); AddPendingEvent(evt); } - else if (dlg->getReturnCode() == 4) + else if (rc == 4) { - wxString val = mmDBWrapper::getINISettingValue(inidb_.get(), - wxT("LASTFILENAME"), wxGetEmptyString()); - if (!val.IsEmpty()) - { - /* Try Opening the file */ - wxFileName fName(val); - wxFileName appPath(mmGetBaseWorkingPath(true)); - fName.Normalize( wxPATH_NORM_ALL, appPath.GetPath()); - wxString absName = fName.GetFullPath(); - if (!absName.IsEmpty()) - openFile(absName, false); + wxFileName fname(mmDBWrapper::getINISettingValue(inidb_.get(), wxT("LASTFILENAME"))); + if (fname.IsOk()) { + openFile(fname.GetFullPath(), false); } } - else if (dlg->getReturnCode() == -1) + else if (rc == -1) { /* Do Nothing in this case */ } Modified: trunk/mmex/src/qifimport.cpp =================================================================== --- trunk/mmex/src/qifimport.cpp 2009-11-29 13:06:32 UTC (rev 837) +++ trunk/mmex/src/qifimport.cpp 2009-11-29 13:08:40 UTC (rev 838) @@ -219,6 +219,7 @@ #include "fileviewerdialog.h" #include "mmex.h" #include "mmcoredb.h" +#include "platfdep.h" namespace { @@ -402,16 +403,16 @@ wxT(""), wxT(""), wxT(""), wxT("*.qif"), wxFILE_MUST_EXIST); if ( !fileName.IsEmpty() ) { - wxFileInputStream input( fileName ); - wxTextInputStream text( input ); + wxFileInputStream input(fileName); + wxTextInputStream text(input); - /* Create Log File */ - wxFileName csvName(fileName); - wxString logFile = mmGetBaseWorkingPath() + wxT("\\") - + csvName.GetName() + wxT(".txt"); - wxFileOutputStream outputLog( logFile ); - wxTextOutputStream log( outputLog ); + wxFileName logFile = mmex::GetLogDir(true); + logFile.SetFullName(fileName); + logFile.SetExt(wxT(".txt")); + wxFileOutputStream outputLog(logFile.GetFullPath()); + wxTextOutputStream log(outputLog); + wxString readLine; int numLines = 0; int numImported = 0; @@ -710,7 +711,7 @@ outputLog.Close(); - fileviewer* dlg = new fileviewer(logFile, 0); + fileviewer *dlg = new fileviewer(logFile.GetFullPath(), 0); dlg->ShowModal(); dlg->Destroy(); } Modified: trunk/mmex/src/univcsvdialog.cpp =================================================================== --- trunk/mmex/src/univcsvdialog.cpp 2009-11-29 13:06:32 UTC (rev 837) +++ trunk/mmex/src/univcsvdialog.cpp 2009-11-29 13:08:40 UTC (rev 838) @@ -21,6 +21,7 @@ #include "fileviewerdialog.h" #include "defs.h" #include "paths.h" +#include "platfdep.h" IMPLEMENT_DYNAMIC_CLASS( mmUnivCSVImportDialog, wxDialog ) @@ -59,7 +60,7 @@ { wxString toReturn = orig; toReturn.Replace(wxT("'"), wxT("`")); - toReturn.Replace(wxT("\""), wxT("")); + toReturn.Replace(wxT("\""), wxGetEmptyString()); toReturn.Trim(); return toReturn; } @@ -322,7 +323,7 @@ void mmUnivCSVImportDialog::OnLoad(wxCommandEvent& /*event*/) { wxString fileName = wxFileSelector(wxT("Choose Universal CSV format file to load"), - wxT(""), wxT(""), wxT(""), wxT("CSV Template(*.mcv)|*.mcv"), wxFILE_MUST_EXIST); + wxGetEmptyString(), wxGetEmptyString(), wxGetEmptyString(), wxT("CSV Template(*.mcv)|*.mcv"), wxFILE_MUST_EXIST); if ( !fileName.empty() ) { wxTextFile tFile(fileName); @@ -358,7 +359,7 @@ void mmUnivCSVImportDialog::OnSave(wxCommandEvent& /*event*/) { wxString fileName = wxFileSelector(wxT("Choose Universal CSV format file to save"), - wxT(""), wxT(""), wxT(""), wxT("CSV Template(*.mcv)|*.mcv"), wxSAVE); + wxGetEmptyString(), wxGetEmptyString(), wxGetEmptyString(), wxT("CSV Template(*.mcv)|*.mcv"), wxSAVE); if ( !fileName.empty() ) { wxTextFile tFile(fileName); @@ -437,19 +438,19 @@ mmCurrencyFormatter::loadSettings(pCurrencyPtr); wxString fileName = wxFileSelector(_("Choose MM.NET CSV data file to import"), - wxT(""), wxT(""), wxT(""), wxT("*.csv"), wxFILE_MUST_EXIST); + wxGetEmptyString(), wxGetEmptyString(), wxGetEmptyString(), wxT("*.csv"), wxFILE_MUST_EXIST); if ( !fileName.IsEmpty() ) { - wxFileInputStream input( fileName ); - wxTextInputStream text( input ); + wxFileInputStream input(fileName); + wxTextInputStream text(input); - /* Create Log File */ - wxFileName csvName(fileName); - wxString logFile = mmGetBaseWorkingPath() + wxT("\\") - + csvName.GetName() + wxT(".txt"); - wxFileOutputStream outputLog( logFile ); - wxTextOutputStream log( outputLog ); + wxFileName logFile = mmex::GetLogDir(true); + logFile.SetFullName(fileName); + logFile.SetExt(wxT(".txt")); + wxFileOutputStream outputLog(logFile.GetFullPath()); + wxTextOutputStream log(outputLog); + /* date, payeename, amount(+/-), Number, status, category : subcategory, notes */ int countNumTotal = 0; @@ -458,18 +459,18 @@ { wxString line = text.ReadLine(); if (!line.IsEmpty()) - countNumTotal++; + ++countNumTotal; else continue; - dt_ = wxT(""); - payee_ = wxT(""); - type_ = wxT(""); - amount_ = wxT(""); - categ_ = wxT(""); - subcateg_ = wxT(""); - transNum_ = wxT(""); - notes_ = wxT(""); + dt_.clear(); + payee_.clear(); + type_.clear(); + amount_.clear(); + categ_.clear(); + subcateg_.clear(); + transNum_.clear(); + notes_.clear(); payeeID_ = -1; categID_ = -1; subCategID_ = -1; @@ -560,11 +561,11 @@ log << _("Line : " ) << countNumTotal << _(" imported OK.") << endl; } - wxString msg = wxString::Format(_("Total Lines : %d \nTotal Imported : %d\n\nLog file written to : %s.\n\nImported transactions have been flagged so you can review them. "), countNumTotal, countImported, logFile.c_str()); + wxString msg = wxString::Format(_("Total Lines : %d \nTotal Imported : %d\n\nLog file written to : %s.\n\nImported transactions have been flagged so you can review them. "), countNumTotal, countImported, logFile.GetFullPath().c_str()); mmShowErrorMessage(0, msg, _("Import from CSV")); outputLog.Close(); - fileviewer* dlg = new fileviewer(logFile, 0); + fileviewer* dlg = new fileviewer(logFile.GetFullPath(), 0); dlg->ShowModal(); dlg->Destroy(); Modified: trunk/mmex/src/util.cpp =================================================================== --- trunk/mmex/src/util.cpp 2009-11-29 13:06:32 UTC (rev 837) +++ trunk/mmex/src/util.cpp 2009-11-29 13:08:40 UTC (rev 838) @@ -24,10 +24,10 @@ #include "univcsvdialog.h" #include "mmcoredb.h" #include "paths.h" +#include "platfdep.h" #include "wxautocombobox.h" - +//---------------------------------------------------------------------------- #include <wx/sound.h> - //---------------------------------------------------------------------------- namespace @@ -193,24 +193,6 @@ } } -wxString mmGetBaseWorkingPath(bool ignoreCommandLine) -{ -#if defined (__WXMAC__) - wxString path = wxStandardPaths::Get().GetResourcesDir(); - return path; -#else - if (!ignoreCommandLine && (wxTheApp->argc > 1)) - { - wxString path = wxTheApp->argv[1]; - if (wxFileName::DirExists(path)) - return path; - } - wxFileName fname(wxTheApp->argv[0]); - return fname.GetPath(wxPATH_GET_VOLUME); -#endif -} - - /* locale.AddCatalog(lang) calls wxLogWarning and returns true for corrupted .mo file, so I should use locale.IsLoaded(lang) also. @@ -705,16 +687,16 @@ wxT(""), wxT(""), wxT(""), wxT("*.csv"), wxFILE_MUST_EXIST); if ( !fileName.empty() ) { - wxFileInputStream input( fileName ); - wxTextInputStream text( input ); + wxFileInputStream input(fileName); + wxTextInputStream text(input); - /* Create Log File */ - wxFileName csvName(fileName); - wxString logFile = mmGetBaseWorkingPath() + wxT("\\") - + csvName.GetName() + wxT(".txt"); - wxFileOutputStream outputLog( logFile ); - wxTextOutputStream log( outputLog ); + wxFileName logFile = mmex::GetLogDir(true); + logFile.SetFullName(fileName); + logFile.SetExt(wxT(".txt")); + wxFileOutputStream outputLog(logFile.GetFullPath()); + wxTextOutputStream log(outputLog); + // We have a fixed format for now // date, payeename, "withdrawal/deposit", amount, category, subcategory, transactionnumber, notes int countNumTotal = 0; @@ -723,19 +705,19 @@ { wxString line = text.ReadLine(); if (!line.IsEmpty()) - countNumTotal++; + ++countNumTotal; else continue; wxString dt = wxDateTime::Now().FormatISODate(); - wxString payee = wxT(""); - wxString type = wxT(""); - wxString amount = wxT(""); - wxString categ = wxT(""); - wxString subcateg = wxT(""); - wxString transNum = wxT(""); - wxString notes = wxT(""); - wxString transfer = wxT(""); + wxString payee; + wxString type; + wxString amount; + wxString categ; + wxString subcateg; + wxString transNum; + wxString notes; + wxString transfer; wxStringTokenizer tkz(line, delimit, wxTOKEN_RET_EMPTY_ALL); if (tkz.HasMoreTokens()) @@ -912,11 +894,11 @@ } // while EOF wxString msg = wxString::Format(_("Total Lines : %d.\nTotal Imported : %d\nLog file written to : %s.\n\nImported transactions have been flagged so you can review them."), - countNumTotal, countImported, logFile.c_str()); + countNumTotal, countImported, logFile.GetFullPath().c_str()); mmShowErrorMessage(0, msg, _("Import from CSV")); outputLog.Close(); - fileviewer* dlg = new fileviewer(logFile, 0); + fileviewer* dlg = new fileviewer(logFile.GetFullPath(), 0); dlg->ShowModal(); dlg->Destroy(); } @@ -961,20 +943,20 @@ boost::shared_ptr<mmCurrency> pCurrencyPtr = core->accountList_.getCurrencyWeakPtr(fromAccountID).lock(); wxASSERT(pCurrencyPtr); - wxString fileName = wxFileSelector(_("Choose MM.NET CSV data file to import"), - wxT(""), wxT(""), wxT(""), wxT("*.csv"), wxFILE_MUST_EXIST); + wxString fileName = wxFileSelector(_("Choose MM.NET CSV data file to import"), wxT(""), wxT(""), wxT(""), wxT("*.csv"), wxFILE_MUST_EXIST); + if ( !fileName.IsEmpty() ) { - wxFileInputStream input( fileName ); - wxTextInputStream text( input ); + wxFileInputStream input(fileName); + wxTextInputStream text(input); - /* Create Log File */ - wxFileName csvName(fileName); - wxString logFile = mmGetBaseWorkingPath() + wxT("\\") - + csvName.GetName() + wxT(".txt"); - wxFileOutputStream outputLog( logFile ); - wxTextOutputStream log( outputLog ); + wxFileName logFile = mmex::GetLogDir(true); + logFile.SetFullName(fileName); + logFile.SetExt(wxT(".txt")); + wxFileOutputStream outputLog(logFile.GetFullPath()); + wxTextOutputStream log(outputLog); + /* The following is the MM.NET CSV format */ /* date, payeename, amount(+/-), Number, status, category : subcategory, notes */ int countNumTotal = 0; @@ -988,13 +970,13 @@ continue; wxString dt = wxDateTime::Now().FormatISODate(); - wxString payee = wxT(""); - wxString type = wxT(""); - wxString amount = wxT(""); - wxString categ = wxT(""); - wxString subcateg = wxT(""); - wxString transNum = wxT(""); - wxString notes = wxT(""); + wxString payee; + wxString type; + wxString amount; + wxString categ; + wxString subcateg; + wxString transNum; + wxString notes; wxStringTokenizer tkz(line, delimit, wxTOKEN_RET_EMPTY_ALL); if (tkz.HasMoreTokens()) @@ -1134,11 +1116,11 @@ log << _("Line : " ) << countNumTotal << _(" imported OK.") << endl; } // while EOF - wxString msg = wxString::Format(_("Total Lines : %d \nTotal Imported : %d\n\nLog file written to : %s.\n\nImported transactions have been flagged so you can review them. "), countNumTotal, countImported, logFile.c_str()); + wxString msg = wxString::Format(_("Total Lines : %d \nTotal Imported : %d\n\nLog file written to : %s.\n\nImported transactions have been flagged so you can review them. "), countNumTotal, countImported, logFile.GetFullPath().c_str()); mmShowErrorMessage(0, msg, _("Import from CSV")); outputLog.Close(); - fileviewer* dlg = new fileviewer(logFile, 0); + fileviewer* dlg = new fileviewer(logFile.GetFullPath(), 0); dlg->ShowModal(); dlg->Destroy(); } Modified: trunk/mmex/src/util.h =================================================================== --- trunk/mmex/src/util.h 2009-11-29 13:06:32 UTC (rev 837) +++ trunk/mmex/src/util.h 2009-11-29 13:08:40 UTC (rev 838) @@ -32,8 +32,6 @@ double amount; }; -wxString mmGetBaseWorkingPath(bool ignoreCommandLine = false); - void mmShowErrorMessageInvalid(wxWindow* parent, wxString message); void mmShowErrorMessage(wxWindow* parent, wxString message, wxString messageheader); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-11-29 15:28:21
|
Revision: 844 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=844&view=rev Author: kkkvadim Date: 2009-11-29 15:28:08 +0000 (Sun, 29 Nov 2009) Log Message: ----------- int -> size_t Modified Paths: -------------- trunk/mmex/src/payeedialog.cpp trunk/mmex/src/stockspanel.cpp Modified: trunk/mmex/src/payeedialog.cpp =================================================================== --- trunk/mmex/src/payeedialog.cpp 2009-11-29 15:05:11 UTC (rev 843) +++ trunk/mmex/src/payeedialog.cpp 2009-11-29 15:28:08 UTC (rev 844) @@ -107,7 +107,7 @@ { listBox_->Clear(); wxArrayString filtd = mmDBWrapper::filterPayees(core_->db_.get(),textCtrl->GetValue()); - for (int i=0; i < filtd.GetCount(); i++) + for (size_t i = 0; i < filtd.GetCount(); ++i) { listBox_->Append(filtd.Item(i)); } Modified: trunk/mmex/src/stockspanel.cpp =================================================================== --- trunk/mmex/src/stockspanel.cpp 2009-11-29 15:05:11 UTC (rev 843) +++ trunk/mmex/src/stockspanel.cpp 2009-11-29 15:28:08 UTC (rev 844) @@ -824,7 +824,7 @@ selectedIndex_ = event.GetIndex(); cp_->enableEditDeleteButtons(true); } -void stocksListCtrl::OnListItemDeselected(wxListEvent& event) +void stocksListCtrl::OnListItemDeselected(wxListEvent& /*event*/) { selectedIndex_ = -1; cp_->enableEditDeleteButtons(false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-12-06 10:16:58
|
Revision: 858 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=858&view=rev Author: kkkvadim Date: 2009-12-06 10:16:52 +0000 (Sun, 06 Dec 2009) Log Message: ----------- improvements in temp files generation Modified Paths: -------------- trunk/mmex/src/mmgraphgenerator.cpp trunk/mmex/src/mmgraphgenerator.h Modified: trunk/mmex/src/mmgraphgenerator.cpp =================================================================== --- trunk/mmex/src/mmgraphgenerator.cpp 2009-12-06 10:15:57 UTC (rev 857) +++ trunk/mmex/src/mmgraphgenerator.cpp 2009-12-06 10:16:52 UTC (rev 858) @@ -26,48 +26,69 @@ namespace { -class Deleter +class Eraser { public: - Deleter() : files(64) {} - ~Deleter(); + ~Eraser(); - void add(const wxString &f) { files.push_back(f); } - void delete_all(); + wxString getFilePath(mmGraphGenerator::EType type); + static Eraser& instance(); private: std::vector<wxString> files; + + Eraser() : files(mmGraphGenerator::TYPE_MAX) {} + void clear(); }; //---------------------------------------------------------------------------- -Deleter g_deleter; -//---------------------------------------------------------------------------- -Deleter::~Deleter() +Eraser::~Eraser() { try { - delete_all(); + clear(); } catch (...) { wxASSERT(false); } } //---------------------------------------------------------------------------- -void Deleter::delete_all() +void Eraser::clear() { for_each(files.begin(), files.end(), wxRemoveFile); + files.clear(); } //---------------------------------------------------------------------------- +/* + FIXME: do not create temp files in public temporary directory. +*/ +wxString Eraser::getFilePath(mmGraphGenerator::EType type) +{ + wxASSERT(type < mmGraphGenerator::TYPE_MAX); + + wxString &path = files[type]; + + if (path.empty()) { + path = wxFileName::CreateTempFileName(wxGetEmptyString()); + } + + return path; +} +//---------------------------------------------------------------------------- + +Eraser& Eraser::instance() +{ + static Eraser e; + return e; +} +//---------------------------------------------------------------------------- + } // namespace //---------------------------------------------------------------------------- -/* - FIXME: do not create temp files in public temporary directory. -*/ -mmGraphGenerator::mmGraphGenerator() : - m_htmlString(wxFileName::CreateTempFileName(wxGetEmptyString())) +mmGraphGenerator::mmGraphGenerator(EType type) : + m_path(Eraser::instance().getFilePath(type)) { - g_deleter.add(m_htmlString); } //---------------------------------------------------------------------------- Modified: trunk/mmex/src/mmgraphgenerator.h =================================================================== --- trunk/mmex/src/mmgraphgenerator.h 2009-12-06 10:15:57 UTC (rev 857) +++ trunk/mmex/src/mmgraphgenerator.h 2009-12-06 10:16:52 UTC (rev 858) @@ -24,14 +24,17 @@ class mmGraphGenerator { public: - mmGraphGenerator(); + enum EType { EXPENSES_MONTHS, PIE, TOP_CATEG, TYPE_MAX }; + + mmGraphGenerator(EType type); virtual ~mmGraphGenerator() {} virtual bool Generate(const wxString& chartTitle) = 0; - const wxString& GetOutputFileName() const { return m_htmlString; } + wxString getOutputFileName() const { return m_path; } + private: - wxString m_htmlString; + wxString m_path; }; -#endif +#endif // _MM_EX_GRAPHGENERATOR_H_ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-12-06 10:18:10
|
Revision: 859 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=859&view=rev Author: kkkvadim Date: 2009-12-06 10:18:02 +0000 (Sun, 06 Dec 2009) Log Message: ----------- currency_seed.db3 moved to resources dir Modified Paths: -------------- trunk/mmex/src/paths.cpp trunk/mmex/src/paths.h Modified: trunk/mmex/src/paths.cpp =================================================================== --- trunk/mmex/src/paths.cpp 2009-12-06 10:16:52 UTC (rev 858) +++ trunk/mmex/src/paths.cpp 2009-12-06 10:18:02 UTC (rev 859) @@ -80,7 +80,8 @@ static const wxChar* files[RES_FILES_MAX] = { wxT("mmex.ico"), wxT("splash.png"), - wxT("kaching.wav") + wxT("kaching.wav"), + wxT("currency_seed.db3") }; wxASSERT(sizeof(files)/sizeof(*files) == RES_FILES_MAX); @@ -96,7 +97,6 @@ wxString mmex::getPathShared(ESharedFile f) { static const wxChar* files[SHARED_FILES_MAX] = { - wxT("currency_seed.db3"), wxT("i18n") }; Modified: trunk/mmex/src/paths.h =================================================================== --- trunk/mmex/src/paths.h 2009-12-06 10:16:52 UTC (rev 858) +++ trunk/mmex/src/paths.h 2009-12-06 10:18:02 UTC (rev 859) @@ -34,13 +34,13 @@ enum EDocFile { F_README, F_CONTRIB, F_LICENSE, F_VERSION, HTML_INDEX, DOC_FILES_MAX }; wxString getPathDoc(EDocFile f); -enum EResFile { PROGRAM_ICON, SPLASH_ICON, TRANS_SOUND, RES_FILES_MAX }; +enum EResFile { PROGRAM_ICON, SPLASH_ICON, TRANS_SOUND, CURRENCY_DB_SEED, RES_FILES_MAX }; wxString getPathResource(EResFile f); // use instead of getPathResource(PROGRAM_ICON) const wxIcon& getProgramIcon(); -enum ESharedFile { CURRENCY_DB_SEED, LANG_DIR, SHARED_FILES_MAX }; +enum ESharedFile { LANG_DIR, SHARED_FILES_MAX }; wxString getPathShared(ESharedFile f); enum EUserFile { SETTINGS, USER_FILES_MAX }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kkk...@us...> - 2009-12-06 10:20:07
|
Revision: 861 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=861&view=rev Author: kkkvadim Date: 2009-12-06 10:19:59 +0000 (Sun, 06 Dec 2009) Log Message: ----------- minor changes Modified Paths: -------------- trunk/mmex/src/mmgraphincexpensesmonth.cpp trunk/mmex/src/mmgraphpie.cpp trunk/mmex/src/mmgraphtopcategories.cpp trunk/mmex/src/mmhomepagepanel.cpp trunk/mmex/src/reportcategexp.cpp trunk/mmex/src/reportincexpenses.cpp trunk/mmex/src/reportpayee.cpp Modified: trunk/mmex/src/mmgraphincexpensesmonth.cpp =================================================================== --- trunk/mmex/src/mmgraphincexpensesmonth.cpp 2009-12-06 10:18:49 UTC (rev 860) +++ trunk/mmex/src/mmgraphincexpensesmonth.cpp 2009-12-06 10:19:59 UTC (rev 861) @@ -3,6 +3,7 @@ #include <vector> mmGraphIncExpensesMonth::mmGraphIncExpensesMonth() : + mmGraphGenerator(EXPENSES_MONTHS), chart(new BarChart(200, 240)) { } @@ -25,5 +26,5 @@ bool mmGraphIncExpensesMonth::Generate(const wxString& chartTitle) { chart->Render(chartTitle); - return chart->Save(GetOutputFileName()); + return chart->Save(getOutputFileName()); } Modified: trunk/mmex/src/mmgraphpie.cpp =================================================================== --- trunk/mmex/src/mmgraphpie.cpp 2009-12-06 10:18:49 UTC (rev 860) +++ trunk/mmex/src/mmgraphpie.cpp 2009-12-06 10:19:59 UTC (rev 861) @@ -2,12 +2,20 @@ #include "chart.h" #include "util.h" +namespace +{ + bool sortValueList(const ValuePair& elem1, const ValuePair& elem2) { return fabs(elem1.amount) > fabs(elem2.amount); } -mmGraphPie::mmGraphPie() : chart(new PieChart(480, 320)) +} // namespace + + +mmGraphPie::mmGraphPie() : + mmGraphGenerator(PIE), + chart(new PieChart(480, 320)) { } @@ -32,5 +40,5 @@ bool mmGraphPie::Generate(const wxString& chartTitle) { chart->Render(chartTitle); - return chart->Save(GetOutputFileName()); + return chart->Save(getOutputFileName()); } Modified: trunk/mmex/src/mmgraphtopcategories.cpp =================================================================== --- trunk/mmex/src/mmgraphtopcategories.cpp 2009-12-06 10:18:49 UTC (rev 860) +++ trunk/mmex/src/mmgraphtopcategories.cpp 2009-12-06 10:19:59 UTC (rev 861) @@ -5,6 +5,7 @@ //---------------------------------------------------------------------------- mmGraphTopCategories::mmGraphTopCategories() : + mmGraphGenerator(TOP_CATEG), m_chart(new BarChart(320, 240)) { } @@ -38,6 +39,6 @@ bool mmGraphTopCategories::Generate(const wxString& chartTitle) { m_chart->Render(chartTitle); - return m_chart->Save(GetOutputFileName()); + return m_chart->Save(getOutputFileName()); } //---------------------------------------------------------------------------- Modified: trunk/mmex/src/mmhomepagepanel.cpp =================================================================== --- trunk/mmex/src/mmhomepagepanel.cpp 2009-12-06 10:18:49 UTC (rev 860) +++ trunk/mmex/src/mmhomepagepanel.cpp 2009-12-06 10:19:59 UTC (rev 861) @@ -314,7 +314,7 @@ hb.endTable(); // Add the graph - hb.addImage(gg.GetOutputFileName()); + hb.addImage(gg.getOutputFileName()); hb.endTableCell(); hb.endTableRow(); @@ -503,7 +503,7 @@ // Top 10 Graph. mmGraphTopCategories gtp; - hb.addImage(gtp.GetOutputFileName()); + hb.addImage(gtp.getOutputFileName()); */ hb.addLineBreak(); Modified: trunk/mmex/src/reportcategexp.cpp =================================================================== --- trunk/mmex/src/reportcategexp.cpp 2009-12-06 10:18:49 UTC (rev 860) +++ trunk/mmex/src/reportcategexp.cpp 2009-12-06 10:19:59 UTC (rev 861) @@ -72,7 +72,7 @@ // Add the graph mmGraphPie gg; - hb.addImage(gg.GetOutputFileName()); + hb.addImage(gg.getOutputFileName()); hb.startTable(wxT("50%")); hb.startTableRow(); Modified: trunk/mmex/src/reportincexpenses.cpp =================================================================== --- trunk/mmex/src/reportincexpenses.cpp 2009-12-06 10:18:49 UTC (rev 860) +++ trunk/mmex/src/reportincexpenses.cpp 2009-12-06 10:19:59 UTC (rev 861) @@ -58,7 +58,7 @@ mmGraphIncExpensesMonth gg; gg.init(income, expenses); gg.Generate(_("Income vs Expenses")); - hb.addImage(gg.GetOutputFileName()); + hb.addImage(gg.getOutputFileName()); hb.startTable(wxT("50%")); hb.startTableRow(); Modified: trunk/mmex/src/reportpayee.cpp =================================================================== --- trunk/mmex/src/reportpayee.cpp 2009-12-06 10:18:49 UTC (rev 860) +++ trunk/mmex/src/reportpayee.cpp 2009-12-06 10:19:59 UTC (rev 861) @@ -52,7 +52,7 @@ // Add the graph mmGraphPie gg; if (numPayees) - hb.addImage(gg.GetOutputFileName()); + hb.addImage(gg.getOutputFileName()); hb.startTable(wxT("50%")); hb.startTableRow(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2011-03-31 12:31:20
|
Revision: 1214 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=1214&view=rev Author: stef145g Date: 2011-03-31 12:31:14 +0000 (Thu, 31 Mar 2011) Log Message: ----------- Fix the reset of payee when changing withdrawal to deposit and Advanced Button Action Modified Paths: -------------- trunk/mmex/src/billsdepositsdialog.cpp trunk/mmex/src/billsdepositsdialog.h Modified: trunk/mmex/src/billsdepositsdialog.cpp =================================================================== --- trunk/mmex/src/billsdepositsdialog.cpp 2011-03-31 12:26:05 UTC (rev 1213) +++ trunk/mmex/src/billsdepositsdialog.cpp 2011-03-31 12:31:14 UTC (rev 1214) @@ -78,6 +78,8 @@ toTransAmount_ = -1; enterOccur_ = enterOccur; advancedToTransAmountSet_ = false; + payeeUnknown_ = true; + autoExecuteUserAck_ = false; autoExecuteSilent_ = false; @@ -105,6 +107,11 @@ dataToControls(); } + if (advancedToTransAmountSet_) + staticTextAdvancedActive_->Show(); + else + staticTextAdvancedActive_->Show(false); + Centre(); return TRUE; } @@ -271,6 +278,10 @@ bPayee_->SetLabel(fromAccount); bTo_->SetLabel(toAccount); payeeID_ = accountID_; + + // When editing an advanced transaction record, we do not reset the toTransAmount_ + if ((edit_ || enterOccur_) && (toTransAmount_ != transAmount)) + advancedToTransAmountSet_ = true; } } @@ -406,6 +417,10 @@ // bAdvanced_->SetToolTip(_("Specify advanced settings for transaction")); bAdvanced_->SetToolTip(_("Specify the transfer amount in the To Account")); + staticTextAdvancedActive_ = new wxStaticText( itemDialog1, wxID_STATIC, + _(" is active!"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer4->Add(staticTextAdvancedActive_, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 0); + wxPanel* itemPanel7 = new wxPanel( itemDialog1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); itemStaticBoxSizer14->Add(itemPanel7, 1, wxGROW|wxALL, 5); @@ -598,14 +613,18 @@ bPayee_->SetLabel(acctName); } - } else { - mmPayeeDialog dlg(this, core_); - if ( dlg.ShowModal() == wxID_OK ) + } + else + { + mmPayeeDialog dlg(this, core_); + + if ( dlg.ShowModal() == wxID_OK ) { payeeID_ = dlg.getPayeeId(); if (payeeID_ == -1) { bPayee_->SetLabel(wxT("Select Payee")); + payeeUnknown_ = true; return; } @@ -615,9 +634,9 @@ int tempCategID = -1; int tempSubCategID = -1; - wxString payeeName = mmDBWrapper::getPayee(db_, - payeeID_, tempCategID, tempSubCategID); - bPayee_->SetLabel(mmReadyDisplayString(payeeName)); + wxString payeeName = mmDBWrapper::getPayee(db_, payeeID_, tempCategID, tempSubCategID); + bPayee_->SetLabel(mmReadyDisplayString(payeeName)); + payeeUnknown_ = false; if (tempCategID == -1) { @@ -641,18 +660,20 @@ } else { - wxString payeeName = mmDBWrapper::getPayee(db_, payeeID_, categID_, subcategID_); - if (payeeName.IsEmpty()) + wxString payeeName = mmDBWrapper::getPayee(db_, payeeID_, categID_, subcategID_); + if (payeeName.IsEmpty()) { payeeID_ = -1; categID_ = -1; subcategID_ = -1; bCategory_->SetLabel(_("Select Category")); bPayee_->SetLabel(_("Select Payee")); + payeeUnknown_ = true; } else { bPayee_->SetLabel(payeeName); + payeeUnknown_ = false; } } @@ -694,19 +715,18 @@ void mmBDDialog::OnAdvanced(wxCommandEvent& /*event*/) { wxString dispString = textAmount_->GetValue(); - if (toTransAmount_ > 0.0) + if (toTransAmount_ >= 0.0) { mmex::formatDoubleToCurrencyEdit(toTransAmount_, dispString); } - wxTextEntryDialog dlg(this, _("To Account Amount Entry"), _("Amount to be recorded in To Account"), dispString); + wxTextEntryDialog dlg(this, _("Amount to be recorded in To Account"), _("To Account Amount Entry"), dispString); if ( dlg.ShowModal() == wxID_OK ) { wxString currText = dlg.GetValue().Trim(); if (!currText.IsEmpty()) { double amount; - if (!mmex::formatCurrencyToDouble(currText, amount) - || (amount < 0.0)) + if (!mmex::formatCurrencyToDouble(currText, amount) || (amount < 0.0)) { mmShowErrorMessage(this, _("Invalid To Amount Entered "), _("Error")); } @@ -714,6 +734,7 @@ { toTransAmount_ = amount; advancedToTransAmountSet_ = true; + staticTextAdvancedActive_->Show(); } } } @@ -800,37 +821,53 @@ if (choiceTrans_->GetSelection() == DEF_WITHDRAWAL) { - bPayee_->SetLabel(_("Select Payee")); fillControls(); st->Show(false); bTo_->Show(false); stp->SetLabel(_("Payee")); - payeeID_ = -1; - toID_ = -1; + if (payeeUnknown_) + { + bPayee_->SetLabel(_("Select Payee")); + payeeID_ = -1; + toID_ = -1; + } bAdvanced_->Enable(false); bPayee_->SetToolTip(_("Specify where the transaction is going to or coming from ")); textAmount_->SetToolTip(_("Specify the amount for this transaction")); } else if (choiceTrans_->GetSelection() == DEF_DEPOSIT) { - bPayee_->SetLabel(_("Select Payee")); fillControls(); bTo_->Show(false); st->Show(false); stp->SetLabel(_("From")); - payeeID_ = -1; - toID_ = -1; + if (payeeUnknown_) + { + bPayee_->SetLabel(_("Select Payee")); + payeeID_ = -1; + toID_ = -1; + } bAdvanced_->Enable(false); bPayee_->SetToolTip(_("Specify where the transaction is going to or coming from ")); textAmount_->SetToolTip(_("Specify the amount for this transaction")); } else if (choiceTrans_->GetSelection() == DEF_TRANSFER) { - bPayee_->SetLabel(_("Select From")); + if (accountID_ < 0 ) + { + bPayee_->SetLabel(_("Select From")); + payeeID_ = -1; + } + else + { + bPayee_->SetLabel(itemAccountName_->GetLabel()); + payeeID_ = accountID_; + } + bTo_->SetLabel(_("Select To")); - payeeID_ = -1; toID_ = -1; - + payeeUnknown_ = true; + bTo_->Show(true); st->Show(true); stp->SetLabel(_("From")); Modified: trunk/mmex/src/billsdepositsdialog.h =================================================================== --- trunk/mmex/src/billsdepositsdialog.h 2011-03-31 12:26:05 UTC (rev 1213) +++ trunk/mmex/src/billsdepositsdialog.h 2011-03-31 12:31:14 UTC (rev 1214) @@ -93,6 +93,8 @@ mmAdvancedPopup* m_simplePopup_; wxButton* bAdvanced_; wxCheckBox* cSplit_; + wxStaticText* staticTextAdvancedActive_; + bool payeeUnknown_; wxChoice* choiceStatus_; wxChoice* choiceTrans_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2011-05-03 08:15:33
|
Revision: 1258 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=1258&view=rev Author: vomikan Date: 2011-05-03 08:15:26 +0000 (Tue, 03 May 2011) Log Message: ----------- Added additional info for non transfer transactions if non base currency used Modified Paths: -------------- trunk/mmex/src/mmcheckingpanel.cpp trunk/mmex/src/mmcheckingpanel.h Modified: trunk/mmex/src/mmcheckingpanel.cpp =================================================================== --- trunk/mmex/src/mmcheckingpanel.cpp 2011-05-02 20:26:17 UTC (rev 1257) +++ trunk/mmex/src/mmcheckingpanel.cpp 2011-05-03 08:15:26 UTC (rev 1258) @@ -803,7 +803,7 @@ enableEditDeleteButtons(true); st->SetLabel(getItem(selIndex, COL_NOTES)); wxString miniStr; - miniStr = getTransferInfoStr(selIndex); + miniStr = getMiniInfoStr(selIndex); stm->SetLabel(miniStr); } else { //st->SetLabel(wxT ("")); @@ -813,14 +813,14 @@ } } //---------------------------------------------------------------------------- -wxString mmCheckingPanel::getTransferInfoStr(int selIndex) +wxString mmCheckingPanel::getMiniInfoStr(int selIndex) { char sql[] = "select c.transcode as TRANSCODE, " "c.TRANSAMOUNT as TRANSAMOUNT, TOTRANSAMOUNT, " "cf.CURRENCYNAME as CURRENCYNAME, tcf.CURRENCYNAME as TOCURRENCYNAME, " "cf.CURRENCYID as CURRENCYID, tcf.CURRENCYID as TOCURRENCYID, " - "tcf.BASECONVRATE as ToCurrecyRate, " + "cf.BASECONVRATE as BASECONVRATE, " "c.ACCOUNTID as ACCOUNTID, " "c.TOACCOUNTID as TOACCOUNTID, " "i.infovalue as BASECURRENCYID " @@ -841,37 +841,38 @@ wxString transcodeStr = q1.GetString(wxT("TRANSCODE")); wxString currencynameStr = q1.GetString(wxT("CURRENCYNAME")); wxString tocurrencynameStr = q1.GetString(wxT("TOCURRENCYNAME")); + int currencyid = q1.GetInt(wxT("CURRENCYID")); + double amount = q1.GetDouble(wxT("TRANSAMOUNT")); + wxString amountStr; + double convrate = q1.GetDouble(wxT("BASECONVRATE")); wxString infoStr = wxT(""); if (transcodeStr == wxT("Transfer")) { - int currencyid = q1.GetInt(wxT("CURRENCYID")); int tocurrencyid = q1.GetInt(wxT("TOCURRENCYID")); - double amount = q1.GetDouble(wxT("TRANSAMOUNT")); - wxString amountStr; double toamount = q1.GetDouble(wxT("TOTRANSAMOUNT")); wxString toamountStr; double convertion = (tocurrencyid == basecurrencyid ? toamount/amount : amount/toamount); wxString convertionStr; + int toaccountId = q1.GetInt(wxT("TOACCOUNTID")); + boost::shared_ptr<mmCurrency> pCurrencyPtr = m_core->accountList_.getCurrencyWeakPtr(toaccountId).lock(); + wxASSERT(pCurrencyPtr); + mmex::CurrencyFormatter::instance().loadSettings(*pCurrencyPtr); + mmex::formatDoubleToCurrency(toamount, toamountStr); + if (tocurrencyid == basecurrencyid) + mmex::formatDoubleToCurrencyEdit(convertion, convertionStr); int accountId = q1.GetInt(wxT("ACCOUNTID")); - boost::shared_ptr<mmCurrency> pCurrencyPtr = m_core->accountList_.getCurrencyWeakPtr(accountId).lock(); + pCurrencyPtr = m_core->accountList_.getCurrencyWeakPtr(accountId).lock(); wxASSERT(pCurrencyPtr); mmex::CurrencyFormatter::instance().loadSettings(*pCurrencyPtr); - mmex::formatDoubleToCurrency(amount, amountStr); - infoStr << amountStr << wxT(" -> "); + if (currencyid == basecurrencyid) mmex::formatDoubleToCurrencyEdit(convertion, convertionStr); - int toaccountId = q1.GetInt(wxT("TOACCOUNTID")); - pCurrencyPtr = m_core->accountList_.getCurrencyWeakPtr(toaccountId).lock(); - wxASSERT(pCurrencyPtr); - mmex::CurrencyFormatter::instance().loadSettings(*pCurrencyPtr); + infoStr << amountStr << wxT(" -> ") << toamountStr ; - mmex::formatDoubleToCurrency(toamount, toamountStr); - infoStr << toamountStr ; - if (tocurrencyid != currencyid) { infoStr << wxT(" ("); @@ -884,8 +885,22 @@ infoStr << wxT(")"); } } + else //For deposits and withdrawals calculates amount in base currency + { + if (currencyid != basecurrencyid) //Show nothing if account currency is base + { + double convrate = q1.GetDouble(wxT("BASECONVRATE")); + //load settings for base currency + wxString currencyName = mmDBWrapper::getCurrencyName(m_core->db_.get(), basecurrencyid); + boost::shared_ptr<mmCurrency> pCurrency = m_core->currencyList_.getCurrencySharedPtr(currencyName); + wxASSERT(pCurrency); + mmDBWrapper::loadSettings(m_core->db_.get(), pCurrency->currencyID_); + mmex::formatDoubleToCurrency(amount*convrate, amountStr); + //output + infoStr << _("Amount in the base currency:") << wxT(" ") << amountStr; + } + } - return infoStr; } //--------------------------- Modified: trunk/mmex/src/mmcheckingpanel.h =================================================================== --- trunk/mmex/src/mmcheckingpanel.h 2011-05-02 20:26:17 UTC (rev 1257) +++ trunk/mmex/src/mmcheckingpanel.h 2011-05-03 08:15:26 UTC (rev 1258) @@ -137,6 +137,8 @@ /* Getter for Virtual List Control */ wxString getItem(long item, long column); + wxString getMiniInfoStr(int selIndex); + int accountID() const { return m_AccountID; } }; //---------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2011-05-13 02:48:16
|
Revision: 1269 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=1269&view=rev Author: stef145g Date: 2011-05-13 02:48:06 +0000 (Fri, 13 May 2011) Log Message: ----------- Check for update may be inaccurate Bugs-3300034 Fix: Will need Internet & Code adjust follow up. Modified Paths: -------------- trunk/mmex/src/mmex.cpp trunk/mmex/src/mmex.h Modified: trunk/mmex/src/mmex.cpp =================================================================== --- trunk/mmex/src/mmex.cpp 2011-05-12 16:40:20 UTC (rev 1268) +++ trunk/mmex/src/mmex.cpp 2011-05-13 02:48:06 UTC (rev 1269) @@ -3393,31 +3393,15 @@ } //---------------------------------------------------------------------------- -void mmGUIFrame::OnCheckUpdate(wxCommandEvent& /*event*/) +bool mmGUIFrame::IsUpdateAvailable(wxString page) { - wxString site = wxT("http://www.codelathe.com/mmex/version.html"); - wxURL url(site); - - unsigned char buf[1024]; - boost::scoped_ptr<wxInputStream> in_stream(url.GetInputStream()); - if (!in_stream) - { - mmShowErrorMessage(this, _("Unable to connect!"), _("Check Update")); - return; - } - in_stream->Read(buf, 1024); - //size_t bytes_read=in_stream->LastRead(); - in_stream.reset(); - buf[7] = '\0'; - - wxString page = wxString::FromAscii((const char *)buf); wxStringTokenizer tkz(page, wxT('.'), wxTOKEN_RET_EMPTY_ALL); int numTokens = (int)tkz.CountTokens(); if (numTokens != 4) { wxString url = wxT("http://www.codelathe.com/mmex"); wxLaunchDefaultBrowser(url); - return; + return false; } wxString maj = tkz.GetNextToken(); @@ -3458,7 +3442,54 @@ } } - if (isUpdateAvailable) + return isUpdateAvailable; +} + +void mmGUIFrame::OnCheckUpdate(wxCommandEvent& /*event*/) +{ + wxString site = wxT("http://www.codelathe.com/mmex/version.html"); + wxURL url(site); + + unsigned char buf[1024]; + boost::scoped_ptr<wxInputStream> in_stream(url.GetInputStream()); + if (!in_stream) + { + mmShowErrorMessage(this, _("Unable to connect!"), _("Check Update")); + return; + } + in_stream->Read(buf, 1024); + //size_t bytes_read=in_stream->LastRead(); + in_stream.reset(); + buf[7] = '\0'; + + wxString page = wxString::FromAscii((const char *)buf); + + /********************************************************** + Follow up: + fix when internet has been updated + ***********************************************************/ + page = wxT("Win: 0.9.8.0 - Unix: 0.9.7.0 - MAC: 0.9.5.1"); + + wxStringTokenizer sysTokens(page,wxT("-")); + wxString winSys = sysTokens.GetNextToken().Trim(false); + wxString unixSys = sysTokens.GetNextToken().Trim(false); + wxString macSys = sysTokens.GetNextToken().Trim(false); + + wxString mySys = wxPlatformInfo::Get().GetOperatingSystemFamilyName(); + + wxStringTokenizer mySysToken; + if (mySys == wxT("Windows")) { + mySysToken.SetString(winSys,wxT(":")); + } else if (mySys == wxT("Unix")) { + mySysToken.SetString(unixSys,wxT(":")); + } else if (mySys == wxT("Macintosh")) { + mySysToken.SetString(macSys,wxT(":")); + } + + page = mySysToken.GetNextToken(); // the system + page = mySysToken.GetNextToken().Trim(); // the version + + if (IsUpdateAvailable(page)) { mmShowErrorMessage(this, _("New update available!"), _("Check Update")); wxString url = wxT("http://www.codelathe.com/mmex"); @@ -3468,7 +3499,6 @@ { mmShowErrorMessage(this, _("You have the latest version installed!"), _("Check Update")); } - } //---------------------------------------------------------------------------- Modified: trunk/mmex/src/mmex.h =================================================================== --- trunk/mmex/src/mmex.h 2011-05-12 16:40:20 UTC (rev 1268) +++ trunk/mmex/src/mmex.h 2011-05-13 02:48:06 UTC (rev 1269) @@ -250,6 +250,7 @@ void OnPopupDeleteCustomSqlReport(wxCommandEvent& event); bool financialYearIsDifferent(); + bool IsUpdateAvailable(wxString page); // any class wishing to process wxWindows events must use this macro DECLARE_EVENT_TABLE() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |