What changed
Bitcoin v0.1.5 → v0.2.0
Release commit message: filter out duplicate getblocks and don't relay inv messages during initial block download -- 0.2 rc2
Full source: v0.1.5. v0.2.0. Previous diff: v0.1.3 → v0.1.5. Next: v0.2.0 → v0.2.2.
- bugs.txt added · +2 −1
- build-msw.txt added · +91 −0
- build-unix.txt added · +67 −0
- changelog.txt modified · +5 −1
- db.cpp modified · +218 −72
- db.h modified · +24 −8
- headers.h modified · +46 −5
- irc.cpp modified · +47 −39
- irc.h modified · +1 −3
- key.h modified · +13 −1
- main.cpp modified · +429 −204
- main.h modified · +95 −38
- makefile modified · +16 −18
- makefile.unix added · +89 −0
- makefile.vc modified · +4 −4
- net.cpp modified · +662 −391
- net.h modified · +231 −71
- readme.txt removed · +0 −71
- serialize.h modified · +2 −1
- setup.nsi added · +150 −0
- strlcpy.h added · +84 −0
- ui.cpp modified · +1158 −508
- ui.h modified · +71 −24
- uibase.cpp modified · +1705 −1759
- uibase.h modified · +567 −612
- util.cpp modified · +268 −112
- util.h modified · +306 −109
bugs.txt (added)
1--- /dev/null2+++ v0.2.0/bugs.txt3@@ -1 +1,2 @@4-5+Known bugs:6+- Window flickers when blocks are added (problem with repainting?)
build-msw.txt (added)
1--- /dev/null2+++ v0.2.0/build-msw.txt3@@ -1 +1,92 @@4+Bitcoin v0.2.0 BETA5 6+Copyright (c) 2009 Satoshi Nakamoto7+Distributed under the MIT/X11 software license, see the accompanying8+file license.txt or http://www.opensource.org/licenses/mit-license.php.9+This product includes software developed by the OpenSSL Project for use in10+the OpenSSL Toolkit (http://www.openssl.org/). This product includes11+cryptographic software written by Eric Young (eay@cryptsoft.com).12+13+14+WINDOWS BUILD NOTES15+===================16+17+Compilers Supported18+-------------------19+MinGW GCC20+Microsoft Visual C++ 6.0 SP621+22+23+Dependencies24+------------25+Libraries you need to download separately and build:26+27+ default path download28+wxWidgets \wxwidgets http://www.wxwidgets.org/downloads/29+ or prebuilt: http://wxpack.sourceforge.net30+OpenSSL \openssl http://www.openssl.org/source/31+Berkeley DB \db http://www.oracle.com/technology/software/products/berkeley-db/index.html32+Boost \boost http://www.boost.org/users/download/33+34+Their licenses:35+wxWidgets LGPL 2.1 with very liberal exceptions36+OpenSSL Old BSD license with the problematic advertising requirement37+Berkeley DB New BSD license with additional requirement that linked software must be free open source38+Boost MIT-like license39+40+Versions used in this release:41+MinGW GCC 3.4.542+wxWidgets 2.8.943+OpenSSL 0.9.8k44+Berkeley DB 4.7.25.NC45+Boost 1.34.146+47+48+Notes49+-----50+The UI layout is edited with wxFormBuilder. The project file is51+uiproject.fbp. It generates uibase.cpp and uibase.h, which define base52+classes that do the rote work of constructing all the UI elements.53+54+The release is built with GCC and then "strip bitcoin.exe" to strip the debug55+symbols, which reduces the executable size by about 90%.56+57+58+OpenSSL59+-------60+Bitcoin does not use any encryption. If you want to do a no-everything61+build of OpenSSL to exclude encryption routines, a few patches are required.62+(instructions for OpenSSL v0.9.8k)63+64+Edit engines\e_gmp.c and engines\e_capi.c and add this #ifndef around65+the openssl/rsa.h include:66+ #ifndef OPENSSL_NO_RSA67+ #include <openssl/rsa.h>68+ #endif69+70+Edit ms\mingw32.bat and replace the Configure line's parameters with this71+no-everything list. You have to put this in the batch file because batch72+files can't take more than nine command line parameters.73+ perl Configure mingw threads no-rc2 no-rc4 no-rc5 no-idea no-des no-bf no-cast no-aes no-camellia no-seed no-rsa no-dh74+75+Also REM out the following line in ms\mingw32.bat after the mingw32-make76+line. The build fails after it's already finished building libeay32, which77+is all we care about, but the failure aborts the script before it runs78+dllwrap to generate libeay32.dll.79+ REM if errorlevel 1 goto end80+81+Build82+ cd \openssl83+ ms\mingw32.bat84+85+If you want to use it with MSVC, generate the .lib file86+ lib /machine:i386 /def:ms\libeay32.def /out:out\libeay32.lib87+88+89+Berkeley DB90+-----------91+Using MinGW and MSYS:92+cd \db\build_unix93+sh ../dist/configure --enable-mingw --enable-cxx94+make95+
build-unix.txt (added)
1--- /dev/null2+++ v0.2.0/build-unix.txt3@@ -1 +1,68 @@4+Bitcoin v0.2.0 BETA5 6+Copyright (c) 2009 Satoshi Nakamoto7+Distributed under the MIT/X11 software license, see the accompanying8+file license.txt or http://www.opensource.org/licenses/mit-license.php.9+This product includes software developed by the OpenSSL Project for use in10+the OpenSSL Toolkit (http://www.openssl.org/). This product includes11+cryptographic software written by Eric Young (eay@cryptsoft.com).12+13+14+UNIX BUILD NOTES15+================16+17+Dependencies18+------------19+apt-get install build-essential20+apt-get install libgtk2.0-dev21+apt-get install libssl-dev22+apt-get install libdb4.7-dev23+apt-get install libdb4.7++-dev24+apt-get install libboost-dev25+26+You need to download wxWidgets from http://www.wxwidgets.org/downloads/27+and build it yourself.28+29+Licenses of statically linked libraries:30+wxWidgets LGPL 2.1 with very liberal exceptions31+Berkeley DB New BSD license with additional requirement that linked software must be free open source32+Boost MIT-like license33+34+Versions used in this release:35+GCC 4.3.336+OpenSSL 0.9.8k37+wxWidgets 2.8.938+Berkeley DB 4.7.25.NC39+Boost 1.40.040+41+42+Notes43+-----44+The UI layout is edited with wxFormBuilder. The project file is45+uiproject.fbp. It generates uibase.cpp and uibase.h, which define base46+classes that do the rote work of constructing all the UI elements.47+48+The release is built with GCC and then "strip bitcoin" to strip the debug49+symbols, which reduces the executable size by about 90%.50+51+52+wxWidgets53+---------54+cd /usr/local/wxWidgets-2.8.955+mkdir buildgtk56+cd buildgtk57+../configure --with-gtk --enable-debug --disable-shared --enable-monolithic58+make59+su60+make install61+ldconfig62+63+64+Boost65+-----66+If you want to build Boost yourself,67+cd /usr/local/boost_1_40_068+su69+./bootstrap.sh70+./bjam install71+
changelog.txt (modified)
1--- v0.1.5/changelog.txt2+++ v0.2.0/changelog.txt3@@ -1,3 +1,7 @@4 Changes after 0.1.5:5 --------------------6-7++ Options dialog layout changed - added the UI options panel8++ Minimize to tray feature9++ Startup on system boot feature10++ Ask before closing11++ NSIS installer
db.cpp (modified)
1--- v0.1.5/db.cpp2+++ v0.2.0/db.cpp3@@ -4,7 +4,10 @@4 5 #include "headers.h"6 7-8+void ThreadFlushWalletDB(void* parg);9+10+11+unsigned int nWalletDBUpdated;12 13 14 15@@ -17,6 +20,7 @@16 static bool fDbEnvInit = false;17 DbEnv dbenv(0);18 static map<string, int> mapFileUseCount;19+static map<string, Db*> mapDb;20 21 class CDBInit22 {23@@ -36,38 +40,37 @@24 instance_of_cdbinit;25 26 27-CDB::CDB(const char* pszFile, const char* pszMode, bool fTxn) : pdb(NULL)28+CDB::CDB(const char* pszFile, const char* pszMode) : pdb(NULL)29 {30 int ret;31 if (pszFile == NULL)32 return;33 34+ fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));35 bool fCreate = strchr(pszMode, 'c');36- bool fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));37 unsigned int nFlags = DB_THREAD;38 if (fCreate)39 nFlags |= DB_CREATE;40- else if (fReadOnly)41- nFlags |= DB_RDONLY;42- if (!fReadOnly || fTxn)43- nFlags |= DB_AUTO_COMMIT;44 45 CRITICAL_BLOCK(cs_db)46 {47 if (!fDbEnvInit)48 {49- string strAppDir = GetAppDir();50- string strLogDir = strAppDir + "\\database";51+ if (fShutdown)52+ return;53+ string strDataDir = GetDataDir();54+ string strLogDir = strDataDir + "/database";55 _mkdir(strLogDir.c_str());56- printf("dbenv.open strAppDir=%s\n", strAppDir.c_str());57+ string strErrorFile = strDataDir + "/db.log";58+ printf("dbenv.open strLogDir=%s strErrorFile=%s\n", strLogDir.c_str(), strErrorFile.c_str());59 60 dbenv.set_lg_dir(strLogDir.c_str());61 dbenv.set_lg_max(10000000);62 dbenv.set_lk_max_locks(10000);63 dbenv.set_lk_max_objects(10000);64- dbenv.set_errfile(fopen("db.log", "a")); /// debug65- ///dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1); /// causes corruption66- ret = dbenv.open(strAppDir.c_str(),67+ dbenv.set_errfile(fopen(strErrorFile.c_str(), "a")); /// debug68+ dbenv.set_flags(DB_AUTO_COMMIT, 1);69+ ret = dbenv.open(strDataDir.c_str(),70 DB_CREATE |71 DB_INIT_LOCK |72 DB_INIT_LOG |73@@ -76,7 +79,7 @@74 DB_THREAD |75 DB_PRIVATE |76 DB_RECOVER,77- 0);78+ S_IRUSR | S_IWUSR);79 if (ret > 0)80 throw runtime_error(strprintf("CDB() : error %d opening database environment\n", ret));81 fDbEnvInit = true;82@@ -84,31 +87,39 @@83 84 strFile = pszFile;85 ++mapFileUseCount[strFile];86- }87-88- pdb = new Db(&dbenv, 0);89-90- ret = pdb->open(NULL, // Txn pointer91- pszFile, // Filename92- "main", // Logical db name93- DB_BTREE, // Database type94- nFlags, // Flags95- 0);96-97- if (ret > 0)98- {99- delete pdb;100- pdb = NULL;101- CRITICAL_BLOCK(cs_db)102- --mapFileUseCount[strFile];103- strFile = "";104- throw runtime_error(strprintf("CDB() : can't open database file %s, error %d\n", pszFile, ret));105- }106-107- if (fCreate && !Exists(string("version")))108- WriteVersion(VERSION);109-110- RandAddSeed();111+ pdb = mapDb[strFile];112+ if (pdb == NULL)113+ {114+ pdb = new Db(&dbenv, 0);115+116+ ret = pdb->open(NULL, // Txn pointer117+ pszFile, // Filename118+ "main", // Logical db name119+ DB_BTREE, // Database type120+ nFlags, // Flags121+ 0);122+123+ if (ret > 0)124+ {125+ delete pdb;126+ pdb = NULL;127+ CRITICAL_BLOCK(cs_db)128+ --mapFileUseCount[strFile];129+ strFile = "";130+ throw runtime_error(strprintf("CDB() : can't open database file %s, error %d\n", pszFile, ret));131+ }132+133+ if (fCreate && !Exists(string("version")))134+ {135+ bool fTmp = fReadOnly;136+ fReadOnly = false;137+ WriteVersion(VERSION);138+ fReadOnly = fTmp;139+ }140+141+ mapDb[strFile] = pdb;142+ }143+ }144 }145 146 void CDB::Close()147@@ -118,8 +129,6 @@148 if (!vTxn.empty())149 vTxn.front()->abort();150 vTxn.clear();151- pdb->close(0);152- delete pdb;153 pdb = NULL;154 dbenv.txn_checkpoint(0, 0, 0);155 156@@ -129,21 +138,42 @@157 RandAddSeed();158 }159 160+void CloseDb(const string& strFile)161+{162+ CRITICAL_BLOCK(cs_db)163+ {164+ if (mapDb[strFile] != NULL)165+ {166+ // Close the database handle167+ Db* pdb = mapDb[strFile];168+ pdb->close(0);169+ delete pdb;170+ mapDb[strFile] = NULL;171+ }172+ }173+}174+175 void DBFlush(bool fShutdown)176 {177 // Flush log data to the actual data file178 // on all files that are not in use179- printf("DBFlush(%s)\n", fShutdown ? "true" : "false");180+ printf("DBFlush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");181+ if (!fDbEnvInit)182+ return;183 CRITICAL_BLOCK(cs_db)184 {185- dbenv.txn_checkpoint(0, 0, 0);186 map<string, int>::iterator mi = mapFileUseCount.begin();187 while (mi != mapFileUseCount.end())188 {189 string strFile = (*mi).first;190 int nRefCount = (*mi).second;191+ printf("%s refcount=%d\n", strFile.c_str(), nRefCount);192 if (nRefCount == 0)193 {194+ // Move log data to the dat file195+ CloseDb(strFile);196+ dbenv.txn_checkpoint(0, 0, 0);197+ printf("%s flush\n", strFile.c_str());198 dbenv.lsn_reset(strFile.c_str(), 0);199 mapFileUseCount.erase(mi++);200 }201@@ -230,7 +260,10 @@202 if (ret == DB_NOTFOUND)203 break;204 else if (ret != 0)205+ {206+ pcursor->close();207 return false;208+ }209 210 // Unserialize211 string strType;212@@ -247,9 +280,14 @@213 {214 vtx.resize(vtx.size()+1);215 if (!vtx.back().ReadFromDisk(pos))216+ {217+ pcursor->close();218 return false;219- }220- }221+ }222+ }223+ }224+225+ pcursor->close();226 return true;227 }228 229@@ -371,19 +409,20 @@230 break;231 }232 }233+ pcursor->close();234 235 if (!ReadHashBestChain(hashBestChain))236 {237 if (pindexGenesisBlock == NULL)238 return true;239- return error("CTxDB::LoadBlockIndex() : hashBestChain not found\n");240+ return error("CTxDB::LoadBlockIndex() : hashBestChain not found");241 }242 243 if (!mapBlockIndex.count(hashBestChain))244- return error("CTxDB::LoadBlockIndex() : blockindex for hashBestChain not found\n");245+ return error("CTxDB::LoadBlockIndex() : blockindex for hashBestChain not found");246 pindexBest = mapBlockIndex[hashBestChain];247 nBestHeight = pindexBest->nHeight;248- printf("LoadBlockIndex(): hashBestChain=%s height=%d\n", hashBestChain.ToString().substr(0,14).c_str(), nBestHeight);249+ printf("LoadBlockIndex(): hashBestChain=%s height=%d\n", hashBestChain.ToString().substr(0,16).c_str(), nBestHeight);250 251 return true;252 }253@@ -403,11 +442,10 @@254 255 bool CAddrDB::LoadAddresses()256 {257- CRITICAL_BLOCK(cs_mapIRCAddresses)258 CRITICAL_BLOCK(cs_mapAddresses)259 {260 // Load user provided addresses261- CAutoFile filein = fopen("addr.txt", "rt");262+ CAutoFile filein = fopen((GetDataDir() + "/addr.txt").c_str(), "rt");263 if (filein)264 {265 try266@@ -416,11 +454,9 @@267 while (fgets(psz, sizeof(psz), filein))268 {269 CAddress addr(psz, NODE_NETWORK);270- if (addr.ip != 0)271- {272+ addr.nTime = 0; // so it won't relay unless successfully connected273+ if (addr.IsValid())274 AddAddress(*this, addr);275- mapIRCAddresses.insert(make_pair(addr.GetKey(), addr));276- }277 }278 }279 catch (...) { }280@@ -452,12 +488,9 @@281 mapAddresses.insert(make_pair(addr.GetKey(), addr));282 }283 }284-285- //// debug print286- printf("mapAddresses:\n");287- foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)288- item.second.print();289- printf("-----\n");290+ pcursor->close();291+292+ printf("Loaded %d addresses\n", mapAddresses.size());293 294 // Fix for possible bug that manifests in mapAddresses.count in irc.cpp,295 // just need to call count here and it doesn't happen there. The bug was the296@@ -504,6 +537,14 @@297 bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)298 {299 vchDefaultKeyRet.clear();300+ int nFileVersion = 0;301+302+ // Modify defaults303+#ifndef __WXMSW__304+ // Tray icon sometimes disappears on 9.10 karmic koala 64-bit, leaving no way to access the program305+ fMinimizeToTray = false;306+ fMinimizeOnClose = false;307+#endif308 309 //// todo: shouldn't we catch exceptions and try to recover and continue?310 CRITICAL_BLOCK(cs_mapKeys)311@@ -550,8 +591,8 @@312 //printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str());313 //printf(" %12I64d %s %s %s\n",314 // wtx.vout[0].nValue,315- // DateTimeStr(wtx.nTime).c_str(),316- // wtx.hashBlock.ToString().substr(0,14).c_str(),317+ // DateTimeStrFormat("%x %H:%M:%S", wtx.nTime).c_str(),318+ // wtx.hashBlock.ToString().substr(0,16).c_str(),319 // wtx.mapValue["message"].c_str());320 }321 else if (strType == "key")322@@ -568,29 +609,73 @@323 {324 ssValue >> vchDefaultKeyRet;325 }326- else if (strType == "setting") /// or settings or option or options or config?327+ else if (strType == "version")328+ {329+ ssValue >> nFileVersion;330+ }331+ else if (strType == "setting")332 {333 string strKey;334 ssKey >> strKey;335+336+ // Menu state337+ if (strKey == "fShowGenerated") ssValue >> fShowGenerated;338 if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins;339+340+ // Options341 if (strKey == "nTransactionFee") ssValue >> nTransactionFee;342 if (strKey == "addrIncoming") ssValue >> addrIncoming;343- }344- }345- }346-347+ if (strKey == "fLimitProcessors") ssValue >> fLimitProcessors;348+ if (strKey == "nLimitProcessors") ssValue >> nLimitProcessors;349+ if (strKey == "fMinimizeToTray") ssValue >> fMinimizeToTray;350+ if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose;351+ if (strKey == "fUseProxy") ssValue >> fUseProxy;352+ if (strKey == "addrProxy") ssValue >> addrProxy;353+354+ }355+ }356+ pcursor->close();357+ }358+359+ printf("nFileVersion = %d\n", nFileVersion);360+ printf("fShowGenerated = %d\n", fShowGenerated);361 printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);362- printf("nTransactionFee = %I64d\n", nTransactionFee);363+ printf("nTransactionFee = %"PRI64d"\n", nTransactionFee);364 printf("addrIncoming = %s\n", addrIncoming.ToString().c_str());365+ printf("fMinimizeToTray = %d\n", fMinimizeToTray);366+ printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);367+ printf("fUseProxy = %d\n", fUseProxy);368+ printf("addrProxy = %s\n", addrProxy.ToString().c_str());369+370+371+ // The transaction fee setting won't be needed for many years to come.372+ // Setting it to zero here in case they set it to something in an earlier version.373+ if (nTransactionFee != 0)374+ {375+ nTransactionFee = 0;376+ WriteSetting("nTransactionFee", nTransactionFee);377+ }378+379+ // Upgrade380+ if (nFileVersion < VERSION)381+ {382+ // Get rid of old debug.log file in current directory383+ if (nFileVersion <= 105 && !pszSetDataDir[0])384+ unlink("debug.log");385+386+ WriteVersion(VERSION);387+ }388 389 return true;390 }391 392-bool LoadWallet()393-{394+bool LoadWallet(bool& fFirstRunRet)395+{396+ fFirstRunRet = false;397 vector<unsigned char> vchDefaultKey;398- if (!CWalletDB("cr").LoadWallet(vchDefaultKey))399+ if (!CWalletDB("cr+").LoadWallet(vchDefaultKey))400 return false;401+ fFirstRunRet = vchDefaultKey.empty();402 403 if (mapKeys.count(vchDefaultKey))404 {405@@ -601,7 +686,7 @@406 else407 {408 // Create new keyUser and set as default key409- RandAddSeed(true);410+ RandAddSeedPerfmon();411 keyUser.MakeNewKey();412 if (!AddKey(keyUser))413 return false;414@@ -610,6 +695,67 @@415 CWalletDB().WriteDefaultKey(keyUser.GetPubKey());416 }417 418+ CreateThread(ThreadFlushWalletDB, NULL);419 return true;420 }421 422+void ThreadFlushWalletDB(void* parg)423+{424+ static bool fOneThread;425+ if (fOneThread)426+ return;427+ fOneThread = true;428+ if (mapArgs.count("-noflushwallet"))429+ return;430+431+ unsigned int nLastSeen = nWalletDBUpdated;432+ unsigned int nLastFlushed = nWalletDBUpdated;433+ int64 nLastWalletUpdate = GetTime();434+ while (!fShutdown)435+ {436+ Sleep(500);437+438+ if (nLastSeen != nWalletDBUpdated)439+ {440+ nLastSeen = nWalletDBUpdated;441+ nLastWalletUpdate = GetTime();442+ }443+444+ if (nLastFlushed != nWalletDBUpdated && GetTime() - nLastWalletUpdate >= 2)445+ {446+ TRY_CRITICAL_BLOCK(cs_db)447+ {448+ // Don't do this if any databases are in use449+ int nRefCount = 0;450+ map<string, int>::iterator mi = mapFileUseCount.begin();451+ while (mi != mapFileUseCount.end())452+ {453+ nRefCount += (*mi).second;454+ mi++;455+ }456+457+ if (nRefCount == 0 && !fShutdown)458+ {459+ string strFile = "wallet.dat";460+ map<string, int>::iterator mi = mapFileUseCount.find(strFile);461+ if (mi != mapFileUseCount.end())462+ {463+ printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());464+ printf("Flushing wallet.dat\n");465+ nLastFlushed = nWalletDBUpdated;466+ int64 nStart = GetTimeMillis();467+468+ // Flush wallet.dat so it's self contained469+ CloseDb(strFile);470+ dbenv.txn_checkpoint(0, 0, 0);471+ dbenv.lsn_reset(strFile.c_str(), 0);472+473+ mapFileUseCount.erase(mi++);474+ printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart);475+ }476+ }477+ }478+ }479+ }480+}481+
db.h (modified)
1--- v0.1.5/db.h2+++ v0.2.0/db.h3@@ -17,7 +17,10 @@4 extern bool fClient;5 6 7+extern unsigned int nWalletDBUpdated;8 extern DbEnv dbenv;9+10+11 extern void DBFlush(bool fShutdown);12 13 14@@ -29,8 +32,9 @@15 Db* pdb;16 string strFile;17 vector<DbTxn*> vTxn;18-19- explicit CDB(const char* pszFile, const char* pszMode="r+", bool fTxn=false);20+ bool fReadOnly;21+22+ explicit CDB(const char* pszFile, const char* pszMode="r+");23 ~CDB() { Close(); }24 public:25 void Close();26@@ -74,6 +78,8 @@27 {28 if (!pdb)29 return false;30+ if (fReadOnly)31+ assert(("Write called on database in read-only mode", false));32 33 // Key34 CDataStream ssKey(SER_DISK);35@@ -101,6 +107,8 @@36 {37 if (!pdb)38 return false;39+ if (fReadOnly)40+ assert(("Erase called on database in read-only mode", false));41 42 // Key43 CDataStream ssKey(SER_DISK);44@@ -251,7 +259,7 @@45 class CTxDB : public CDB46 {47 public:48- CTxDB(const char* pszMode="r+", bool fTxn=false) : CDB(!fClient ? "blkindex.dat" : NULL, pszMode, fTxn) { }49+ CTxDB(const char* pszMode="r+") : CDB(!fClient ? "blkindex.dat" : NULL, pszMode) { }50 private:51 CTxDB(const CTxDB&);52 void operator=(const CTxDB&);53@@ -280,7 +288,7 @@54 class CReviewDB : public CDB55 {56 public:57- CReviewDB(const char* pszMode="r+", bool fTxn=false) : CDB("reviews.dat", pszMode, fTxn) { }58+ CReviewDB(const char* pszMode="r+") : CDB("reviews.dat", pszMode) { }59 private:60 CReviewDB(const CReviewDB&);61 void operator=(const CReviewDB&);62@@ -306,7 +314,7 @@63 class CMarketDB : public CDB64 {65 public:66- CMarketDB(const char* pszMode="r+", bool fTxn=false) : CDB("market.dat", pszMode, fTxn) { }67+ CMarketDB(const char* pszMode="r+") : CDB("market.dat", pszMode) { }68 private:69 CMarketDB(const CMarketDB&);70 void operator=(const CMarketDB&);71@@ -319,7 +327,7 @@72 class CAddrDB : public CDB73 {74 public:75- CAddrDB(const char* pszMode="r+", bool fTxn=false) : CDB("addr.dat", pszMode, fTxn) { }76+ CAddrDB(const char* pszMode="r+") : CDB("addr.dat", pszMode) { }77 private:78 CAddrDB(const CAddrDB&);79 void operator=(const CAddrDB&);80@@ -334,10 +342,11 @@81 82 83 84+85 class CWalletDB : public CDB86 {87 public:88- CWalletDB(const char* pszMode="r+", bool fTxn=false) : CDB("wallet.dat", pszMode, fTxn) { }89+ CWalletDB(const char* pszMode="r+") : CDB("wallet.dat", pszMode) { }90 private:91 CWalletDB(const CWalletDB&);92 void operator=(const CWalletDB&);93@@ -350,12 +359,14 @@94 95 bool WriteName(const string& strAddress, const string& strName)96 {97+ nWalletDBUpdated++;98 mapAddressBook[strAddress] = strName;99 return Write(make_pair(string("name"), strAddress), strName);100 }101 102 bool EraseName(const string& strAddress)103 {104+ nWalletDBUpdated++;105 mapAddressBook.erase(strAddress);106 return Erase(make_pair(string("name"), strAddress));107 }108@@ -367,11 +378,13 @@109 110 bool WriteTx(uint256 hash, const CWalletTx& wtx)111 {112+ nWalletDBUpdated++;113 return Write(make_pair(string("tx"), hash), wtx);114 }115 116 bool EraseTx(uint256 hash)117 {118+ nWalletDBUpdated++;119 return Erase(make_pair(string("tx"), hash));120 }121 122@@ -383,6 +396,7 @@123 124 bool WriteKey(const vector<unsigned char>& vchPubKey, const CPrivKey& vchPrivKey)125 {126+ nWalletDBUpdated++;127 return Write(make_pair(string("key"), vchPubKey), vchPrivKey, false);128 }129 130@@ -394,6 +408,7 @@131 132 bool WriteDefaultKey(const vector<unsigned char>& vchPubKey)133 {134+ nWalletDBUpdated++;135 return Write(string("defaultkey"), vchPubKey);136 }137 138@@ -406,13 +421,14 @@139 template<typename T>140 bool WriteSetting(const string& strKey, const T& value)141 {142+ nWalletDBUpdated++;143 return Write(make_pair(string("setting"), strKey), value);144 }145 146 bool LoadWallet(vector<unsigned char>& vchDefaultKeyRet);147 };148 149-bool LoadWallet();150+bool LoadWallet(bool& fFirstRunRet);151 152 inline bool SetAddressBookName(const string& strAddress, const string& strName)153 {
headers.h (modified)
1--- v0.1.5/headers.h2+++ v0.2.0/headers.h3@@ -5,32 +5,36 @@4 #ifdef _MSC_VER5 #pragma warning(disable:4786)6 #pragma warning(disable:4804)7+#pragma warning(disable:4805)8 #pragma warning(disable:4717)9 #endif10 #ifdef _WIN32_WINNT11 #undef _WIN32_WINNT12 #endif13 #define _WIN32_WINNT 0x040014+#ifdef _WIN32_IE15+#undef _WIN32_IE16+#endif17+#define _WIN32_IE 0x040018 #define WIN32_LEAN_AND_MEAN 119+#define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h20 #include <wx/wx.h>21 #include <wx/clipbrd.h>22 #include <wx/snglinst.h>23+#include <wx/taskbar.h>24+#include <wx/stdpaths.h>25+#include <wx/utils.h>26 #include <openssl/ecdsa.h>27 #include <openssl/evp.h>28 #include <openssl/rand.h>29 #include <openssl/sha.h>30 #include <openssl/ripemd.h>31-#include <windows.h>32-#include <winsock2.h>33-#include <mswsock.h>34 #include <stdio.h>35 #include <stdlib.h>36-#include <io.h>37 #include <math.h>38 #include <limits.h>39 #include <float.h>40 #include <assert.h>41-#include <process.h>42 #include <malloc.h>43 #include <memory>44 #define BOUNDSCHECK 145@@ -49,12 +53,38 @@46 #include <boost/tuple/tuple_comparison.hpp>47 #include <boost/tuple/tuple_io.hpp>48 #include <boost/array.hpp>49+#include <boost/bind.hpp>50+#include <boost/function.hpp>51+52+#ifdef __WXMSW__53+#include <windows.h>54+#include <winsock2.h>55+#include <mswsock.h>56+#include <shlobj.h>57+#include <shlwapi.h>58+#include <io.h>59+#include <process.h>60+#else61+#include <sys/time.h>62+#include <sys/resource.h>63+#include <sys/socket.h>64+#include <arpa/inet.h>65+#include <netdb.h>66+#include <unistd.h>67+#include <errno.h>68+#include <net/if.h>69+#include <ifaddrs.h>70+#include <boost/filesystem.hpp>71+#include <boost/algorithm/string.hpp>72+#endif73+74 #pragma hdrstop75 using namespace std;76 using namespace boost;77 78 79 80+#include "strlcpy.h"81 #include "serialize.h"82 #include "uint256.h"83 #include "util.h"84@@ -70,3 +100,14 @@85 #include "uibase.h"86 #include "ui.h"87 88+#include "xpm/addressbook16.xpm"89+#include "xpm/addressbook20.xpm"90+#include "xpm/bitcoin16.xpm"91+#include "xpm/bitcoin20.xpm"92+#include "xpm/bitcoin32.xpm"93+#include "xpm/bitcoin48.xpm"94+#include "xpm/check.xpm"95+#include "xpm/send16.xpm"96+#include "xpm/send16noshadow.xpm"97+#include "xpm/send20.xpm"98+
irc.cpp (modified)
1--- v0.1.5/irc.cpp2+++ v0.2.0/irc.cpp3@@ -4,10 +4,7 @@4 5 #include "headers.h"6 7-8-map<vector<unsigned char>, CAddress> mapIRCAddresses;9-CCriticalSection cs_mapIRCAddresses;10-11+int nGotIRCAddresses = 0;12 13 14 15@@ -40,7 +37,7 @@16 return false;17 memcpy(&tmp, &vch[0], sizeof(tmp));18 19- addr = CAddress(tmp.ip, tmp.port);20+ addr = CAddress(tmp.ip, tmp.port, NODE_NETWORK);21 return true;22 }23 24@@ -52,12 +49,12 @@25 static bool Send(SOCKET hSocket, const char* pszSend)26 {27 if (strstr(pszSend, "PONG") != pszSend)28- printf("SENDING: %s\n", pszSend);29+ printf("IRC SENDING: %s\n", pszSend);30 const char* psz = pszSend;31 const char* pszEnd = psz + strlen(psz);32 while (psz < pszEnd)33 {34- int ret = send(hSocket, psz, pszEnd - psz, 0);35+ int ret = send(hSocket, psz, pszEnd - psz, MSG_NOSIGNAL);36 if (ret < 0)37 return false;38 psz += ret;39@@ -124,20 +121,20 @@40 }41 }42 43-bool RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL)44+int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL)45 {46 loop47 {48 string strLine;49 if (!RecvLineIRC(hSocket, strLine))50- return false;51+ return 0;52 printf("IRC %s\n", strLine.c_str());53 if (psz1 && strLine.find(psz1) != -1)54- return true;55+ return 1;56 if (psz2 && strLine.find(psz2) != -1)57- return true;58+ return 2;59 if (psz3 && strLine.find(psz3) != -1)60- return true;61+ return 3;62 }63 }64 65@@ -145,7 +142,7 @@66 {67 if (fShutdown)68 return false;69- printf("Waiting %d seconds to reconnect to IRC\n", nSeconds);70+ printf("IRC waiting %d seconds to reconnect\n", nSeconds);71 for (int i = 0; i < nSeconds; i++)72 {73 if (fShutdown)74@@ -159,16 +156,21 @@75 76 void ThreadIRCSeed(void* parg)77 {78- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);79+ SetThreadPriority(THREAD_PRIORITY_NORMAL);80 int nErrorWait = 10;81 int nRetryWait = 10;82+ bool fNameInUse = false;83+ bool fTOR = (fUseProxy && addrProxy.port == htons(9050));84 85 while (!fShutdown)86 {87 CAddress addrConnect("216.155.130.130:6667");88- struct hostent* phostent = gethostbyname("chat.freenode.net");89- if (phostent && phostent->h_addr_list && phostent->h_addr_list[0])90- addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(6667));91+ if (!fTOR)92+ {93+ struct hostent* phostent = gethostbyname("chat.freenode.net");94+ if (phostent && phostent->h_addr_list && phostent->h_addr_list[0])95+ addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(6667));96+ }97 98 SOCKET hSocket;99 if (!ConnectSocket(addrConnect, hSocket))100@@ -184,6 +186,7 @@101 if (!RecvUntil(hSocket, "Found your hostname", "using your IP address instead", "Couldn't look up your hostname"))102 {103 closesocket(hSocket);104+ hSocket = INVALID_SOCKET;105 nErrorWait = nErrorWait * 11 / 10;106 if (Wait(nErrorWait += 60))107 continue;108@@ -191,18 +194,28 @@109 return;110 }111 112- string strMyName = EncodeAddress(addrLocalHost);113-114- if (!addrLocalHost.IsRoutable())115+ string strMyName;116+ if (addrLocalHost.IsRoutable() && !fUseProxy && !fNameInUse)117+ strMyName = EncodeAddress(addrLocalHost);118+ else119 strMyName = strprintf("x%u", GetRand(1000000000));120 121 122 Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());123 Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str());124 125- if (!RecvUntil(hSocket, " 004 "))126+ int nRet = RecvUntil(hSocket, " 004 ", " 433 ");127+ if (nRet != 1)128 {129 closesocket(hSocket);130+ hSocket = INVALID_SOCKET;131+ if (nRet == 2)132+ {133+ printf("IRC name already in use\n");134+ fNameInUse = true;135+ Wait(10);136+ continue;137+ }138 nErrorWait = nErrorWait * 11 / 10;139 if (Wait(nErrorWait += 60))140 continue;141@@ -220,7 +233,6 @@142 {143 if (strLine.empty() || strLine.size() > 900 || strLine[0] != ':')144 continue;145- printf("IRC %s\n", strLine.c_str());146 147 vector<string> vWords;148 ParseString(strLine, ' ', vWords);149@@ -234,17 +246,17 @@150 {151 // index 7 is limited to 16 characters152 // could get full length name at index 10, but would be different from join messages153- strcpy(pszName, vWords[7].c_str());154- printf("GOT WHO: [%s] ", pszName);155+ strlcpy(pszName, vWords[7].c_str(), sizeof(pszName));156+ printf("IRC got who\n");157 }158 159 if (vWords[1] == "JOIN" && vWords[0].size() > 1)160 {161 // :username!username@50000007.F000000B.90000002.IP JOIN :#channelname162- strcpy(pszName, vWords[0].c_str() + 1);163+ strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName));164 if (strchr(pszName, '!'))165 *strchr(pszName, '!') = '\0';166- printf("GOT JOIN: [%s] ", pszName);167+ printf("IRC got join\n");168 }169 170 if (pszName[0] == 'u')171@@ -252,28 +264,24 @@172 CAddress addr;173 if (DecodeAddress(pszName, addr))174 {175+ addr.nTime = GetAdjustedTime() - 51 * 60;176 CAddrDB addrdb;177 if (AddAddress(addrdb, addr))178- printf("new ");179- else180- {181- // make it try connecting again182- CRITICAL_BLOCK(cs_mapAddresses)183- if (mapAddresses.count(addr.GetKey()))184- mapAddresses[addr.GetKey()].nLastFailed = 0;185- }186- addr.print();187-188- CRITICAL_BLOCK(cs_mapIRCAddresses)189- mapIRCAddresses.insert(make_pair(addr.GetKey(), addr));190+ printf("IRC got new address\n");191+ nGotIRCAddresses++;192 }193 else194 {195- printf("decode failed\n");196+ printf("IRC decode failed\n");197 }198 }199 }200 closesocket(hSocket);201+ hSocket = INVALID_SOCKET;202+203+ // IRC usually blocks TOR, so only try once204+ if (fTOR)205+ return;206 207 if (GetTime() - nStart > 20 * 60)208 {
irc.h (modified)
1--- v0.1.5/irc.h2+++ v0.2.0/irc.h3@@ -4,8 +4,6 @@4 5 extern bool RecvLine(SOCKET hSocket, string& strLine);6 extern void ThreadIRCSeed(void* parg);7-extern bool fRestartIRCSeed;8 9-extern map<vector<unsigned char>, CAddress> mapIRCAddresses;10-extern CCriticalSection cs_mapIRCAddresses;11+extern int nGotIRCAddresses;12
key.h (modified)
1--- v0.1.5/key.h2+++ v0.2.0/key.h3@@ -35,7 +35,7 @@4 };5 6 7-// secure_allocator is defined is serialize.h8+// secure_allocator is defined in serialize.h9 typedef vector<unsigned char, secure_allocator<unsigned char> > CPrivKey;10 11 12@@ -44,6 +44,7 @@13 {14 protected:15 EC_KEY* pkey;16+ bool fSet;17 18 public:19 CKey()20@@ -51,6 +52,7 @@21 pkey = EC_KEY_new_by_curve_name(NID_secp256k1);22 if (pkey == NULL)23 throw key_error("CKey::CKey() : EC_KEY_new_by_curve_name failed");24+ fSet = false;25 }26 27 CKey(const CKey& b)28@@ -58,12 +60,14 @@29 pkey = EC_KEY_dup(b.pkey);30 if (pkey == NULL)31 throw key_error("CKey::CKey(const CKey&) : EC_KEY_dup failed");32+ fSet = b.fSet;33 }34 35 CKey& operator=(const CKey& b)36 {37 if (!EC_KEY_copy(pkey, b.pkey))38 throw key_error("CKey::operator=(const CKey&) : EC_KEY_copy failed");39+ fSet = b.fSet;40 return (*this);41 }42 43@@ -72,10 +76,16 @@44 EC_KEY_free(pkey);45 }46 47+ bool IsNull() const48+ {49+ return !fSet;50+ }51+52 void MakeNewKey()53 {54 if (!EC_KEY_generate_key(pkey))55 throw key_error("CKey::MakeNewKey() : EC_KEY_generate_key failed");56+ fSet = true;57 }58 59 bool SetPrivKey(const CPrivKey& vchPrivKey)60@@ -83,6 +93,7 @@61 const unsigned char* pbegin = &vchPrivKey[0];62 if (!d2i_ECPrivateKey(&pkey, &pbegin, vchPrivKey.size()))63 return false;64+ fSet = true;65 return true;66 }67 68@@ -103,6 +114,7 @@69 const unsigned char* pbegin = &vchPubKey[0];70 if (!o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size()))71 return false;72+ fSet = true;73 return true;74 }75
main.cpp (modified)
1--- v0.1.5/main.cpp2+++ v0.2.0/main.cpp3@@ -34,7 +34,7 @@4 multimap<uint256, CDataStream*> mapOrphanTransactionsByPrev;5 6 map<uint256, CWalletTx> mapWallet;7-vector<pair<uint256, bool> > vWalletUpdated;8+vector<uint256> vWalletUpdated;9 CCriticalSection cs_mapWallet;10 11 map<vector<unsigned char>, CPrivKey> mapKeys;12@@ -42,15 +42,15 @@13 CCriticalSection cs_mapKeys;14 CKey keyUser;15 16-string strSetDataDir;17-int nDropMessagesTest = 0;18+map<uint256, int> mapRequestCount;19+CCriticalSection cs_mapRequestCount;20 21 // Settings22-int fGenerateBitcoins;23+int fGenerateBitcoins = false;24 int64 nTransactionFee = 0;25 CAddress addrIncoming;26-27-28+int fLimitProcessors = false;29+int nLimitProcessors = 1;30 31 32 33@@ -101,13 +101,10 @@34 if (fInsertedNew)35 wtx.nTimeReceived = GetAdjustedTime();36 37- //// debug print38- printf("AddToWallet %s %s\n", wtxIn.GetHash().ToString().substr(0,6).c_str(), fInsertedNew ? "new" : "update");39-40+ bool fUpdated = false;41 if (!fInsertedNew)42 {43 // Merge44- bool fUpdated = false;45 if (wtxIn.hashBlock != 0 && wtxIn.hashBlock != wtx.hashBlock)46 {47 wtx.hashBlock = wtxIn.hashBlock;48@@ -129,16 +126,18 @@49 wtx.fSpent = wtxIn.fSpent;50 fUpdated = true;51 }52- if (!fUpdated)53- return true;54- }55+ }56+57+ //// debug print58+ printf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString().substr(0,6).c_str(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));59 60 // Write to disk61- if (!wtx.WriteToDisk())62- return false;63+ if (fInsertedNew || fUpdated)64+ if (!wtx.WriteToDisk())65+ return false;66 67 // Notify UI68- vWalletUpdated.push_back(make_pair(hash, fInsertedNew));69+ vWalletUpdated.push_back(hash);70 }71 72 // Refresh UI73@@ -278,7 +277,44 @@74 return nTimeReceived;75 }76 77-78+int CWalletTx::GetRequestCount() const79+{80+ // Returns -1 if it wasn't being tracked81+ int nRequests = -1;82+ CRITICAL_BLOCK(cs_mapRequestCount)83+ {84+ if (IsCoinBase())85+ {86+ // Generated block87+ if (hashBlock != 0)88+ {89+ map<uint256, int>::iterator mi = mapRequestCount.find(hashBlock);90+ if (mi != mapRequestCount.end())91+ nRequests = (*mi).second;92+ }93+ }94+ else95+ {96+ // Did anyone request this transaction?97+ map<uint256, int>::iterator mi = mapRequestCount.find(GetHash());98+ if (mi != mapRequestCount.end())99+ {100+ nRequests = (*mi).second;101+102+ // How about the block it's in?103+ if (nRequests == 0 && hashBlock != 0)104+ {105+ map<uint256, int>::iterator mi = mapRequestCount.find(hashBlock);106+ if (mi != mapRequestCount.end())107+ nRequests = (*mi).second;108+ else109+ nRequests = 1; // If it's in someone else's block it must have got out110+ }111+ }112+ }113+ }114+ return nRequests;115+}116 117 118 119@@ -299,7 +335,7 @@120 CTxIndex txindex;121 if (!CTxDB("r").ReadTxIndex(GetHash(), txindex))122 return 0;123- if (!blockTmp.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, true))124+ if (!blockTmp.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos))125 return 0;126 pblock = &blockTmp;127 }128@@ -415,6 +451,10 @@129 if (!CheckTransaction())130 return error("AcceptTransaction() : CheckTransaction failed");131 132+ // To help v0.1.5 clients who would see it as negative number. please delete this later.133+ if (nLockTime > INT_MAX)134+ return error("AcceptTransaction() : not accepting nLockTime beyond 2038");135+136 // Do we already have it?137 uint256 hash = GetHash();138 CRITICAL_BLOCK(cs_mapTransactions)139@@ -720,7 +760,7 @@140 bnNew = bnProofOfWorkLimit;141 142 /// debug print143- printf("\n\n\nGetNextWorkRequired RETARGET *****\n");144+ printf("GetNextWorkRequired RETARGET\n");145 printf("nTargetTimespan = %d nActualTimespan = %d\n", nTargetTimespan, nActualTimespan);146 printf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString().c_str());147 printf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str());148@@ -817,7 +857,7 @@149 }150 151 if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size())152- return error("ConnectInputs() : %s prevout.n out of range %d %d %d", GetHash().ToString().substr(0,6).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size());153+ return error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,6).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,6).c_str(), txPrev.ToString().c_str());154 155 // If prev is coinbase, check that it's matured156 if (txPrev.IsCoinBase())157@@ -973,7 +1013,7 @@158 159 bool Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)160 {161- printf("*** REORGANIZE ***\n");162+ printf("REORGANIZE\n");163 164 // Find the fork165 CBlockIndex* pfork = pindexBest;166@@ -1003,7 +1043,7 @@167 foreach(CBlockIndex* pindex, vDisconnect)168 {169 CBlock block;170- if (!block.ReadFromDisk(pindex->nFile, pindex->nBlockPos, true))171+ if (!block.ReadFromDisk(pindex->nFile, pindex->nBlockPos))172 return error("Reorganize() : ReadFromDisk for disconnect failed");173 if (!block.DisconnectBlock(txdb, pindex))174 return error("Reorganize() : DisconnectBlock failed");175@@ -1020,7 +1060,7 @@176 {177 CBlockIndex* pindex = vConnect[i];178 CBlock block;179- if (!block.ReadFromDisk(pindex->nFile, pindex->nBlockPos, true))180+ if (!block.ReadFromDisk(pindex->nFile, pindex->nBlockPos))181 return error("Reorganize() : ReadFromDisk for connect failed");182 if (!block.ConnectBlock(txdb, pindex))183 {184@@ -1074,7 +1114,7 @@185 // Check for duplicate186 uint256 hash = GetHash();187 if (mapBlockIndex.count(hash))188- return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,14).c_str());189+ return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,16).c_str());190 191 // Construct new block index object192 CBlockIndex* pindexNew = new CBlockIndex(nFile, nBlockPos, *this);193@@ -1134,15 +1174,23 @@194 pindexBest = pindexNew;195 nBestHeight = pindexBest->nHeight;196 nTransactionsUpdated++;197- printf("AddToBlockIndex: new best=%s height=%d\n", hashBestChain.ToString().substr(0,14).c_str(), nBestHeight);198+ printf("AddToBlockIndex: new best=%s height=%d\n", hashBestChain.ToString().substr(0,16).c_str(), nBestHeight);199 }200 201 txdb.TxnCommit();202 txdb.Close();203 204- // Relay wallet transactions that haven't gotten in yet205 if (pindexNew == pindexBest)206+ {207+ // Relay wallet transactions that haven't gotten in yet208 RelayWalletTransactions();209+210+ // Notify UI to display prev block's coinbase if it was ours211+ static uint256 hashPrevBestCoinBase;212+ CRITICAL_BLOCK(cs_mapWallet)213+ vWalletUpdated.push_back(hashPrevBestCoinBase);214+ hashPrevBestCoinBase = vtx[0].GetHash();215+ }216 217 MainFrameRepaint();218 return true;219@@ -1205,6 +1253,12 @@220 // Check timestamp against prev221 if (nTime <= pindexPrev->GetMedianTimePast())222 return error("AcceptBlock() : block's timestamp is too early");223+224+ // Check that all transactions are finalized (starting around Mar 2010)225+ if (nBestHeight > 36000)226+ foreach(const CTransaction& tx, vtx)227+ if (!tx.IsFinal(nTime))228+ return error("AcceptBlock() : contains a non-final transaction");229 230 // Check proof of work231 if (nBits != GetNextWorkRequired(pindexPrev))232@@ -1220,7 +1274,7 @@233 if (!AddToBlockIndex(nFile, nBlockPos))234 return error("AcceptBlock() : AddToBlockIndex failed");235 236- if (hashBestChain == hash)237+ if (hashBestChain == hash && nBestHeight > 28000)238 RelayInventory(CInv(MSG_BLOCK, hash));239 240 // // Add atoms to user reviews for coins created241@@ -1240,9 +1294,9 @@242 // Check for duplicate243 uint256 hash = pblock->GetHash();244 if (mapBlockIndex.count(hash))245- return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().substr(0,14).c_str());246+ return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().substr(0,16).c_str());247 if (mapOrphanBlocks.count(hash))248- return error("ProcessBlock() : already have block (orphan) %s", hash.ToString().substr(0,14).c_str());249+ return error("ProcessBlock() : already have block (orphan) %s", hash.ToString().substr(0,16).c_str());250 251 // Preliminary checks252 if (!pblock->CheckBlock())253@@ -1254,13 +1308,13 @@254 // If don't already have its previous block, shunt it off to holding area until we get it255 if (!mapBlockIndex.count(pblock->hashPrevBlock))256 {257- printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,14).c_str());258+ printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,16).c_str());259 mapOrphanBlocks.insert(make_pair(hash, pblock));260 mapOrphanBlocksByPrev.insert(make_pair(pblock->hashPrevBlock, pblock));261 262 // Ask this guy to fill in what we're missing263 if (pfrom)264- pfrom->PushMessage("getblocks", CBlockLocator(pindexBest), GetOrphanRoot(pblock));265+ pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(pblock));266 return true;267 }268 269@@ -1343,48 +1397,13 @@270 }271 }272 273-string GetAppDir()274-{275- string strDir;276- if (!strSetDataDir.empty())277- {278- strDir = strSetDataDir;279- }280- else if (getenv("APPDATA"))281- {282- strDir = strprintf("%s\\Bitcoin", getenv("APPDATA"));283- }284- else if (getenv("USERPROFILE"))285- {286- string strAppData = strprintf("%s\\Application Data", getenv("USERPROFILE"));287- static bool fMkdirDone;288- if (!fMkdirDone)289- {290- fMkdirDone = true;291- _mkdir(strAppData.c_str());292- }293- strDir = strprintf("%s\\Bitcoin", strAppData.c_str());294- }295- else296- {297- return ".";298- }299- static bool fMkdirDone;300- if (!fMkdirDone)301- {302- fMkdirDone = true;303- _mkdir(strDir.c_str());304- }305- return strDir;306-}307-308 bool CheckDiskSpace(int64 nAdditionalBytes)309 {310+#ifdef __WXMSW__311 uint64 nFreeBytesAvailable = 0; // bytes available to caller312 uint64 nTotalNumberOfBytes = 0; // bytes on disk313 uint64 nTotalNumberOfFreeBytes = 0; // free bytes on disk314-315- if (!GetDiskFreeSpaceEx(GetAppDir().c_str(),316+ if (!GetDiskFreeSpaceEx(GetDataDir().c_str(),317 (PULARGE_INTEGER)&nFreeBytesAvailable,318 (PULARGE_INTEGER)&nTotalNumberOfBytes,319 (PULARGE_INTEGER)&nTotalNumberOfFreeBytes))320@@ -1392,13 +1411,16 @@321 printf("ERROR: GetDiskFreeSpaceEx() failed\n");322 return true;323 }324+#else325+ uint64 nFreeBytesAvailable = filesystem::space(GetDataDir()).available;326+#endif327 328 // Check for 15MB because database could create another 10MB log file at any time329- if ((int64)nFreeBytesAvailable < 15000000 + nAdditionalBytes)330+ if (nFreeBytesAvailable < (int64)15000000 + nAdditionalBytes)331 {332 fShutdown = true;333- wxMessageBox("Warning: Your disk space is low ", "Bitcoin", wxICON_EXCLAMATION);334- _beginthread(Shutdown, 0, NULL);335+ ThreadSafeMessageBox("Warning: Your disk space is low ", "Bitcoin", wxOK | wxICON_EXCLAMATION);336+ CreateThread(Shutdown, NULL);337 return false;338 }339 return true;340@@ -1408,7 +1430,7 @@341 {342 if (nFile == -1)343 return NULL;344- FILE* file = fopen(strprintf("%s\\blk%04d.dat", GetAppDir().c_str(), nFile).c_str(), pszMode);345+ FILE* file = fopen(strprintf("%s/blk%04d.dat", GetDataDir().c_str(), nFile).c_str(), pszMode);346 if (!file)347 return NULL;348 if (nBlockPos != 0 && !strchr(pszMode, 'a') && !strchr(pszMode, 'w'))349@@ -1481,11 +1503,11 @@350 // vMerkleTree: 4a5e1e351 352 // Genesis block353- char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";354+ const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";355 CTransaction txNew;356 txNew.vin.resize(1);357 txNew.vout.resize(1);358- txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((unsigned char*)pszTimestamp, (unsigned char*)pszTimestamp + strlen(pszTimestamp));359+ txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));360 txNew.vout[0].nValue = 50 * COIN;361 txNew.vout[0].scriptPubKey = CScript() << CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") << OP_CHECKSIG;362 CBlock block;363@@ -1497,7 +1519,7 @@364 block.nBits = 0x1d00ffff;365 block.nNonce = 2083236893;366 367- //// debug print, delete this later368+ //// debug print369 printf("%s\n", block.GetHash().ToString().c_str());370 printf("%s\n", block.hashMerkleRoot.ToString().c_str());371 printf("%s\n", hashGenesisBlock.ToString().c_str());372@@ -1565,13 +1587,13 @@373 374 // print item375 CBlock block;376- block.ReadFromDisk(pindex, true);377+ block.ReadFromDisk(pindex);378 printf("%d (%u,%u) %s %s tx %d",379 pindex->nHeight,380 pindex->nFile,381 pindex->nBlockPos,382- block.GetHash().ToString().substr(0,14).c_str(),383- DateTimeStr(block.nTime).c_str(),384+ block.GetHash().ToString().substr(0,16).c_str(),385+ DateTimeStrFormat("%x %H:%M:%S", block.nTime).c_str(),386 block.vtx.size());387 388 CRITICAL_BLOCK(cs_mapWallet)389@@ -1641,7 +1663,8 @@390 CDataStream& vRecv = pfrom->vRecv;391 if (vRecv.empty())392 return true;393- printf("ProcessMessages(%d bytes)\n", vRecv.size());394+ //if (fDebug)395+ // printf("ProcessMessages(%d bytes)\n", vRecv.size());396 397 //398 // Message format399@@ -1684,7 +1707,8 @@400 {401 // Rewind and wait for rest of message402 ///// need a mechanism to give up waiting for overlong message size error403- printf("MESSAGE-BREAK\n");404+ //if (fDebug)405+ // printf("message-break\n");406 vRecv.insert(vRecv.begin(), BEGIN(hdr), END(hdr));407 Sleep(100);408 break;409@@ -1698,14 +1722,31 @@410 bool fRet = false;411 try412 {413- CheckForShutdown(2);414 CRITICAL_BLOCK(cs_main)415 fRet = ProcessMessage(pfrom, strCommand, vMsg);416- CheckForShutdown(2);417- }418- CATCH_PRINT_EXCEPTION("ProcessMessage()")419+ if (fShutdown)420+ return true;421+ }422+ catch (std::ios_base::failure& e)423+ {424+ if (strstr(e.what(), "CDataStream::read() : end of data"))425+ {426+ // Allow exceptions from underlength message on vRecv427+ printf("ProcessMessage(%s, %d bytes) : Exception '%s' caught, normally caused by a message being shorter than its stated length\n", strCommand.c_str(), nMessageSize, e.what());428+ }429+ else430+ {431+ PrintException(&e, "ProcessMessage()");432+ }433+ }434+ catch (std::exception& e) {435+ PrintException(&e, "ProcessMessage()");436+ } catch (...) {437+ PrintException(NULL, "ProcessMessage()");438+ }439+440 if (!fRet)441- printf("ProcessMessage(%s, %d bytes) from %s to %s FAILED\n", strCommand.c_str(), nMessageSize, pfrom->addr.ToString().c_str(), addrLocalHost.ToString().c_str());442+ printf("ProcessMessage(%s, %d bytes) FAILED\n", strCommand.c_str(), nMessageSize);443 }444 445 vRecv.Compact();446@@ -1718,29 +1759,45 @@447 bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)448 {449 static map<unsigned int, vector<unsigned char> > mapReuseKey;450- printf("received: %-12s (%d bytes) ", strCommand.c_str(), vRecv.size());451- for (int i = 0; i < min(vRecv.size(), (unsigned int)20); i++)452- printf("%02x ", vRecv[i] & 0xff);453- printf("\n");454- if (nDropMessagesTest > 0 && GetRand(nDropMessagesTest) == 0)455- {456- printf("dropmessages DROPPING RECV MESSAGE\n");457+ RandAddSeedPerfmon();458+ if (fDebug)459+ printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());460+ printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size());461+ if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)462+ {463+ printf("dropmessagestest DROPPING RECV MESSAGE\n");464 return true;465 }466 467 468 469+470+471 if (strCommand == "version")472 {473- // Can only do this once474+ // Each connection can only send one version message475 if (pfrom->nVersion != 0)476 return false;477 478 int64 nTime;479 CAddress addrMe;480+ CAddress addrFrom;481+ uint64 nNonce = 1;482+ string strSubVer;483 vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;484+ if (pfrom->nVersion >= 106 && !vRecv.empty())485+ vRecv >> addrFrom >> nNonce;486+ if (pfrom->nVersion >= 106 && !vRecv.empty())487+ vRecv >> strSubVer;488 if (pfrom->nVersion == 0)489 return false;490+491+ // Disconnect if we connected to ourself492+ if (nNonce == nLocalHostNonce && nNonce > 1)493+ {494+ pfrom->fDisconnect = true;495+ return true;496+ }497 498 pfrom->vSend.SetVersion(min(pfrom->nVersion, VERSION));499 pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));500@@ -1759,10 +1816,12 @@501 if (!fAskedForBlocks && !pfrom->fClient)502 {503 fAskedForBlocks = true;504- pfrom->PushMessage("getblocks", CBlockLocator(pindexBest), uint256(0));505- }506-507- printf("version message: %s has version %d, addrMe=%s\n", pfrom->addr.ToString().c_str(), pfrom->nVersion, addrMe.ToString().c_str());508+ pfrom->PushGetBlocks(pindexBest, uint256(0));509+ }510+511+ pfrom->fSuccessfullyConnected = true;512+513+ printf("version message: version %d\n", pfrom->nVersion);514 }515 516 517@@ -1777,23 +1836,29 @@518 {519 vector<CAddress> vAddr;520 vRecv >> vAddr;521+ if (vAddr.size() > 50000) // lower this to 1000 later522+ return error("message addr size() = %d", vAddr.size());523 524 // Store the new addresses525 CAddrDB addrdb;526- foreach(const CAddress& addr, vAddr)527+ foreach(CAddress& addr, vAddr)528 {529 if (fShutdown)530 return true;531- if (AddAddress(addrdb, addr))532+ addr.nTime = GetAdjustedTime() - 2 * 60 * 60;533+ if (pfrom->fGetAddr)534+ addr.nTime -= 5 * 24 * 60 * 60;535+ AddAddress(addrdb, addr, false);536+ pfrom->AddAddressKnown(addr);537+ if (!pfrom->fGetAddr && addr.IsRoutable())538 {539 // Put on lists to send to other nodes540- pfrom->setAddrKnown.insert(addr);541 CRITICAL_BLOCK(cs_vNodes)542 foreach(CNode* pnode, vNodes)543- if (!pnode->setAddrKnown.count(addr))544- pnode->vAddrToSend.push_back(addr);545- }546- }547+ pnode->PushAddress(addr);548+ }549+ }550+ pfrom->fGetAddr = false;551 }552 553 554@@ -1801,6 +1866,8 @@555 {556 vector<CInv> vInv;557 vRecv >> vInv;558+ if (vInv.size() > 50000)559+ return error("message inv size() = %d", vInv.size());560 561 CTxDB txdb("r");562 foreach(const CInv& inv, vInv)563@@ -1815,7 +1882,15 @@564 if (!fAlreadyHave)565 pfrom->AskFor(inv);566 else if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash))567- pfrom->PushMessage("getblocks", CBlockLocator(pindexBest), GetOrphanRoot(mapOrphanBlocks[inv.hash]));568+ pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(mapOrphanBlocks[inv.hash]));569+570+ // Track requests for our stuff571+ CRITICAL_BLOCK(cs_mapRequestCount)572+ {573+ map<uint256, int>::iterator mi = mapRequestCount.find(inv.hash);574+ if (mi != mapRequestCount.end())575+ (*mi).second++;576+ }577 }578 }579 580@@ -1824,6 +1899,8 @@581 {582 vector<CInv> vInv;583 vRecv >> vInv;584+ if (vInv.size() > 50000)585+ return error("message getdata size() = %d", vInv.size());586 587 foreach(const CInv& inv, vInv)588 {589@@ -1841,6 +1918,18 @@590 CBlock block;591 block.ReadFromDisk((*mi).second, !pfrom->fClient);592 pfrom->PushMessage("block", block);593+594+ // Trigger them to send a getblocks request for the next batch of inventory595+ if (inv.hash == pfrom->hashContinue)596+ {597+ // Bypass PushInventory, this must send even if redundant,598+ // and we want it right after the last block so they don't599+ // wait for other stuff first.600+ vector<CInv> vInv;601+ vInv.push_back(CInv(MSG_BLOCK, hashBestChain));602+ pfrom->PushMessage("inv", vInv);603+ pfrom->hashContinue = 0;604+ }605 }606 }607 else if (inv.IsKnownType())608@@ -1853,6 +1942,14 @@609 pfrom->PushMessage(inv.GetCommand(), (*mi).second);610 }611 }612+613+ // Track requests for our stuff614+ CRITICAL_BLOCK(cs_mapRequestCount)615+ {616+ map<uint256, int>::iterator mi = mapRequestCount.find(inv.hash);617+ if (mi != mapRequestCount.end())618+ (*mi).second++;619+ }620 }621 }622 623@@ -1869,25 +1966,23 @@624 // Send the rest of the chain625 if (pindex)626 pindex = pindex->pnext;627- printf("getblocks %d to %s\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,14).c_str());628+ int nLimit = 500 + locator.GetDistanceBack();629+ printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,16).c_str(), nLimit);630 for (; pindex; pindex = pindex->pnext)631 {632 if (pindex->GetBlockHash() == hashStop)633 {634- printf(" getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,14).c_str());635+ printf(" getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,16).c_str());636 break;637 }638-639- // Bypass setInventoryKnown in case an inventory message got lost640- CRITICAL_BLOCK(pfrom->cs_inventory)641- {642- CInv inv(MSG_BLOCK, pindex->GetBlockHash());643- // returns true if wasn't already contained in the set644- if (pfrom->setInventoryKnown2.insert(inv).second)645- {646- pfrom->setInventoryKnown.erase(inv);647- pfrom->vInventoryToSend.push_back(inv);648- }649+ pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));650+ if (--nLimit <= 0)651+ {652+ // When this block is requested, we'll send an inv that'll make them653+ // getblocks the next batch of inventory.654+ printf(" getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,16).c_str());655+ pfrom->hashContinue = pindex->GetBlockHash();656+ break;657 }658 }659 }660@@ -1970,7 +2065,9 @@661 vRecv >> *pblock;662 663 //// debug print664- printf("received block:\n"); pblock->print();665+ // printf("received block:\n");666+ // pblock->print();667+ printf("received block %s\n", pblock->GetHash().ToString().substr(0,16).c_str());668 669 CInv inv(MSG_BLOCK, pblock->GetHash());670 pfrom->AddInventoryKnown(inv);671@@ -1992,10 +2089,8 @@672 if (fShutdown)673 return true;674 const CAddress& addr = item.second;675- //// will need this if we lose IRC676- //if (addr.nTime > nSince || (rand() % nSize) < 500)677 if (addr.nTime > nSince)678- pfrom->vAddrToSend.push_back(addr);679+ pfrom->PushAddress(addr);680 }681 }682 }683@@ -2062,15 +2157,22 @@684 }685 686 687+ else if (strCommand == "ping")688+ {689+ }690+691+692 else693 {694 // Ignore unknown commands for extensibility695- printf("ProcessMessage(%s) : Ignored unknown message\n", strCommand.c_str());696- }697-698-699- if (!vRecv.empty())700- printf("ProcessMessage(%s) : %d extra bytes\n", strCommand.c_str(), vRecv.size());701+ }702+703+704+ // Update the last seen time for this node's address705+ if (pfrom->fNetworkNode)706+ if (strCommand == "version" || strCommand == "addr" || strCommand == "inv" || strCommand == "getdata" || strCommand == "ping")707+ AddressCurrentlyConnected(pfrom->addr);708+709 710 return true;711 }712@@ -2085,12 +2187,34 @@713 714 bool SendMessages(CNode* pto)715 {716- CheckForShutdown(2);717 CRITICAL_BLOCK(cs_main)718 {719 // Don't send anything until we get their version message720 if (pto->nVersion == 0)721 return true;722+723+ // Keep-alive ping724+ if (pto->nLastSend && GetTime() - pto->nLastSend > 12 * 60 && pto->vSend.empty())725+ pto->PushMessage("ping");726+727+ // Address refresh broadcast728+ static int64 nLastRebroadcast;729+ if (GetTime() - nLastRebroadcast > 24 * 60 * 60) // every 24 hours730+ {731+ nLastRebroadcast = GetTime();732+ CRITICAL_BLOCK(cs_vNodes)733+ {734+ foreach(CNode* pnode, vNodes)735+ {736+ // Periodically clear setAddrKnown to allow refresh broadcasts737+ pnode->setAddrKnown.clear();738+739+ // Rebroadcast our address740+ if (addrLocalHost.IsRoutable() && !fUseProxy)741+ pnode->PushAddress(addrLocalHost);742+ }743+ }744+ }745 746 747 //748@@ -2099,8 +2223,18 @@749 vector<CAddress> vAddrToSend;750 vAddrToSend.reserve(pto->vAddrToSend.size());751 foreach(const CAddress& addr, pto->vAddrToSend)752- if (!pto->setAddrKnown.count(addr))753+ {754+ // returns true if wasn't already contained in the set755+ if (pto->setAddrKnown.insert(addr).second)756+ {757 vAddrToSend.push_back(addr);758+ if (vAddrToSend.size() >= 1000)759+ {760+ pto->PushMessage("addr", vAddrToSend);761+ vAddrToSend.clear();762+ }763+ }764+ }765 pto->vAddrToSend.clear();766 if (!vAddrToSend.empty())767 pto->PushMessage("addr", vAddrToSend);768@@ -2117,10 +2251,16 @@769 {770 // returns true if wasn't already contained in the set771 if (pto->setInventoryKnown.insert(inv).second)772+ {773 vInventoryToSend.push_back(inv);774+ if (vInventoryToSend.size() >= 1000)775+ {776+ pto->PushMessage("inv", vInventoryToSend);777+ vInventoryToSend.clear();778+ }779+ }780 }781 pto->vInventoryToSend.clear();782- pto->setInventoryKnown2.clear();783 }784 if (!vInventoryToSend.empty())785 pto->PushMessage("inv", vInventoryToSend);786@@ -2135,9 +2275,16 @@787 while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow)788 {789 const CInv& inv = (*pto->mapAskFor.begin()).second;790- printf("sending getdata: %s\n", inv.ToString().c_str());791 if (!AlreadyHave(txdb, inv))792+ {793+ printf("sending getdata: %s\n", inv.ToString().c_str());794 vAskFor.push_back(inv);795+ if (vAskFor.size() >= 1000)796+ {797+ pto->PushMessage("getdata", vAskFor);798+ vAskFor.clear();799+ }800+ }801 pto->mapAskFor.erase(pto->mapAskFor.begin());802 }803 if (!vAskFor.empty())804@@ -2164,6 +2311,49 @@805 //806 // BitcoinMiner807 //808+809+void GenerateBitcoins(bool fGenerate)810+{811+ if (fGenerateBitcoins != fGenerate)812+ {813+ fGenerateBitcoins = fGenerate;814+ CWalletDB().WriteSetting("fGenerateBitcoins", fGenerateBitcoins);815+ MainFrameRepaint();816+ }817+ if (fGenerateBitcoins)818+ {819+ int nProcessors = wxThread::GetCPUCount();820+ printf("%d processors\n", nProcessors);821+ if (nProcessors < 1)822+ nProcessors = 1;823+ if (fLimitProcessors && nProcessors > nLimitProcessors)824+ nProcessors = nLimitProcessors;825+ int nAddThreads = nProcessors - vnThreadsRunning[3];826+ printf("Starting %d BitcoinMiner threads\n", nAddThreads);827+ for (int i = 0; i < nAddThreads; i++)828+ if (!CreateThread(ThreadBitcoinMiner, NULL))829+ printf("Error: CreateThread(ThreadBitcoinMiner) failed\n");830+ }831+}832+833+void ThreadBitcoinMiner(void* parg)834+{835+ try836+ {837+ vnThreadsRunning[3]++;838+ BitcoinMiner();839+ vnThreadsRunning[3]--;840+ }841+ catch (std::exception& e) {842+ vnThreadsRunning[3]--;843+ PrintException(&e, "ThreadBitcoinMiner()");844+ } catch (...) {845+ vnThreadsRunning[3]--;846+ PrintException(NULL, "ThreadBitcoinMiner()");847+ }848+849+ printf("ThreadBitcoinMiner exiting, %d threads remaining\n", vnThreadsRunning[3]);850+}851 852 int FormatHashBlocks(void* pbuffer, unsigned int len)853 {854@@ -2210,22 +2400,26 @@855 }856 857 858-bool BitcoinMiner()859+void BitcoinMiner()860 {861 printf("BitcoinMiner started\n");862- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);863 864 CKey key;865 key.MakeNewKey();866 CBigNum bnExtraNonce = 0;867 while (fGenerateBitcoins)868 {869+ SetThreadPriority(THREAD_PRIORITY_LOWEST);870 Sleep(50);871- CheckForShutdown(3);872+ if (fShutdown)873+ return;874 while (vNodes.empty())875 {876 Sleep(1000);877- CheckForShutdown(3);878+ if (fShutdown)879+ return;880+ if (!fGenerateBitcoins)881+ return;882 }883 884 unsigned int nTransactionsUpdatedLast = nTransactionsUpdated;885@@ -2249,7 +2443,7 @@886 //887 auto_ptr<CBlock> pblock(new CBlock());888 if (!pblock.get())889- return false;890+ return;891 892 // Add our coinbase tx as first transaction893 pblock->vtx.push_back(txNew);894@@ -2276,10 +2470,8 @@895 if (tx.IsCoinBase() || !tx.IsFinal())896 continue;897 898- // Transaction fee requirements, mainly only needed for flood control899- // Under 10K (about 80 inputs) is free for first 100 transactions900- // Base rate is 0.01 per KB901- int64 nMinFee = tx.GetMinFee(pblock->vtx.size() < 100);902+ // Transaction fee based on block size903+ int64 nMinFee = tx.GetMinFee(nBlockSize);904 905 map<uint256, CTxIndex> mapTestPoolTmp(mapTestPool);906 if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), 0, nFees, false, true, nMinFee))907@@ -2295,7 +2487,7 @@908 }909 pblock->nBits = nBits;910 pblock->vtx[0].vout[0].nValue = pblock->GetBlockValue(nFees);911- printf("\n\nRunning BitcoinMiner with %d transactions in block\n", pblock->vtx.size());912+ printf("Running BitcoinMiner with %d transactions in block\n", pblock->vtx.size());913 914 915 //916@@ -2333,14 +2525,13 @@917 //918 // Search919 //920- unsigned int nStart = GetTime();921+ int64 nStart = GetTime();922 uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();923 uint256 hash;924 loop925 {926 BlockSHA256(&tmp.block, nBlocks0, &tmp.hash1);927 BlockSHA256(&tmp.hash1, nBlocks1, &hash);928-929 930 if (hash <= hashTarget)931 {932@@ -2352,42 +2543,65 @@933 printf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());934 pblock->print();935 936- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);937+ SetThreadPriority(THREAD_PRIORITY_NORMAL);938 CRITICAL_BLOCK(cs_main)939 {940- // Save key941- if (!AddKey(key))942- return false;943- key.MakeNewKey();944-945- // Process this block the same as if we had received it from another node946- if (!ProcessBlock(NULL, pblock.release()))947- printf("ERROR in BitcoinMiner, ProcessBlock, block not accepted\n");948+ if (pindexPrev == pindexBest)949+ {950+ // Save key951+ if (!AddKey(key))952+ return;953+ key.MakeNewKey();954+955+ // Track how many getdata requests this block gets956+ CRITICAL_BLOCK(cs_mapRequestCount)957+ mapRequestCount[pblock->GetHash()] = 0;958+959+ // Process this block the same as if we had received it from another node960+ if (!ProcessBlock(NULL, pblock.release()))961+ printf("ERROR in BitcoinMiner, ProcessBlock, block not accepted\n");962+ }963 }964- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);965+ SetThreadPriority(THREAD_PRIORITY_LOWEST);966 967 Sleep(500);968 break;969 }970 971 // Update nTime every few seconds972- if ((++tmp.block.nNonce & 0x3ffff) == 0)973- {974- CheckForShutdown(3);975+ if ((++tmp.block.nNonce & 0xffff) == 0)976+ {977+ if (fShutdown)978+ return;979+ if (!fGenerateBitcoins)980+ return;981+ if (fLimitProcessors && vnThreadsRunning[3] > nLimitProcessors)982+ return;983+ if (vNodes.empty())984+ break;985 if (tmp.block.nNonce == 0)986- break;987- if (pindexPrev != pindexBest)988 break;989 if (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)990 break;991- if (!fGenerateBitcoins)992+ if (pindexPrev != pindexBest)993+ {994+ // Pause generating during initial download995+ if (GetTime() - nStart < 20)996+ {997+ CBlockIndex* pindexTmp;998+ do999+ {1000+ pindexTmp = pindexBest;1001+ Sleep(10000);1002+ }1003+ while (pindexTmp != pindexBest);1004+ }1005 break;1006+ }1007 tmp.block.nTime = pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());1008 }1009 }1010 }1011-1012- return true;1013 }1014 1015 1016@@ -2415,8 +2629,7 @@1017 1018 int64 GetBalance()1019 {1020- int64 nStart, nEnd;1021- QueryPerformanceCounter((LARGE_INTEGER*)&nStart);1022+ int64 nStart = GetTimeMillis();1023 1024 int64 nTotal = 0;1025 CRITICAL_BLOCK(cs_mapWallet)1026@@ -2426,12 +2639,11 @@1027 CWalletTx* pcoin = &(*it).second;1028 if (!pcoin->IsFinal() || pcoin->fSpent)1029 continue;1030- nTotal += pcoin->GetCredit();1031- }1032- }1033-1034- QueryPerformanceCounter((LARGE_INTEGER*)&nEnd);1035- ///printf(" GetBalance() time = %16I64d\n", nEnd - nStart);1036+ nTotal += pcoin->GetCredit(true);1037+ }1038+ }1039+1040+ //printf("GetBalance() %"PRI64d"ms\n", GetTimeMillis() - nStart);1041 return nTotal;1042 }1043 1044@@ -2442,7 +2654,7 @@1045 setCoinsRet.clear();1046 1047 // List of values less than target1048- int64 nLowestLarger = _I64_MAX;1049+ int64 nLowestLarger = INT64_MAX;1050 CWalletTx* pcoinLowestLarger = NULL;1051 vector<pair<int64, CWalletTx*> > vValue;1052 int64 nTotalLower = 0;1053@@ -2541,7 +2753,7 @@1054 1055 1056 1057-bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, int64& nFeeRequiredRet)1058+bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CKey& keyRet, int64& nFeeRequiredRet)1059 {1060 nFeeRequiredRet = 0;1061 CRITICAL_BLOCK(cs_main)1062@@ -2558,39 +2770,37 @@1063 if (nValue < 0)1064 return false;1065 int64 nValueOut = nValue;1066- nValue += nFee;1067+ int64 nTotalValue = nValue + nFee;1068 1069 // Choose coins to use1070 set<CWalletTx*> setCoins;1071- if (!SelectCoins(nValue, setCoins))1072+ if (!SelectCoins(nTotalValue, setCoins))1073 return false;1074 int64 nValueIn = 0;1075 foreach(CWalletTx* pcoin, setCoins)1076 nValueIn += pcoin->GetCredit();1077 1078- // Fill vout[0] to the payee1079- wtxNew.vout.push_back(CTxOut(nValueOut, scriptPubKey));1080-1081- // Fill vout[1] back to self with any change1082- if (nValueIn > nValue)1083+ // Fill a vout to the payee1084+ bool fChangeFirst = GetRand(2);1085+ if (!fChangeFirst)1086+ wtxNew.vout.push_back(CTxOut(nValueOut, scriptPubKey));1087+1088+ // Fill a vout back to self with any change1089+ if (nValueIn > nTotalValue)1090 {1091- /// todo: for privacy, should randomize the order of outputs,1092- // would also have to use a new key for the change.1093- // Use the same key as one of the coins1094- vector<unsigned char> vchPubKey;1095- CTransaction& txFirst = *(*setCoins.begin());1096- foreach(const CTxOut& txout, txFirst.vout)1097- if (txout.IsMine())1098- if (ExtractPubKey(txout.scriptPubKey, true, vchPubKey))1099- break;1100- if (vchPubKey.empty())1101- return false;1102-1103- // Fill vout[1] to ourself1104+ // New private key1105+ if (keyRet.IsNull())1106+ keyRet.MakeNewKey();1107+1108+ // Fill a vout to ourself1109 CScript scriptPubKey;1110- scriptPubKey << vchPubKey << OP_CHECKSIG;1111- wtxNew.vout.push_back(CTxOut(nValueIn - nValue, scriptPubKey));1112+ scriptPubKey << keyRet.GetPubKey() << OP_CHECKSIG;1113+ wtxNew.vout.push_back(CTxOut(nValueIn - nTotalValue, scriptPubKey));1114 }1115+1116+ // Fill a vout to the payee1117+ if (fChangeFirst)1118+ wtxNew.vout.push_back(CTxOut(nValueOut, scriptPubKey));1119 1120 // Fill vin1121 foreach(CWalletTx* pcoin, setCoins)1122@@ -2606,9 +2816,9 @@1123 SignSignature(*pcoin, wtxNew, nIn++);1124 1125 // Check that enough fee is included1126- if (nFee < wtxNew.GetMinFee(true))1127+ if (nFee < wtxNew.GetMinFee())1128 {1129- nFee = nFeeRequiredRet = wtxNew.GetMinFee(true);1130+ nFee = nFeeRequiredRet = wtxNew.GetMinFee();1131 continue;1132 }1133 1134@@ -2624,13 +2834,23 @@1135 }1136 1137 // Call after CreateTransaction unless you want to abort1138-bool CommitTransactionSpent(const CWalletTx& wtxNew)1139+bool CommitTransactionSpent(const CWalletTx& wtxNew, const CKey& key)1140 {1141 CRITICAL_BLOCK(cs_main)1142 CRITICAL_BLOCK(cs_mapWallet)1143 {1144- //// todo: make this transactional, never want to add a transaction1145- //// without marking spent transactions1146+ //// todo: eventually should make this transactional, never want to add a1147+ //// transaction without marking spent transactions, although the risk of1148+ //// interruption during this step is remote.1149+1150+ // This is only to keep the database open to defeat the auto-flush for the1151+ // duration of this scope. This is the only place where this optimization1152+ // maybe makes sense; please don't do it anywhere else.1153+ CWalletDB walletdb("r");1154+1155+ // Add the change's private key to wallet1156+ if (!key.IsNull() && !AddKey(key))1157+ throw runtime_error("CommitTransactionSpent() : AddKey failed\n");1158 1159 // Add tx to wallet, because if it has change it's also ours,1160 // otherwise just for transaction history.1161@@ -2644,7 +2864,7 @@1162 {1163 pcoin->fSpent = true;1164 pcoin->WriteToDisk();1165- vWalletUpdated.push_back(make_pair(pcoin->GetHash(), false));1166+ vWalletUpdated.push_back(pcoin->GetHash());1167 }1168 }1169 MainFrameRepaint();1170@@ -2658,8 +2878,9 @@1171 {1172 CRITICAL_BLOCK(cs_main)1173 {1174+ CKey key;1175 int64 nFeeRequired;1176- if (!CreateTransaction(scriptPubKey, nValue, wtxNew, nFeeRequired))1177+ if (!CreateTransaction(scriptPubKey, nValue, wtxNew, key, nFeeRequired))1178 {1179 string strError;1180 if (nValue + nFeeRequired > GetBalance())1181@@ -2667,13 +2888,17 @@1182 else1183 strError = "Error: Transaction creation failed ";1184 wxMessageBox(strError, "Sending...");1185- return error("SendMoney() : %s\n", strError.c_str());1186- }1187- if (!CommitTransactionSpent(wtxNew))1188+ return error("SendMoney() : %s", strError.c_str());1189+ }1190+ if (!CommitTransactionSpent(wtxNew, key))1191 {1192 wxMessageBox("Error finalizing transaction ", "Sending...");1193 return error("SendMoney() : Error finalizing transaction");1194 }1195+1196+ // Track how many getdata requests our transaction gets1197+ CRITICAL_BLOCK(cs_mapRequestCount)1198+ mapRequestCount[wtxNew.GetHash()] = 0;1199 1200 printf("SendMoney: %s\n", wtxNew.GetHash().ToString().substr(0,6).c_str());1201
main.h (modified)
1--- v0.1.5/main.h2+++ v0.2.0/main.h3@@ -34,21 +34,22 @@4 extern uint256 hashBestChain;5 extern CBlockIndex* pindexBest;6 extern unsigned int nTransactionsUpdated;7-extern string strSetDataDir;8-extern int nDropMessagesTest;9+extern map<uint256, int> mapRequestCount;10+extern CCriticalSection cs_mapRequestCount;11 12 // Settings13 extern int fGenerateBitcoins;14 extern int64 nTransactionFee;15 extern CAddress addrIncoming;16-17-18-19-20-21-22-23-string GetAppDir();24+extern int fLimitProcessors;25+extern int nLimitProcessors;26+27+28+29+30+31+32+33 bool CheckDiskSpace(int64 nAdditionalBytes=0);34 FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");35 FILE* AppendBlockFile(unsigned int& nFileRet);36@@ -59,14 +60,17 @@37 void RelayWalletTransactions();38 bool LoadBlockIndex(bool fAllowNew=true);39 void PrintBlockTree();40-bool BitcoinMiner();41 bool ProcessMessages(CNode* pfrom);42 bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv);43 bool SendMessages(CNode* pto);44 int64 GetBalance();45-bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& txNew, int64& nFeeRequiredRet);46-bool CommitTransactionSpent(const CWalletTx& wtxNew);47+bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CKey& keyRet, int64& nFeeRequiredRet);48+bool CommitTransactionSpent(const CWalletTx& wtxNew, const CKey& key);49 bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew);50+void GenerateBitcoins(bool fGenerate);51+void ThreadBitcoinMiner(void* parg);52+void BitcoinMiner();53+54 55 56 57@@ -339,7 +343,7 @@58 {59 if (scriptPubKey.size() < 6)60 return "CTxOut(error)";61- return strprintf("CTxOut(nValue=%I64d.%08I64d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,24).c_str());62+ return strprintf("CTxOut(nValue=%"PRI64d".%08"PRI64d", scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,24).c_str());63 }64 65 void print() const66@@ -361,7 +365,7 @@67 int nVersion;68 vector<CTxIn> vin;69 vector<CTxOut> vout;70- int nLockTime;71+ unsigned int nLockTime;72 73 74 CTransaction()75@@ -396,9 +400,15 @@76 return SerializeHash(*this);77 }78 79- bool IsFinal() const80- {81- if (nLockTime == 0 || nLockTime < nBestHeight)82+ bool IsFinal(int64 nBlockTime=0) const83+ {84+ // Time based nLockTime implemented in 0.1.6,85+ // do not use time based until most 0.1.5 nodes have upgraded.86+ if (nLockTime == 0)87+ return true;88+ if (nBlockTime == 0)89+ nBlockTime = GetAdjustedTime();90+ if (nLockTime < (nLockTime < 500000000 ? nBestHeight : nBlockTime))91 return true;92 foreach(const CTxIn& txin, vin)93 if (!txin.IsFinal())94@@ -502,14 +512,19 @@95 return nValueOut;96 }97 98- int64 GetMinFee(bool fDiscount=false) const99+ int64 GetMinFee(unsigned int nBlockSize=1) const100 {101 // Base fee is 1 cent per kilobyte102 unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK);103 int64 nMinFee = (1 + (int64)nBytes / 1000) * CENT;104 105- // First 100 transactions in a block are free106- if (fDiscount && nBytes < 10000)107+ // Transactions under 60K are free as long as block size is under 80K108+ // (about 27,000bc if made of 50bc inputs)109+ if (nBytes < 60000 && nBlockSize < 80000)110+ nMinFee = 0;111+112+ // Transactions under 3K are free as long as block size is under 200K113+ if (nBytes < 3000 && nBlockSize < 200000)114 nMinFee = 0;115 116 // To limit dust spam, require a 0.01 fee if any output is less than 0.01117@@ -616,6 +631,8 @@118 119 // memory only120 mutable bool fMerkleVerified;121+ mutable bool fGetCreditCached;122+ mutable int64 nGetCreditCached;123 124 125 CMerkleTx()126@@ -633,14 +650,8 @@127 hashBlock = 0;128 nIndex = -1;129 fMerkleVerified = false;130- }131-132- int64 GetCredit() const133- {134- // Must wait until coinbase is safely deep enough in the chain before valuing it135- if (IsCoinBase() && GetBlocksToMaturity() > 0)136- return 0;137- return CTransaction::GetCredit();138+ fGetCreditCached = false;139+ nGetCreditCached = 0;140 }141 142 IMPLEMENT_SERIALIZE143@@ -652,6 +663,20 @@144 READWRITE(nIndex);145 )146 147+ int64 GetCredit(bool fUseCache=false) const148+ {149+ // Must wait until coinbase is safely deep enough in the chain before valuing it150+ if (IsCoinBase() && GetBlocksToMaturity() > 0)151+ return 0;152+153+ // GetBalance can assume transactions in mapWallet won't change154+ if (fUseCache && fGetCreditCached)155+ return nGetCreditCached;156+ nGetCreditCached = CTransaction::GetCredit();157+ fGetCreditCached = true;158+ return nGetCreditCached;159+ }160+161 162 int SetMerkleBranch(const CBlock* pblock=NULL);163 int GetDepthInMainChain() const;164@@ -681,8 +706,9 @@165 char fSpent;166 //// probably need to sign the order info so know it came from payer167 168- // memory only169+ // memory only UI hints170 mutable unsigned int nTimeDisplayed;171+ mutable int nLinesDisplayed;172 173 174 CWalletTx()175@@ -707,6 +733,7 @@176 fFromMe = false;177 fSpent = false;178 nTimeDisplayed = 0;179+ nLinesDisplayed = 0;180 }181 182 IMPLEMENT_SERIALIZE183@@ -729,6 +756,7 @@184 185 186 int64 GetTxTime() const;187+ int GetRequestCount() const;188 189 void AddSupportingTransactions(CTxDB& txdb);190 191@@ -947,10 +975,18 @@192 return error("CBlock::WriteToDisk() : ftell failed");193 fileout << *this;194 195+ // Flush stdio buffers and commit to disk before returning196+ fflush(fileout);197+#ifdef __WXMSW__198+ _commit(_fileno(fileout));199+#else200+ fsync(fileno(fileout));201+#endif202+203 return true;204 }205 206- bool ReadFromDisk(unsigned int nFile, unsigned int nBlockPos, bool fReadTransactions)207+ bool ReadFromDisk(unsigned int nFile, unsigned int nBlockPos, bool fReadTransactions=true)208 {209 SetNull();210 211@@ -978,9 +1014,9 @@212 void print() const213 {214 printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%d)\n",215- GetHash().ToString().substr(0,14).c_str(),216+ GetHash().ToString().substr(0,16).c_str(),217 nVersion,218- hashPrevBlock.ToString().substr(0,14).c_str(),219+ hashPrevBlock.ToString().substr(0,16).c_str(),220 hashMerkleRoot.ToString().substr(0,6).c_str(),221 nTime, nBits, nNonce,222 vtx.size());223@@ -999,7 +1035,7 @@224 int64 GetBlockValue(int64 nFees) const;225 bool DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex);226 bool ConnectBlock(CTxDB& txdb, CBlockIndex* pindex);227- bool ReadFromDisk(const CBlockIndex* blockindex, bool fReadTransactions);228+ bool ReadFromDisk(const CBlockIndex* blockindex, bool fReadTransactions=true);229 bool AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos);230 bool CheckBlock() const;231 bool AcceptBlock();232@@ -1128,7 +1164,7 @@233 return strprintf("CBlockIndex(nprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nHeight=%d, merkle=%s, hashBlock=%s)",234 pprev, pnext, nFile, nBlockPos, nHeight,235 hashMerkleRoot.ToString().substr(0,6).c_str(),236- GetBlockHash().ToString().substr(0,14).c_str());237+ GetBlockHash().ToString().substr(0,16).c_str());238 }239 240 void print() const241@@ -1198,8 +1234,8 @@242 str += CBlockIndex::ToString();243 str += strprintf("\n hashBlock=%s, hashPrev=%s, hashNext=%s)",244 GetBlockHash().ToString().c_str(),245- hashPrev.ToString().substr(0,14).c_str(),246- hashNext.ToString().substr(0,14).c_str());247+ hashPrev.ToString().substr(0,16).c_str(),248+ hashNext.ToString().substr(0,16).c_str());249 return str;250 }251 252@@ -1265,6 +1301,27 @@253 nStep *= 2;254 }255 vHave.push_back(hashGenesisBlock);256+ }257+258+ int GetDistanceBack()259+ {260+ // Retrace how far back it was in the sender's branch261+ int nDistance = 0;262+ int nStep = 1;263+ foreach(const uint256& hash, vHave)264+ {265+ map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);266+ if (mi != mapBlockIndex.end())267+ {268+ CBlockIndex* pindex = (*mi).second;269+ if (pindex->IsInMainChain())270+ return nDistance;271+ }272+ nDistance += nStep;273+ if (nDistance > 10)274+ nStep *= 2;275+ }276+ return nDistance;277 }278 279 CBlockIndex* GetBlockIndex()280@@ -1321,7 +1378,7 @@281 282 extern map<uint256, CTransaction> mapTransactions;283 extern map<uint256, CWalletTx> mapWallet;284-extern vector<pair<uint256, bool> > vWalletUpdated;285+extern vector<uint256> vWalletUpdated;286 extern CCriticalSection cs_mapWallet;287 extern map<vector<unsigned char>, CPrivKey> mapKeys;288 extern map<uint160, vector<unsigned char> > mapPubKeys;
makefile (modified)
1--- v0.1.5/makefile2+++ v0.2.0/makefile3@@ -10,20 +10,18 @@4 endif5 ifeq "$(BUILD)" "debug"6 D=d7-# note: gcc 3.x profile doesn't work8-#DEBUGFLAGS=-O0 -g -pg -D__WXDEBUG__9 DEBUGFLAGS=-g -D__WXDEBUG__10 endif11 12 13 14-INCLUDEPATHS=-I"/boost" -I"/DB/build_unix" -I"/OpenSSL/include" -I"/wxWidgets/lib/vc_lib/mswd" -I"/wxWidgets/include"15-LIBPATHS=-L"/DB/build_unix" -L"/OpenSSL/out" -L"/wxWidgets/lib/gcc_lib"16+INCLUDEPATHS=-I"/boost" -I"/db/build_unix" -I"/openssl/include" -I"/wxwidgets/lib/vc_lib/mswd" -I"/wxwidgets/include"17+LIBPATHS=-L"/db/build_unix" -L"/openssl/out" -L"/wxwidgets/lib/gcc_lib"18 LIBS= \19 -l db_cxx \20 -l eay32 \21- -l wxmsw28$(D)_richtext -l wxmsw28$(D)_html -l wxmsw28$(D)_core -l wxbase28$(D) -l wxtiff$(D) -l wxjpeg$(D) -l wxpng$(D) -l wxzlib$(D) -l wxregex$(D) -l wxexpat$(D) \22- -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_3223+ -l wxmsw28$(D)_richtext -l wxmsw28$(D)_html -l wxmsw28$(D)_core -l wxmsw28$(D)_adv -l wxbase28$(D) -l wxtiff$(D) -l wxjpeg$(D) -l wxpng$(D) -l wxzlib$(D) -l wxregex$(D) -l wxexpat$(D) \24+ -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi25 WXDEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH26 CFLAGS=-mthreads -O0 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)27 HEADERS=headers.h util.h main.h serialize.h uint256.h key.h bignum.h script.h db.h base58.h28@@ -36,34 +34,34 @@29 headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h30 g++ -c $(CFLAGS) -o $@ $<31 32-obj/util.o: util.cpp $(HEADERS)33+obj/util.o: util.cpp $(HEADERS)34 g++ -c $(CFLAGS) -o $@ $<35 36-obj/script.o: script.cpp $(HEADERS)37+obj/script.o: script.cpp $(HEADERS)38 g++ -c $(CFLAGS) -o $@ $<39 40-obj/db.o: db.cpp $(HEADERS) market.h41+obj/db.o: db.cpp $(HEADERS) market.h42 g++ -c $(CFLAGS) -o $@ $<43 44-obj/net.o: net.cpp $(HEADERS) net.h45+obj/net.o: net.cpp $(HEADERS) net.h46 g++ -c $(CFLAGS) -o $@ $<47 48-obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h49+obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h50 g++ -c $(CFLAGS) -o $@ $<51 52-obj/market.o: market.cpp $(HEADERS) market.h53+obj/market.o: market.cpp $(HEADERS) market.h54 g++ -c $(CFLAGS) -o $@ $<55 56-obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h57+obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h58 g++ -c $(CFLAGS) -o $@ $<59 60-obj/uibase.o: uibase.cpp uibase.h61+obj/uibase.o: uibase.cpp uibase.h62 g++ -c $(CFLAGS) -o $@ $<63 64-obj/sha.o: sha.cpp sha.h65+obj/sha.o: sha.cpp sha.h66 g++ -c $(CFLAGS) -O3 -o $@ $<67 68-obj/irc.o: irc.cpp $(HEADERS)69+obj/irc.o: irc.cpp $(HEADERS)70 g++ -c $(CFLAGS) -o $@ $<71 72 obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp73@@ -71,8 +69,8 @@74 75 76 77-OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \78- obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ui_res.o79+OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \80+ obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ui_res.o81 82 bitcoin.exe: headers.h.gch $(OBJS)83 -kill /f bitcoin.exe
makefile.unix (added)
1--- /dev/null2+++ v0.2.0/makefile.unix3@@ -1 +1,90 @@4+# Copyright (c) 2009 Satoshi Nakamoto5+# Distributed under the MIT/X11 software license, see the accompanying6+# file license.txt or http://www.opensource.org/licenses/mit-license.php.7 8+9+ifneq "$(BUILD)" "debug"10+ifneq "$(BUILD)" "release"11+BUILD=debug12+endif13+endif14+ifeq "$(BUILD)" "debug"15+D=d16+DEBUGFLAGS=-g -D__WXDEBUG__17+endif18+19+20+21+INCLUDEPATHS= \22+ -I"/usr/include" \23+ -I"/usr/local/include/wx-2.8" \24+ -I"/usr/local/lib/wx/include/gtk2-ansi-debug-static-2.8"25+26+LIBPATHS= \27+ -L"/usr/lib" \28+ -L"/usr/local/lib"29+30+LIBS= \31+ -Wl,-Bstatic \32+ -l boost_system -l boost_filesystem \33+ -l db_cxx \34+ -l wx_gtk2$(D)-2.8 \35+ -Wl,-Bdynamic \36+ -l crypto \37+ -l gtk-x11-2.0 -l gthread-2.0 -l SM38+39+WXDEFS=-D__WXGTK__ -DNOPCH40+CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)41+HEADERS=headers.h util.h main.h serialize.h uint256.h key.h bignum.h script.h db.h base58.h42+43+44+45+all: bitcoin46+47+48+headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h49+ g++ -c $(CFLAGS) -o $@ $<50+51+obj/util.o: util.cpp $(HEADERS)52+ g++ -c $(CFLAGS) -o $@ $<53+54+obj/script.o: script.cpp $(HEADERS)55+ g++ -c $(CFLAGS) -o $@ $<56+57+obj/db.o: db.cpp $(HEADERS) market.h58+ g++ -c $(CFLAGS) -o $@ $<59+60+obj/net.o: net.cpp $(HEADERS) net.h61+ g++ -c $(CFLAGS) -o $@ $<62+63+obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h64+ g++ -c $(CFLAGS) -o $@ $<65+66+obj/market.o: market.cpp $(HEADERS) market.h67+ g++ -c $(CFLAGS) -o $@ $<68+69+obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h70+ g++ -c $(CFLAGS) -o $@ $<71+72+obj/uibase.o: uibase.cpp uibase.h73+ g++ -c $(CFLAGS) -o $@ $<74+75+obj/sha.o: sha.cpp sha.h76+ g++ -c $(CFLAGS) -O3 -o $@ $<77+78+obj/irc.o: irc.cpp $(HEADERS)79+ g++ -c $(CFLAGS) -o $@ $<80+81+82+83+84+OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \85+ obj/ui.o obj/uibase.o obj/sha.o obj/irc.o86+87+bitcoin: headers.h.gch $(OBJS)88+ g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS)89+90+clean:91+ -rm obj/*92+ -rm headers.h.gch93+
makefile.vc (modified)
1--- v0.1.5/makefile.vc2+++ v0.2.0/makefile.vc3@@ -13,13 +13,13 @@4 5 6 7-INCLUDEPATHS=/I"/boost" /I"/DB/build_windows" /I"/OpenSSL/include" /I"/wxWidgets/lib/vc_lib/mswd" /I"/wxWidgets/include"8-LIBPATHS=/LIBPATH:"/DB/build_windows/$(BUILD)" /LIBPATH:"/OpenSSL/out" /LIBPATH:"/wxWidgets/lib/vc_lib"9+INCLUDEPATHS=/I"/boost" /I"/db/build_windows" /I"/openssl/include" /I"/wxwidgets/lib/vc_lib/mswd" /I"/wxwidgets/include"10+LIBPATHS=/LIBPATH:"/db/build_windows/$(BUILD)" /LIBPATH:"/openssl/out" /LIBPATH:"/wxwidgets/lib/vc_lib"11 LIBS= \12 libdb47s$(D).lib \13 libeay32.lib \14- wxmsw28$(D)_richtext.lib wxmsw28$(D)_html.lib wxmsw28$(D)_core.lib wxbase28$(D).lib wxtiff$(D).lib wxjpeg$(D).lib wxpng$(D).lib wxzlib$(D).lib wxregex$(D).lib wxexpat$(D).lib \15- kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib16+ wxmsw28$(D)_richtext.lib wxmsw28$(D)_html.lib wxmsw28$(D)_core.lib wxmsw28$(D)_adv.lib wxbase28$(D).lib wxtiff$(D).lib wxjpeg$(D).lib wxpng$(D).lib wxzlib$(D).lib wxregex$(D).lib wxexpat$(D).lib \17+ kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib18 WXDEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH19 CFLAGS=/c /nologo /Ob0 /MD$(D) /EHsc /GR /Zm300 /YX /Fpobj/headers.pch $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)20 HEADERS=headers.h util.h main.h serialize.h uint256.h key.h bignum.h script.h db.h base58.h
net.cpp (modified)
1--- v0.1.5/net.cpp2+++ v0.2.0/net.cpp3@@ -3,12 +3,11 @@4 // file license.txt or http://www.opensource.org/licenses/mit-license.php.5 6 #include "headers.h"7-#include <winsock2.h>8 9 void ThreadMessageHandler2(void* parg);10 void ThreadSocketHandler2(void* parg);11 void ThreadOpenConnections2(void* parg);12-13+bool OpenNetworkConnection(const CAddress& addrConnect);14 15 16 17@@ -20,10 +19,12 @@18 bool fClient = false;19 uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);20 CAddress addrLocalHost(0, DEFAULT_PORT, nLocalServices);21-CNode nodeLocalHost(INVALID_SOCKET, CAddress("127.0.0.1", nLocalServices));22-CNode* pnodeLocalHost = &nodeLocalHost;23-bool fShutdown = false;24-array<bool, 10> vfThreadRunning;25+CNode* pnodeLocalHost = NULL;26+uint64 nLocalHostNonce = 0;27+array<int, 10> vnThreadsRunning;28+SOCKET hListenSocket = INVALID_SOCKET;29+int64 nThreadSocketHandlerHeartbeat = INT64_MAX;30+31 vector<CNode*> vNodes;32 CCriticalSection cs_vNodes;33 map<vector<unsigned char>, CAddress> mapAddresses;34@@ -33,9 +34,28 @@35 CCriticalSection cs_mapRelay;36 map<CInv, int64> mapAlreadyAskedFor;37 38-39-40-CAddress addrProxy;41+// Settings42+int fUseProxy = false;43+CAddress addrProxy("127.0.0.1:9050");44+45+46+47+48+49+void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd)50+{51+ // Filter out duplicate requests52+ if (pindexBegin == pindexLastGetBlocksBegin && hashEnd == hashLastGetBlocksEnd)53+ return;54+ pindexLastGetBlocksBegin = pindexBegin;55+ hashLastGetBlocksEnd = hashEnd;56+57+ PushMessage("getblocks", CBlockLocator(pindexBegin), hashEnd);58+}59+60+61+62+63 64 bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet)65 {66@@ -44,9 +64,13 @@67 SOCKET hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);68 if (hSocket == INVALID_SOCKET)69 return false;70+#if defined(__BSD__) || defined(__WXOSX__)71+ int set = 1;72+ setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int));73+#endif74 75 bool fRoutable = !(addrConnect.GetByte(3) == 10 || (addrConnect.GetByte(3) == 192 && addrConnect.GetByte(2) == 168));76- bool fProxy = (addrProxy.ip && fRoutable);77+ bool fProxy = (fUseProxy && fRoutable);78 struct sockaddr_in sockaddr = (fProxy ? addrProxy.GetSockAddr() : addrConnect.GetSockAddr());79 80 if (connect(hSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR)81@@ -57,31 +81,33 @@82 83 if (fProxy)84 {85- printf("Proxy connecting to %s\n", addrConnect.ToString().c_str());86+ printf("proxy connecting %s\n", addrConnect.ToStringLog().c_str());87 char pszSocks4IP[] = "\4\1\0\0\0\0\0\0user";88 memcpy(pszSocks4IP + 2, &addrConnect.port, 2);89 memcpy(pszSocks4IP + 4, &addrConnect.ip, 4);90 char* pszSocks4 = pszSocks4IP;91 int nSize = sizeof(pszSocks4IP);92 93- int ret = send(hSocket, pszSocks4, nSize, 0);94+ int ret = send(hSocket, pszSocks4, nSize, MSG_NOSIGNAL);95 if (ret != nSize)96 {97 closesocket(hSocket);98- return error("Error sending to proxy\n");99+ return error("Error sending to proxy");100 }101 char pchRet[8];102 if (recv(hSocket, pchRet, 8, 0) != 8)103 {104 closesocket(hSocket);105- return error("Error reading proxy response\n");106+ return error("Error reading proxy response");107 }108 if (pchRet[1] != 0x5a)109 {110 closesocket(hSocket);111- return error("Proxy returned error %d\n", pchRet[1]);112- }113- printf("Proxy connection established %s\n", addrConnect.ToString().c_str());114+ if (pchRet[1] != 0x5b)115+ printf("ERROR: Proxy returned error %d\n", pchRet[1]);116+ return false;117+ }118+ printf("proxy connected %s\n", addrConnect.ToStringLog().c_str());119 }120 121 hSocketRet = hSocket;122@@ -94,9 +120,9 @@123 {124 SOCKET hSocket;125 if (!ConnectSocket(addrConnect, hSocket))126- return error("GetMyExternalIP() : connection to %s failed\n", addrConnect.ToString().c_str());127-128- send(hSocket, pszGet, strlen(pszGet), 0);129+ return error("GetMyExternalIP() : connection to %s failed", addrConnect.ToString().c_str());130+131+ send(hSocket, pszGet, strlen(pszGet), MSG_NOSIGNAL);132 133 string strLine;134 while (RecvLine(hSocket, strLine))135@@ -120,25 +146,29 @@136 if (strLine.find("<"))137 strLine = strLine.substr(0, strLine.find("<"));138 strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r"));139- strLine = wxString(strLine).Trim();140+ while (strLine.size() > 0 && isspace(strLine[strLine.size()-1]))141+ strLine.resize(strLine.size()-1);142 CAddress addr(strLine.c_str());143 printf("GetMyExternalIP() received [%s] %s\n", strLine.c_str(), addr.ToString().c_str());144- if (addr.ip == 0 || !addr.IsRoutable())145+ if (addr.ip == 0 || addr.ip == INADDR_NONE || !addr.IsRoutable())146 return false;147 ipRet = addr.ip;148 return true;149 }150 }151 closesocket(hSocket);152- return error("GetMyExternalIP() : connection closed\n");153+ return error("GetMyExternalIP() : connection closed");154 }155 156 157 bool GetMyExternalIP(unsigned int& ipRet)158 {159 CAddress addrConnect;160- char* pszGet;161- char* pszKeyword;162+ const char* pszGet;163+ const char* pszKeyword;164+165+ if (fUseProxy)166+ return false;167 168 for (int nLookup = 0; nLookup <= 1; nLookup++)169 for (int nHost = 1; nHost <= 2; nHost++)170@@ -193,35 +223,68 @@171 172 173 174-bool AddAddress(CAddrDB& addrdb, const CAddress& addr)175+bool AddAddress(CAddrDB& addrdb, CAddress addr, bool fCurrentlyOnline)176 {177 if (!addr.IsRoutable())178 return false;179 if (addr.ip == addrLocalHost.ip)180 return false;181+ if (fCurrentlyOnline)182+ addr.nTime = GetAdjustedTime();183 CRITICAL_BLOCK(cs_mapAddresses)184 {185 map<vector<unsigned char>, CAddress>::iterator it = mapAddresses.find(addr.GetKey());186 if (it == mapAddresses.end())187 {188 // New address189+ printf("AddAddress(%s)\n", addr.ToStringLog().c_str());190 mapAddresses.insert(make_pair(addr.GetKey(), addr));191 addrdb.WriteAddress(addr);192 return true;193 }194 else195 {196+ bool fUpdated = false;197 CAddress& addrFound = (*it).second;198 if ((addrFound.nServices | addr.nServices) != addrFound.nServices)199 {200 // Services have been added201 addrFound.nServices |= addr.nServices;202+ fUpdated = true;203+ }204+ int64 nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);205+ if (addrFound.nTime < addr.nTime - nUpdateInterval)206+ {207+ // Periodically update most recently seen time208+ addrFound.nTime = addr.nTime;209+ fUpdated = true;210+ }211+ if (fUpdated)212 addrdb.WriteAddress(addrFound);213- return true;214- }215 }216 }217 return false;218+}219+220+void AddressCurrentlyConnected(const CAddress& addr)221+{222+ CRITICAL_BLOCK(cs_mapAddresses)223+ {224+ // Only if it's been published already225+ map<vector<unsigned char>, CAddress>::iterator it = mapAddresses.find(addr.GetKey());226+ if (it != mapAddresses.end())227+ {228+ CAddress& addrFound = (*it).second;229+ int64 nUpdateInterval = 20 * 60;230+ if (addrFound.nTime < GetAdjustedTime() - nUpdateInterval)231+ {232+ // Periodically update most recently seen time233+ addrFound.nTime = GetAdjustedTime();234+ CAddrDB addrdb;235+ addrdb.WriteAddress(addrFound);236+ }237+ }238+ }239 }240 241 242@@ -373,19 +436,30 @@243 }244 245 /// debug print246- printf("trying %s\n", addrConnect.ToString().c_str());247+ printf("trying connection %s lastseen=%.1fhrs lasttry=%.1fhrs\n",248+ addrConnect.ToStringLog().c_str(),249+ (double)(addrConnect.nTime - GetAdjustedTime())/3600.0,250+ (double)(addrConnect.nLastTry - GetAdjustedTime())/3600.0);251+252+ CRITICAL_BLOCK(cs_mapAddresses)253+ mapAddresses[addrConnect.GetKey()].nLastTry = GetAdjustedTime();254 255 // Connect256 SOCKET hSocket;257 if (ConnectSocket(addrConnect, hSocket))258 {259 /// debug print260- printf("connected %s\n", addrConnect.ToString().c_str());261+ printf("connected %s\n", addrConnect.ToStringLog().c_str());262 263 // Set to nonblocking264+#ifdef __WXMSW__265 u_long nOne = 1;266 if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR)267 printf("ConnectSocket() : ioctlsocket nonblocking setting failed, error %d\n", WSAGetLastError());268+#else269+ if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)270+ printf("ConnectSocket() : fcntl nonblocking setting failed, error %d\n", errno);271+#endif272 273 // Add node274 CNode* pnode = new CNode(hSocket, addrConnect, false);275@@ -396,29 +470,30 @@276 CRITICAL_BLOCK(cs_vNodes)277 vNodes.push_back(pnode);278 279- CRITICAL_BLOCK(cs_mapAddresses)280- mapAddresses[addrConnect.GetKey()].nLastFailed = 0;281+ pnode->nTimeConnected = GetTime();282 return pnode;283 }284 else285 {286- CRITICAL_BLOCK(cs_mapAddresses)287- mapAddresses[addrConnect.GetKey()].nLastFailed = GetTime();288 return NULL;289 }290 }291 292-void CNode::Disconnect()293-{294- printf("disconnecting node %s\n", addr.ToString().c_str());295-296- closesocket(hSocket);297-298- // If outbound and never got version message, mark address as failed299- if (!fInbound && nVersion == 0)300- CRITICAL_BLOCK(cs_mapAddresses)301- mapAddresses[addr.GetKey()].nLastFailed = GetTime();302-303+void CNode::CloseSocketDisconnect()304+{305+ fDisconnect = true;306+ if (hSocket != INVALID_SOCKET)307+ {308+ if (fDebug)309+ printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());310+ printf("disconnecting node %s\n", addr.ToStringLog().c_str());311+ closesocket(hSocket);312+ hSocket = INVALID_SOCKET;313+ }314+}315+316+void CNode::Cleanup()317+{318 // All of a nodes broadcasts and subscriptions are automatically torn down319 // when it goes down, so a node has to stay up to keep its broadcast going.320 321@@ -448,24 +523,26 @@322 {323 IMPLEMENT_RANDOMIZE_STACK(ThreadSocketHandler(parg));324 325- loop326- {327- vfThreadRunning[0] = true;328- CheckForShutdown(0);329- try330- {331- ThreadSocketHandler2(parg);332- }333- CATCH_PRINT_EXCEPTION("ThreadSocketHandler()")334- vfThreadRunning[0] = false;335- Sleep(5000);336- }337+ try338+ {339+ vnThreadsRunning[0]++;340+ ThreadSocketHandler2(parg);341+ vnThreadsRunning[0]--;342+ }343+ catch (std::exception& e) {344+ vnThreadsRunning[0]--;345+ PrintException(&e, "ThreadSocketHandler()");346+ } catch (...) {347+ vnThreadsRunning[0]--;348+ throw; // support pthread_cancel()349+ }350+351+ printf("ThreadSocketHandler exiting\n");352 }353 354 void ThreadSocketHandler2(void* parg)355 {356 printf("ThreadSocketHandler started\n");357- SOCKET hListenSocket = *(SOCKET*)parg;358 list<CNode*> vNodesDisconnected;359 int nPrevNodeCount = 0;360 361@@ -480,15 +557,19 @@362 vector<CNode*> vNodesCopy = vNodes;363 foreach(CNode* pnode, vNodesCopy)364 {365- if (pnode->ReadyToDisconnect() && pnode->vRecv.empty() && pnode->vSend.empty())366+ if (pnode->fDisconnect ||367+ (pnode->GetRefCount() <= 0 && pnode->vRecv.empty() && pnode->vSend.empty()))368 {369 // remove from vNodes370 vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end());371- pnode->Disconnect();372+373+ // close socket and cleanup374+ pnode->CloseSocketDisconnect();375+ pnode->Cleanup();376 377 // hold in disconnected pool until all refs are released378- pnode->nReleaseTime = max(pnode->nReleaseTime, GetTime() + 5 * 60);379- if (pnode->fNetworkNode)380+ pnode->nReleaseTime = max(pnode->nReleaseTime, GetTime() + 15 * 60);381+ if (pnode->fNetworkNode || pnode->fInbound)382 pnode->Release();383 vNodesDisconnected.push_back(pnode);384 }385@@ -529,10 +610,12 @@386 timeout.tv_sec = 0;387 timeout.tv_usec = 50000; // frequency to poll pnode->vSend388 389- struct fd_set fdsetRecv;390- struct fd_set fdsetSend;391+ fd_set fdsetRecv;392+ fd_set fdsetSend;393+ fd_set fdsetError;394 FD_ZERO(&fdsetRecv);395 FD_ZERO(&fdsetSend);396+ FD_ZERO(&fdsetError);397 SOCKET hSocketMax = 0;398 FD_SET(hListenSocket, &fdsetRecv);399 hSocketMax = max(hSocketMax, hListenSocket);400@@ -540,7 +623,10 @@401 {402 foreach(CNode* pnode, vNodes)403 {404+ if (pnode->hSocket == INVALID_SOCKET || pnode->hSocket < 0)405+ continue;406 FD_SET(pnode->hSocket, &fdsetRecv);407+ FD_SET(pnode->hSocket, &fdsetError);408 hSocketMax = max(hSocketMax, pnode->hSocket);409 TRY_CRITICAL_BLOCK(pnode->cs_vSend)410 if (!pnode->vSend.empty())411@@ -548,30 +634,21 @@412 }413 }414 415- vfThreadRunning[0] = false;416- int nSelect = select(hSocketMax + 1, &fdsetRecv, &fdsetSend, NULL, &timeout);417- vfThreadRunning[0] = true;418- CheckForShutdown(0);419+ vnThreadsRunning[0]--;420+ int nSelect = select(hSocketMax + 1, &fdsetRecv, &fdsetSend, &fdsetError, &timeout);421+ vnThreadsRunning[0]++;422+ if (fShutdown)423+ return;424 if (nSelect == SOCKET_ERROR)425 {426 int nErr = WSAGetLastError();427- printf("select failed: %d\n", nErr);428+ printf("socket select error %d\n", nErr);429 for (int i = 0; i <= hSocketMax; i++)430- {431 FD_SET(i, &fdsetRecv);432- FD_SET(i, &fdsetSend);433- }434+ FD_ZERO(&fdsetSend);435+ FD_ZERO(&fdsetError);436 Sleep(timeout.tv_usec/1000);437 }438- RandAddSeed();439-440- //// debug print441- //foreach(CNode* pnode, vNodes)442- //{443- // printf("vRecv = %-5d ", pnode->vRecv.size());444- // printf("vSend = %-5d ", pnode->vSend.size());445- //}446- //printf("\n");447 448 449 //450@@ -580,17 +657,21 @@451 if (FD_ISSET(hListenSocket, &fdsetRecv))452 {453 struct sockaddr_in sockaddr;454+#ifdef __WXMSW__455 int len = sizeof(sockaddr);456+#else457+ socklen_t len = sizeof(sockaddr);458+#endif459 SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len);460 CAddress addr(sockaddr);461 if (hSocket == INVALID_SOCKET)462 {463 if (WSAGetLastError() != WSAEWOULDBLOCK)464- printf("ERROR ThreadSocketHandler accept failed: %d\n", WSAGetLastError());465+ printf("socket error accept failed: %d\n", WSAGetLastError());466 }467 else468 {469- printf("accepted connection from %s\n", addr.ToString().c_str());470+ printf("accepted connection %s\n", addr.ToStringLog().c_str());471 CNode* pnode = new CNode(hSocket, addr, true);472 pnode->AddRef();473 CRITICAL_BLOCK(cs_vNodes)474@@ -604,16 +685,22 @@475 //476 vector<CNode*> vNodesCopy;477 CRITICAL_BLOCK(cs_vNodes)478+ {479 vNodesCopy = vNodes;480+ foreach(CNode* pnode, vNodesCopy)481+ pnode->AddRef();482+ }483 foreach(CNode* pnode, vNodesCopy)484 {485- CheckForShutdown(0);486- SOCKET hSocket = pnode->hSocket;487+ if (fShutdown)488+ return;489 490 //491 // Receive492 //493- if (FD_ISSET(hSocket, &fdsetRecv))494+ if (pnode->hSocket == INVALID_SOCKET)495+ continue;496+ if (FD_ISSET(pnode->hSocket, &fdsetRecv) || FD_ISSET(pnode->hSocket, &fdsetError))497 {498 TRY_CRITICAL_BLOCK(pnode->cs_vRecv)499 {500@@ -621,26 +708,30 @@501 unsigned int nPos = vRecv.size();502 503 // typical socket buffer is 8K-64K504- const unsigned int nBufSize = 0x10000;505- vRecv.resize(nPos + nBufSize);506- int nBytes = recv(hSocket, &vRecv[nPos], nBufSize, 0);507- vRecv.resize(nPos + max(nBytes, 0));508- if (nBytes == 0)509+ char pchBuf[0x10000];510+ int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);511+ if (nBytes > 0)512+ {513+ vRecv.resize(nPos + nBytes);514+ memcpy(&vRecv[nPos], pchBuf, nBytes);515+ pnode->nLastRecv = GetTime();516+ }517+ else if (nBytes == 0)518 {519 // socket closed gracefully520 if (!pnode->fDisconnect)521- printf("recv: socket closed\n");522- pnode->fDisconnect = true;523+ printf("socket closed\n");524+ pnode->CloseSocketDisconnect();525 }526 else if (nBytes < 0)527 {528- // socket error529+ // error530 int nErr = WSAGetLastError();531 if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)532 {533 if (!pnode->fDisconnect)534- printf("recv failed: %d\n", nErr);535- pnode->fDisconnect = true;536+ printf("socket recv error %d\n", nErr);537+ pnode->CloseSocketDisconnect();538 }539 }540 }541@@ -649,35 +740,66 @@542 //543 // Send544 //545- if (FD_ISSET(hSocket, &fdsetSend))546+ if (pnode->hSocket == INVALID_SOCKET)547+ continue;548+ if (FD_ISSET(pnode->hSocket, &fdsetSend))549 {550 TRY_CRITICAL_BLOCK(pnode->cs_vSend)551 {552 CDataStream& vSend = pnode->vSend;553 if (!vSend.empty())554 {555- int nBytes = send(hSocket, &vSend[0], vSend.size(), 0);556+ int nBytes = send(pnode->hSocket, &vSend[0], vSend.size(), MSG_NOSIGNAL | MSG_DONTWAIT);557 if (nBytes > 0)558 {559 vSend.erase(vSend.begin(), vSend.begin() + nBytes);560+ pnode->nLastSend = GetTime();561 }562- else if (nBytes == 0)563+ else if (nBytes < 0)564 {565- if (pnode->ReadyToDisconnect())566- pnode->vSend.clear();567- }568- else569- {570- printf("send error %d\n", nBytes);571- if (pnode->ReadyToDisconnect())572- pnode->vSend.clear();573+ // error574+ int nErr = WSAGetLastError();575+ if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)576+ {577+ printf("socket send error %d\n", nErr);578+ pnode->CloseSocketDisconnect();579+ }580 }581 }582 }583 }584- }585-586-587+588+ //589+ // Inactivity checking590+ //591+ if (pnode->vSend.empty())592+ pnode->nLastSendEmpty = GetTime();593+ if (GetTime() - pnode->nTimeConnected > 60)594+ {595+ if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)596+ {597+ printf("socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0);598+ pnode->fDisconnect = true;599+ }600+ else if (GetTime() - pnode->nLastSend > 90*60 && GetTime() - pnode->nLastSendEmpty > 90*60)601+ {602+ printf("socket not sending\n");603+ pnode->fDisconnect = true;604+ }605+ else if (GetTime() - pnode->nLastRecv > 90*60)606+ {607+ printf("socket inactivity timeout\n");608+ pnode->fDisconnect = true;609+ }610+ }611+ }612+ CRITICAL_BLOCK(cs_vNodes)613+ {614+ foreach(CNode* pnode, vNodesCopy)615+ pnode->Release();616+ }617+618+ nThreadSocketHandlerHeartbeat = GetTime();619 Sleep(10);620 }621 }622@@ -695,163 +817,193 @@623 {624 IMPLEMENT_RANDOMIZE_STACK(ThreadOpenConnections(parg));625 626+ try627+ {628+ vnThreadsRunning[1]++;629+ ThreadOpenConnections2(parg);630+ vnThreadsRunning[1]--;631+ }632+ catch (std::exception& e) {633+ vnThreadsRunning[1]--;634+ PrintException(&e, "ThreadOpenConnections()");635+ } catch (...) {636+ vnThreadsRunning[1]--;637+ PrintException(NULL, "ThreadOpenConnections()");638+ }639+640+ printf("ThreadOpenConnections exiting\n");641+}642+643+void ThreadOpenConnections2(void* parg)644+{645+ printf("ThreadOpenConnections started\n");646+647+ // Connect to specific addresses648+ if (mapArgs.count("-connect"))649+ {650+ for (int64 nLoop = 0;; nLoop++)651+ {652+ foreach(string strAddr, mapMultiArgs["-connect"])653+ {654+ CAddress addr(strAddr, NODE_NETWORK);655+ if (addr.IsValid())656+ OpenNetworkConnection(addr);657+ for (int i = 0; i < 10 && i < nLoop; i++)658+ {659+ Sleep(500);660+ if (fShutdown)661+ return;662+ }663+ }664+ }665+ }666+667+ // Connect to manually added nodes first668+ if (mapArgs.count("-addnode"))669+ {670+ foreach(string strAddr, mapMultiArgs["-addnode"])671+ {672+ CAddress addr(strAddr, NODE_NETWORK);673+ if (addr.IsValid())674+ {675+ OpenNetworkConnection(addr);676+ Sleep(500);677+ if (fShutdown)678+ return;679+ }680+ }681+ }682+683+ // Initiate network connections684 loop685 {686- vfThreadRunning[1] = true;687- CheckForShutdown(1);688- try689- {690- ThreadOpenConnections2(parg);691- }692- CATCH_PRINT_EXCEPTION("ThreadOpenConnections()")693- vfThreadRunning[1] = false;694- Sleep(5000);695- }696-}697-698-void ThreadOpenConnections2(void* parg)699-{700- printf("ThreadOpenConnections started\n");701-702- // Initiate network connections703- int nTry = 0;704- bool fIRCOnly = false;705- const int nMaxConnections = 15;706- loop707- {708 // Wait709- vfThreadRunning[1] = false;710+ vnThreadsRunning[1]--;711 Sleep(500);712+ const int nMaxConnections = 15;713 while (vNodes.size() >= nMaxConnections || vNodes.size() >= mapAddresses.size())714 {715- CheckForShutdown(1);716+ if (fShutdown)717+ return;718 Sleep(2000);719 }720- vfThreadRunning[1] = true;721- CheckForShutdown(1);722-723+ vnThreadsRunning[1]++;724+ if (fShutdown)725+ return;726 727 //728- // The IP selection process is designed to limit vulnerability to address flooding.729- // Any class C (a.b.c.?) has an equal chance of being chosen, then an IP is730- // chosen within the class C. An attacker may be able to allocate many IPs, but731- // they would normally be concentrated in blocks of class C's. They can hog the732- // attention within their class C, but not the whole IP address space overall.733- // A lone node in a class C will get as much attention as someone holding all 255734- // IPs in another class C.735+ // Choose an address to connect to based on most recently seen736 //737-738- // Every other try is with IRC addresses only739- fIRCOnly = !fIRCOnly;740- if (mapIRCAddresses.empty())741- fIRCOnly = false;742- else if (nTry++ < 30 && vNodes.size() < nMaxConnections/2)743- fIRCOnly = true;744-745- // Make a list of unique class C's746- unsigned char pchIPCMask[4] = { 0xff, 0xff, 0xff, 0x00 };747- unsigned int nIPCMask = *(unsigned int*)pchIPCMask;748- vector<unsigned int> vIPC;749- CRITICAL_BLOCK(cs_mapIRCAddresses)750+ CAddress addrConnect;751+ int64 nBest = INT64_MIN;752+753+ // Do this here so we don't have to critsect vNodes inside mapAddresses critsect754+ set<unsigned int> setConnected;755+ CRITICAL_BLOCK(cs_vNodes)756+ foreach(CNode* pnode, vNodes)757+ setConnected.insert(pnode->addr.ip);758+759 CRITICAL_BLOCK(cs_mapAddresses)760 {761- vIPC.reserve(mapAddresses.size());762- unsigned int nPrev = 0;763 foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)764 {765 const CAddress& addr = item.second;766- if (!addr.IsIPv4())767+ if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip))768 continue;769- if (fIRCOnly && !mapIRCAddresses.count(item.first))770+ int64 nSinceLastSeen = GetAdjustedTime() - addr.nTime;771+ int64 nSinceLastTry = GetAdjustedTime() - addr.nLastTry;772+773+ // Randomize the order in a deterministic way, putting the standard port first774+ int64 nRandomizer = (uint64)(addr.nLastTry * 9567851 + addr.ip * 7789) % (30 * 60);775+ if (addr.port != DEFAULT_PORT)776+ nRandomizer += 30 * 60;777+778+ // Last seen Base retry frequency779+ // <1 hour 10 min780+ // 1 hour 1 hour781+ // 4 hours 2 hours782+ // 24 hours 5 hours783+ // 48 hours 7 hours784+ // 7 days 13 hours785+ // 30 days 27 hours786+ // 90 days 46 hours787+ // 365 days 93 hours788+ int64 nDelay = (int64)(3600.0 * sqrt(fabs(nSinceLastSeen) / 3600.0) + nRandomizer);789+790+ // Fast reconnect for one hour after last seen791+ if (nSinceLastSeen < 60 * 60)792+ nDelay = 10 * 60;793+794+ // Limit retry frequency795+ if (nSinceLastTry < nDelay)796 continue;797 798- // Taking advantage of mapAddresses being in sorted order,799- // with IPs of the same class C grouped together.800- unsigned int ipC = addr.ip & nIPCMask;801- if (ipC != nPrev)802- vIPC.push_back(nPrev = ipC);803- }804- }805- if (vIPC.empty())806- continue;807-808- // Choose a random class C809- unsigned int ipC = vIPC[GetRand(vIPC.size())];810-811- // Organize all addresses in the class C by IP812- map<unsigned int, vector<CAddress> > mapIP;813- CRITICAL_BLOCK(cs_mapIRCAddresses)814- CRITICAL_BLOCK(cs_mapAddresses)815- {816- int64 nDelay = ((30 * 60) << vNodes.size());817- if (!fIRCOnly)818- {819- nDelay *= 2;820- if (vNodes.size() >= 3)821- nDelay *= 4;822- if (!mapIRCAddresses.empty())823- nDelay *= 100;824- }825-826- for (map<vector<unsigned char>, CAddress>::iterator mi = mapAddresses.lower_bound(CAddress(ipC, 0).GetKey());827- mi != mapAddresses.upper_bound(CAddress(ipC | ~nIPCMask, 0xffff).GetKey());828- ++mi)829- {830- const CAddress& addr = (*mi).second;831- if (fIRCOnly && !mapIRCAddresses.count((*mi).first))832+ // If we have IRC, we'll be notified when they first come online,833+ // and again every 24 hours by the refresh broadcast.834+ if (nGotIRCAddresses > 0 && vNodes.size() >= 2 && nSinceLastSeen > 24 * 60 * 60)835 continue;836 837- int64 nRandomizer = (addr.nLastFailed * addr.ip * 7777U) % 20000;838- if (GetTime() - addr.nLastFailed > nDelay * nRandomizer / 10000)839- mapIP[addr.ip].push_back(addr);840- }841- }842- if (mapIP.empty())843- continue;844-845- // Choose a random IP in the class C846- map<unsigned int, vector<CAddress> >::iterator mi = mapIP.begin();847- advance(mi, GetRand(mapIP.size()));848-849- // Once we've chosen an IP, we'll try every given port before moving on850- foreach(const CAddress& addrConnect, (*mi).second)851- {852- //853- // Initiate outbound network connection854- //855- CheckForShutdown(1);856- if (addrConnect.ip == addrLocalHost.ip || !addrConnect.IsIPv4() || FindNode(addrConnect.ip))857- continue;858-859- vfThreadRunning[1] = false;860- CNode* pnode = ConnectNode(addrConnect);861- vfThreadRunning[1] = true;862- CheckForShutdown(1);863- if (!pnode)864- continue;865- pnode->fNetworkNode = true;866-867- if (addrLocalHost.IsRoutable())868- {869- // Advertise our address870- vector<CAddress> vAddrToSend;871- vAddrToSend.push_back(addrLocalHost);872- pnode->PushMessage("addr", vAddrToSend);873- }874-875- // Get as many addresses as we can876- pnode->PushMessage("getaddr");877-878- ////// should the one on the receiving end do this too?879- // Subscribe our local subscription list880- const unsigned int nHops = 0;881- for (unsigned int nChannel = 0; nChannel < pnodeLocalHost->vfSubscribe.size(); nChannel++)882- if (pnodeLocalHost->vfSubscribe[nChannel])883- pnode->PushMessage("subscribe", nChannel, nHops);884-885- break;886- }887- }888+ // Only try the old stuff if we don't have enough connections889+ if (vNodes.size() >= 2 && nSinceLastSeen > 7 * 24 * 60 * 60)890+ continue;891+ if (vNodes.size() >= 5 && nSinceLastSeen > 24 * 60 * 60)892+ continue;893+894+ // If multiple addresses are ready, prioritize by time since895+ // last seen and time since last tried.896+ int64 nScore = min(nSinceLastTry, (int64)24 * 60 * 60) - nSinceLastSeen - nRandomizer;897+ if (nScore > nBest)898+ {899+ nBest = nScore;900+ addrConnect = addr;901+ }902+ }903+ }904+905+ if (addrConnect.IsValid())906+ OpenNetworkConnection(addrConnect);907+ }908+}909+910+bool OpenNetworkConnection(const CAddress& addrConnect)911+{912+ //913+ // Initiate outbound network connection914+ //915+ if (fShutdown)916+ return false;917+ if (addrConnect.ip == addrLocalHost.ip || !addrConnect.IsIPv4() || FindNode(addrConnect.ip))918+ return false;919+920+ vnThreadsRunning[1]--;921+ CNode* pnode = ConnectNode(addrConnect);922+ vnThreadsRunning[1]++;923+ if (fShutdown)924+ return false;925+ if (!pnode)926+ return false;927+ pnode->fNetworkNode = true;928+929+ if (addrLocalHost.IsRoutable() && !fUseProxy)930+ {931+ // Advertise our address932+ vector<CAddress> vAddrToSend;933+ vAddrToSend.push_back(addrLocalHost);934+ pnode->PushMessage("addr", vAddrToSend);935+ }936+937+ // Get as many addresses as we can938+ pnode->PushMessage("getaddr");939+ pnode->fGetAddr = true; // don't relay the results of the getaddr940+941+ ////// should the one on the receiving end do this too?942+ // Subscribe our local subscription list943+ const unsigned int nHops = 0;944+ for (unsigned int nChannel = 0; nChannel < pnodeLocalHost->vfSubscribe.size(); nChannel++)945+ if (pnodeLocalHost->vfSubscribe[nChannel])946+ pnode->PushMessage("subscribe", nChannel, nHops);947+948+ return true;949 }950 951 952@@ -865,90 +1017,81 @@953 {954 IMPLEMENT_RANDOMIZE_STACK(ThreadMessageHandler(parg));955 956- loop957- {958- vfThreadRunning[2] = true;959- CheckForShutdown(2);960- try961- {962- ThreadMessageHandler2(parg);963- }964- CATCH_PRINT_EXCEPTION("ThreadMessageHandler()")965- vfThreadRunning[2] = false;966- Sleep(5000);967- }968+ try969+ {970+ vnThreadsRunning[2]++;971+ ThreadMessageHandler2(parg);972+ vnThreadsRunning[2]--;973+ }974+ catch (std::exception& e) {975+ vnThreadsRunning[2]--;976+ PrintException(&e, "ThreadMessageHandler()");977+ } catch (...) {978+ vnThreadsRunning[2]--;979+ PrintException(NULL, "ThreadMessageHandler()");980+ }981+982+ printf("ThreadMessageHandler exiting\n");983 }984 985 void ThreadMessageHandler2(void* parg)986 {987 printf("ThreadMessageHandler started\n");988- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);989+ SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);990 loop991 {992 // Poll the connected nodes for messages993 vector<CNode*> vNodesCopy;994 CRITICAL_BLOCK(cs_vNodes)995+ {996 vNodesCopy = vNodes;997+ foreach(CNode* pnode, vNodesCopy)998+ pnode->AddRef();999+ }1000 foreach(CNode* pnode, vNodesCopy)1001 {1002- pnode->AddRef();1003-1004 // Receive messages1005 TRY_CRITICAL_BLOCK(pnode->cs_vRecv)1006 ProcessMessages(pnode);1007+ if (fShutdown)1008+ return;1009 1010 // Send messages1011 TRY_CRITICAL_BLOCK(pnode->cs_vSend)1012 SendMessages(pnode);1013-1014- pnode->Release();1015+ if (fShutdown)1016+ return;1017+ }1018+ CRITICAL_BLOCK(cs_vNodes)1019+ {1020+ foreach(CNode* pnode, vNodesCopy)1021+ pnode->Release();1022 }1023 1024 // Wait and allow messages to bunch up1025- vfThreadRunning[2] = false;1026+ vnThreadsRunning[2]--;1027 Sleep(100);1028- vfThreadRunning[2] = true;1029- CheckForShutdown(2);1030- }1031-}1032-1033-1034-1035-1036-1037-1038-1039-1040-1041-//// todo: start one thread per processor, use getenv("NUMBER_OF_PROCESSORS")1042-void ThreadBitcoinMiner(void* parg)1043-{1044- vfThreadRunning[3] = true;1045- CheckForShutdown(3);1046- try1047- {1048- bool fRet = BitcoinMiner();1049- printf("BitcoinMiner returned %s\n\n\n", fRet ? "true" : "false");1050- }1051- CATCH_PRINT_EXCEPTION("BitcoinMiner()")1052- vfThreadRunning[3] = false;1053-}1054-1055-1056-1057-1058-1059-1060-1061-1062-1063-1064-1065-bool StartNode(string& strError)1066+ vnThreadsRunning[2]++;1067+ if (fShutdown)1068+ return;1069+ }1070+}1071+1072+1073+1074+1075+1076+1077+1078+1079+1080+bool BindListenPort(string& strError)1081 {1082 strError = "";1083-1084- // Sockets startup1085+ int nOne = 1;1086+1087+#ifdef __WXMSW__1088+ // Initialize Windows Sockets1089 WSADATA wsadata;1090 int ret = WSAStartup(MAKEWORD(2,2), &wsadata);1091 if (ret != NO_ERROR)1092@@ -957,29 +1100,10 @@1093 printf("%s\n", strError.c_str());1094 return false;1095 }1096-1097- // Get local host ip1098- char pszHostName[255];1099- if (gethostname(pszHostName, 255) == SOCKET_ERROR)1100- {1101- strError = strprintf("Error: Unable to get IP address of this computer (gethostname returned error %d)", WSAGetLastError());1102- printf("%s\n", strError.c_str());1103- return false;1104- }1105- struct hostent* phostent = gethostbyname(pszHostName);1106- if (!phostent)1107- {1108- strError = strprintf("Error: Unable to get IP address of this computer (gethostbyname returned error %d)", WSAGetLastError());1109- printf("%s\n", strError.c_str());1110- return false;1111- }1112- addrLocalHost = CAddress(*(long*)(phostent->h_addr_list[0]),1113- DEFAULT_PORT,1114- nLocalServices);1115- printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());1116+#endif1117 1118 // Create socket for listening for incoming connections1119- SOCKET hListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);1120+ hListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);1121 if (hListenSocket == INVALID_SOCKET)1122 {1123 strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %d)", WSAGetLastError());1124@@ -987,30 +1111,47 @@1125 return false;1126 }1127 1128+#if defined(__BSD__) || defined(__WXOSX__)1129+ // Different way of disabling SIGPIPE on BSD1130+ setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));1131+#endif1132+1133+#ifndef __WXMSW__1134+ // Allow binding if the port is still in TIME_WAIT state after1135+ // the program was closed and restarted. Not an issue on windows.1136+ setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int));1137+#endif1138+1139+#ifdef __WXMSW__1140 // Set to nonblocking, incoming connections will also inherit this1141- u_long nOne = 1;1142- if (ioctlsocket(hListenSocket, FIONBIO, &nOne) == SOCKET_ERROR)1143- {1144- strError = strprintf("Error: Couldn't set properties on socket for incoming connections (ioctlsocket returned error %d)", WSAGetLastError());1145+ if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR)1146+#else1147+ if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)1148+#endif1149+ {1150+ strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError());1151 printf("%s\n", strError.c_str());1152 return false;1153 }1154 1155 // The sockaddr_in structure specifies the address family,1156 // IP address, and port for the socket that is being bound1157- int nRetryLimit = 15;1158- struct sockaddr_in sockaddr = addrLocalHost.GetSockAddr();1159- if (bind(hListenSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR)1160+ struct sockaddr_in sockaddr;1161+ memset(&sockaddr, 0, sizeof(sockaddr));1162+ sockaddr.sin_family = AF_INET;1163+ sockaddr.sin_addr.s_addr = INADDR_ANY; // bind to all IPs on this computer1164+ sockaddr.sin_port = DEFAULT_PORT;1165+ if (::bind(hListenSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR)1166 {1167 int nErr = WSAGetLastError();1168 if (nErr == WSAEADDRINUSE)1169- strError = strprintf("Error: Unable to bind to port %s on this computer. The program is probably already running.", addrLocalHost.ToString().c_str());1170+ strError = strprintf("Unable to bind to port %d on this computer. Bitcoin is probably already running.", ntohs(sockaddr.sin_port));1171 else1172- strError = strprintf("Error: Unable to bind to port %s on this computer (bind returned error %d)", addrLocalHost.ToString().c_str(), nErr);1173+ strError = strprintf("Error: Unable to bind to port %d on this computer (bind returned error %d)", ntohs(sockaddr.sin_port), nErr);1174 printf("%s\n", strError.c_str());1175 return false;1176 }1177- printf("bound to addrLocalHost = %s\n\n", addrLocalHost.ToString().c_str());1178+ printf("Bound to port %d\n", ntohs(sockaddr.sin_port));1179 1180 // Listen for incoming connections1181 if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR)1182@@ -1020,45 +1161,166 @@1183 return false;1184 }1185 1186+ return true;1187+}1188+1189+void StartNode(void* parg)1190+{1191+ if (pnodeLocalHost == NULL)1192+ pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", nLocalServices));1193+1194+#ifdef __WXMSW__1195+ // Get local host ip1196+ char pszHostName[1000] = "";1197+ if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)1198+ {1199+ struct hostent* phostent = gethostbyname(pszHostName);1200+ if (phostent)1201+ {1202+ // Take the first IP that isn't loopback 127.x.x.x1203+ for (int i = 0; phostent->h_addr_list[i] != NULL; i++)1204+ printf("host ip %d: %s\n", i, CAddress(*(unsigned int*)phostent->h_addr_list[i]).ToStringIP().c_str());1205+ for (int i = 0; phostent->h_addr_list[i] != NULL; i++)1206+ {1207+ CAddress addr(*(unsigned int*)phostent->h_addr_list[i], DEFAULT_PORT, nLocalServices);1208+ if (addr.IsValid() && addr.GetByte(3) != 127)1209+ {1210+ addrLocalHost = addr;1211+ break;1212+ }1213+ }1214+ }1215+ }1216+#else1217+ // Get local host ip1218+ struct ifaddrs* myaddrs;1219+ if (getifaddrs(&myaddrs) == 0)1220+ {1221+ for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next)1222+ {1223+ if (ifa->ifa_addr == NULL) continue;1224+ if ((ifa->ifa_flags & IFF_UP) == 0) continue;1225+ if (strcmp(ifa->ifa_name, "lo") == 0) continue;1226+ if (strcmp(ifa->ifa_name, "lo0") == 0) continue;1227+ char pszIP[100];1228+ if (ifa->ifa_addr->sa_family == AF_INET)1229+ {1230+ struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);1231+ if (inet_ntop(ifa->ifa_addr->sa_family, (void*)&(s4->sin_addr), pszIP, sizeof(pszIP)) != NULL)1232+ printf("ipv4 %s: %s\n", ifa->ifa_name, pszIP);1233+1234+ // Take the first IP that isn't loopback 127.x.x.x1235+ CAddress addr(*(unsigned int*)&s4->sin_addr, DEFAULT_PORT, nLocalServices);1236+ if (addr.IsValid() && addr.GetByte(3) != 127)1237+ {1238+ addrLocalHost = addr;1239+ break;1240+ }1241+ }1242+ else if (ifa->ifa_addr->sa_family == AF_INET6)1243+ {1244+ struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr);1245+ if (inet_ntop(ifa->ifa_addr->sa_family, (void*)&(s6->sin6_addr), pszIP, sizeof(pszIP)) != NULL)1246+ printf("ipv6 %s: %s\n", ifa->ifa_name, pszIP);1247+ }1248+ }1249+ freeifaddrs(myaddrs);1250+ }1251+#endif1252+ printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());1253+1254 // Get our external IP address for incoming connections1255- if (addrIncoming.ip)1256- addrLocalHost.ip = addrIncoming.ip;1257-1258- if (GetMyExternalIP(addrLocalHost.ip))1259- {1260- addrIncoming = addrLocalHost;1261- CWalletDB().WriteSetting("addrIncoming", addrIncoming);1262- }1263-1264- // Get addresses from IRC and advertise ours1265- if (_beginthread(ThreadIRCSeed, 0, NULL) == -1)1266- printf("Error: _beginthread(ThreadIRCSeed) failed\n");1267+ if (fUseProxy)1268+ {1269+ // Proxies can't take incoming connections1270+ addrLocalHost.ip = CAddress("0.0.0.0").ip;1271+ printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());1272+ }1273+ else1274+ {1275+ if (addrIncoming.IsValid())1276+ addrLocalHost.ip = addrIncoming.ip;1277+1278+ if (GetMyExternalIP(addrLocalHost.ip))1279+ {1280+ addrIncoming = addrLocalHost;1281+ CWalletDB().WriteSetting("addrIncoming", addrIncoming);1282+ printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());1283+ }1284+ }1285 1286 //1287 // Start threads1288 //1289- if (_beginthread(ThreadSocketHandler, 0, new SOCKET(hListenSocket)) == -1)1290- {1291- strError = "Error: _beginthread(ThreadSocketHandler) failed";1292- printf("%s\n", strError.c_str());1293- return false;1294- }1295-1296- if (_beginthread(ThreadOpenConnections, 0, NULL) == -1)1297- {1298- strError = "Error: _beginthread(ThreadOpenConnections) failed";1299- printf("%s\n", strError.c_str());1300- return false;1301- }1302-1303- if (_beginthread(ThreadMessageHandler, 0, NULL) == -1)1304- {1305- strError = "Error: _beginthread(ThreadMessageHandler) failed";1306- printf("%s\n", strError.c_str());1307- return false;1308- }1309-1310- return true;1311+1312+ // Get addresses from IRC and advertise ours1313+ if (!CreateThread(ThreadIRCSeed, NULL))1314+ printf("Error: CreateThread(ThreadIRCSeed) failed\n");1315+1316+ // Send and receive from sockets, accept connections1317+ pthread_t hThreadSocketHandler = CreateThread(ThreadSocketHandler, NULL, true);1318+1319+ // Initiate outbound connections1320+ if (!CreateThread(ThreadOpenConnections, NULL))1321+ printf("Error: CreateThread(ThreadOpenConnections) failed\n");1322+1323+ // Process messages1324+ if (!CreateThread(ThreadMessageHandler, NULL))1325+ printf("Error: CreateThread(ThreadMessageHandler) failed\n");1326+1327+ // Generate coins in the background1328+ GenerateBitcoins(fGenerateBitcoins);1329+1330+ //1331+ // Thread monitoring1332+ // Not really needed anymore, the cause of the hanging was fixed1333+ //1334+ loop1335+ {1336+ Sleep(1000);1337+ if (fShutdown)1338+ return;1339+ if (GetTime() - nThreadSocketHandlerHeartbeat > 15 * 60)1340+ {1341+ // First see if closing sockets will free it1342+ printf("*** ThreadSocketHandler is stopped ***\n");1343+ CRITICAL_BLOCK(cs_vNodes)1344+ {1345+ foreach(CNode* pnode, vNodes)1346+ {1347+ bool fGot = false;1348+ TRY_CRITICAL_BLOCK(pnode->cs_vRecv)1349+ TRY_CRITICAL_BLOCK(pnode->cs_vSend)1350+ fGot = true;1351+ if (!fGot)1352+ {1353+ printf("*** closing socket\n");1354+ pnode->CloseSocketDisconnect();1355+ }1356+ }1357+ }1358+ Sleep(10000);1359+ if (fShutdown)1360+ return;1361+ if (GetTime() - nThreadSocketHandlerHeartbeat < 60)1362+ continue;1363+1364+ // Hopefully it never comes to this.1365+ // We know it'll always be hung in the recv or send call.1366+ // cs_vRecv or cs_vSend may be left permanently unreleased,1367+ // but we always only use TRY_CRITICAL_SECTION on them.1368+ printf("*** Restarting ThreadSocketHandler ***\n");1369+ TerminateThread(hThreadSocketHandler, 0);1370+ #ifdef __WXMSW__1371+ CloseHandle(hThreadSocketHandler);1372+ #endif1373+ vnThreadsRunning[0] = 0;1374+1375+ // Restart1376+ hThreadSocketHandler = CreateThread(ThreadSocketHandler, NULL, true);1377+ nThreadSocketHandlerHeartbeat = GetTime();1378+ }1379+ }1380 }1381 1382 bool StopNode()1383@@ -1067,35 +1329,44 @@1384 fShutdown = true;1385 nTransactionsUpdated++;1386 int64 nStart = GetTime();1387- while (vfThreadRunning[0] || vfThreadRunning[2] || vfThreadRunning[3])1388- {1389- if (GetTime() - nStart > 15)1390+ while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0)1391+ {1392+ if (GetTime() - nStart > 20)1393 break;1394 Sleep(20);1395 }1396- if (vfThreadRunning[0]) printf("ThreadSocketHandler still running\n");1397- if (vfThreadRunning[1]) printf("ThreadOpenConnections still running\n");1398- if (vfThreadRunning[2]) printf("ThreadMessageHandler still running\n");1399- if (vfThreadRunning[3]) printf("ThreadBitcoinMiner still running\n");1400- while (vfThreadRunning[2])1401+ if (vnThreadsRunning[0] > 0) printf("ThreadSocketHandler still running\n");1402+ if (vnThreadsRunning[1] > 0) printf("ThreadOpenConnections still running\n");1403+ if (vnThreadsRunning[2] > 0) printf("ThreadMessageHandler still running\n");1404+ if (vnThreadsRunning[3] > 0) printf("ThreadBitcoinMiner still running\n");1405+ while (vnThreadsRunning[2] > 0)1406 Sleep(20);1407 Sleep(50);1408 1409- // Sockets shutdown1410- WSACleanup();1411 return true;1412 }1413 1414-void CheckForShutdown(int n)1415-{1416- if (fShutdown)1417- {1418- if (n != -1)1419- vfThreadRunning[n] = false;1420- if (n == 0)1421- foreach(CNode* pnode, vNodes)1422+class CNetCleanup1423+{1424+public:1425+ CNetCleanup()1426+ {1427+ }1428+ ~CNetCleanup()1429+ {1430+ // Close sockets1431+ foreach(CNode* pnode, vNodes)1432+ if (pnode->hSocket != INVALID_SOCKET)1433 closesocket(pnode->hSocket);1434- _endthread();1435- }1436-}1437-1438+ if (hListenSocket != INVALID_SOCKET)1439+ if (closesocket(hListenSocket) == SOCKET_ERROR)1440+ printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());1441+1442+#ifdef __WXMSW__1443+ // Shutdown Windows Sockets1444+ WSACleanup();1445+#endif1446+ }1447+}1448+instance_of_cnetcleanup;1449+
net.h (modified)
1--- v0.1.5/net.h2+++ v0.2.0/net.h3@@ -7,6 +7,7 @@4 class CInv;5 class CRequestTracker;6 class CNode;7+class CBlockIndex;8 9 10 11@@ -20,20 +21,17 @@12 13 14 15-16-17 bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet);18 bool GetMyExternalIP(unsigned int& ipRet);19-bool AddAddress(CAddrDB& addrdb, const CAddress& addr);20+bool AddAddress(CAddrDB& addrdb, CAddress addr, bool fCurrentlyOnline=true);21+void AddressCurrentlyConnected(const CAddress& addr);22 CNode* FindNode(unsigned int ip);23 CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);24 void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);25 bool AnySubscribed(unsigned int nChannel);26-void ThreadBitcoinMiner(void* parg);27-bool StartNode(string& strError=REF(string()));28+bool BindListenPort(string& strError=REF(string()));29+void StartNode(void* parg);30 bool StopNode();31-void CheckForShutdown(int n);32-33 34 35 36@@ -141,61 +139,77 @@37 unsigned int nTime;38 39 // memory only40- unsigned int nLastFailed;41+ unsigned int nLastTry;42 43 CAddress()44 {45- nServices = 0;46+ Init();47+ }48+49+ CAddress(unsigned int ipIn, unsigned short portIn=DEFAULT_PORT, uint64 nServicesIn=NODE_NETWORK)50+ {51+ Init();52+ ip = ipIn;53+ port = portIn;54+ nServices = nServicesIn;55+ }56+57+ explicit CAddress(const struct sockaddr_in& sockaddr, uint64 nServicesIn=NODE_NETWORK)58+ {59+ Init();60+ ip = sockaddr.sin_addr.s_addr;61+ port = sockaddr.sin_port;62+ nServices = nServicesIn;63+ }64+65+ explicit CAddress(const char* pszIn, uint64 nServicesIn=NODE_NETWORK)66+ {67+ Init();68+ SetAddress(pszIn);69+ nServices = nServicesIn;70+ }71+72+ explicit CAddress(string strIn, uint64 nServicesIn=NODE_NETWORK)73+ {74+ Init();75+ SetAddress(strIn.c_str());76+ nServices = nServicesIn;77+ }78+79+ void Init()80+ {81+ nServices = NODE_NETWORK;82 memcpy(pchReserved, pchIPv4, sizeof(pchReserved));83- ip = 0;84+ ip = INADDR_NONE;85 port = DEFAULT_PORT;86 nTime = GetAdjustedTime();87- nLastFailed = 0;88- }89-90- CAddress(unsigned int ipIn, unsigned short portIn=DEFAULT_PORT, uint64 nServicesIn=0)91- {92- nServices = nServicesIn;93- memcpy(pchReserved, pchIPv4, sizeof(pchReserved));94- ip = ipIn;95- port = portIn;96- nTime = GetAdjustedTime();97- nLastFailed = 0;98- }99-100- explicit CAddress(const struct sockaddr_in& sockaddr, uint64 nServicesIn=0)101- {102- nServices = nServicesIn;103- memcpy(pchReserved, pchIPv4, sizeof(pchReserved));104- ip = sockaddr.sin_addr.s_addr;105- port = sockaddr.sin_port;106- nTime = GetAdjustedTime();107- nLastFailed = 0;108- }109-110- explicit CAddress(const char* pszIn, uint64 nServicesIn=0)111- {112- nServices = nServicesIn;113- memcpy(pchReserved, pchIPv4, sizeof(pchReserved));114- ip = 0;115+ nLastTry = 0;116+ }117+118+ bool SetAddress(const char* pszIn)119+ {120+ ip = INADDR_NONE;121 port = DEFAULT_PORT;122- nTime = GetAdjustedTime();123- nLastFailed = 0;124-125 char psz[100];126- if (strlen(pszIn) > ARRAYLEN(psz)-1)127- return;128- strcpy(psz, pszIn);129- unsigned int a, b, c, d, e;130+ strlcpy(psz, pszIn, sizeof(psz));131+ unsigned int a=0, b=0, c=0, d=0, e=0;132 if (sscanf(psz, "%u.%u.%u.%u:%u", &a, &b, &c, &d, &e) < 4)133- return;134+ return false;135 char* pszPort = strchr(psz, ':');136 if (pszPort)137 {138 *pszPort++ = '\0';139 port = htons(atoi(pszPort));140+ if (atoi(pszPort) < 0 || atoi(pszPort) > USHRT_MAX)141+ port = htons(USHRT_MAX);142 }143 ip = inet_addr(psz);144+ return IsValid();145+ }146+147+ bool SetAddress(string strIn)148+ {149+ return SetAddress(strIn.c_str());150 }151 152 IMPLEMENT_SERIALIZE153@@ -206,7 +220,7 @@154 READWRITE(nTime);155 }156 READWRITE(nServices);157- READWRITE(FLATDATA(pchReserved));158+ READWRITE(FLATDATA(pchReserved)); // for IPv6159 READWRITE(ip);160 READWRITE(port);161 )162@@ -216,6 +230,11 @@163 return (memcmp(a.pchReserved, b.pchReserved, sizeof(a.pchReserved)) == 0 &&164 a.ip == b.ip &&165 a.port == b.port);166+ }167+168+ friend inline bool operator!=(const CAddress& a, const CAddress& b)169+ {170+ return (!(a == b));171 }172 173 friend inline bool operator<(const CAddress& a, const CAddress& b)174@@ -249,6 +268,7 @@175 struct sockaddr_in GetSockAddr() const176 {177 struct sockaddr_in sockaddr;178+ memset(&sockaddr, 0, sizeof(sockaddr));179 sockaddr.sin_family = AF_INET;180 sockaddr.sin_addr.s_addr = ip;181 sockaddr.sin_port = port;182@@ -262,7 +282,17 @@183 184 bool IsRoutable() const185 {186- return !(GetByte(3) == 10 || (GetByte(3) == 192 && GetByte(2) == 168) || GetByte(3) == 127 || GetByte(3) == 0);187+ return !(GetByte(3) == 10 ||188+ (GetByte(3) == 192 && GetByte(2) == 168) ||189+ GetByte(3) == 127 ||190+ GetByte(3) == 0 ||191+ ip == 0 ||192+ ip == INADDR_NONE);193+ }194+195+ bool IsValid() const196+ {197+ return (ip != 0 && ip != INADDR_NONE && port != htons(USHRT_MAX));198 }199 200 unsigned char GetByte(int n) const201@@ -280,10 +310,19 @@202 return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0));203 }204 205+ string ToStringPort() const206+ {207+ return strprintf("%u", ntohs(port));208+ }209+210+ string ToStringLog() const211+ {212+ return "";213+ }214+215 string ToString() const216 {217 return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port));218- //return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0));219 }220 221 void print() const222@@ -376,7 +415,7 @@223 224 string ToString() const225 {226- return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,14).c_str());227+ return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,16).c_str());228 }229 230 void print() const231@@ -415,8 +454,11 @@232 extern uint64 nLocalServices;233 extern CAddress addrLocalHost;234 extern CNode* pnodeLocalHost;235-extern bool fShutdown;236-extern array<bool, 10> vfThreadRunning;237+extern uint64 nLocalHostNonce;238+extern array<int, 10> vnThreadsRunning;239+extern SOCKET hListenSocket;240+extern int64 nThreadSocketHandlerHeartbeat;241+242 extern vector<CNode*> vNodes;243 extern CCriticalSection cs_vNodes;244 extern map<vector<unsigned char>, CAddress> mapAddresses;245@@ -425,6 +467,9 @@246 extern deque<pair<int64, CInv> > vRelayExpiration;247 extern CCriticalSection cs_mapRelay;248 extern map<CInv, int64> mapAlreadyAskedFor;249+250+// Settings251+extern int fUseProxy;252 extern CAddress addrProxy;253 254 255@@ -441,12 +486,17 @@256 CDataStream vRecv;257 CCriticalSection cs_vSend;258 CCriticalSection cs_vRecv;259+ int64 nLastSend;260+ int64 nLastRecv;261+ int64 nLastSendEmpty;262+ int64 nTimeConnected;263 unsigned int nPushPos;264 CAddress addr;265 int nVersion;266 bool fClient;267 bool fInbound;268 bool fNetworkNode;269+ bool fSuccessfullyConnected;270 bool fDisconnect;271 protected:272 int nRefCount;273@@ -454,14 +504,17 @@274 int64 nReleaseTime;275 map<uint256, CRequestTracker> mapRequests;276 CCriticalSection cs_mapRequests;277+ uint256 hashContinue;278+ CBlockIndex* pindexLastGetBlocksBegin;279+ uint256 hashLastGetBlocksEnd;280 281 // flood282 vector<CAddress> vAddrToSend;283 set<CAddress> setAddrKnown;284+ bool fGetAddr;285 286 // inventory based relay287 set<CInv> setInventoryKnown;288- set<CInv> setInventoryKnown2;289 vector<CInv> vInventoryToSend;290 CCriticalSection cs_inventory;291 multimap<int64, CInv> mapAskFor;292@@ -476,27 +529,42 @@293 hSocket = hSocketIn;294 vSend.SetType(SER_NETWORK);295 vRecv.SetType(SER_NETWORK);296+ nLastSend = 0;297+ nLastRecv = 0;298+ nLastSendEmpty = GetTime();299+ nTimeConnected = GetTime();300 nPushPos = -1;301 addr = addrIn;302 nVersion = 0;303 fClient = false; // set by version message304 fInbound = fInboundIn;305 fNetworkNode = false;306+ fSuccessfullyConnected = false;307 fDisconnect = false;308 nRefCount = 0;309 nReleaseTime = 0;310+ hashContinue = 0;311+ pindexLastGetBlocksBegin = 0;312+ hashLastGetBlocksEnd = 0;313+ fGetAddr = false;314 vfSubscribe.assign(256, false);315 316 // Push a version message317 /// when NTP implemented, change to just nTime = GetAdjustedTime()318 int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());319- PushMessage("version", VERSION, nLocalServices, nTime, addr);320+ CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);321+ CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);322+ RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));323+ PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe, nLocalHostNonce, string(pszSubVer));324 }325 326 ~CNode()327 {328 if (hSocket != INVALID_SOCKET)329+ {330 closesocket(hSocket);331+ hSocket = INVALID_SOCKET;332+ }333 }334 335 private:336@@ -505,22 +573,18 @@337 public:338 339 340- bool ReadyToDisconnect()341- {342- return fDisconnect || GetRefCount() <= 0;343- }344-345 int GetRefCount()346 {347 return max(nRefCount, 0) + (GetTime() < nReleaseTime ? 1 : 0);348 }349 350- void AddRef(int64 nTimeout=0)351+ CNode* AddRef(int64 nTimeout=0)352 {353 if (nTimeout != 0)354 nReleaseTime = max(nReleaseTime, GetTime() + nTimeout);355 else356 nRefCount++;357+ return this;358 }359 360 void Release()361@@ -528,6 +592,21 @@362 nRefCount--;363 }364 365+366+367+ void AddAddressKnown(const CAddress& addr)368+ {369+ setAddrKnown.insert(addr);370+ }371+372+ void PushAddress(const CAddress& addr)373+ {374+ // Known checking here is only to save space from duplicates.375+ // SendMessages will filter it again for knowns that were added376+ // after addresses were pushed.377+ if (!setAddrKnown.count(addr))378+ vAddrToSend.push_back(addr);379+ }380 381 382 void AddInventoryKnown(const CInv& inv)383@@ -548,7 +627,7 @@384 // We're using mapAskFor as a priority queue,385 // the key is the earliest time the request can be sent386 int64& nRequestTime = mapAlreadyAskedFor[inv];387- printf("askfor %s %I64d\n", inv.ToString().c_str(), nRequestTime);388+ printf("askfor %s %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);389 390 // Make sure not to reuse time indexes to keep things in the same order391 int64 nNow = (GetTime() - 1) * 1000000;392@@ -564,12 +643,14 @@393 394 void BeginMessage(const char* pszCommand)395 {396- EnterCriticalSection(&cs_vSend);397+ cs_vSend.Enter();398 if (nPushPos != -1)399 AbortMessage();400 nPushPos = vSend.size();401 vSend << CMessageHeader(pszCommand, 0);402- printf("sending: %-12s ", pszCommand);403+ if (fDebug)404+ printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());405+ printf("sending: %s ", pszCommand);406 }407 408 void AbortMessage()409@@ -578,14 +659,13 @@410 return;411 vSend.resize(nPushPos);412 nPushPos = -1;413- LeaveCriticalSection(&cs_vSend);414+ cs_vSend.Leave();415 printf("(aborted)\n");416 }417 418 void EndMessage()419 {420- extern int nDropMessagesTest;421- if (nDropMessagesTest > 0 && GetRand(nDropMessagesTest) == 0)422+ if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)423 {424 printf("dropmessages DROPPING SEND MESSAGE\n");425 AbortMessage();426@@ -599,13 +679,11 @@427 unsigned int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader);428 memcpy((char*)&vSend[nPushPos] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize));429 430- printf("(%d bytes) ", nSize);431- //for (int i = nPushPos+sizeof(CMessageHeader); i < min(vSend.size(), nPushPos+sizeof(CMessageHeader)+20U); i++)432- // printf("%02x ", vSend[i] & 0xff);433+ printf("(%d bytes) ", nSize);434 printf("\n");435 436 nPushPos = -1;437- LeaveCriticalSection(&cs_vSend);438+ cs_vSend.Leave();439 }440 441 void EndMessageAbortIfEmpty()442@@ -707,6 +785,86 @@443 }444 }445 446+ template<typename T1, typename T2, typename T3, typename T4, typename T5>447+ void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5)448+ {449+ try450+ {451+ BeginMessage(pszCommand);452+ vSend << a1 << a2 << a3 << a4 << a5;453+ EndMessage();454+ }455+ catch (...)456+ {457+ AbortMessage();458+ throw;459+ }460+ }461+462+ template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>463+ void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6)464+ {465+ try466+ {467+ BeginMessage(pszCommand);468+ vSend << a1 << a2 << a3 << a4 << a5 << a6;469+ EndMessage();470+ }471+ catch (...)472+ {473+ AbortMessage();474+ throw;475+ }476+ }477+478+ template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>479+ void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7)480+ {481+ try482+ {483+ BeginMessage(pszCommand);484+ vSend << a1 << a2 << a3 << a4 << a5 << a6 << a7;485+ EndMessage();486+ }487+ catch (...)488+ {489+ AbortMessage();490+ throw;491+ }492+ }493+494+ template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>495+ void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7, const T8& a8)496+ {497+ try498+ {499+ BeginMessage(pszCommand);500+ vSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8;501+ EndMessage();502+ }503+ catch (...)504+ {505+ AbortMessage();506+ throw;507+ }508+ }509+510+ template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>511+ void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7, const T8& a8, const T9& a9)512+ {513+ try514+ {515+ BeginMessage(pszCommand);516+ vSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8 << a9;517+ EndMessage();518+ }519+ catch (...)520+ {521+ AbortMessage();522+ throw;523+ }524+ }525+526 527 void PushRequest(const char* pszCommand,528 void (*fn)(void*, CDataStream&), void* param1)529@@ -748,10 +906,12 @@530 531 532 533+ void PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd);534 bool IsSubscribed(unsigned int nChannel);535 void Subscribe(unsigned int nChannel, unsigned int nHops=0);536 void CancelSubscribe(unsigned int nChannel);537- void Disconnect();538+ void CloseSocketDisconnect();539+ void Cleanup();540 };541 542
readme.txt (removed)
1--- v0.1.5/readme.txt2+++ /dev/null3@@ -1,77 +1 @@4-BitCoin v0.1.5 ALPHA5 6-Copyright (c) 2009 Satoshi Nakamoto7-Distributed under the MIT/X11 software license, see the accompanying8-file license.txt or http://www.opensource.org/licenses/mit-license.php.9-This product includes software developed by the OpenSSL Project for use in10-the OpenSSL Toolkit (http://www.openssl.org/). This product includes11-cryptographic software written by Eric Young (eay@cryptsoft.com).12-13-14-Compilers Supported15--------------------16-MinGW GCC (v3.4.5)17-Microsoft Visual C++ 6.0 SP618-19-20-Dependencies21-------------22-Libraries you need to obtain separately to build:23-24- default path download25-wxWidgets \wxWidgets http://www.wxwidgets.org/downloads/26-OpenSSL \OpenSSL http://www.openssl.org/source/27-Berkeley DB \DB http://www.oracle.com/technology/software/products/berkeley-db/index.html28-Boost \Boost http://www.boost.org/users/download/29-30-Their licenses:31-wxWidgets LGPL 2.1 with very liberal exceptions32-OpenSSL Old BSD license with the problematic advertising requirement33-Berkeley DB New BSD license with additional requirement that linked software must be free open source34-Boost MIT-like license35-36-37-OpenSSL38--------39-Bitcoin does not use any encryption. If you want to do a no-everything40-build of OpenSSL to exclude encryption routines, a few patches are required.41-(OpenSSL v0.9.8h)42-43-Edit engines\e_gmp.c and put this #ifndef around #include <openssl/rsa.h>44- #ifndef OPENSSL_NO_RSA45- #include <openssl/rsa.h>46- #endif47-48-Add this to crypto\err\err_all.c before the ERR_load_crypto_strings line:49- void ERR_load_RSA_strings(void) { }50-51-Edit ms\mingw32.bat and replace the Configure line's parameters with this52-no-everything list. You have to put this in the batch file because batch53-files can't handle more than 9 parameters.54- perl Configure mingw threads no-rc2 no-rc4 no-rc5 no-idea no-des no-bf no-cast no-aes no-camellia no-seed no-rsa no-dh55-56-Also REM out the following line in ms\mingw32.bat. The build fails after it's57-already finished building libeay32, which is all we care about, but the58-failure aborts the script before it runs dllwrap to generate libeay32.dll.59- REM if errorlevel 1 goto end60-61-Build62- ms\mingw32.bat63-64-If you want to use it with MSVC, generate the .lib file65- lib /machine:i386 /def:ms\libeay32.def /out:out\libeay32.lib66-67-68-Berkeley DB69------------70-MinGW with MSYS:71-cd \DB\build_unix72-sh ../dist/configure --enable-mingw --enable-cxx73-make74-75-76-Boost77------78-You may need Boost version 1.35 to build with MSVC 6.0. I couldn't get79-version 1.37 to compile with MSVC 6.0.80-
serialize.h (modified)
1--- v0.1.5/serialize.h2+++ v0.2.0/serialize.h3@@ -19,7 +19,8 @@4 class CDataStream;5 class CAutoFile;6 7-static const int VERSION = 105;8+static const int VERSION = 200;9+static const char* pszSubVer = " rc2";10 11 12
setup.nsi (added)
1--- /dev/null2+++ v0.2.0/setup.nsi3@@ -1 +1,151 @@4+# Auto-generated by EclipseNSIS Script Wizard5+# 3.10.2009 19:00:286 7+Name Bitcoin8+9+RequestExecutionLevel highest10+11+# General Symbol Definitions12+!define REGKEY "SOFTWARE\$(^Name)"13+!define VERSION 0.2.014+!define COMPANY "Bitcoin project"15+!define URL http://www.bitcoin.org/16+17+# MUI Symbol Definitions18+!define MUI_ICON "src\rc\bitcoin.ico"19+!define MUI_FINISHPAGE_NOAUTOCLOSE20+!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM21+!define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY}22+!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup23+!define MUI_STARTMENUPAGE_DEFAULTFOLDER Bitcoin24+!define MUI_FINISHPAGE_RUN $INSTDIR\bitcoin.exe25+!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"26+!define MUI_UNFINISHPAGE_NOAUTOCLOSE27+28+# Included files29+!include Sections.nsh30+!include MUI2.nsh31+32+# Variables33+Var StartMenuGroup34+35+# Installer pages36+!insertmacro MUI_PAGE_WELCOME37+!insertmacro MUI_PAGE_DIRECTORY38+!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup39+!insertmacro MUI_PAGE_INSTFILES40+!insertmacro MUI_PAGE_FINISH41+!insertmacro MUI_UNPAGE_CONFIRM42+!insertmacro MUI_UNPAGE_INSTFILES43+44+# Installer languages45+!insertmacro MUI_LANGUAGE English46+47+# Installer attributes48+OutFile bitcoin-0.2.0-win32-setup.exe49+InstallDir $PROGRAMFILES\Bitcoin50+CRCCheck on51+XPStyle on52+ShowInstDetails show53+VIProductVersion 0.2.0.054+VIAddVersionKey ProductName Bitcoin55+VIAddVersionKey ProductVersion "${VERSION}"56+VIAddVersionKey CompanyName "${COMPANY}"57+VIAddVersionKey CompanyWebsite "${URL}"58+VIAddVersionKey FileVersion "${VERSION}"59+VIAddVersionKey FileDescription ""60+VIAddVersionKey LegalCopyright ""61+InstallDirRegKey HKCU "${REGKEY}" Path62+ShowUninstDetails show63+64+# Installer sections65+Section -Main SEC000066+ SetOutPath $INSTDIR67+ SetOverwrite on68+ File bitcoin.exe69+ File libeay32.dll70+ File mingwm10.dll71+ File license.txt72+ File readme.txt73+ SetOutPath $INSTDIR\src74+ File /r src\*.*75+ SetOutPath $INSTDIR76+ WriteRegStr HKCU "${REGKEY}\Components" Main 177+SectionEnd78+79+Section -post SEC000180+ WriteRegStr HKCU "${REGKEY}" Path $INSTDIR81+ SetOutPath $INSTDIR82+ WriteUninstaller $INSTDIR\uninstall.exe83+ !insertmacro MUI_STARTMENU_WRITE_BEGIN Application84+ CreateDirectory $SMPROGRAMS\$StartMenuGroup85+ CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk" $INSTDIR\bitcoin.exe86+ CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall Bitcoin.lnk" $INSTDIR\uninstall.exe87+ !insertmacro MUI_STARTMENU_WRITE_END88+ WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"89+ WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"90+ WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"91+ WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"92+ WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe93+ WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe94+ WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 195+ WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 196+SectionEnd97+98+# Macro for selecting uninstaller sections99+!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID100+ Push $R0101+ ReadRegStr $R0 HKCU "${REGKEY}\Components" "${SECTION_NAME}"102+ StrCmp $R0 1 0 next${UNSECTION_ID}103+ !insertmacro SelectSection "${UNSECTION_ID}"104+ GoTo done${UNSECTION_ID}105+next${UNSECTION_ID}:106+ !insertmacro UnselectSection "${UNSECTION_ID}"107+done${UNSECTION_ID}:108+ Pop $R0109+!macroend110+111+# Uninstaller sections112+Section /o -un.Main UNSEC0000113+ Delete /REBOOTOK $INSTDIR\bitcoin.exe114+ Delete /REBOOTOK $INSTDIR\libeay32.dll115+ Delete /REBOOTOK $INSTDIR\mingwm10.dll116+ Delete /REBOOTOK $INSTDIR\license.txt117+ Delete /REBOOTOK $INSTDIR\readme.txt118+ RMDir /r /REBOOTOK $INSTDIR\src119+ DeleteRegValue HKCU "${REGKEY}\Components" Main120+SectionEnd121+122+Section -un.post UNSEC0001123+ DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"124+ Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall Bitcoin.lnk"125+ Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk"126+ Delete /REBOOTOK "$SMSTARTUP\Bitcoin.lnk"127+ Delete /REBOOTOK $INSTDIR\uninstall.exe128+ Delete /REBOOTOK $INSTDIR\debug.log129+ Delete /REBOOTOK $INSTDIR\db.log130+ DeleteRegValue HKCU "${REGKEY}" StartMenuGroup131+ DeleteRegValue HKCU "${REGKEY}" Path132+ DeleteRegKey /IfEmpty HKCU "${REGKEY}\Components"133+ DeleteRegKey /IfEmpty HKCU "${REGKEY}"134+ RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup135+ RmDir /REBOOTOK $INSTDIR136+ Push $R0137+ StrCpy $R0 $StartMenuGroup 1138+ StrCmp $R0 ">" no_smgroup139+no_smgroup:140+ Pop $R0141+SectionEnd142+143+# Installer functions144+Function .onInit145+ InitPluginsDir146+FunctionEnd147+148+# Uninstaller functions149+Function un.onInit150+ ReadRegStr $INSTDIR HKCU "${REGKEY}" Path151+ !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup152+ !insertmacro SELECT_UNSECTION Main ${UNSEC0000}153+FunctionEnd154+
strlcpy.h (added)
1--- /dev/null2+++ v0.2.0/strlcpy.h3@@ -1 +1,85 @@4+/*5+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>6+ *7+ * Permission to use, copy, modify, and distribute this software for any8+ * purpose with or without fee is hereby granted, provided that the above9+ * copyright notice and this permission notice appear in all copies.10+ *11+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES12+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF13+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR14+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES15+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN16+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF17+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.18+ */19 20+/*21+ * Copy src to string dst of size siz. At most siz-1 characters22+ * will be copied. Always NUL terminates (unless siz == 0).23+ * Returns strlen(src); if retval >= siz, truncation occurred.24+ */25+inline size_t strlcpy(char *dst, const char *src, size_t siz)26+{27+ char *d = dst;28+ const char *s = src;29+ size_t n = siz;30+31+ /* Copy as many bytes as will fit */32+ if (n != 0)33+ {34+ while (--n != 0)35+ {36+ if ((*d++ = *s++) == '\0')37+ break;38+ }39+ }40+41+ /* Not enough room in dst, add NUL and traverse rest of src */42+ if (n == 0)43+ {44+ if (siz != 0)45+ *d = '\0'; /* NUL-terminate dst */46+ while (*s++)47+ ;48+ }49+50+ return(s - src - 1); /* count does not include NUL */51+}52+53+/*54+ * Appends src to string dst of size siz (unlike strncat, siz is the55+ * full size of dst, not space left). At most siz-1 characters56+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).57+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).58+ * If retval >= siz, truncation occurred.59+ */60+inline size_t strlcat(char *dst, const char *src, size_t siz)61+{62+ char *d = dst;63+ const char *s = src;64+ size_t n = siz;65+ size_t dlen;66+67+ /* Find the end of dst and adjust bytes left but don't go past end */68+ while (n-- != 0 && *d != '\0')69+ d++;70+ dlen = d - dst;71+ n = siz - dlen;72+73+ if (n == 0)74+ return(dlen + strlen(s));75+ while (*s != '\0')76+ {77+ if (n != 1)78+ {79+ *d++ = *s;80+ n--;81+ }82+ s++;83+ }84+ *d = '\0';85+86+ return(dlen + (s - src)); /* count does not include NUL */87+}88+
ui.cpp (modified)
1--- v0.1.5/ui.cpp2+++ v0.2.0/ui.cpp3@@ -7,25 +7,31 @@4 #include <crtdbg.h>5 #endif6 7-8-9-DEFINE_EVENT_TYPE(wxEVT_CROSSTHREADCALL)10+void ThreadRequestProductDetails(void* parg);11+void ThreadRandSendTest(void* parg);12+bool GetStartOnSystemStartup();13+void SetStartOnSystemStartup(bool fAutoStart);14+15+16+17+DEFINE_EVENT_TYPE(wxEVT_UITHREADCALL)18 DEFINE_EVENT_TYPE(wxEVT_REPLY1)19 DEFINE_EVENT_TYPE(wxEVT_REPLY2)20 DEFINE_EVENT_TYPE(wxEVT_REPLY3)21-DEFINE_EVENT_TYPE(wxEVT_TABLEADDED)22-DEFINE_EVENT_TYPE(wxEVT_TABLEUPDATED)23-DEFINE_EVENT_TYPE(wxEVT_TABLEDELETED)24 25 CMainFrame* pframeMain = NULL;26+CMyTaskBarIcon* ptaskbaricon = NULL;27 map<string, string> mapAddressBook;28-29-30-void ThreadRequestProductDetails(void* parg);31-void ThreadRandSendTest(void* parg);32 bool fRandSendTest = false;33 void RandSend();34 extern int g_isPainting;35+bool fClosedToTray = false;36+37+// Settings38+int fShowGenerated = true;39+int fMinimizeToTray = true;40+int fMinimizeOnClose = true;41+42 43 44 45@@ -57,11 +63,13 @@46 47 string DateStr(int64 nTime)48 {49+ // Can only be used safely here in the UI50 return (string)wxDateTime((time_t)nTime).FormatDate();51 }52 53 string DateTimeStr(int64 nTime)54 {55+ // Can only be used safely here in the UI56 wxDateTime datetime((time_t)nTime);57 if (Is24HourTime())58 return (string)datetime.Format("%x %H:%M");59@@ -174,6 +182,37 @@60 "");61 }62 63+void CalledMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y, int* pnRet, bool* pfDone)64+{65+ *pnRet = wxMessageBox(message, caption, style, parent, x, y);66+ *pfDone = true;67+}68+69+int ThreadSafeMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y)70+{71+#ifdef __WXMSW__72+ return wxMessageBox(message, caption, style, parent, x, y);73+#else74+ if (wxThread::IsMain())75+ {76+ return wxMessageBox(message, caption, style, parent, x, y);77+ }78+ else79+ {80+ int nRet = 0;81+ bool fDone = false;82+ UIThreadCall(bind(CalledMessageBox, message, caption, style, parent, x, y, &nRet, &fDone));83+ while (!fDone)84+ Sleep(100);85+ return nRet;86+ }87+#endif88+}89+90+91+92+93+94 95 96 97@@ -183,6 +222,7 @@98 //99 // Custom events100 //101+// If this code gets used again, it should be replaced with something like UIThreadCall102 103 set<void*> setCallbackAvailable;104 CCriticalSection cs_setCallbackAvailable;105@@ -252,7 +292,8 @@106 CDataStream GetStreamFromEvent(const wxCommandEvent& event)107 {108 wxString strData = event.GetString();109- return CDataStream(strData.begin(), strData.begin() + event.GetInt(), SER_NETWORK);110+ const char* pszBegin = strData.c_str();111+ return CDataStream(pszBegin, pszBegin + event.GetInt(), SER_NETWORK);112 }113 114 115@@ -268,42 +309,48 @@116 117 CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)118 {119- Connect(wxEVT_CROSSTHREADCALL, wxCommandEventHandler(CMainFrame::OnCrossThreadCall), NULL, this);120+ Connect(wxEVT_UITHREADCALL, wxCommandEventHandler(CMainFrame::OnUIThreadCall), NULL, this);121 122 // Init123 fRefreshListCtrl = false;124 fRefreshListCtrlRunning = false;125 fOnSetFocusAddress = false;126- pindexBestLast = NULL;127+ fRefresh = false;128 m_choiceFilter->SetSelection(0);129+ double dResize = 1.0;130+#ifdef __WXMSW__131+ SetIcon(wxICON(bitcoin));132+#else133+ SetIcon(bitcoin16_xpm);134+ wxFont fontTmp = m_staticText41->GetFont();135+ fontTmp.SetFamily(wxFONTFAMILY_TELETYPE);136+ m_staticTextBalance->SetFont(fontTmp);137+ m_staticTextBalance->SetSize(140, 17);138+ // & underlines don't work on the toolbar buttons on gtk139+ m_toolBar->ClearTools();140+ m_toolBar->AddTool(wxID_BUTTONSEND, "Send Coins", wxBitmap(send20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);141+ m_toolBar->AddTool(wxID_BUTTONRECEIVE, "Address Book", wxBitmap(addressbook20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);142+ m_toolBar->Realize();143+ // resize to fit ubuntu's huge default font144+ dResize = 1.19;145+ SetSize(dResize * GetSize().GetWidth(), 1.1 * GetSize().GetHeight());146+ dResize = 1.20;147+#endif148 m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " ");149 m_listCtrl->SetFocus();150- SetIcon(wxICON(bitcoin));151- m_menuOptions->Check(wxID_OPTIONSGENERATEBITCOINS, fGenerateBitcoins);152-153- // Init toolbar with transparency masked bitmaps154- m_toolBar->ClearTools();155-156- //// shouldn't have to do mask separately anymore, bitmap alpha support added in wx 2.8.9,157- wxBitmap bmpSend(wxT("send20"), wxBITMAP_TYPE_RESOURCE);158- bmpSend.SetMask(new wxMask(wxBitmap(wxT("send20mask"), wxBITMAP_TYPE_RESOURCE)));159- m_toolBar->AddTool(wxID_BUTTONSEND, wxT("&Send Coins"), bmpSend, wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);160-161- wxBitmap bmpAddressBook(wxT("addressbook20"), wxBITMAP_TYPE_RESOURCE);162- bmpAddressBook.SetMask(new wxMask(wxBitmap(wxT("addressbook20mask"), wxBITMAP_TYPE_RESOURCE)));163- m_toolBar->AddTool(wxID_BUTTONRECEIVE, wxT("&Address Book"), bmpAddressBook, wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);164-165- m_toolBar->Realize();166+ ptaskbaricon = new CMyTaskBarIcon();167 168 // Init column headers169 int nDateWidth = DateTimeStr(1229413914).size() * 6 + 8;170- m_listCtrl->InsertColumn(0, "", wxLIST_FORMAT_LEFT, 0);171- m_listCtrl->InsertColumn(1, "", wxLIST_FORMAT_LEFT, 0);172- m_listCtrl->InsertColumn(2, "Status", wxLIST_FORMAT_LEFT, 90);173- m_listCtrl->InsertColumn(3, "Date", wxLIST_FORMAT_LEFT, nDateWidth);174- m_listCtrl->InsertColumn(4, "Description", wxLIST_FORMAT_LEFT, 409 - nDateWidth);175- m_listCtrl->InsertColumn(5, "Debit", wxLIST_FORMAT_RIGHT, 79);176- m_listCtrl->InsertColumn(6, "Credit", wxLIST_FORMAT_RIGHT, 79);177+ if (!strstr(DateTimeStr(1229413914).c_str(), "2008"))178+ nDateWidth += 12;179+ m_listCtrl->InsertColumn(0, "", wxLIST_FORMAT_LEFT, dResize * 0);180+ m_listCtrl->InsertColumn(1, "", wxLIST_FORMAT_LEFT, dResize * 0);181+ m_listCtrl->InsertColumn(2, "Status", wxLIST_FORMAT_LEFT, dResize * 90);182+ m_listCtrl->InsertColumn(3, "Date", wxLIST_FORMAT_LEFT, dResize * nDateWidth);183+ m_listCtrl->InsertColumn(4, "Description", wxLIST_FORMAT_LEFT, dResize * 409 - nDateWidth);184+ m_listCtrl->InsertColumn(5, "Debit", wxLIST_FORMAT_RIGHT, dResize * 79);185+ m_listCtrl->InsertColumn(6, "Credit", wxLIST_FORMAT_RIGHT, dResize * 79);186 187 //m_listCtrlProductsSent->InsertColumn(0, "Category", wxLIST_FORMAT_LEFT, 100);188 //m_listCtrlProductsSent->InsertColumn(1, "Title", wxLIST_FORMAT_LEFT, 100);189@@ -324,7 +371,11 @@190 //m_listCtrlOrdersReceived->InsertColumn(4, "", wxLIST_FORMAT_LEFT, 100);191 192 // Init status bar193- int pnWidths[3] = { -100, 81, 286 };194+ int pnWidths[3] = { -100, 88, 290 };195+#ifndef __WXMSW__196+ pnWidths[1] = pnWidths[1] * 1.1 * dResize;197+ pnWidths[2] = pnWidths[2] * 1.1 * dResize;198+#endif199 m_statusBar->SetFieldsCount(3, pnWidths);200 201 // Fill your address text box202@@ -339,28 +390,81 @@203 CMainFrame::~CMainFrame()204 {205 pframeMain = NULL;206+ delete ptaskbaricon;207+ ptaskbaricon = NULL;208+}209+210+void ExitTimeout(void* parg)211+{212+#ifdef __WXMSW__213+ Sleep(5000);214+ ExitProcess(0);215+#endif216 }217 218 void Shutdown(void* parg)219 {220 static CCriticalSection cs_Shutdown;221+ static bool fTaken;222+ bool fFirstThread;223 CRITICAL_BLOCK(cs_Shutdown)224+ {225+ fFirstThread = !fTaken;226+ fTaken = true;227+ }228+ static bool fExit;229+ if (fFirstThread)230 {231 fShutdown = true;232 nTransactionsUpdated++;233 DBFlush(false);234 StopNode();235 DBFlush(true);236-237- printf("Bitcoin exiting\n");238+ CreateThread(ExitTimeout, NULL);239+ Sleep(10);240+ printf("Bitcoin exiting\n\n");241+ fExit = true;242 exit(0);243 }244+ else245+ {246+ while (!fExit)247+ Sleep(500);248+ Sleep(100);249+ ExitThread(0);250+ }251 }252 253 void CMainFrame::OnClose(wxCloseEvent& event)254 {255- Destroy();256- _beginthread(Shutdown, 0, NULL);257+ if (fMinimizeOnClose && event.CanVeto() && !IsIconized())258+ {259+ // Divert close to minimize260+ event.Veto();261+ fClosedToTray = true;262+ Iconize(true);263+ }264+ else265+ {266+ Destroy();267+ CreateThread(Shutdown, NULL);268+ }269+}270+271+void CMainFrame::OnIconize(wxIconizeEvent& event)272+{273+ // Hide the task bar button when minimized.274+ // Event is sent when the frame is minimized or restored.275+ if (!event.Iconized())276+ fClosedToTray = false;277+#ifndef __WXMSW__278+ // Tray is not reliable on Linux gnome279+ fClosedToTray = false;280+#endif281+ if (fMinimizeToTray && event.Iconized())282+ fClosedToTray = true;283+ Show(!fClosedToTray);284+ ptaskbaricon->Show(fMinimizeToTray || fClosedToTray);285 }286 287 void CMainFrame::OnMouseEvents(wxMouseEvent& event)288@@ -377,35 +481,55 @@289 event.Veto();290 }291 292+int CMainFrame::GetSortIndex(const string& strSort)293+{294+#ifdef __WXMSW__295+ return 0;296+#else297+ // The wx generic listctrl implementation used on GTK doesn't sort,298+ // so we have to do it ourselves. Remember, we sort in reverse order.299+ // In the wx generic implementation, they store the list of items300+ // in a vector, so indexed lookups are fast, but inserts are slower301+ // the closer they are to the top.302+ int low = 0;303+ int high = m_listCtrl->GetItemCount();304+ while (low < high)305+ {306+ int mid = low + ((high - low) / 2);307+ if (strSort.compare(m_listCtrl->GetItemText(mid).c_str()) >= 0)308+ high = mid;309+ else310+ low = mid + 1;311+ }312+ return low;313+#endif314+}315+316 void CMainFrame::InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5, const wxString& str6)317 {318 string str0 = strSort;319 long nData = *(long*)&hashKey;320 321- if (fNew)322- {323- nIndex = m_listCtrl->InsertItem(0, str0);324+ // Find item325+ if (!fNew && nIndex == -1)326+ {327+ while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1)328+ if (GetItemText(m_listCtrl, nIndex, 1) == hashKey.ToString())329+ break;330+ }331+332+ // fNew is for blind insert, only use if you're sure it's new333+ if (fNew || nIndex == -1)334+ {335+ nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), str0);336 }337 else338 {339- if (nIndex == -1)340- {341- // Find item342- while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1)343- if (GetItemText(m_listCtrl, nIndex, 1) == hashKey.ToString())344- break;345- if (nIndex == -1)346- {347- printf("CMainFrame::InsertLine : Couldn't find item to be updated\n");348- return;349- }350- }351-352 // If sort key changed, must delete and reinsert to make it relocate353 if (GetItemText(m_listCtrl, nIndex, 0) != str0)354 {355 m_listCtrl->DeleteItem(nIndex);356- nIndex = m_listCtrl->InsertItem(0, str0);357+ nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), str0);358 }359 }360 361@@ -418,16 +542,42 @@362 m_listCtrl->SetItemData(nIndex, nData);363 }364 365+bool CMainFrame::DeleteLine(uint256 hashKey)366+{367+ long nData = *(long*)&hashKey;368+369+ // Find item370+ int nIndex = -1;371+ while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1)372+ if (GetItemText(m_listCtrl, nIndex, 1) == hashKey.ToString())373+ break;374+375+ if (nIndex != -1)376+ m_listCtrl->DeleteItem(nIndex);377+378+ return nIndex != -1;379+}380+381 string FormatTxStatus(const CWalletTx& wtx)382 {383 // Status384- int nDepth = wtx.GetDepthInMainChain();385 if (!wtx.IsFinal())386- return strprintf("Open for %d blocks", nBestHeight - wtx.nLockTime);387- else if (nDepth < 6)388- return strprintf("%d/unconfirmed", nDepth);389+ {390+ if (wtx.nLockTime < 500000000)391+ return strprintf("Open for %d blocks", nBestHeight - wtx.nLockTime);392+ else393+ return strprintf("Open until %s", DateTimeStr(wtx.nLockTime).c_str());394+ }395 else396- return strprintf("%d blocks", nDepth);397+ {398+ int nDepth = wtx.GetDepthInMainChain();399+ if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)400+ return strprintf("%d/offline?", nDepth);401+ else if (nDepth < 6)402+ return strprintf("%d/unconfirmed", nDepth);403+ else404+ return strprintf("%d blocks", nDepth);405+ }406 }407 408 string SingleLine(const string& strIn)409@@ -451,7 +601,7 @@410 return strOut;411 }412 413-void CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)414+bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)415 {416 int64 nTime = wtx.nTimeDisplayed = wtx.GetTxTime();417 int64 nCredit = wtx.GetCredit();418@@ -460,6 +610,33 @@419 uint256 hash = wtx.GetHash();420 string strStatus = FormatTxStatus(wtx);421 map<string, string> mapValue = wtx.mapValue;422+ wtx.nLinesDisplayed = 1;423+ nListViewUpdated++;424+425+ // Filter426+ if (wtx.IsCoinBase())427+ {428+ // Don't show generated coin until confirmed by at least one block after it429+ // so we don't get the user's hopes up until it looks like it's probably accepted.430+ //431+ // It is not an error when generated blocks are not accepted. By design,432+ // some percentage of blocks, like 10% or more, will end up not accepted.433+ // This is the normal mechanism by which the network copes with latency.434+ //435+ // We display regular transactions right away before any confirmation436+ // because they can always get into some block eventually. Generated coins437+ // are special because if their block is not accepted, they are not valid.438+ //439+ if (wtx.GetDepthInMainChain() < 2)440+ {441+ wtx.nLinesDisplayed = 0;442+ return false;443+ }444+445+ // View->Show Generated446+ if (!fShowGenerated)447+ return false;448+ }449 450 // Find the block the tx is in451 CBlockIndex* pindex = NULL;452@@ -491,9 +668,17 @@453 foreach(const CTxOut& txout, wtx.vout)454 nUnmatured += txout.GetCredit();455 if (wtx.IsInMainChain())456- strDescription += strprintf(" (%s matures in %d more blocks)", FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());457+ {458+ strDescription = strprintf("Generated (%s matures in %d more blocks)", FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());459+460+ // Check if the block was requested by anyone461+ if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)462+ strDescription = "Generated - Warning: This block was not received by any other nodes and will probably not be accepted!";463+ }464 else465- strDescription += " (not accepted)";466+ {467+ strDescription = "Generated (not accepted)";468+ }469 }470 }471 else if (!mapValue["from"].empty() || !mapValue["message"].empty())472@@ -563,8 +748,11 @@473 strStatus,474 nTime ? DateTimeStr(nTime) : "",475 "Payment to yourself",476- FormatMoney(nNet - nValue, true),477- FormatMoney(nValue, true));478+ "",479+ "");480+ /// issue: can't tell which is the payment and which is the change anymore481+ // FormatMoney(nNet - nValue, true),482+ // FormatMoney(nValue, true));483 }484 else if (fAllFromMe)485 {486@@ -572,6 +760,7 @@487 // Debit488 //489 int64 nTxFee = nDebit - wtx.GetValueOut();490+ wtx.nLinesDisplayed = 0;491 for (int nOut = 0; nOut < wtx.vout.size(); nOut++)492 {493 const CTxOut& txout = wtx.vout[nOut];494@@ -613,6 +802,7 @@495 SingleLine(strDescription),496 FormatMoney(-nValue, true),497 "");498+ wtx.nLinesDisplayed++;499 }500 }501 else502@@ -634,45 +824,8 @@503 "");504 }505 }506-}507-508-void CMainFrame::RefreshStatus()509-{510- static int nLastTop;511- int nTop = m_listCtrl->GetTopItem();512- if (nTop == nLastTop && pindexBestLast == pindexBest)513- return;514-515- TRY_CRITICAL_BLOCK(cs_mapWallet)516- {517- int nStart = nTop;518- int nEnd = min(nStart + 100, m_listCtrl->GetItemCount());519- if (pindexBestLast == pindexBest)520- {521- if (nStart >= nLastTop && nStart < nLastTop + 100)522- nStart = nLastTop + 100;523- if (nEnd >= nLastTop && nEnd < nLastTop + 100)524- nEnd = nLastTop;525- }526- nLastTop = nTop;527- pindexBestLast = pindexBest;528-529- for (int nIndex = nStart; nIndex < nEnd; nIndex++)530- {531- uint256 hash((string)GetItemText(m_listCtrl, nIndex, 1));532- map<uint256, CWalletTx>::iterator mi = mapWallet.find(hash);533- if (mi == mapWallet.end())534- {535- printf("CMainFrame::RefreshStatus() : tx not found in mapWallet\n");536- continue;537- }538- const CWalletTx& wtx = (*mi).second;539- if (wtx.IsCoinBase() || wtx.GetTxTime() != wtx.nTimeDisplayed)540- InsertTransaction(wtx, false, nIndex);541- else542- m_listCtrl->SetItem(nIndex, 2, FormatTxStatus(wtx));543- }544- }545+546+ return true;547 }548 549 void CMainFrame::RefreshListCtrl()550@@ -729,6 +882,9 @@551 }552 553 printf("RefreshListCtrl done\n");554+555+ // Update transaction total display556+ MainFrameRepaint();557 }558 else559 {560@@ -750,36 +906,166 @@561 }562 }563 564+void CMainFrame::RefreshStatusColumn()565+{566+ static int nLastTop;567+ static CBlockIndex* pindexLastBest;568+ static unsigned int nLastRefreshed;569+570+ int nTop = max((int)m_listCtrl->GetTopItem(), 0);571+ if (nTop == nLastTop && pindexLastBest == pindexBest)572+ return;573+574+ TRY_CRITICAL_BLOCK(cs_mapWallet)575+ {576+ int nStart = nTop;577+ int nEnd = min(nStart + 100, m_listCtrl->GetItemCount());578+579+ if (pindexLastBest == pindexBest && nLastRefreshed == nListViewUpdated)580+ {581+ // If no updates, only need to do the part that moved onto the screen582+ if (nStart >= nLastTop && nStart < nLastTop + 100)583+ nStart = nLastTop + 100;584+ if (nEnd >= nLastTop && nEnd < nLastTop + 100)585+ nEnd = nLastTop;586+ }587+ nLastTop = nTop;588+ pindexLastBest = pindexBest;589+ nLastRefreshed = nListViewUpdated;590+591+ for (int nIndex = nStart; nIndex < min(nEnd, m_listCtrl->GetItemCount()); nIndex++)592+ {593+ uint256 hash((string)GetItemText(m_listCtrl, nIndex, 1));594+ map<uint256, CWalletTx>::iterator mi = mapWallet.find(hash);595+ if (mi == mapWallet.end())596+ {597+ printf("CMainFrame::RefreshStatusColumn() : tx not found in mapWallet\n");598+ continue;599+ }600+ CWalletTx& wtx = (*mi).second;601+ if (wtx.IsCoinBase() || wtx.GetTxTime() != wtx.nTimeDisplayed)602+ {603+ if (!InsertTransaction(wtx, false, nIndex))604+ m_listCtrl->DeleteItem(nIndex--);605+ }606+ else607+ m_listCtrl->SetItem(nIndex, 2, FormatTxStatus(wtx));608+ }609+ }610+}611+612 void CMainFrame::OnPaint(wxPaintEvent& event)613 {614+ if (fRefresh)615+ {616+ fRefresh = false;617+ Refresh();618+ }619 event.Skip();620 }621 622+623+unsigned int nNeedRepaint = 0;624+unsigned int nLastRepaint = 0;625+int64 nLastRepaintTime = 0;626+int64 nRepaintInterval = 500;627+628+void ThreadDelayedRepaint(void* parg)629+{630+ while (!fShutdown)631+ {632+ if (nLastRepaint != nNeedRepaint && GetTimeMillis() - nLastRepaintTime >= nRepaintInterval)633+ {634+ nLastRepaint = nNeedRepaint;635+ if (pframeMain)636+ {637+ printf("DelayedRepaint\n");638+ wxPaintEvent event;639+ pframeMain->fRefresh = true;640+ pframeMain->AddPendingEvent(event);641+ }642+ }643+ Sleep(nRepaintInterval);644+ }645+}646+647+void MainFrameRepaint()648+{649+ // This is called by network code that shouldn't access pframeMain650+ // directly because it could still be running after the UI is closed.651+ if (pframeMain)652+ {653+ // Don't repaint too often654+ static int64 nLastRepaintRequest;655+ if (GetTimeMillis() - nLastRepaintRequest < 100)656+ {657+ nNeedRepaint++;658+ return;659+ }660+ nLastRepaintRequest = GetTimeMillis();661+662+ printf("MainFrameRepaint\n");663+ wxPaintEvent event;664+ pframeMain->fRefresh = true;665+ pframeMain->AddPendingEvent(event);666+ }667+}668+669 void CMainFrame::OnPaintListCtrl(wxPaintEvent& event)670 {671- // Update listctrl contents672- if (!vWalletUpdated.empty())673- {674+ if (ptaskbaricon)675+ ptaskbaricon->UpdateTooltip();676+677+ //678+ // Slower stuff679+ //680+ static int nTransactionCount;681+ bool fPaintedBalance = false;682+ if (GetTimeMillis() - nLastRepaintTime >= nRepaintInterval)683+ {684+ nLastRepaint = nNeedRepaint;685+ nLastRepaintTime = GetTimeMillis();686+687+ // Update listctrl contents688+ if (!vWalletUpdated.empty())689+ {690+ TRY_CRITICAL_BLOCK(cs_mapWallet)691+ {692+ string strTop;693+ if (m_listCtrl->GetItemCount())694+ strTop = (string)m_listCtrl->GetItemText(0);695+ foreach(uint256 hash, vWalletUpdated)696+ {697+ map<uint256, CWalletTx>::iterator mi = mapWallet.find(hash);698+ if (mi != mapWallet.end())699+ InsertTransaction((*mi).second, false);700+ }701+ vWalletUpdated.clear();702+ if (m_listCtrl->GetItemCount() && strTop != (string)m_listCtrl->GetItemText(0))703+ m_listCtrl->ScrollList(0, INT_MIN/2);704+ }705+ }706+707+ // Balance total708 TRY_CRITICAL_BLOCK(cs_mapWallet)709 {710- pair<uint256, bool> item;711- foreach(item, vWalletUpdated)712+ fPaintedBalance = true;713+ m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " ");714+715+ // Count hidden and multi-line transactions716+ nTransactionCount = 0;717+ for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)718 {719- bool fNew = item.second;720- map<uint256, CWalletTx>::iterator mi = mapWallet.find(item.first);721- if (mi != mapWallet.end())722- {723- printf("vWalletUpdated: %s %s\n", (*mi).second.GetHash().ToString().substr(0,6).c_str(), fNew ? "new" : "");724- InsertTransaction((*mi).second, fNew);725- }726+ CWalletTx& wtx = (*it).second;727+ nTransactionCount += wtx.nLinesDisplayed;728 }729- m_listCtrl->ScrollList(0, INT_MAX);730- vWalletUpdated.clear();731- }732- }733+ }734+ }735+ if (!vWalletUpdated.empty() || !fPaintedBalance)736+ nNeedRepaint++;737 738 // Update status column of visible items only739- RefreshStatus();740+ RefreshStatusColumn();741 742 // Update status bar743 string strGen = "";744@@ -789,94 +1075,94 @@745 strGen = "(not connected)";746 m_statusBar->SetStatusText(strGen, 1);747 748- string strStatus = strprintf(" %d connections %d blocks %d transactions", vNodes.size(), nBestHeight + 1, m_listCtrl->GetItemCount());749+ string strStatus = strprintf(" %d connections %d blocks %d transactions", vNodes.size(), nBestHeight + 1, nTransactionCount);750 m_statusBar->SetStatusText(strStatus, 2);751 752- // Balance total753- TRY_CRITICAL_BLOCK(cs_mapWallet)754- m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " ");755-756- m_listCtrl->OnPaint(event);757-}758-759-void CrossThreadCall(wxCommandEvent& event)760-{761+ if (fDebug && GetTime() - nThreadSocketHandlerHeartbeat > 60)762+ m_statusBar->SetStatusText(" ERROR: ThreadSocketHandler has stopped", 0);763+764+ // Pass through to listctrl to actually do the paint, we're just hooking the message765+ m_listCtrl->Disconnect(wxEVT_PAINT, (wxObjectEventFunction)NULL, NULL, this);766+ m_listCtrl->GetEventHandler()->ProcessEvent(event);767+ m_listCtrl->Connect(wxEVT_PAINT, wxPaintEventHandler(CMainFrame::OnPaintListCtrl), NULL, this);768+}769+770+771+void UIThreadCall(boost::function0<void> fn)772+{773+ // Call this with a function object created with bind.774+ // bind needs all parameters to match the function's expected types775+ // and all default parameters specified. Some examples:776+ // UIThreadCall(bind(wxBell));777+ // UIThreadCall(bind(wxMessageBox, wxT("Message"), wxT("Title"), wxOK, (wxWindow*)NULL, -1, -1));778+ // UIThreadCall(bind(&CMainFrame::OnMenuHelpAbout, pframeMain, event));779 if (pframeMain)780+ {781+ wxCommandEvent event(wxEVT_UITHREADCALL);782+ event.SetClientData((void*)new boost::function0<void>(fn));783 pframeMain->GetEventHandler()->AddPendingEvent(event);784-}785-786-void CrossThreadCall(int nID, void* pdata)787-{788- wxCommandEvent event;789- event.SetInt(nID);790- event.SetClientData(pdata);791- if (pframeMain)792- pframeMain->GetEventHandler()->AddPendingEvent(event);793-}794-795-void CMainFrame::OnCrossThreadCall(wxCommandEvent& event)796-{797- void* pdata = event.GetClientData();798- switch (event.GetInt())799- {800- case UICALL_ADDORDER:801- {802- break;803- }804-805- case UICALL_UPDATEORDER:806- {807- break;808- }809- }810+ }811+}812+813+void CMainFrame::OnUIThreadCall(wxCommandEvent& event)814+{815+ boost::function0<void>* pfn = (boost::function0<void>*)event.GetClientData();816+ (*pfn)();817+ delete pfn;818 }819 820 void CMainFrame::OnMenuFileExit(wxCommandEvent& event)821 {822+ // File->Exit823 Close(true);824 }825 826+void CMainFrame::OnMenuViewShowGenerated(wxCommandEvent& event)827+{828+ // View->Show Generated829+ fShowGenerated = event.IsChecked();830+ CWalletDB().WriteSetting("fShowGenerated", fShowGenerated);831+ RefreshListCtrl();832+}833+834+void CMainFrame::OnUpdateUIViewShowGenerated(wxUpdateUIEvent& event)835+{836+ event.Check(fShowGenerated);837+}838+839 void CMainFrame::OnMenuOptionsGenerate(wxCommandEvent& event)840 {841- fGenerateBitcoins = event.IsChecked();842- nTransactionsUpdated++;843- CWalletDB().WriteSetting("fGenerateBitcoins", fGenerateBitcoins);844-845- if (fGenerateBitcoins)846- if (_beginthread(ThreadBitcoinMiner, 0, NULL) == -1)847- printf("Error: _beginthread(ThreadBitcoinMiner) failed\n");848-849- Refresh();850- wxPaintEvent eventPaint;851- AddPendingEvent(eventPaint);852+ // Options->Generate Coins853+ GenerateBitcoins(event.IsChecked());854+}855+856+void CMainFrame::OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event)857+{858+ event.Check(fGenerateBitcoins);859 }860 861 void CMainFrame::OnMenuOptionsChangeYourAddress(wxCommandEvent& event)862 {863+ // Options->Change Your Address864 OnButtonChange(event);865 }866 867 void CMainFrame::OnMenuOptionsOptions(wxCommandEvent& event)868 {869+ // Options->Options870 COptionsDialog dialog(this);871 dialog.ShowModal();872 }873 874 void CMainFrame::OnMenuHelpAbout(wxCommandEvent& event)875 {876+ // Help->About877 CAboutDialog dialog(this);878 dialog.ShowModal();879 }880 881 void CMainFrame::OnButtonSend(wxCommandEvent& event)882 {883- /// debug test884- if (fRandSendTest)885- {886- RandSend();887- return;888- }889-890 // Toolbar: Send891 CSendDialog dialog(this);892 dialog.ShowModal();893@@ -1004,7 +1290,19 @@894 895 896 897- strHTML += "<b>Status:</b> " + FormatTxStatus(wtx) + "<br>";898+ strHTML += "<b>Status:</b> " + FormatTxStatus(wtx);899+ int nRequests = wtx.GetRequestCount();900+ if (nRequests != -1)901+ {902+ if (nRequests == 0)903+ strHTML += ", has not been successfully broadcast yet";904+ else if (nRequests == 1)905+ strHTML += strprintf(", broadcast through %d node", nRequests);906+ else907+ strHTML += strprintf(", broadcast through %d nodes", nRequests);908+ }909+ strHTML += "<br>";910+911 strHTML += "<b>Date:</b> " + (nTime ? DateTimeStr(nTime) : "") + "<br>";912 913 914@@ -1133,9 +1431,10 @@915 if (fAllToMe)916 {917 // Payment to self918- int64 nValue = wtx.vout[0].nValue;919- strHTML += "<b>Debit:</b> " + FormatMoney(-nValue) + "<br>";920- strHTML += "<b>Credit:</b> " + FormatMoney(nValue) + "<br>";921+ /// issue: can't tell which is the payment and which is the change anymore922+ //int64 nValue = wtx.vout[0].nValue;923+ //strHTML += "<b>Debit:</b> " + FormatMoney(-nValue) + "<br>";924+ //strHTML += "<b>Credit:</b> " + FormatMoney(nValue) + "<br>";925 }926 927 int64 nTxFee = nDebit - wtx.GetValueOut();928@@ -1231,8 +1530,51 @@929 930 COptionsDialog::COptionsDialog(wxWindow* parent) : COptionsDialogBase(parent)931 {932+ // Set up list box of page choices933+ m_listBox->Append("Main");934+ //m_listBox->Append("Test 2");935+ m_listBox->SetSelection(0);936+ SelectPage(0);937+#ifndef __WXMSW__938+ m_checkBoxMinimizeOnClose->SetLabel("&Minimize on close");939+ m_checkBoxStartOnSystemStartup->Enable(false); // not implemented yet940+#endif941+942+ // Init values943 m_textCtrlTransactionFee->SetValue(FormatMoney(nTransactionFee));944+ m_checkBoxLimitProcessors->SetValue(fLimitProcessors);945+ m_spinCtrlLimitProcessors->Enable(fLimitProcessors);946+ m_spinCtrlLimitProcessors->SetValue(nLimitProcessors);947+ int nProcessors = wxThread::GetCPUCount();948+ if (nProcessors < 1)949+ nProcessors = 999;950+ m_spinCtrlLimitProcessors->SetRange(1, nProcessors);951+ m_checkBoxStartOnSystemStartup->SetValue(fTmpStartOnSystemStartup = GetStartOnSystemStartup());952+ m_checkBoxMinimizeToTray->SetValue(fMinimizeToTray);953+ m_checkBoxMinimizeOnClose->SetValue(fMinimizeOnClose);954+ m_checkBoxUseProxy->SetValue(fUseProxy);955+ m_textCtrlProxyIP->Enable(fUseProxy);956+ m_textCtrlProxyPort->Enable(fUseProxy);957+ m_staticTextProxyIP->Enable(fUseProxy);958+ m_staticTextProxyPort->Enable(fUseProxy);959+ m_textCtrlProxyIP->SetValue(addrProxy.ToStringIP());960+ m_textCtrlProxyPort->SetValue(addrProxy.ToStringPort());961+962 m_buttonOK->SetFocus();963+}964+965+void COptionsDialog::SelectPage(int nPage)966+{967+ m_panelMain->Show(nPage == 0);968+ m_panelTest2->Show(nPage == 1);969+970+ m_scrolledWindow->Layout();971+ m_scrolledWindow->SetScrollbars(0, 0, 0, 0, 0, 0);972+}973+974+void COptionsDialog::OnListBox(wxCommandEvent& event)975+{976+ SelectPage(event.GetSelection());977 }978 979 void COptionsDialog::OnKillFocusTransactionFee(wxFocusEvent& event)980@@ -1242,19 +1584,96 @@981 m_textCtrlTransactionFee->SetValue(FormatMoney(nTmp));982 }983 984+void COptionsDialog::OnCheckBoxLimitProcessors(wxCommandEvent& event)985+{986+ m_spinCtrlLimitProcessors->Enable(event.IsChecked());987+}988+989+void COptionsDialog::OnCheckBoxUseProxy(wxCommandEvent& event)990+{991+ m_textCtrlProxyIP->Enable(event.IsChecked());992+ m_textCtrlProxyPort->Enable(event.IsChecked());993+ m_staticTextProxyIP->Enable(event.IsChecked());994+ m_staticTextProxyPort->Enable(event.IsChecked());995+}996+997+CAddress COptionsDialog::GetProxyAddr()998+{999+ // Be careful about byte order, addr.ip and addr.port are big endian1000+ CAddress addr(m_textCtrlProxyIP->GetValue() + ":" + m_textCtrlProxyPort->GetValue());1001+ if (addr.ip == INADDR_NONE)1002+ addr.ip = addrProxy.ip;1003+ int nPort = atoi(m_textCtrlProxyPort->GetValue());1004+ addr.port = htons(nPort);1005+ if (nPort <= 0 || nPort > USHRT_MAX)1006+ addr.port = addrProxy.port;1007+ return addr;1008+}1009+1010+void COptionsDialog::OnKillFocusProxy(wxFocusEvent& event)1011+{1012+ m_textCtrlProxyIP->SetValue(GetProxyAddr().ToStringIP());1013+ m_textCtrlProxyPort->SetValue(GetProxyAddr().ToStringPort());1014+}1015+1016+1017 void COptionsDialog::OnButtonOK(wxCommandEvent& event)1018 {1019- // nTransactionFee1020+ OnButtonApply(event);1021+ Close();1022+}1023+1024+void COptionsDialog::OnButtonCancel(wxCommandEvent& event)1025+{1026+ Close();1027+}1028+1029+void COptionsDialog::OnButtonApply(wxCommandEvent& event)1030+{1031+ CWalletDB walletdb;1032+1033 int64 nPrevTransactionFee = nTransactionFee;1034 if (ParseMoney(m_textCtrlTransactionFee->GetValue(), nTransactionFee) && nTransactionFee != nPrevTransactionFee)1035- CWalletDB().WriteSetting("nTransactionFee", nTransactionFee);1036-1037- Close();1038-}1039-1040-void COptionsDialog::OnButtonCancel(wxCommandEvent& event)1041-{1042- Close();1043+ walletdb.WriteSetting("nTransactionFee", nTransactionFee);1044+1045+ int nPrevMaxProc = (fLimitProcessors ? nLimitProcessors : INT_MAX);1046+ if (fLimitProcessors != m_checkBoxLimitProcessors->GetValue())1047+ {1048+ fLimitProcessors = m_checkBoxLimitProcessors->GetValue();1049+ walletdb.WriteSetting("fLimitProcessors", fLimitProcessors);1050+ }1051+ if (nLimitProcessors != m_spinCtrlLimitProcessors->GetValue())1052+ {1053+ nLimitProcessors = m_spinCtrlLimitProcessors->GetValue();1054+ walletdb.WriteSetting("nLimitProcessors", nLimitProcessors);1055+ }1056+ if (fGenerateBitcoins && (fLimitProcessors ? nLimitProcessors : INT_MAX) > nPrevMaxProc)1057+ GenerateBitcoins(fGenerateBitcoins);1058+1059+ if (fTmpStartOnSystemStartup != m_checkBoxStartOnSystemStartup->GetValue())1060+ {1061+ fTmpStartOnSystemStartup = m_checkBoxStartOnSystemStartup->GetValue();1062+ SetStartOnSystemStartup(fTmpStartOnSystemStartup);1063+ }1064+1065+ if (fMinimizeToTray != m_checkBoxMinimizeToTray->GetValue())1066+ {1067+ fMinimizeToTray = m_checkBoxMinimizeToTray->GetValue();1068+ walletdb.WriteSetting("fMinimizeToTray", fMinimizeToTray);1069+ ptaskbaricon->Show(fMinimizeToTray || fClosedToTray);1070+ }1071+1072+ if (fMinimizeOnClose != m_checkBoxMinimizeOnClose->GetValue())1073+ {1074+ fMinimizeOnClose = m_checkBoxMinimizeOnClose->GetValue();1075+ walletdb.WriteSetting("fMinimizeOnClose", fMinimizeOnClose);1076+ }1077+1078+ fUseProxy = m_checkBoxUseProxy->GetValue();1079+ walletdb.WriteSetting("fUseProxy", fUseProxy);1080+1081+ addrProxy = GetProxyAddr();1082+ walletdb.WriteSetting("addrProxy", addrProxy);1083 }1084 1085 1086@@ -1269,13 +1688,16 @@1087 1088 CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent)1089 {1090- m_staticTextVersion->SetLabel(strprintf("version 0.%d.%d Alpha", VERSION/100, VERSION%100));1091+ m_staticTextVersion->SetLabel(strprintf("version 0.%d.%d beta", VERSION/100, VERSION%100));1092 1093 // Workaround until upgrade to wxWidgets supporting UTF-81094 wxString str = m_staticTextMain->GetLabel();1095 if (str.Find('Â') != wxNOT_FOUND)1096 str.Remove(str.Find('Â'), 1);1097 m_staticTextMain->SetLabel(str);1098+#ifndef __WXMSW__1099+ SetSize(510, 380);1100+#endif1101 }1102 1103 void CAboutDialog::OnButtonOK(wxCommandEvent& event)1104@@ -1299,13 +1721,20 @@1105 m_textCtrlAddress->SetValue(strAddress);1106 m_choiceTransferType->SetSelection(0);1107 m_bitmapCheckMark->Show(false);1108+ fEnabledPrev = true;1109+ m_textCtrlAddress->SetFocus();1110 //// todo: should add a display of your balance for convenience1111+#ifndef __WXMSW__1112+ wxFont fontTmp = m_staticTextInstructions->GetFont();1113+ if (fontTmp.GetPointSize() > 9);1114+ fontTmp.SetPointSize(9);1115+ m_staticTextInstructions->SetFont(fontTmp);1116+ SetSize(725, wxDefaultCoord);1117+#endif1118 1119 // Set Icon1120- wxBitmap bmpSend(wxT("send16"), wxBITMAP_TYPE_RESOURCE);1121- bmpSend.SetMask(new wxMask(wxBitmap(wxT("send16masknoshadow"), wxBITMAP_TYPE_RESOURCE)));1122 wxIcon iconSend;1123- iconSend.CopyFromBitmap(bmpSend);1124+ iconSend.CopyFromBitmap(wxBitmap(send16noshadow_xpm));1125 SetIcon(iconSend);1126 1127 wxCommandEvent event;1128@@ -1330,6 +1759,19 @@1129 m_staticTextMessage->Enable(fEnable);1130 m_textCtrlMessage->Enable(fEnable);1131 m_textCtrlMessage->SetBackgroundColour(wxSystemSettings::GetColour(fEnable ? wxSYS_COLOUR_WINDOW : wxSYS_COLOUR_BTNFACE));1132+ if (!fEnable && fEnabledPrev)1133+ {1134+ strFromSave = m_textCtrlFrom->GetValue();1135+ strMessageSave = m_textCtrlMessage->GetValue();1136+ m_textCtrlFrom->SetValue("Will appear as \"From: Unknown\"");1137+ m_textCtrlMessage->SetValue("Can't include a message when sending to a Bitcoin address");1138+ }1139+ else if (fEnable && !fEnabledPrev)1140+ {1141+ m_textCtrlFrom->SetValue(strFromSave);1142+ m_textCtrlMessage->SetValue(strMessageSave);1143+ }1144+ fEnabledPrev = fEnable;1145 }1146 1147 void CSendDialog::OnKillFocusAmount(wxFocusEvent& event)1148@@ -1406,8 +1848,8 @@1149 else1150 {1151 // Parse IP address1152- CAddress addr(strAddress.c_str());1153- if (addr.ip == 0)1154+ CAddress addr(strAddress);1155+ if (!addr.IsValid())1156 {1157 wxMessageBox("Invalid address ", "Send Coins");1158 return;1159@@ -1452,17 +1894,20 @@1160 nPrice = nPriceIn;1161 wtx = wtxIn;1162 start = wxDateTime::UNow();1163- strStatus = "";1164+ memset(pszStatus, 0, sizeof(pszStatus));1165 fCanCancel = true;1166 fAbort = false;1167 fSuccess = false;1168 fUIDone = false;1169 fWorkDone = false;1170-1171- SetTitle(strprintf("Sending %s to %s...", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str()));1172+#ifndef __WXMSW__1173+ SetSize(1.2 * GetSize().GetWidth(), 1.05 * GetSize().GetHeight());1174+#endif1175+1176+ SetTitle(strprintf("Sending %s to %s", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str()));1177 m_textCtrlStatus->SetValue("");1178 1179- _beginthread(SendingDialogStartTransfer, 0, this);1180+ CreateThread(SendingDialogStartTransfer, this);1181 }1182 1183 CSendingDialog::~CSendingDialog()1184@@ -1516,10 +1961,10 @@1185 1186 void CSendingDialog::OnPaint(wxPaintEvent& event)1187 {1188- if (strStatus.size() > 130)1189- m_textCtrlStatus->SetValue(string("\n") + strStatus);1190+ if (strlen(pszStatus) > 130)1191+ m_textCtrlStatus->SetValue(string("\n") + pszStatus);1192 else1193- m_textCtrlStatus->SetValue(string("\n\n") + strStatus);1194+ m_textCtrlStatus->SetValue(string("\n\n") + pszStatus);1195 m_staticTextSending->SetFocus();1196 if (!fCanCancel)1197 m_buttonCancel->Enable(false);1198@@ -1531,7 +1976,7 @@1199 }1200 if (fAbort && fCanCancel && IsShown())1201 {1202- strStatus = "CANCELLED";1203+ strcpy(pszStatus, "CANCELLED");1204 m_buttonOK->Enable(true);1205 m_buttonOK->SetFocus();1206 m_buttonCancel->Enable(false);1207@@ -1540,14 +1985,6 @@1208 wxMessageBox("Transfer cancelled ", "Sending...", wxOK, this);1209 }1210 event.Skip();1211-1212- /// debug test1213- if (fRandSendTest && fWorkDone && fSuccess)1214- {1215- Close();1216- Sleep(1000);1217- RandSend();1218- }1219 }1220 1221 1222@@ -1572,7 +2009,8 @@1223 }1224 if (fAbort && fCanCancel)1225 {1226- strStatus = "CANCELLED";1227+ memset(pszStatus, 0, 10);1228+ strcpy(pszStatus, "CANCELLED");1229 Repaint();1230 fWorkDone = true;1231 return false;1232@@ -1584,7 +2022,12 @@1233 {1234 if (!Status())1235 return false;1236- strStatus = str;1237+1238+ // This can be read by the UI thread at any time,1239+ // so copy in a way that can be read cleanly at all times.1240+ memset(pszStatus, 0, min(str.size()+1, sizeof(pszStatus)));1241+ strlcpy(pszStatus, str.c_str(), sizeof(pszStatus));1242+1243 Repaint();1244 return true;1245 }1246@@ -1614,7 +2057,7 @@1247 // We may have connected already for product details1248 if (!Status("Connecting..."))1249 return;1250- CNode* pnode = ConnectNode(addr, 5 * 60);1251+ CNode* pnode = ConnectNode(addr, 15 * 60);1252 if (!pnode)1253 {1254 Error("Unable to connect");1255@@ -1659,14 +2102,6 @@1256 return;1257 }1258 1259- // Should already be connected1260- CNode* pnode = ConnectNode(addr, 5 * 60);1261- if (!pnode)1262- {1263- Error("Lost connection");1264- return;1265- }1266-1267 // Pause to give the user a chance to cancel1268 while (wxDateTime::UNow() < start + wxTimeSpan(0, 0, 0, 2 * 1000))1269 {1270@@ -1685,13 +2120,22 @@1271 Error("You don't have enough money");1272 return;1273 }1274+ CKey key;1275 int64 nFeeRequired;1276- if (!CreateTransaction(scriptPubKey, nPrice, wtx, nFeeRequired))1277+ if (!CreateTransaction(scriptPubKey, nPrice, wtx, key, nFeeRequired))1278 {1279 if (nPrice + nFeeRequired > GetBalance())1280 Error(strprintf("This is an oversized transaction that requires a transaction fee of %s", FormatMoney(nFeeRequired).c_str()));1281 else1282 Error("Transaction creation failed");1283+ return;1284+ }1285+1286+ // Make sure we're still connected1287+ CNode* pnode = ConnectNode(addr, 2 * 60 * 60);1288+ if (!pnode)1289+ {1290+ Error("Lost connection, transaction cancelled");1291 return;1292 }1293 1294@@ -1711,7 +2155,7 @@1295 return;1296 1297 // Commit1298- if (!CommitTransactionSpent(wtx))1299+ if (!CommitTransactionSpent(wtx, key))1300 {1301 Error("Error finalizing payment");1302 return;1303@@ -1744,8 +2188,8 @@1304 if (nRet > 0)1305 {1306 Error("The payment was sent, but the recipient was unable to verify it.\n"1307- "The transaction is recorded and will credit to the recipient if it is valid,\n"1308- "but without comment information.");1309+ "The transaction is recorded and will credit to the recipient,\n"1310+ "but the comment information will be blank.");1311 return;1312 }1313 }1314@@ -1913,10 +2357,8 @@1315 m_listCtrl->SetFocus();1316 1317 // Set Icon1318- wxBitmap bmpAddressBook(wxT("addressbook16"), wxBITMAP_TYPE_RESOURCE);1319- bmpAddressBook.SetMask(new wxMask(wxBitmap(wxT("addressbook16mask"), wxBITMAP_TYPE_RESOURCE)));1320 wxIcon iconAddressBook;1321- iconAddressBook.CopyFromBitmap(bmpAddressBook);1322+ iconAddressBook.CopyFromBitmap(wxBitmap(addressbook16_xpm));1323 SetIcon(iconAddressBook);1324 1325 // Fill listctrl with address book data1326@@ -2472,7 +2914,7 @@1327 this->Layout();1328 1329 // Request details from seller1330- _beginthread(ThreadRequestProductDetails, 0, new pair<CProduct, wxEvtHandler*>(product, GetEventHandler()));1331+ CreateThread(ThreadRequestProductDetails, new pair<CProduct, wxEvtHandler*>(product, GetEventHandler()));1332 }1333 1334 CViewProductDialog::~CViewProductDialog()1335@@ -2864,6 +3306,126 @@1336 1337 1338 1339+//////////////////////////////////////////////////////////////////////////////1340+//1341+// CMyTaskBarIcon1342+//1343+1344+enum1345+{1346+ ID_TASKBAR_RESTORE = 10001,1347+ ID_TASKBAR_OPTIONS,1348+ ID_TASKBAR_GENERATE,1349+ ID_TASKBAR_EXIT,1350+};1351+1352+BEGIN_EVENT_TABLE(CMyTaskBarIcon, wxTaskBarIcon)1353+ EVT_TASKBAR_LEFT_DCLICK(CMyTaskBarIcon::OnLeftButtonDClick)1354+ EVT_MENU(ID_TASKBAR_RESTORE, CMyTaskBarIcon::OnMenuRestore)1355+ EVT_MENU(ID_TASKBAR_OPTIONS, CMyTaskBarIcon::OnMenuOptions)1356+ EVT_MENU(ID_TASKBAR_GENERATE, CMyTaskBarIcon::OnMenuGenerate)1357+ EVT_UPDATE_UI(ID_TASKBAR_GENERATE, CMyTaskBarIcon::OnUpdateUIGenerate)1358+ EVT_MENU(ID_TASKBAR_EXIT, CMyTaskBarIcon::OnMenuExit)1359+END_EVENT_TABLE()1360+1361+void CMyTaskBarIcon::Show(bool fShow)1362+{1363+ static char pszPrevTip[200];1364+ if (fShow)1365+ {1366+ string strTooltip = "Bitcoin";1367+ if (fGenerateBitcoins)1368+ strTooltip = "Bitcoin - Generating";1369+ if (fGenerateBitcoins && vNodes.empty())1370+ strTooltip = "Bitcoin - (not connected)";1371+1372+ // Optimization, only update when changed, using char array to be reentrant1373+ if (strncmp(pszPrevTip, strTooltip.c_str(), sizeof(pszPrevTip)-1) != 0)1374+ {1375+ strlcpy(pszPrevTip, strTooltip.c_str(), sizeof(pszPrevTip));1376+#ifdef __WXMSW__1377+ SetIcon(wxICON(bitcoin), strTooltip);1378+#else1379+ SetIcon(bitcoin20_xpm, strTooltip);1380+#endif1381+ }1382+ }1383+ else1384+ {1385+ strlcpy(pszPrevTip, "", sizeof(pszPrevTip));1386+ RemoveIcon();1387+ }1388+}1389+1390+void CMyTaskBarIcon::Hide()1391+{1392+ Show(false);1393+}1394+1395+void CMyTaskBarIcon::OnLeftButtonDClick(wxTaskBarIconEvent& event)1396+{1397+ Restore();1398+}1399+1400+void CMyTaskBarIcon::OnMenuRestore(wxCommandEvent& event)1401+{1402+ Restore();1403+}1404+1405+void CMyTaskBarIcon::OnMenuOptions(wxCommandEvent& event)1406+{1407+ // Since it's modal, get the main window to do it1408+ wxCommandEvent event2(wxEVT_COMMAND_MENU_SELECTED, wxID_MENUOPTIONSOPTIONS);1409+ pframeMain->AddPendingEvent(event2);1410+}1411+1412+void CMyTaskBarIcon::Restore()1413+{1414+ pframeMain->Show();1415+ wxIconizeEvent event(0, false);1416+ pframeMain->AddPendingEvent(event);1417+ pframeMain->Iconize(false);1418+ pframeMain->Raise();1419+}1420+1421+void CMyTaskBarIcon::OnMenuGenerate(wxCommandEvent& event)1422+{1423+ GenerateBitcoins(event.IsChecked());1424+}1425+1426+void CMyTaskBarIcon::OnUpdateUIGenerate(wxUpdateUIEvent& event)1427+{1428+ event.Check(fGenerateBitcoins);1429+}1430+1431+void CMyTaskBarIcon::OnMenuExit(wxCommandEvent& event)1432+{1433+ pframeMain->Close(true);1434+}1435+1436+void CMyTaskBarIcon::UpdateTooltip()1437+{1438+ if (IsIconInstalled())1439+ Show(true);1440+}1441+1442+wxMenu* CMyTaskBarIcon::CreatePopupMenu()1443+{1444+ wxMenu* pmenu = new wxMenu;1445+ pmenu->Append(ID_TASKBAR_RESTORE, "&Open Bitcoin");1446+ pmenu->Append(ID_TASKBAR_OPTIONS, "O&ptions...");1447+ pmenu->AppendCheckItem(ID_TASKBAR_GENERATE, "&Generate Coins")->Check(fGenerateBitcoins);1448+#ifndef __WXMAC_OSX__ // Mac has built-in quit menu1449+ pmenu->AppendSeparator();1450+ pmenu->Append(ID_TASKBAR_EXIT, "E&xit");1451+#endif1452+ return pmenu;1453+}1454+1455+1456+1457+1458+1459 1460 1461 1462@@ -2901,37 +3463,19 @@1463 1464 bool CMyApp::OnInit()1465 {1466+ bool fRet = false;1467 try1468 {1469- return OnInit2();1470+ fRet = OnInit2();1471 }1472 catch (std::exception& e) {1473 PrintException(&e, "OnInit()");1474 } catch (...) {1475 PrintException(NULL, "OnInit()");1476 }1477- return false;1478-}1479-1480-map<string, string> ParseParameters(int argc, char* argv[])1481-{1482- map<string, string> mapArgs;1483- for (int i = 0; i < argc; i++)1484- {1485- char psz[10000];1486- strcpy(psz, argv[i]);1487- char* pszValue = "";1488- if (strchr(psz, '='))1489- {1490- pszValue = strchr(psz, '=');1491- *pszValue++ = '\0';1492- }1493- strlwr(psz);1494- if (psz[0] == '-')1495- psz[0] = '/';1496- mapArgs[psz] = pszValue;1497- }1498- return mapArgs;1499+ if (!fRet)1500+ Shutdown(NULL);1501+ return fRet;1502 }1503 1504 bool CMyApp::OnInit2()1505@@ -2941,20 +3485,84 @@1506 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);1507 _CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));1508 #endif1509-#ifdef __WXDEBUG__1510+#if defined(__WXMSW__) && defined(__WXDEBUG__)1511 // Disable malfunctioning wxWidgets debug assertion1512 g_isPainting = 10000;1513 #endif1514-1515- //// debug print1516+ wxImage::AddHandler(new wxPNGHandler);1517+#ifdef __WXMSW__1518+ SetAppName("Bitcoin");1519+#else1520+ SetAppName("bitcoin");1521+ umask(077);1522+#endif1523+1524+ //1525+ // Parameters1526+ //1527+ ParseParameters(argc, argv);1528+ if (mapArgs.count("-?") || mapArgs.count("--help"))1529+ {1530+#ifdef __WXMSW__1531+ string strUsage =1532+ "Usage: bitcoin [options]\t\t\t\t\t\t\n"1533+ "Options:\n"1534+ " -gen\t\t Generate coins\n"1535+ " -gen=0\t\t Don't generate coins\n"1536+ " -min\t\t Start minimized\n"1537+ " -datadir=<dir>\t Specify data directory\n"1538+ " -proxy=<ip:port>\t Connect through socks4 proxy\n"1539+ " -addnode=<ip>\t Add a node to connect to\n"1540+ " -connect=<ip>\t Connect only to the specified node\n"1541+ " -?\t\t This help message\n";1542+ wxMessageBox(strUsage, "Bitcoin", wxOK);1543+#else1544+ string strUsage =1545+ "Usage: bitcoin [options]\n"1546+ "Options:\n"1547+ " -gen Generate coins\n"1548+ " -gen=0 Don't generate coins\n"1549+ " -min Start minimized\n"1550+ " -datadir=<dir> Specify data directory\n"1551+ " -proxy=<ip:port> Connect through socks4 proxy\n"1552+ " -addnode=<ip> Add a node to connect to\n"1553+ " -connect=<ip> Connect only to the specified node\n"1554+ " -? This help message\n";1555+ fprintf(stderr, "%s", strUsage.c_str());1556+#endif1557+ return false;1558+ }1559+1560+ if (mapArgs.count("-datadir"))1561+ strlcpy(pszSetDataDir, mapArgs["-datadir"].c_str(), sizeof(pszSetDataDir));1562+1563+ if (mapArgs.count("-debug"))1564+ fDebug = true;1565+1566+ if (mapArgs.count("-printtodebugger"))1567+ fPrintToDebugger = true;1568+1569+ if (!fDebug && !pszSetDataDir[0])1570+ ShrinkDebugFile();1571 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");1572- printf("Bitcoin version %d, Windows version %08x\n", VERSION, GetVersion());1573+ printf("Bitcoin version %d%s, OS version %s\n", VERSION, pszSubVer, wxGetOsDescription().mb_str());1574+1575+ if (mapArgs.count("-loadblockindextest"))1576+ {1577+ CTxDB txdb("r");1578+ txdb.LoadBlockIndex();1579+ PrintBlockTree();1580+ return false;1581+ }1582 1583 //1584 // Limit to single instance per user1585 // Required to protect the database files if we're going to keep deleting log.*1586 //1587- wxString strMutexName = wxString("Bitcoin.") + getenv("HOMEPATH");1588+#ifdef __WXMSW__1589+ // todo: wxSingleInstanceChecker wasn't working on Linux, never deleted its lock file1590+ // maybe should go by whether successfully bind port 8333 instead1591+ wxString strMutexName = wxString("bitcoin_running.") + getenv("HOMEPATH");1592 for (int i = 0; i < strMutexName.size(); i++)1593 if (!isalnum(strMutexName[i]))1594 strMutexName[i] = '.';1595@@ -2965,6 +3573,7 @@1596 unsigned int nStart = GetTime();1597 loop1598 {1599+ // TODO: find out how to do this in Linux, or replace with wxWidgets commands1600 // Show the previous instance and exit1601 HWND hwndPrev = FindWindow("wxWindowClassNR", "Bitcoin");1602 if (hwndPrev)1603@@ -2986,63 +3595,41 @@1604 break;1605 }1606 }1607-1608- //1609- // Parameters1610- //1611- wxImage::AddHandler(new wxPNGHandler);1612- map<string, string> mapArgs = ParseParameters(argc, argv);1613-1614- if (mapArgs.count("/datadir"))1615- strSetDataDir = mapArgs["/datadir"];1616-1617- if (mapArgs.count("/proxy"))1618- addrProxy = CAddress(mapArgs["/proxy"].c_str());1619-1620- if (mapArgs.count("/debug"))1621- fDebug = true;1622-1623- if (mapArgs.count("/dropmessages"))1624- {1625- nDropMessagesTest = atoi(mapArgs["/dropmessages"]);1626- if (nDropMessagesTest == 0)1627- nDropMessagesTest = 20;1628- }1629-1630- if (mapArgs.count("/loadblockindextest"))1631- {1632- CTxDB txdb("r");1633- txdb.LoadBlockIndex();1634- PrintBlockTree();1635- ExitProcess(0);1636+#endif1637+1638+ // Bind to the port early so we can tell if another instance is already running.1639+ // This is a backup to wxSingleInstanceChecker, which doesn't work on Linux.1640+ string strErrors;1641+ if (!BindListenPort(strErrors))1642+ {1643+ wxMessageBox(strErrors, "Bitcoin");1644+ return false;1645 }1646 1647 //1648 // Load data files1649 //1650- string strErrors;1651- int64 nStart, nEnd;1652+ bool fFirstRun;1653+ strErrors = "";1654+ int64 nStart;1655 1656 printf("Loading addresses...\n");1657- QueryPerformanceCounter((LARGE_INTEGER*)&nStart);1658+ nStart = GetTimeMillis();1659 if (!LoadAddresses())1660 strErrors += "Error loading addr.dat \n";1661- QueryPerformanceCounter((LARGE_INTEGER*)&nEnd);1662- printf(" addresses %20I64d\n", nEnd - nStart);1663+ printf(" addresses %15"PRI64d"ms\n", GetTimeMillis() - nStart);1664 1665 printf("Loading block index...\n");1666- QueryPerformanceCounter((LARGE_INTEGER*)&nStart);1667+ nStart = GetTimeMillis();1668 if (!LoadBlockIndex())1669 strErrors += "Error loading blkindex.dat \n";1670- QueryPerformanceCounter((LARGE_INTEGER*)&nEnd);1671- printf(" block index %20I64d\n", nEnd - nStart);1672+ printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);1673 1674 printf("Loading wallet...\n");1675- QueryPerformanceCounter((LARGE_INTEGER*)&nStart);1676- if (!LoadWallet())1677+ nStart = GetTimeMillis();1678+ if (!LoadWallet(fFirstRun))1679 strErrors += "Error loading wallet.dat \n";1680- QueryPerformanceCounter((LARGE_INTEGER*)&nEnd);1681- printf(" wallet %20I64d\n", nEnd - nStart);1682+ printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);1683 1684 printf("Done loading\n");1685 1686@@ -3057,7 +3644,6 @@1687 if (!strErrors.empty())1688 {1689 wxMessageBox(strErrors, "Bitcoin");1690- OnExit();1691 return false;1692 }1693 1694@@ -3067,225 +3653,289 @@1695 //1696 // Parameters1697 //1698- if (mapArgs.count("/printblockindex") || mapArgs.count("/printblocktree"))1699+ if (mapArgs.count("-printblockindex") || mapArgs.count("-printblocktree"))1700 {1701 PrintBlockTree();1702- OnExit();1703 return false;1704 }1705 1706- if (mapArgs.count("/gen"))1707- {1708- if (mapArgs["/gen"].empty())1709+ if (mapArgs.count("-printblock"))1710+ {1711+ string strMatch = mapArgs["-printblock"];1712+ int nFound = 0;1713+ for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)1714+ {1715+ uint256 hash = (*mi).first;1716+ if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0)1717+ {1718+ CBlockIndex* pindex = (*mi).second;1719+ CBlock block;1720+ block.ReadFromDisk(pindex);1721+ block.BuildMerkleTree();1722+ block.print();1723+ printf("\n");1724+ nFound++;1725+ }1726+ }1727+ if (nFound == 0)1728+ printf("No blocks matching %s were found\n", strMatch.c_str());1729+ return false;1730+ }1731+1732+ if (mapArgs.count("-gen"))1733+ {1734+ if (mapArgs["-gen"].empty())1735 fGenerateBitcoins = true;1736 else1737- fGenerateBitcoins = atoi(mapArgs["/gen"].c_str());1738+ fGenerateBitcoins = (atoi(mapArgs["-gen"].c_str()) != 0);1739+ }1740+1741+ if (mapArgs.count("-proxy"))1742+ {1743+ fUseProxy = true;1744+ addrProxy = CAddress(mapArgs["-proxy"]);1745+ if (!addrProxy.IsValid())1746+ {1747+ wxMessageBox("Invalid -proxy address", "Bitcoin");1748+ return false;1749+ }1750+ }1751+1752+ if (mapArgs.count("-addnode"))1753+ {1754+ CAddrDB addrdb;1755+ foreach(string strAddr, mapMultiArgs["-addnode"])1756+ {1757+ CAddress addr(strAddr, NODE_NETWORK);1758+ addr.nTime = 0; // so it won't relay unless successfully connected1759+ if (addr.IsValid())1760+ AddAddress(addrdb, addr);1761+ }1762 }1763 1764 //1765 // Create the main frame window1766 //1767- {1768- pframeMain = new CMainFrame(NULL);1769- pframeMain->Show();1770-1771- if (!CheckDiskSpace())1772- {1773- OnExit();1774- return false;1775- }1776-1777- if (!StartNode(strErrors))1778- wxMessageBox(strErrors, "Bitcoin");1779-1780- if (fGenerateBitcoins)1781- if (_beginthread(ThreadBitcoinMiner, 0, NULL) == -1)1782- printf("Error: _beginthread(ThreadBitcoinMiner) failed\n");1783-1784- //1785- // Tests1786- //1787- if (argc >= 2 && stricmp(argv[1], "/send") == 0)1788- {1789- int64 nValue = 1;1790- if (argc >= 3)1791- ParseMoney(argv[2], nValue);1792-1793- string strAddress;1794- if (argc >= 4)1795- strAddress = argv[3];1796- CAddress addr(strAddress.c_str());1797-1798- CWalletTx wtx;1799- wtx.mapValue["to"] = strAddress;1800- wtx.mapValue["from"] = addrLocalHost.ToString();1801- wtx.mapValue["message"] = "command line send";1802-1803- // Send to IP address1804- CSendingDialog* pdialog = new CSendingDialog(pframeMain, addr, nValue, wtx);1805- if (!pdialog->ShowModal())1806- return false;1807- }1808-1809- if (mapArgs.count("/randsendtest"))1810- {1811- if (!mapArgs["/randsendtest"].empty())1812- _beginthread(ThreadRandSendTest, 0, new string(mapArgs["/randsendtest"]));1813- else1814- fRandSendTest = true;1815- fDebug = true;1816- }1817- }1818-1819- return true;1820-}1821-1822-int CMyApp::OnExit()1823-{1824- Shutdown(NULL);1825- return wxApp::OnExit();1826-}1827-1828-bool CMyApp::OnExceptionInMainLoop()1829-{1830- try1831- {1832- throw;1833- }1834- catch (std::exception& e)1835- {1836- PrintException(&e, "CMyApp::OnExceptionInMainLoop()");1837- wxLogWarning(_T("Exception %s %s"), typeid(e).name(), e.what());1838- Sleep(1000);1839- throw;1840- }1841- catch (...)1842- {1843- PrintException(NULL, "CMyApp::OnExceptionInMainLoop()");1844- wxLogWarning(_T("Unknown exception"));1845- Sleep(1000);1846- throw;1847- }1848-1849- return true;1850-}1851-1852-void CMyApp::OnUnhandledException()1853-{1854- // this shows how we may let some exception propagate uncaught1855- try1856- {1857- throw;1858- }1859- catch (std::exception& e)1860- {1861- PrintException(&e, "CMyApp::OnUnhandledException()");1862- wxLogWarning(_T("Exception %s %s"), typeid(e).name(), e.what());1863- Sleep(1000);1864- throw;1865- }1866- catch (...)1867- {1868- PrintException(NULL, "CMyApp::OnUnhandledException()");1869- wxLogWarning(_T("Unknown exception"));1870- Sleep(1000);1871- throw;1872- }1873-}1874-1875-void CMyApp::OnFatalException()1876-{1877- wxMessageBox("Program has crashed and will terminate. ", "Bitcoin", wxOK | wxICON_ERROR);1878-}1879-1880-1881-1882-void MainFrameRepaint()1883-{1884- if (pframeMain)1885- {1886- printf("MainFrameRepaint()\n");1887- wxPaintEvent event;1888- pframeMain->Refresh();1889- pframeMain->AddPendingEvent(event);1890- }1891-}1892-1893-1894-1895-1896-1897-1898-1899-// randsendtest to bitcoin address1900-void ThreadRandSendTest(void* parg)1901-{1902- string strAddress = *(string*)parg;1903- uint160 hash160;1904- if (!AddressToHash160(strAddress, hash160))1905- {1906- wxMessageBox(strprintf("ThreadRandSendTest: Bitcoin address '%s' not valid ", strAddress.c_str()));1907- return;1908- }1909-1910- loop1911- {1912- Sleep(GetRand(30) * 1000 + 100);1913-1914- // Message1915+ pframeMain = new CMainFrame(NULL);1916+ if (mapArgs.count("-min"))1917+ pframeMain->Iconize(true);1918+ pframeMain->Show(true); // have to show first to get taskbar button to hide1919+ if (fMinimizeToTray && pframeMain->IsIconized())1920+ fClosedToTray = true;1921+ pframeMain->Show(!fClosedToTray);1922+ ptaskbaricon->Show(fMinimizeToTray || fClosedToTray);1923+1924+ CreateThread(ThreadDelayedRepaint, NULL);1925+1926+ if (!CheckDiskSpace())1927+ return false;1928+1929+ RandAddSeedPerfmon();1930+1931+ if (!CreateThread(StartNode, NULL))1932+ wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin");1933+1934+ if (fFirstRun)1935+ SetStartOnSystemStartup(true);1936+1937+1938+ //1939+ // Tests1940+ //1941+#ifdef __WXMSW__1942+ if (argc >= 2 && stricmp(argv[1], "-send") == 0)1943+#else1944+ if (argc >= 2 && strcmp(argv[1], "-send") == 0)1945+#endif1946+ {1947+ int64 nValue = 1;1948+ if (argc >= 3)1949+ ParseMoney(argv[2], nValue);1950+1951+ string strAddress;1952+ if (argc >= 4)1953+ strAddress = argv[3];1954+ CAddress addr(strAddress);1955+1956 CWalletTx wtx;1957 wtx.mapValue["to"] = strAddress;1958 wtx.mapValue["from"] = addrLocalHost.ToString();1959- static int nRep;1960- wtx.mapValue["message"] = strprintf("randsendtest %d\n", ++nRep);1961-1962- // Value1963- int64 nValue = (GetRand(9) + 1) * 100 * CENT;1964- if (GetBalance() < nValue)1965- {1966- wxMessageBox("Out of money ");1967- return;1968- }1969- nValue += (nRep % 100) * CENT;1970-1971- // Send to bitcoin address1972- CScript scriptPubKey;1973- scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;1974-1975- if (!SendMoney(scriptPubKey, nValue, wtx))1976- return;1977- }1978-}1979-1980-1981-// randsendtest to any connected node1982-void RandSend()1983-{1984- CWalletTx wtx;1985-1986- while (vNodes.empty())1987+ wtx.mapValue["message"] = "command line send";1988+1989+ // Send to IP address1990+ CSendingDialog* pdialog = new CSendingDialog(pframeMain, addr, nValue, wtx);1991+ if (!pdialog->ShowModal())1992+ return false;1993+ }1994+1995+ return true;1996+}1997+1998+int CMyApp::OnExit()1999+{2000+ Shutdown(NULL);2001+ return wxApp::OnExit();2002+}2003+2004+bool CMyApp::OnExceptionInMainLoop()2005+{2006+ try2007+ {2008+ throw;2009+ }2010+ catch (std::exception& e)2011+ {2012+ PrintException(&e, "CMyApp::OnExceptionInMainLoop()");2013+ wxLogWarning("Exception %s %s", typeid(e).name(), e.what());2014 Sleep(1000);2015- CAddress addr;2016- CRITICAL_BLOCK(cs_vNodes)2017- addr = vNodes[GetRand(vNodes.size())]->addr;2018-2019- // Message2020- wtx.mapValue["to"] = addr.ToString();2021- wtx.mapValue["from"] = addrLocalHost.ToString();2022- static int nRep;2023- wtx.mapValue["message"] = strprintf("randsendtest %d\n", ++nRep);2024-2025- // Value2026- int64 nValue = (GetRand(999) + 1) * CENT;2027- if (GetBalance() < nValue)2028- {2029- wxMessageBox("Out of money ");2030- return;2031- }2032-2033- // Send to IP address2034- CSendingDialog* pdialog = new CSendingDialog(pframeMain, addr, nValue, wtx);2035- if (!pdialog->Show())2036- wxMessageBox("ShowModal Failed ");2037-}2038-2039+ throw;2040+ }2041+ catch (...)2042+ {2043+ PrintException(NULL, "CMyApp::OnExceptionInMainLoop()");2044+ wxLogWarning("Unknown exception");2045+ Sleep(1000);2046+ throw;2047+ }2048+2049+ return true;2050+}2051+2052+void CMyApp::OnUnhandledException()2053+{2054+ // this shows how we may let some exception propagate uncaught2055+ try2056+ {2057+ throw;2058+ }2059+ catch (std::exception& e)2060+ {2061+ PrintException(&e, "CMyApp::OnUnhandledException()");2062+ wxLogWarning("Exception %s %s", typeid(e).name(), e.what());2063+ Sleep(1000);2064+ throw;2065+ }2066+ catch (...)2067+ {2068+ PrintException(NULL, "CMyApp::OnUnhandledException()");2069+ wxLogWarning("Unknown exception");2070+ Sleep(1000);2071+ throw;2072+ }2073+}2074+2075+void CMyApp::OnFatalException()2076+{2077+ wxMessageBox("Program has crashed and will terminate. ", "Bitcoin", wxOK | wxICON_ERROR);2078+}2079+2080+2081+2082+2083+2084+#ifdef __WXMSW__2085+typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);2086+2087+string MyGetSpecialFolderPath(int nFolder, bool fCreate)2088+{2089+ char pszPath[MAX_PATH+100] = "";2090+2091+ // SHGetSpecialFolderPath is not usually available on NT 4.02092+ HMODULE hShell32 = LoadLibrary("shell32.dll");2093+ if (hShell32)2094+ {2095+ PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =2096+ (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");2097+ if (pSHGetSpecialFolderPath)2098+ (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);2099+ FreeModule(hShell32);2100+ }2101+2102+ // Backup option2103+ if (pszPath[0] == '\0')2104+ {2105+ if (nFolder == CSIDL_STARTUP)2106+ {2107+ strcpy(pszPath, getenv("USERPROFILE"));2108+ strcat(pszPath, "\\Start Menu\\Programs\\Startup");2109+ }2110+ else if (nFolder == CSIDL_APPDATA)2111+ {2112+ strcpy(pszPath, getenv("APPDATA"));2113+ }2114+ }2115+2116+ return pszPath;2117+}2118+2119+string StartupShortcutPath()2120+{2121+ return MyGetSpecialFolderPath(CSIDL_STARTUP, true) + "\\Bitcoin.lnk";2122+}2123+2124+bool GetStartOnSystemStartup()2125+{2126+ return wxFileExists(StartupShortcutPath());2127+}2128+2129+void SetStartOnSystemStartup(bool fAutoStart)2130+{2131+ // If the shortcut exists already, remove it for updating2132+ remove(StartupShortcutPath().c_str());2133+2134+ if (fAutoStart)2135+ {2136+ CoInitialize(NULL);2137+2138+ // Get a pointer to the IShellLink interface.2139+ IShellLink* psl = NULL;2140+ HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL,2141+ CLSCTX_INPROC_SERVER, IID_IShellLink,2142+ reinterpret_cast<void**>(&psl));2143+2144+ if (SUCCEEDED(hres))2145+ {2146+ // Get the current executable path2147+ char pszExePath[MAX_PATH];2148+ GetModuleFileName(NULL, pszExePath, sizeof(pszExePath));2149+2150+ // Set the path to the shortcut target2151+ psl->SetPath(pszExePath);2152+ PathRemoveFileSpec(pszExePath);2153+ psl->SetWorkingDirectory(pszExePath);2154+ psl->SetShowCmd(SW_SHOWMINNOACTIVE);2155+2156+ // Query IShellLink for the IPersistFile interface for2157+ // saving the shortcut in persistent storage.2158+ IPersistFile* ppf = NULL;2159+ hres = psl->QueryInterface(IID_IPersistFile,2160+ reinterpret_cast<void**>(&ppf));2161+ if (SUCCEEDED(hres))2162+ {2163+ WCHAR pwsz[MAX_PATH];2164+ // Ensure that the string is ANSI.2165+ MultiByteToWideChar(CP_ACP, 0, StartupShortcutPath().c_str(), -1, pwsz, MAX_PATH);2166+ // Save the link by calling IPersistFile::Save.2167+ hres = ppf->Save(pwsz, TRUE);2168+ ppf->Release();2169+ }2170+ psl->Release();2171+ }2172+ CoUninitialize();2173+ }2174+}2175+#else2176+bool GetStartOnSystemStartup() { return false; }2177+void SetStartOnSystemStartup(bool fAutoStart) { }2178+#endif2179+2180+2181+2182+2183+2184+2185+2186+2187+2188+2189+
ui.h (modified)
1--- v0.1.5/ui.h2+++ v0.2.0/ui.h3@@ -5,28 +5,29 @@4 5 6 7-DECLARE_EVENT_TYPE(wxEVT_CROSSTHREADCALL, -1)8+DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)9 DECLARE_EVENT_TYPE(wxEVT_REPLY1, -1)10 DECLARE_EVENT_TYPE(wxEVT_REPLY2, -1)11 DECLARE_EVENT_TYPE(wxEVT_REPLY3, -1)12-DECLARE_EVENT_TYPE(wxEVT_TABLEADDED, -1)13-DECLARE_EVENT_TYPE(wxEVT_TABLEUPDATED, -1)14-DECLARE_EVENT_TYPE(wxEVT_TABLEDELETED, -1)15-16-enum17-{18- UICALL_ADDORDER = 1,19- UICALL_UPDATEORDER,20-};21+22+23+24+25+extern map<string, string> mapArgs;26+27+// Settings28+extern int fShowGenerated;29+extern int fMinimizeToTray;30+extern int fMinimizeOnClose;31 32 33 34 extern void HandleCtrlA(wxKeyEvent& event);35-extern string DateTimeStr(int64 nTime);36 extern string FormatTxStatus(const CWalletTx& wtx);37-extern void CrossThreadCall(int nID, void* pdata);38+extern void UIThreadCall(boost::function0<void>);39 extern void MainFrameRepaint();40 extern void Shutdown(void* parg);41+extern int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);42 43 44 45@@ -38,13 +39,17 @@46 protected:47 // Event handlers48 void OnClose(wxCloseEvent& event);49+ void OnIconize(wxIconizeEvent& event);50 void OnMouseEvents(wxMouseEvent& event);51 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }52 void OnIdle(wxIdleEvent& event);53 void OnPaint(wxPaintEvent& event);54 void OnPaintListCtrl(wxPaintEvent& event);55 void OnMenuFileExit(wxCommandEvent& event);56+ void OnMenuViewShowGenerated(wxCommandEvent& event);57+ void OnUpdateUIViewShowGenerated(wxUpdateUIEvent& event);58 void OnMenuOptionsGenerate(wxCommandEvent& event);59+ void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);60 void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);61 void OnMenuOptionsOptions(wxCommandEvent& event);62 void OnMenuHelpAbout(wxCommandEvent& event);63@@ -69,14 +74,16 @@64 bool fRefreshListCtrl;65 bool fRefreshListCtrlRunning;66 bool fOnSetFocusAddress;67- CBlockIndex* pindexBestLast;68- set<uint256> setUnmaturedDisplayed;69-70- void OnCrossThreadCall(wxCommandEvent& event);71+ unsigned int nListViewUpdated;72+ bool fRefresh;73+74+ void OnUIThreadCall(wxCommandEvent& event);75+ int GetSortIndex(const string& strSort);76 void InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str1, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5);77- void InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);78+ bool DeleteLine(uint256 hashKey);79+ bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);80 void RefreshListCtrl();81- void RefreshStatus();82+ void RefreshStatusColumn();83 };84 85 86@@ -102,13 +109,25 @@87 {88 protected:89 // Event handlers90+ void OnListBox(wxCommandEvent& event);91 void OnKillFocusTransactionFee(wxFocusEvent& event);92- void OnButtonOK(wxCommandEvent& event);93- void OnButtonCancel(wxCommandEvent& event);94+ void OnCheckBoxLimitProcessors(wxCommandEvent& event);95+ void OnCheckBoxUseProxy(wxCommandEvent& event);96+ void OnKillFocusProxy(wxFocusEvent& event);97+98+ void OnButtonOK(wxCommandEvent& event);99+ void OnButtonCancel(wxCommandEvent& event);100+ void OnButtonApply(wxCommandEvent& event);101 102 public:103 /** Constructor */104 COptionsDialog(wxWindow* parent);105+106+ // Custom107+ bool fTmpStartOnSystemStartup;108+ bool fTmpMinimizeOnClose;109+ void SelectPage(int nPage);110+ CAddress GetProxyAddr();111 };112 113 114@@ -141,6 +160,11 @@115 public:116 /** Constructor */117 CSendDialog(wxWindow* parent, const wxString& strAddress="");118+119+ // Custom120+ bool fEnabledPrev;121+ string strFromSave;122+ string strMessageSave;123 };124 125 126@@ -164,7 +188,7 @@127 int64 nPrice;128 CWalletTx wtx;129 wxDateTime start;130- string strStatus;131+ char pszStatus[10000];132 bool fCanCancel;133 bool fAbort;134 bool fSuccess;135@@ -416,6 +440,29 @@136 137 138 139-140-141-142+class CMyTaskBarIcon : public wxTaskBarIcon143+{144+protected:145+ // Event handlers146+ void OnLeftButtonDClick(wxTaskBarIconEvent& event);147+ void OnMenuRestore(wxCommandEvent& event);148+ void OnMenuOptions(wxCommandEvent& event);149+ void OnUpdateUIGenerate(wxUpdateUIEvent& event);150+ void OnMenuGenerate(wxCommandEvent& event);151+ void OnMenuExit(wxCommandEvent& event);152+153+public:154+ CMyTaskBarIcon() : wxTaskBarIcon()155+ {156+ Show(true);157+ }158+159+ void Show(bool fShow=true);160+ void Hide();161+ void Restore();162+ void UpdateTooltip();163+ virtual wxMenu* CreatePopupMenu();164+165+DECLARE_EVENT_TABLE()166+};167+
uibase.cpp (modified)
1--- v0.1.5/uibase.cpp2+++ v0.2.0/uibase.cpp3@@ -1,7 +1,3 @@4-// Copyright (c) 2009 Satoshi Nakamoto5-// Distributed under the MIT/X11 software license, see the accompanying6-// file license.txt or http://www.opensource.org/licenses/mit-license.php.7-8 ///////////////////////////////////////////////////////////////////////////9 // C++ code generated with wxFormBuilder (version Apr 16 2008)10 // http://www.wxformbuilder.org/11@@ -11,1816 +7,1766 @@12 13 #include "uibase.h"14 15+#include "xpm/addressbook20.xpm"16+#include "xpm/check.xpm"17+#include "xpm/send20.xpm"18+19 ///////////////////////////////////////////////////////////////////////////20 21-CMainFrameBase::CMainFrameBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style)22-{23- this->SetSizeHints(wxDefaultSize, wxDefaultSize);24- this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));25-26- m_menubar = new wxMenuBar(0);27- m_menubar->SetBackgroundColour(wxColour(240, 240, 240));28-29- m_menuFile = new wxMenu();30- wxMenuItem* m_menuFileExit;31- m_menuFileExit = new wxMenuItem(m_menuFile, wxID_ANY, wxString(wxT("E&xit")) , wxEmptyString, wxITEM_NORMAL);32- m_menuFile->Append(m_menuFileExit);33-34- m_menubar->Append(m_menuFile, wxT("&File"));35-36- m_menuOptions = new wxMenu();37- wxMenuItem* m_menuOptionsGenerateBitcoins;38- m_menuOptionsGenerateBitcoins = new wxMenuItem(m_menuOptions, wxID_OPTIONSGENERATEBITCOINS, wxString(wxT("&Generate Coins")) , wxEmptyString, wxITEM_CHECK);39- m_menuOptions->Append(m_menuOptionsGenerateBitcoins);40-41- wxMenuItem* m_menuChangeYourAddress;42- m_menuChangeYourAddress = new wxMenuItem(m_menuOptions, wxID_ANY, wxString(wxT("&Change Your Address...")) , wxEmptyString, wxITEM_NORMAL);43- m_menuOptions->Append(m_menuChangeYourAddress);44-45- wxMenuItem* m_menuOptionsOptions;46- m_menuOptionsOptions = new wxMenuItem(m_menuOptions, wxID_ANY, wxString(wxT("&Options...")) , wxEmptyString, wxITEM_NORMAL);47- m_menuOptions->Append(m_menuOptionsOptions);48-49- m_menubar->Append(m_menuOptions, wxT("&Options"));50-51- m_menuHelp = new wxMenu();52- wxMenuItem* m_menuHelpAbout;53- m_menuHelpAbout = new wxMenuItem(m_menuHelp, wxID_ANY, wxString(wxT("&About...")) , wxEmptyString, wxITEM_NORMAL);54- m_menuHelp->Append(m_menuHelpAbout);55-56- m_menubar->Append(m_menuHelp, wxT("&Help"));57-58- this->SetMenuBar(m_menubar);59-60- m_toolBar = this->CreateToolBar(wxTB_FLAT|wxTB_HORZ_TEXT, wxID_ANY);61- m_toolBar->SetToolBitmapSize(wxSize(20,20));62- m_toolBar->SetToolSeparation(1);63- m_toolBar->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString));64-65- m_toolBar->AddTool(wxID_BUTTONSEND, wxT("&Send Coins"), wxBitmap(wxT("send20"), wxBITMAP_TYPE_RESOURCE), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);66- m_toolBar->AddTool(wxID_BUTTONRECEIVE, wxT("&Address Book"), wxBitmap(wxT("addressbook20"), wxBITMAP_TYPE_RESOURCE), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);67- m_toolBar->Realize();68-69- m_statusBar = this->CreateStatusBar(1, wxST_SIZEGRIP, wxID_ANY);70- m_statusBar->SetBackgroundColour(wxColour(240, 240, 240));71-72- wxBoxSizer* bSizer2;73- bSizer2 = new wxBoxSizer(wxVERTICAL);74-75-76- bSizer2->Add(0, 2, 0, wxEXPAND, 5);77-78- wxBoxSizer* bSizer85;79- bSizer85 = new wxBoxSizer(wxHORIZONTAL);80-81- m_staticText32 = new wxStaticText(this, wxID_ANY, wxT("Your Bitcoin Address:"), wxDefaultPosition, wxDefaultSize, 0);82- m_staticText32->Wrap(-1);83- bSizer85->Add(m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5);84-85- m_textCtrlAddress = new wxTextCtrl(this, wxID_TEXTCTRLADDRESS, wxEmptyString, wxDefaultPosition, wxSize(250,-1), wxTE_READONLY);86- m_textCtrlAddress->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENU));87-88- bSizer85->Add(m_textCtrlAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);89-90- m_buttonCopy = new wxButton(this, wxID_BUTTONCOPY, wxT("&Copy to Clipboard"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);91- bSizer85->Add(m_buttonCopy, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5);92-93- m_button91 = new wxButton(this, wxID_BUTTONCHANGE, wxT("C&hange..."), wxDefaultPosition, wxDefaultSize, 0);94- m_button91->Hide();95-96- bSizer85->Add(m_button91, 0, wxRIGHT, 5);97-98-99- bSizer85->Add(0, 0, 0, wxEXPAND, 5);100-101- bSizer2->Add(bSizer85, 0, wxEXPAND|wxRIGHT|wxLEFT, 5);102-103- wxBoxSizer* bSizer3;104- bSizer3 = new wxBoxSizer(wxHORIZONTAL);105-106- m_panel14 = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);107- wxBoxSizer* bSizer66;108- bSizer66 = new wxBoxSizer(wxHORIZONTAL);109-110- m_staticText41 = new wxStaticText(m_panel14, wxID_ANY, wxT("Balance:"), wxDefaultPosition, wxSize(-1,15), 0);111- m_staticText41->Wrap(-1);112- bSizer66->Add(m_staticText41, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5);113-114- m_staticTextBalance = new wxStaticText(m_panel14, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(120,15), wxALIGN_RIGHT|wxST_NO_AUTORESIZE);115- m_staticTextBalance->Wrap(-1);116- m_staticTextBalance->SetFont(wxFont(8, 70, 90, 90, false, wxEmptyString));117- m_staticTextBalance->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));118-119- bSizer66->Add(m_staticTextBalance, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);120-121- m_panel14->SetSizer(bSizer66);122- m_panel14->Layout();123- bSizer66->Fit(m_panel14);124- bSizer3->Add(m_panel14, 1, wxEXPAND|wxALIGN_BOTTOM|wxALL, 5);125-126-127- bSizer3->Add(0, 0, 0, wxEXPAND, 5);128-129- wxString m_choiceFilterChoices[] = { wxT(" All"), wxT(" Sent"), wxT(" Received"), wxT(" In Progress") };130- int m_choiceFilterNChoices = sizeof(m_choiceFilterChoices) / sizeof(wxString);131- m_choiceFilter = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(110,-1), m_choiceFilterNChoices, m_choiceFilterChoices, 0);132- m_choiceFilter->SetSelection(0);133- m_choiceFilter->Hide();134-135- bSizer3->Add(m_choiceFilter, 0, wxALIGN_BOTTOM|wxTOP|wxRIGHT|wxLEFT, 5);136-137- bSizer2->Add(bSizer3, 0, wxEXPAND, 5);138-139- m_notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);140- m_panel7 = new wxPanel(m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);141- wxBoxSizer* bSizer157;142- bSizer157 = new wxBoxSizer(wxVERTICAL);143-144- m_listCtrl = new wxListCtrl(m_panel7, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING|wxALWAYS_SHOW_SB);145- bSizer157->Add(m_listCtrl, 1, wxEXPAND|wxALL, 5);146-147- m_panel7->SetSizer(bSizer157);148- m_panel7->Layout();149- bSizer157->Fit(m_panel7);150- m_notebook->AddPage(m_panel7, wxT("All Transactions"), false);151-152- bSizer2->Add(m_notebook, 1, wxEXPAND, 5);153-154- wxBoxSizer* bSizer_TabsForFutureUse;155- bSizer_TabsForFutureUse = new wxBoxSizer(wxVERTICAL);156-157- m_panel9 = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);158- m_panel9->Hide();159-160- wxBoxSizer* bSizer159;161- bSizer159 = new wxBoxSizer(wxVERTICAL);162-163- m_listCtrlEscrows = new wxListCtrl(m_panel9, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT);164- bSizer159->Add(m_listCtrlEscrows, 1, wxALL|wxEXPAND, 5);165-166- m_panel9->SetSizer(bSizer159);167- m_panel9->Layout();168- bSizer159->Fit(m_panel9);169- bSizer_TabsForFutureUse->Add(m_panel9, 1, wxEXPAND | wxALL, 5);170-171- m_panel8 = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);172- m_panel8->Hide();173-174- wxBoxSizer* bSizer158;175- bSizer158 = new wxBoxSizer(wxVERTICAL);176-177- m_listCtrlOrdersSent = new wxListCtrl(m_panel8, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT);178- bSizer158->Add(m_listCtrlOrdersSent, 1, wxALL|wxEXPAND, 5);179-180- m_panel8->SetSizer(bSizer158);181- m_panel8->Layout();182- bSizer158->Fit(m_panel8);183- bSizer_TabsForFutureUse->Add(m_panel8, 1, wxEXPAND | wxALL, 5);184-185- m_panel10 = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);186- m_panel10->Hide();187-188- wxBoxSizer* bSizer160;189- bSizer160 = new wxBoxSizer(wxVERTICAL);190-191- m_listCtrlProductsSent = new wxListCtrl(m_panel10, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT);192- bSizer160->Add(m_listCtrlProductsSent, 1, wxALL|wxEXPAND, 5);193-194- m_panel10->SetSizer(bSizer160);195- m_panel10->Layout();196- bSizer160->Fit(m_panel10);197- bSizer_TabsForFutureUse->Add(m_panel10, 1, wxEXPAND | wxALL, 5);198-199- m_panel11 = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);200- m_panel11->Hide();201-202- wxBoxSizer* bSizer161;203- bSizer161 = new wxBoxSizer(wxVERTICAL);204-205- m_listCtrlOrdersReceived = new wxListCtrl(m_panel11, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT);206- bSizer161->Add(m_listCtrlOrdersReceived, 1, wxALL|wxEXPAND, 5);207-208- m_panel11->SetSizer(bSizer161);209- m_panel11->Layout();210- bSizer161->Fit(m_panel11);211- bSizer_TabsForFutureUse->Add(m_panel11, 1, wxEXPAND | wxALL, 5);212-213- bSizer2->Add(bSizer_TabsForFutureUse, 1, wxEXPAND, 5);214-215- this->SetSizer(bSizer2);216- this->Layout();217-218- // Connect Events219- this->Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CMainFrameBase::OnClose));220- this->Connect(wxEVT_IDLE, wxIdleEventHandler(CMainFrameBase::OnIdle));221- this->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));222- this->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));223- this->Connect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));224- this->Connect(wxEVT_MIDDLE_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));225- this->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));226- this->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));227- this->Connect(wxEVT_MOTION, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));228- this->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));229- this->Connect(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));230- this->Connect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));231- this->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));232- this->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));233- this->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));234- this->Connect(wxEVT_PAINT, wxPaintEventHandler(CMainFrameBase::OnPaint));235- this->Connect(m_menuFileExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuFileExit));236- this->Connect(m_menuOptionsGenerateBitcoins->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsGenerate));237- this->Connect(m_menuChangeYourAddress->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsChangeYourAddress));238- this->Connect(m_menuOptionsOptions->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsOptions));239- this->Connect(m_menuHelpAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuHelpAbout));240- this->Connect(wxID_BUTTONSEND, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonSend));241- this->Connect(wxID_BUTTONRECEIVE, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonAddressBook));242- m_textCtrlAddress->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CMainFrameBase::OnKeyDown), NULL, this);243- m_textCtrlAddress->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);244- m_textCtrlAddress->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);245- m_textCtrlAddress->Connect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);246- m_textCtrlAddress->Connect(wxEVT_MIDDLE_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);247- m_textCtrlAddress->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);248- m_textCtrlAddress->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);249- m_textCtrlAddress->Connect(wxEVT_MOTION, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);250- m_textCtrlAddress->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);251- m_textCtrlAddress->Connect(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);252- m_textCtrlAddress->Connect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);253- m_textCtrlAddress->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);254- m_textCtrlAddress->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);255- m_textCtrlAddress->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);256- m_textCtrlAddress->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(CMainFrameBase::OnSetFocusAddress), NULL, this);257- m_buttonCopy->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonCopy), NULL, this);258- m_button91->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonChange), NULL, this);259- m_listCtrl->Connect(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler(CMainFrameBase::OnListColBeginDrag), NULL, this);260- m_listCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CMainFrameBase::OnListItemActivatedAllTransactions), NULL, this);261- m_listCtrl->Connect(wxEVT_PAINT, wxPaintEventHandler(CMainFrameBase::OnPaintListCtrl), NULL, this);262- m_listCtrlOrdersSent->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CMainFrameBase::OnListItemActivatedOrdersSent), NULL, this);263- m_listCtrlProductsSent->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CMainFrameBase::OnListItemActivatedProductsSent), NULL, this);264- m_listCtrlOrdersReceived->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CMainFrameBase::OnListItemActivatedOrdersReceived), NULL, this);265+CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )266+{267+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );268+ this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );269+ 270+ m_menubar = new wxMenuBar( 0 );271+ m_menubar->SetBackgroundColour( wxColour( 240, 240, 240 ) );272+ 273+ m_menuFile = new wxMenu();274+ wxMenuItem* m_menuFileExit;275+ m_menuFileExit = new wxMenuItem( m_menuFile, wxID_ANY, wxString( wxT("E&xit") ) , wxEmptyString, wxITEM_NORMAL );276+ m_menuFile->Append( m_menuFileExit );277+ 278+ m_menubar->Append( m_menuFile, wxT("&File") );279+ 280+ m_menuView = new wxMenu();281+ wxMenuItem* m_menuViewShowGenerated;282+ m_menuViewShowGenerated = new wxMenuItem( m_menuView, wxID_VIEWSHOWGENERATED, wxString( wxT("&Show Generated Coins") ) , wxEmptyString, wxITEM_CHECK );283+ m_menuView->Append( m_menuViewShowGenerated );284+ 285+ m_menubar->Append( m_menuView, wxT("&View") );286+ 287+ m_menuOptions = new wxMenu();288+ wxMenuItem* m_menuOptionsGenerateBitcoins;289+ m_menuOptionsGenerateBitcoins = new wxMenuItem( m_menuOptions, wxID_OPTIONSGENERATEBITCOINS, wxString( wxT("&Generate Coins") ) , wxEmptyString, wxITEM_CHECK );290+ m_menuOptions->Append( m_menuOptionsGenerateBitcoins );291+ 292+ wxMenuItem* m_menuOptionsChangeYourAddress;293+ m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( wxT("&Change Your Address...") ) , wxEmptyString, wxITEM_NORMAL );294+ m_menuOptions->Append( m_menuOptionsChangeYourAddress );295+ 296+ wxMenuItem* m_menuOptionsOptions;297+ m_menuOptionsOptions = new wxMenuItem( m_menuOptions, wxID_MENUOPTIONSOPTIONS, wxString( wxT("&Options...") ) , wxEmptyString, wxITEM_NORMAL );298+ m_menuOptions->Append( m_menuOptionsOptions );299+ 300+ m_menubar->Append( m_menuOptions, wxT("&Options") );301+ 302+ m_menuHelp = new wxMenu();303+ wxMenuItem* m_menuHelpAbout;304+ m_menuHelpAbout = new wxMenuItem( m_menuHelp, wxID_ANY, wxString( wxT("&About...") ) , wxEmptyString, wxITEM_NORMAL );305+ m_menuHelp->Append( m_menuHelpAbout );306+ 307+ m_menubar->Append( m_menuHelp, wxT("&Help") );308+ 309+ this->SetMenuBar( m_menubar );310+ 311+ m_toolBar = this->CreateToolBar( wxTB_FLAT|wxTB_HORZ_TEXT, wxID_ANY );312+ m_toolBar->SetToolBitmapSize( wxSize( 20,20 ) );313+ m_toolBar->SetToolSeparation( 1 );314+ m_toolBar->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );315+ 316+ m_toolBar->AddTool( wxID_BUTTONSEND, wxT("&Send Coins"), wxBitmap( send20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );317+ m_toolBar->AddTool( wxID_BUTTONRECEIVE, wxT("&Address Book"), wxBitmap( addressbook20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );318+ m_toolBar->Realize();319+ 320+ m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );321+ m_statusBar->SetBackgroundColour( wxColour( 240, 240, 240 ) );322+ 323+ wxBoxSizer* bSizer2;324+ bSizer2 = new wxBoxSizer( wxVERTICAL );325+ 326+ 327+ bSizer2->Add( 0, 2, 0, wxEXPAND, 5 );328+ 329+ wxBoxSizer* bSizer85;330+ bSizer85 = new wxBoxSizer( wxHORIZONTAL );331+ 332+ m_staticText32 = new wxStaticText( this, wxID_ANY, wxT("Your Bitcoin Address:"), wxDefaultPosition, wxDefaultSize, 0 );333+ m_staticText32->Wrap( -1 );334+ bSizer85->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );335+ 336+ m_textCtrlAddress = new wxTextCtrl( this, wxID_TEXTCTRLADDRESS, wxEmptyString, wxDefaultPosition, wxSize( 340,-1 ), wxTE_READONLY );337+ m_textCtrlAddress->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );338+ 339+ bSizer85->Add( m_textCtrlAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );340+ 341+ m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, wxT(" &Copy to Clipboard "), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );342+ bSizer85->Add( m_buttonCopy, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );343+ 344+ m_button91 = new wxButton( this, wxID_BUTTONCHANGE, wxT("C&hange..."), wxDefaultPosition, wxDefaultSize, 0 );345+ m_button91->Hide();346+ 347+ bSizer85->Add( m_button91, 0, wxRIGHT, 5 );348+ 349+ 350+ bSizer85->Add( 0, 0, 0, wxEXPAND, 5 );351+ 352+ bSizer2->Add( bSizer85, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );353+ 354+ wxBoxSizer* bSizer3;355+ bSizer3 = new wxBoxSizer( wxHORIZONTAL );356+ 357+ m_panel14 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );358+ wxBoxSizer* bSizer66;359+ bSizer66 = new wxBoxSizer( wxHORIZONTAL );360+ 361+ m_staticText41 = new wxStaticText( m_panel14, wxID_ANY, wxT("Balance:"), wxDefaultPosition, wxSize( -1,15 ), 0 );362+ m_staticText41->Wrap( -1 );363+ bSizer66->Add( m_staticText41, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );364+ 365+ m_staticTextBalance = new wxStaticText( m_panel14, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 120,15 ), wxALIGN_RIGHT|wxST_NO_AUTORESIZE );366+ m_staticTextBalance->Wrap( -1 );367+ m_staticTextBalance->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );368+ m_staticTextBalance->SetBackgroundColour( wxColour( 255, 255, 255 ) );369+ 370+ bSizer66->Add( m_staticTextBalance, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );371+ 372+ m_panel14->SetSizer( bSizer66 );373+ m_panel14->Layout();374+ bSizer66->Fit( m_panel14 );375+ bSizer3->Add( m_panel14, 1, wxEXPAND|wxALIGN_BOTTOM|wxALL, 5 );376+ 377+ 378+ bSizer3->Add( 0, 0, 0, wxEXPAND, 5 );379+ 380+ wxString m_choiceFilterChoices[] = { wxT(" All"), wxT(" Sent"), wxT(" Received"), wxT(" In Progress") };381+ int m_choiceFilterNChoices = sizeof( m_choiceFilterChoices ) / sizeof( wxString );382+ m_choiceFilter = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxSize( 110,-1 ), m_choiceFilterNChoices, m_choiceFilterChoices, 0 );383+ m_choiceFilter->SetSelection( 0 );384+ m_choiceFilter->Hide();385+ 386+ bSizer3->Add( m_choiceFilter, 0, wxALIGN_BOTTOM|wxTOP|wxRIGHT|wxLEFT, 5 );387+ 388+ bSizer2->Add( bSizer3, 0, wxEXPAND, 5 );389+ 390+ m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );391+ m_panel7 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );392+ wxBoxSizer* bSizer157;393+ bSizer157 = new wxBoxSizer( wxVERTICAL );394+ 395+ m_listCtrl = new wxListCtrl( m_panel7, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING|wxVSCROLL );396+ bSizer157->Add( m_listCtrl, 1, wxEXPAND|wxALL, 5 );397+ 398+ m_panel7->SetSizer( bSizer157 );399+ m_panel7->Layout();400+ bSizer157->Fit( m_panel7 );401+ m_notebook->AddPage( m_panel7, wxT("All Transactions"), false );402+ 403+ bSizer2->Add( m_notebook, 1, wxEXPAND, 5 );404+ 405+ wxBoxSizer* bSizer_TabsForFutureUse;406+ bSizer_TabsForFutureUse = new wxBoxSizer( wxVERTICAL );407+ 408+ m_panel9 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );409+ m_panel9->Hide();410+ 411+ wxBoxSizer* bSizer159;412+ bSizer159 = new wxBoxSizer( wxVERTICAL );413+ 414+ m_listCtrlEscrows = new wxListCtrl( m_panel9, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );415+ bSizer159->Add( m_listCtrlEscrows, 1, wxALL|wxEXPAND, 5 );416+ 417+ m_panel9->SetSizer( bSizer159 );418+ m_panel9->Layout();419+ bSizer159->Fit( m_panel9 );420+ bSizer_TabsForFutureUse->Add( m_panel9, 1, wxEXPAND | wxALL, 5 );421+ 422+ m_panel8 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );423+ m_panel8->Hide();424+ 425+ wxBoxSizer* bSizer158;426+ bSizer158 = new wxBoxSizer( wxVERTICAL );427+ 428+ m_listCtrlOrdersSent = new wxListCtrl( m_panel8, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );429+ bSizer158->Add( m_listCtrlOrdersSent, 1, wxALL|wxEXPAND, 5 );430+ 431+ m_panel8->SetSizer( bSizer158 );432+ m_panel8->Layout();433+ bSizer158->Fit( m_panel8 );434+ bSizer_TabsForFutureUse->Add( m_panel8, 1, wxEXPAND | wxALL, 5 );435+ 436+ m_panel10 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );437+ m_panel10->Hide();438+ 439+ wxBoxSizer* bSizer160;440+ bSizer160 = new wxBoxSizer( wxVERTICAL );441+ 442+ m_listCtrlProductsSent = new wxListCtrl( m_panel10, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );443+ bSizer160->Add( m_listCtrlProductsSent, 1, wxALL|wxEXPAND, 5 );444+ 445+ m_panel10->SetSizer( bSizer160 );446+ m_panel10->Layout();447+ bSizer160->Fit( m_panel10 );448+ bSizer_TabsForFutureUse->Add( m_panel10, 1, wxEXPAND | wxALL, 5 );449+ 450+ m_panel11 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );451+ m_panel11->Hide();452+ 453+ wxBoxSizer* bSizer161;454+ bSizer161 = new wxBoxSizer( wxVERTICAL );455+ 456+ m_listCtrlOrdersReceived = new wxListCtrl( m_panel11, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );457+ bSizer161->Add( m_listCtrlOrdersReceived, 1, wxALL|wxEXPAND, 5 );458+ 459+ m_panel11->SetSizer( bSizer161 );460+ m_panel11->Layout();461+ bSizer161->Fit( m_panel11 );462+ bSizer_TabsForFutureUse->Add( m_panel11, 1, wxEXPAND | wxALL, 5 );463+ 464+ bSizer2->Add( bSizer_TabsForFutureUse, 1, wxEXPAND, 5 );465+ 466+ this->SetSizer( bSizer2 );467+ this->Layout();468+ 469+ // Connect Events470+ this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CMainFrameBase::OnClose ) );471+ this->Connect( wxEVT_ICONIZE, wxIconizeEventHandler( CMainFrameBase::OnIconize ) );472+ this->Connect( wxEVT_IDLE, wxIdleEventHandler( CMainFrameBase::OnIdle ) );473+ this->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );474+ this->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );475+ this->Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );476+ this->Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );477+ this->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );478+ this->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );479+ this->Connect( wxEVT_MOTION, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );480+ this->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );481+ this->Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );482+ this->Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );483+ this->Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );484+ this->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );485+ this->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );486+ this->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaint ) );487+ this->Connect( m_menuFileExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuFileExit ) );488+ this->Connect( m_menuViewShowGenerated->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuViewShowGenerated ) );489+ this->Connect( m_menuViewShowGenerated->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIViewShowGenerated ) );490+ this->Connect( m_menuOptionsGenerateBitcoins->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsGenerate ) );491+ this->Connect( m_menuOptionsGenerateBitcoins->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIOptionsGenerate ) );492+ this->Connect( m_menuOptionsChangeYourAddress->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsChangeYourAddress ) );493+ this->Connect( m_menuOptionsOptions->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsOptions ) );494+ this->Connect( m_menuHelpAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuHelpAbout ) );495+ this->Connect( wxID_BUTTONSEND, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonSend ) );496+ this->Connect( wxID_BUTTONRECEIVE, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonAddressBook ) );497+ m_textCtrlAddress->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CMainFrameBase::OnKeyDown ), NULL, this );498+ m_textCtrlAddress->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );499+ m_textCtrlAddress->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );500+ m_textCtrlAddress->Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );501+ m_textCtrlAddress->Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );502+ m_textCtrlAddress->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );503+ m_textCtrlAddress->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );504+ m_textCtrlAddress->Connect( wxEVT_MOTION, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );505+ m_textCtrlAddress->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );506+ m_textCtrlAddress->Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );507+ m_textCtrlAddress->Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );508+ m_textCtrlAddress->Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );509+ m_textCtrlAddress->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );510+ m_textCtrlAddress->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );511+ m_textCtrlAddress->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( CMainFrameBase::OnSetFocusAddress ), NULL, this );512+ m_buttonCopy->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonCopy ), NULL, this );513+ m_button91->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );514+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );515+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedAllTransactions ), NULL, this );516+ m_listCtrl->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );517+ m_listCtrlOrdersSent->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedOrdersSent ), NULL, this );518+ m_listCtrlProductsSent->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedProductsSent ), NULL, this );519+ m_listCtrlOrdersReceived->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedOrdersReceived ), NULL, this );520 }521 522 CMainFrameBase::~CMainFrameBase()523 {524- // Disconnect Events525- this->Disconnect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CMainFrameBase::OnClose));526- this->Disconnect(wxEVT_IDLE, wxIdleEventHandler(CMainFrameBase::OnIdle));527- this->Disconnect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));528- this->Disconnect(wxEVT_LEFT_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));529- this->Disconnect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));530- this->Disconnect(wxEVT_MIDDLE_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));531- this->Disconnect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));532- this->Disconnect(wxEVT_RIGHT_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));533- this->Disconnect(wxEVT_MOTION, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));534- this->Disconnect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));535- this->Disconnect(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));536- this->Disconnect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));537- this->Disconnect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));538- this->Disconnect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));539- this->Disconnect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(CMainFrameBase::OnMouseEvents));540- this->Disconnect(wxEVT_PAINT, wxPaintEventHandler(CMainFrameBase::OnPaint));541- this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuFileExit));542- this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsGenerate));543- this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsChangeYourAddress));544- this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsOptions));545- this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuHelpAbout));546- this->Disconnect(wxID_BUTTONSEND, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonSend));547- this->Disconnect(wxID_BUTTONRECEIVE, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonAddressBook));548- m_textCtrlAddress->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CMainFrameBase::OnKeyDown), NULL, this);549- m_textCtrlAddress->Disconnect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);550- m_textCtrlAddress->Disconnect(wxEVT_LEFT_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);551- m_textCtrlAddress->Disconnect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);552- m_textCtrlAddress->Disconnect(wxEVT_MIDDLE_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);553- m_textCtrlAddress->Disconnect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);554- m_textCtrlAddress->Disconnect(wxEVT_RIGHT_UP, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);555- m_textCtrlAddress->Disconnect(wxEVT_MOTION, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);556- m_textCtrlAddress->Disconnect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);557- m_textCtrlAddress->Disconnect(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);558- m_textCtrlAddress->Disconnect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);559- m_textCtrlAddress->Disconnect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);560- m_textCtrlAddress->Disconnect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);561- m_textCtrlAddress->Disconnect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(CMainFrameBase::OnMouseEventsAddress), NULL, this);562- m_textCtrlAddress->Disconnect(wxEVT_SET_FOCUS, wxFocusEventHandler(CMainFrameBase::OnSetFocusAddress), NULL, this);563- m_buttonCopy->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonCopy), NULL, this);564- m_button91->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonChange), NULL, this);565- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler(CMainFrameBase::OnListColBeginDrag), NULL, this);566- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CMainFrameBase::OnListItemActivatedAllTransactions), NULL, this);567- m_listCtrl->Disconnect(wxEVT_PAINT, wxPaintEventHandler(CMainFrameBase::OnPaintListCtrl), NULL, this);568- m_listCtrlOrdersSent->Disconnect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CMainFrameBase::OnListItemActivatedOrdersSent), NULL, this);569- m_listCtrlProductsSent->Disconnect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CMainFrameBase::OnListItemActivatedProductsSent), NULL, this);570- m_listCtrlOrdersReceived->Disconnect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CMainFrameBase::OnListItemActivatedOrdersReceived), NULL, this);571-}572-573-CTxDetailsDialogBase::CTxDetailsDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)574-{575- this->SetSizeHints(wxDefaultSize, wxDefaultSize);576-577- wxBoxSizer* bSizer64;578- bSizer64 = new wxBoxSizer(wxVERTICAL);579-580- wxBoxSizer* bSizer66;581- bSizer66 = new wxBoxSizer(wxVERTICAL);582-583- m_htmlWin = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);584- bSizer66->Add(m_htmlWin, 1, wxALL|wxEXPAND, 5);585-586- bSizer64->Add(bSizer66, 1, wxEXPAND, 5);587-588- wxBoxSizer* bSizer65;589- bSizer65 = new wxBoxSizer(wxVERTICAL);590-591- m_buttonOK = new wxButton(this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize(85,25), 0);592- bSizer65->Add(m_buttonOK, 0, wxALL, 5);593-594- bSizer64->Add(bSizer65, 0, wxALIGN_RIGHT, 5);595-596- this->SetSizer(bSizer64);597- this->Layout();598-599- // Connect Events600- m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CTxDetailsDialogBase::OnButtonOK), NULL, this);601+ // Disconnect Events602+ this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CMainFrameBase::OnClose ) );603+ this->Disconnect( wxEVT_ICONIZE, wxIconizeEventHandler( CMainFrameBase::OnIconize ) );604+ this->Disconnect( wxEVT_IDLE, wxIdleEventHandler( CMainFrameBase::OnIdle ) );605+ this->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );606+ this->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );607+ this->Disconnect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );608+ this->Disconnect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );609+ this->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );610+ this->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );611+ this->Disconnect( wxEVT_MOTION, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );612+ this->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );613+ this->Disconnect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );614+ this->Disconnect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );615+ this->Disconnect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );616+ this->Disconnect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );617+ this->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );618+ this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaint ) );619+ this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuFileExit ) );620+ this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuViewShowGenerated ) );621+ this->Disconnect( wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIViewShowGenerated ) );622+ this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsGenerate ) );623+ this->Disconnect( wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIOptionsGenerate ) );624+ this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsChangeYourAddress ) );625+ this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsOptions ) );626+ this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuHelpAbout ) );627+ this->Disconnect( wxID_BUTTONSEND, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonSend ) );628+ this->Disconnect( wxID_BUTTONRECEIVE, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonAddressBook ) );629+ m_textCtrlAddress->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CMainFrameBase::OnKeyDown ), NULL, this );630+ m_textCtrlAddress->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );631+ m_textCtrlAddress->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );632+ m_textCtrlAddress->Disconnect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );633+ m_textCtrlAddress->Disconnect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );634+ m_textCtrlAddress->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );635+ m_textCtrlAddress->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );636+ m_textCtrlAddress->Disconnect( wxEVT_MOTION, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );637+ m_textCtrlAddress->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );638+ m_textCtrlAddress->Disconnect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );639+ m_textCtrlAddress->Disconnect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );640+ m_textCtrlAddress->Disconnect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );641+ m_textCtrlAddress->Disconnect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );642+ m_textCtrlAddress->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );643+ m_textCtrlAddress->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( CMainFrameBase::OnSetFocusAddress ), NULL, this );644+ m_buttonCopy->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonCopy ), NULL, this );645+ m_button91->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );646+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );647+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedAllTransactions ), NULL, this );648+ m_listCtrl->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );649+ m_listCtrlOrdersSent->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedOrdersSent ), NULL, this );650+ m_listCtrlProductsSent->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedProductsSent ), NULL, this );651+ m_listCtrlOrdersReceived->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedOrdersReceived ), NULL, this );652+}653+654+CTxDetailsDialogBase::CTxDetailsDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )655+{656+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );657+ 658+ wxBoxSizer* bSizer64;659+ bSizer64 = new wxBoxSizer( wxVERTICAL );660+ 661+ wxBoxSizer* bSizer66;662+ bSizer66 = new wxBoxSizer( wxVERTICAL );663+ 664+ m_htmlWin = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );665+ bSizer66->Add( m_htmlWin, 1, wxALL|wxEXPAND, 5 );666+ 667+ bSizer64->Add( bSizer66, 1, wxEXPAND, 5 );668+ 669+ wxBoxSizer* bSizer65;670+ bSizer65 = new wxBoxSizer( wxHORIZONTAL );671+ 672+ m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );673+ bSizer65->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );674+ 675+ bSizer64->Add( bSizer65, 0, wxALIGN_RIGHT, 5 );676+ 677+ this->SetSizer( bSizer64 );678+ this->Layout();679+ 680+ // Connect Events681+ m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CTxDetailsDialogBase::OnButtonOK ), NULL, this );682 }683 684 CTxDetailsDialogBase::~CTxDetailsDialogBase()685 {686- // Disconnect Events687- m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CTxDetailsDialogBase::OnButtonOK), NULL, this);688-}689-690-COptionsDialogBase::COptionsDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)691-{692- this->SetSizeHints(wxDefaultSize, wxDefaultSize);693-694- wxBoxSizer* bSizer55;695- bSizer55 = new wxBoxSizer(wxVERTICAL);696-697- wxBoxSizer* bSizer57;698- bSizer57 = new wxBoxSizer(wxVERTICAL);699-700-701- bSizer57->Add(0, 20, 0, wxEXPAND, 5);702-703- m_staticText32 = new wxStaticText(this, wxID_ANY, wxT("Optional transaction fee you give to the nodes that process your transactions."), wxDefaultPosition, wxDefaultSize, 0);704- m_staticText32->Wrap(-1);705- bSizer57->Add(m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);706-707- wxBoxSizer* bSizer56;708- bSizer56 = new wxBoxSizer(wxHORIZONTAL);709-710- m_staticText31 = new wxStaticText(this, wxID_ANY, wxT("Transaction fee:"), wxDefaultPosition, wxDefaultSize, 0);711- m_staticText31->Wrap(-1);712- bSizer56->Add(m_staticText31, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5);713-714- m_textCtrlTransactionFee = new wxTextCtrl(this, wxID_TRANSACTIONFEE, wxEmptyString, wxDefaultPosition, wxSize(70,-1), 0);715- bSizer56->Add(m_textCtrlTransactionFee, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);716-717- bSizer57->Add(bSizer56, 0, wxEXPAND, 5);718-719- bSizer55->Add(bSizer57, 1, wxEXPAND|wxLEFT, 5);720-721- wxBoxSizer* bSizer58;722- bSizer58 = new wxBoxSizer(wxHORIZONTAL);723-724- m_buttonOK = new wxButton(this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize(85,25), 0);725- bSizer58->Add(m_buttonOK, 0, wxALL, 5);726-727- m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize(-1,-1), 0);728- m_buttonCancel->SetMinSize(wxSize(85,25));729-730- bSizer58->Add(m_buttonCancel, 0, wxALL, 5);731-732- bSizer55->Add(bSizer58, 0, wxALIGN_RIGHT, 5);733-734- this->SetSizer(bSizer55);735- this->Layout();736-737- // Connect Events738- m_textCtrlTransactionFee->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(COptionsDialogBase::OnKillFocusTransactionFee), NULL, this);739- m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(COptionsDialogBase::OnButtonOK), NULL, this);740- m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(COptionsDialogBase::OnButtonCancel), NULL, this);741+ // Disconnect Events742+ m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CTxDetailsDialogBase::OnButtonOK ), NULL, this );743+}744+745+COptionsDialogBase::COptionsDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )746+{747+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );748+ 749+ wxBoxSizer* bSizer55;750+ bSizer55 = new wxBoxSizer( wxVERTICAL );751+ 752+ wxBoxSizer* bSizer66;753+ bSizer66 = new wxBoxSizer( wxHORIZONTAL );754+ 755+ m_listBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxSize( 110,-1 ), 0, NULL, wxLB_NEEDED_SB|wxLB_SINGLE ); 756+ bSizer66->Add( m_listBox, 0, wxEXPAND|wxRIGHT, 5 );757+ 758+ m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );759+ m_scrolledWindow->SetScrollRate( 5, 5 );760+ wxBoxSizer* bSizer63;761+ bSizer63 = new wxBoxSizer( wxVERTICAL );762+ 763+ m_panelMain = new wxPanel( m_scrolledWindow, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );764+ wxBoxSizer* bSizer69;765+ bSizer69 = new wxBoxSizer( wxVERTICAL );766+ 767+ 768+ bSizer69->Add( 0, 16, 0, wxEXPAND, 5 );769+ 770+ m_staticText32 = new wxStaticText( m_panelMain, wxID_ANY, wxT("Optional transaction fee you give to the nodes that process your transactions."), wxDefaultPosition, wxDefaultSize, 0 );771+ m_staticText32->Wrap( -1 );772+ m_staticText32->Hide();773+ 774+ bSizer69->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );775+ 776+ wxBoxSizer* bSizer56;777+ bSizer56 = new wxBoxSizer( wxHORIZONTAL );778+ 779+ m_staticText31 = new wxStaticText( m_panelMain, wxID_ANY, wxT("Transaction fee:"), wxDefaultPosition, wxDefaultSize, 0 );780+ m_staticText31->Wrap( -1 );781+ m_staticText31->Hide();782+ 783+ bSizer56->Add( m_staticText31, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );784+ 785+ m_textCtrlTransactionFee = new wxTextCtrl( m_panelMain, wxID_TRANSACTIONFEE, wxEmptyString, wxDefaultPosition, wxSize( 70,-1 ), 0 );786+ m_textCtrlTransactionFee->Hide();787+ 788+ bSizer56->Add( m_textCtrlTransactionFee, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );789+ 790+ bSizer69->Add( bSizer56, 0, wxEXPAND, 5 );791+ 792+ wxBoxSizer* bSizer71;793+ bSizer71 = new wxBoxSizer( wxHORIZONTAL );794+ 795+ m_checkBoxLimitProcessors = new wxCheckBox( m_panelMain, wxID_ANY, wxT("&Limit coin generation to"), wxDefaultPosition, wxDefaultSize, 0 );796+ 797+ bSizer71->Add( m_checkBoxLimitProcessors, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );798+ 799+ m_spinCtrlLimitProcessors = new wxSpinCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 48,-1 ), wxSP_ARROW_KEYS, 1, 999, 1 );800+ bSizer71->Add( m_spinCtrlLimitProcessors, 0, wxALIGN_CENTER_VERTICAL, 5 );801+ 802+ m_staticText35 = new wxStaticText( m_panelMain, wxID_ANY, wxT("processors"), wxDefaultPosition, wxDefaultSize, 0 );803+ m_staticText35->Wrap( -1 );804+ bSizer71->Add( m_staticText35, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );805+ 806+ bSizer69->Add( bSizer71, 0, 0, 5 );807+ 808+ m_checkBoxStartOnSystemStartup = new wxCheckBox( m_panelMain, wxID_ANY, wxT("&Start Bitcoin on system startup"), wxDefaultPosition, wxDefaultSize, 0 );809+ 810+ bSizer69->Add( m_checkBoxStartOnSystemStartup, 0, wxALL, 5 );811+ 812+ m_checkBoxMinimizeToTray = new wxCheckBox( m_panelMain, wxID_ANY, wxT("&Minimize to the tray instead of the taskbar"), wxDefaultPosition, wxDefaultSize, 0 );813+ 814+ bSizer69->Add( m_checkBoxMinimizeToTray, 0, wxALL, 5 );815+ 816+ m_checkBoxMinimizeOnClose = new wxCheckBox( m_panelMain, wxID_ANY, wxT("M&inimize to the tray on close"), wxDefaultPosition, wxDefaultSize, 0 );817+ 818+ bSizer69->Add( m_checkBoxMinimizeOnClose, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );819+ 820+ wxBoxSizer* bSizer102;821+ bSizer102 = new wxBoxSizer( wxHORIZONTAL );822+ 823+ m_checkBoxUseProxy = new wxCheckBox( m_panelMain, wxID_ANY, wxT("&Connect through socks4 proxy: "), wxDefaultPosition, wxDefaultSize, 0 );824+ 825+ bSizer102->Add( m_checkBoxUseProxy, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );826+ 827+ bSizer69->Add( bSizer102, 1, wxEXPAND, 5 );828+ 829+ wxBoxSizer* bSizer103;830+ bSizer103 = new wxBoxSizer( wxHORIZONTAL );831+ 832+ 833+ bSizer103->Add( 18, 0, 0, 0, 5 );834+ 835+ m_staticTextProxyIP = new wxStaticText( m_panelMain, wxID_ANY, wxT("Proxy &IP:"), wxDefaultPosition, wxDefaultSize, 0 );836+ m_staticTextProxyIP->Wrap( -1 );837+ bSizer103->Add( m_staticTextProxyIP, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );838+ 839+ m_textCtrlProxyIP = new wxTextCtrl( m_panelMain, wxID_PROXYIP, wxEmptyString, wxDefaultPosition, wxSize( 140,-1 ), 0 );840+ m_textCtrlProxyIP->SetMaxLength( 15 ); 841+ bSizer103->Add( m_textCtrlProxyIP, 0, wxALIGN_CENTER_VERTICAL, 5 );842+ 843+ m_staticTextProxyPort = new wxStaticText( m_panelMain, wxID_ANY, wxT(" &Port:"), wxDefaultPosition, wxDefaultSize, 0 );844+ m_staticTextProxyPort->Wrap( -1 );845+ bSizer103->Add( m_staticTextProxyPort, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );846+ 847+ m_textCtrlProxyPort = new wxTextCtrl( m_panelMain, wxID_PROXYPORT, wxEmptyString, wxDefaultPosition, wxSize( 55,-1 ), 0 );848+ m_textCtrlProxyPort->SetMaxLength( 5 ); 849+ bSizer103->Add( m_textCtrlProxyPort, 0, wxALIGN_CENTER_VERTICAL, 5 );850+ 851+ bSizer69->Add( bSizer103, 1, wxEXPAND, 5 );852+ 853+ m_panelMain->SetSizer( bSizer69 );854+ m_panelMain->Layout();855+ bSizer69->Fit( m_panelMain );856+ bSizer63->Add( m_panelMain, 0, wxEXPAND, 5 );857+ 858+ m_panelTest2 = new wxPanel( m_scrolledWindow, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );859+ wxBoxSizer* bSizer64;860+ bSizer64 = new wxBoxSizer( wxVERTICAL );861+ 862+ 863+ bSizer64->Add( 0, 16, 0, wxEXPAND, 5 );864+ 865+ m_staticText321 = new wxStaticText( m_panelTest2, wxID_ANY, wxT("Test panel 2 for future expansion"), wxDefaultPosition, wxDefaultSize, 0 );866+ m_staticText321->Wrap( -1 );867+ bSizer64->Add( m_staticText321, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );868+ 869+ m_staticText69 = new wxStaticText( m_panelTest2, wxID_ANY, wxT("Let's not start multiple pages until the first page is filled up"), wxDefaultPosition, wxDefaultSize, 0 );870+ m_staticText69->Wrap( -1 );871+ bSizer64->Add( m_staticText69, 0, wxALL, 5 );872+ 873+ m_staticText70 = new wxStaticText( m_panelTest2, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );874+ m_staticText70->Wrap( -1 );875+ bSizer64->Add( m_staticText70, 0, wxALL, 5 );876+ 877+ m_staticText71 = new wxStaticText( m_panelTest2, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );878+ m_staticText71->Wrap( -1 );879+ bSizer64->Add( m_staticText71, 0, wxALL, 5 );880+ 881+ m_panelTest2->SetSizer( bSizer64 );882+ m_panelTest2->Layout();883+ bSizer64->Fit( m_panelTest2 );884+ bSizer63->Add( m_panelTest2, 0, wxEXPAND, 5 );885+ 886+ m_scrolledWindow->SetSizer( bSizer63 );887+ m_scrolledWindow->Layout();888+ bSizer63->Fit( m_scrolledWindow );889+ bSizer66->Add( m_scrolledWindow, 1, wxEXPAND|wxLEFT, 5 );890+ 891+ bSizer55->Add( bSizer66, 1, wxEXPAND|wxALL, 9 );892+ 893+ wxBoxSizer* bSizer58;894+ bSizer58 = new wxBoxSizer( wxHORIZONTAL );895+ 896+ m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );897+ bSizer58->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );898+ 899+ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );900+ bSizer58->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );901+ 902+ m_buttonApply = new wxButton( this, wxID_APPLY, wxT("&Apply"), wxDefaultPosition, wxSize( -1,-1 ), 0 );903+ bSizer58->Add( m_buttonApply, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );904+ 905+ bSizer55->Add( bSizer58, 0, wxALIGN_RIGHT, 5 );906+ 907+ this->SetSizer( bSizer55 );908+ this->Layout();909+ 910+ // Connect Events911+ m_listBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( COptionsDialogBase::OnListBox ), NULL, this );912+ m_textCtrlTransactionFee->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusTransactionFee ), NULL, this );913+ m_checkBoxLimitProcessors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxLimitProcessors ), NULL, this );914+ m_checkBoxMinimizeToTray->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxMinimizeToTray ), NULL, this );915+ m_checkBoxUseProxy->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxUseProxy ), NULL, this );916+ m_textCtrlProxyIP->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this );917+ m_textCtrlProxyPort->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this );918+ m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonOK ), NULL, this );919+ m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonCancel ), NULL, this );920+ m_buttonApply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonApply ), NULL, this );921 }922 923 COptionsDialogBase::~COptionsDialogBase()924 {925- // Disconnect Events926- m_textCtrlTransactionFee->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(COptionsDialogBase::OnKillFocusTransactionFee), NULL, this);927- m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(COptionsDialogBase::OnButtonOK), NULL, this);928- m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(COptionsDialogBase::OnButtonCancel), NULL, this);929-}930-931-CAboutDialogBase::CAboutDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)932-{933- this->SetSizeHints(wxDefaultSize, wxDefaultSize);934-935- wxBoxSizer* bSizer60;936- bSizer60 = new wxBoxSizer(wxVERTICAL);937-938- wxBoxSizer* bSizer62;939- bSizer62 = new wxBoxSizer(wxHORIZONTAL);940-941-942- bSizer62->Add(60, 0, 0, wxEXPAND, 5);943-944- wxBoxSizer* bSizer63;945- bSizer63 = new wxBoxSizer(wxVERTICAL);946-947-948- bSizer63->Add(0, 50, 0, wxEXPAND, 5);949-950- wxBoxSizer* bSizer64;951- bSizer64 = new wxBoxSizer(wxHORIZONTAL);952-953- m_staticText40 = new wxStaticText(this, wxID_ANY, wxT("Bitcoin "), wxDefaultPosition, wxDefaultSize, 0);954- m_staticText40->Wrap(-1);955- m_staticText40->SetFont(wxFont(10, 74, 90, 92, false, wxT("Tahoma")));956-957- bSizer64->Add(m_staticText40, 0, wxALIGN_BOTTOM|wxTOP|wxBOTTOM|wxLEFT, 5);958-959- m_staticTextVersion = new wxStaticText(this, wxID_ANY, wxT("version"), wxDefaultPosition, wxDefaultSize, 0);960- m_staticTextVersion->Wrap(-1);961- m_staticTextVersion->SetFont(wxFont(10, 74, 90, 90, false, wxT("Tahoma")));962-963- bSizer64->Add(m_staticTextVersion, 0, wxALIGN_BOTTOM|wxTOP|wxBOTTOM|wxRIGHT, 5);964-965- bSizer63->Add(bSizer64, 0, wxEXPAND, 5);966-967-968- bSizer63->Add(0, 4, 0, wxEXPAND, 5);969-970- m_staticTextMain = new wxStaticText(this, wxID_ANY, wxT("Copyright © 2009 Satoshi Nakamoto.\n\nThis is experimental software. Do not rely on it for actual financial transactions.\n\nDistributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0);971- m_staticTextMain->Wrap(400);972- bSizer63->Add(m_staticTextMain, 0, wxALL, 5);973-974-975- bSizer63->Add(0, 0, 1, wxEXPAND, 5);976-977- bSizer62->Add(bSizer63, 1, wxEXPAND, 5);978-979- bSizer60->Add(bSizer62, 1, wxEXPAND, 5);980-981- wxBoxSizer* bSizer61;982- bSizer61 = new wxBoxSizer(wxHORIZONTAL);983-984-985- bSizer61->Add(0, 0, 1, wxEXPAND, 5);986-987- m_buttonOK = new wxButton(this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize(85,25), 0);988- bSizer61->Add(m_buttonOK, 0, wxALL, 5);989-990- bSizer60->Add(bSizer61, 0, wxALIGN_RIGHT|wxEXPAND, 5);991-992- this->SetSizer(bSizer60);993- this->Layout();994-995- // Connect Events996- m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAboutDialogBase::OnButtonOK), NULL, this);997+ // Disconnect Events998+ m_listBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( COptionsDialogBase::OnListBox ), NULL, this );999+ m_textCtrlTransactionFee->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusTransactionFee ), NULL, this );1000+ m_checkBoxLimitProcessors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxLimitProcessors ), NULL, this );1001+ m_checkBoxMinimizeToTray->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxMinimizeToTray ), NULL, this );1002+ m_checkBoxUseProxy->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxUseProxy ), NULL, this );1003+ m_textCtrlProxyIP->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this );1004+ m_textCtrlProxyPort->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this );1005+ m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonOK ), NULL, this );1006+ m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonCancel ), NULL, this );1007+ m_buttonApply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonApply ), NULL, this );1008+}1009+1010+CAboutDialogBase::CAboutDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )1011+{1012+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );1013+ 1014+ wxBoxSizer* bSizer60;1015+ bSizer60 = new wxBoxSizer( wxVERTICAL );1016+ 1017+ wxBoxSizer* bSizer62;1018+ bSizer62 = new wxBoxSizer( wxHORIZONTAL );1019+ 1020+ 1021+ bSizer62->Add( 60, 0, 0, wxEXPAND, 5 );1022+ 1023+ wxBoxSizer* bSizer63;1024+ bSizer63 = new wxBoxSizer( wxVERTICAL );1025+ 1026+ 1027+ bSizer63->Add( 0, 50, 0, wxEXPAND, 5 );1028+ 1029+ wxBoxSizer* bSizer64;1030+ bSizer64 = new wxBoxSizer( wxHORIZONTAL );1031+ 1032+ m_staticText40 = new wxStaticText( this, wxID_ANY, wxT("Bitcoin "), wxDefaultPosition, wxDefaultSize, 0 );1033+ m_staticText40->Wrap( -1 );1034+ m_staticText40->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) );1035+ 1036+ bSizer64->Add( m_staticText40, 0, wxALIGN_BOTTOM|wxTOP|wxBOTTOM|wxLEFT, 5 );1037+ 1038+ m_staticTextVersion = new wxStaticText( this, wxID_ANY, wxT("version"), wxDefaultPosition, wxDefaultSize, 0 );1039+ m_staticTextVersion->Wrap( -1 );1040+ m_staticTextVersion->SetFont( wxFont( 10, 74, 90, 90, false, wxT("Tahoma") ) );1041+ 1042+ bSizer64->Add( m_staticTextVersion, 0, wxALIGN_BOTTOM|wxTOP|wxBOTTOM|wxRIGHT, 5 );1043+ 1044+ bSizer63->Add( bSizer64, 0, wxEXPAND, 5 );1045+ 1046+ 1047+ bSizer63->Add( 0, 4, 0, wxEXPAND, 5 );1048+ 1049+ m_staticTextMain = new wxStaticText( this, wxID_ANY, wxT("Copyright © 2009 Satoshi Nakamoto.\n\nThis is experimental software. Do not rely on it for actual financial transactions.\n\nDistributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 );1050+ m_staticTextMain->Wrap( 400 );1051+ bSizer63->Add( m_staticTextMain, 0, wxALL, 5 );1052+ 1053+ 1054+ bSizer63->Add( 0, 0, 1, wxEXPAND, 5 );1055+ 1056+ bSizer62->Add( bSizer63, 1, wxEXPAND, 5 );1057+ 1058+ bSizer60->Add( bSizer62, 1, wxEXPAND, 5 );1059+ 1060+ wxBoxSizer* bSizer61;1061+ bSizer61 = new wxBoxSizer( wxHORIZONTAL );1062+ 1063+ 1064+ bSizer61->Add( 0, 0, 1, wxEXPAND, 5 );1065+ 1066+ m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );1067+ bSizer61->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1068+ 1069+ bSizer60->Add( bSizer61, 0, wxALIGN_RIGHT|wxEXPAND, 5 );1070+ 1071+ this->SetSizer( bSizer60 );1072+ this->Layout();1073+ 1074+ // Connect Events1075+ m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAboutDialogBase::OnButtonOK ), NULL, this );1076 }1077 1078 CAboutDialogBase::~CAboutDialogBase()1079 {1080- // Disconnect Events1081- m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAboutDialogBase::OnButtonOK), NULL, this);1082-}1083-1084-CSendDialogBase::CSendDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)1085-{1086- this->SetSizeHints(wxDefaultSize, wxDefaultSize);1087-1088- wxBoxSizer* bSizer21;1089- bSizer21 = new wxBoxSizer(wxVERTICAL);1090-1091-1092- bSizer21->Add(0, 5, 0, wxEXPAND, 5);1093-1094- wxFlexGridSizer* fgSizer1;1095- fgSizer1 = new wxFlexGridSizer(3, 2, 0, 0);1096- fgSizer1->AddGrowableCol(1);1097- fgSizer1->SetFlexibleDirection(wxBOTH);1098- fgSizer1->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);1099-1100-1101- fgSizer1->Add(0, 0, 0, wxEXPAND, 5);1102-1103- m_staticText14 = new wxStaticText(this, wxID_ANY, wxT("Enter the recipient's IP address (e.g. 123.45.6.7) for online transfer with comments and confirmation, \nor Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) if recipient is not online."), wxDefaultPosition, wxDefaultSize, 0);1104- m_staticText14->Wrap(-1);1105- fgSizer1->Add(m_staticText14, 0, wxTOP|wxRIGHT|wxLEFT, 5);1106-1107- wxBoxSizer* bSizer47;1108- bSizer47 = new wxBoxSizer(wxHORIZONTAL);1109-1110- bSizer47->SetMinSize(wxSize(70,-1));1111-1112- bSizer47->Add(0, 0, 1, wxEXPAND, 5);1113-1114- m_bitmapCheckMark = new wxStaticBitmap(this, wxID_ANY, wxICON(check), wxDefaultPosition, wxSize(16,16), 0);1115- bSizer47->Add(m_bitmapCheckMark, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);1116-1117- m_staticText36 = new wxStaticText(this, wxID_ANY, wxT("Pay &To:"), wxDefaultPosition, wxSize(-1,-1), wxALIGN_RIGHT);1118- m_staticText36->Wrap(-1);1119- bSizer47->Add(m_staticText36, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5);1120-1121- fgSizer1->Add(bSizer47, 1, wxEXPAND|wxLEFT, 5);1122-1123- wxBoxSizer* bSizer19;1124- bSizer19 = new wxBoxSizer(wxHORIZONTAL);1125-1126- m_textCtrlAddress = new wxTextCtrl(this, wxID_TEXTCTRLPAYTO, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);1127- bSizer19->Add(m_textCtrlAddress, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);1128-1129- m_buttonPaste = new wxButton(this, wxID_BUTTONPASTE, wxT("&Paste"), wxDefaultPosition, wxSize(-1,-1), wxBU_EXACTFIT);1130- bSizer19->Add(m_buttonPaste, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5);1131-1132- m_buttonAddress = new wxButton(this, wxID_BUTTONADDRESSBOOK, wxT(" Address &Book..."), wxDefaultPosition, wxDefaultSize, 0);1133- bSizer19->Add(m_buttonAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5);1134-1135- fgSizer1->Add(bSizer19, 1, wxEXPAND|wxRIGHT, 5);1136-1137- m_staticText19 = new wxStaticText(this, wxID_ANY, wxT("&Amount:"), wxDefaultPosition, wxSize(-1,-1), wxALIGN_RIGHT);1138- m_staticText19->Wrap(-1);1139- fgSizer1->Add(m_staticText19, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxALIGN_RIGHT, 5);1140-1141- m_textCtrlAmount = new wxTextCtrl(this, wxID_TEXTCTRLAMOUNT, wxEmptyString, wxDefaultPosition, wxSize(145,-1), 0);1142- m_textCtrlAmount->SetMaxLength(20);1143- m_textCtrlAmount->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString));1144-1145- fgSizer1->Add(m_textCtrlAmount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);1146-1147- m_staticText20 = new wxStaticText(this, wxID_ANY, wxT("T&ransfer:"), wxDefaultPosition, wxSize(-1,-1), wxALIGN_RIGHT);1148- m_staticText20->Wrap(-1);1149- m_staticText20->Hide();1150-1151- fgSizer1->Add(m_staticText20, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5);1152-1153- wxString m_choiceTransferTypeChoices[] = { wxT(" Standard") };1154- int m_choiceTransferTypeNChoices = sizeof(m_choiceTransferTypeChoices) / sizeof(wxString);1155- m_choiceTransferType = new wxChoice(this, wxID_CHOICETRANSFERTYPE, wxDefaultPosition, wxDefaultSize, m_choiceTransferTypeNChoices, m_choiceTransferTypeChoices, 0);1156- m_choiceTransferType->SetSelection(0);1157- m_choiceTransferType->Hide();1158-1159- fgSizer1->Add(m_choiceTransferType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);1160-1161-1162- fgSizer1->Add(0, 3, 0, wxEXPAND, 5);1163-1164-1165- fgSizer1->Add(0, 0, 0, wxEXPAND, 5);1166-1167- bSizer21->Add(fgSizer1, 0, wxEXPAND|wxLEFT, 5);1168-1169- wxBoxSizer* bSizer672;1170- bSizer672 = new wxBoxSizer(wxHORIZONTAL);1171-1172- wxBoxSizer* bSizer681;1173- bSizer681 = new wxBoxSizer(wxVERTICAL);1174-1175- m_staticTextFrom = new wxStaticText(this, wxID_ANY, wxT("&From:"), wxDefaultPosition, wxDefaultSize, 0);1176- m_staticTextFrom->Wrap(-1);1177- bSizer681->Add(m_staticTextFrom, 0, wxBOTTOM|wxLEFT, 5);1178-1179- m_textCtrlFrom = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);1180- bSizer681->Add(m_textCtrlFrom, 0, wxLEFT|wxEXPAND, 5);1181-1182- bSizer672->Add(bSizer681, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5);1183-1184- bSizer21->Add(bSizer672, 0, wxEXPAND, 5);1185-1186- wxBoxSizer* bSizer67;1187- bSizer67 = new wxBoxSizer(wxHORIZONTAL);1188-1189- wxBoxSizer* bSizer68;1190- bSizer68 = new wxBoxSizer(wxVERTICAL);1191-1192- m_staticTextMessage = new wxStaticText(this, wxID_ANY, wxT("&Message:"), wxDefaultPosition, wxDefaultSize, 0);1193- m_staticTextMessage->Wrap(-1);1194- bSizer68->Add(m_staticTextMessage, 0, wxTOP|wxBOTTOM|wxLEFT, 5);1195-1196- m_textCtrlMessage = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);1197- bSizer68->Add(m_textCtrlMessage, 1, wxEXPAND|wxLEFT, 5);1198-1199- bSizer67->Add(bSizer68, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5);1200-1201- bSizer21->Add(bSizer67, 1, wxEXPAND, 5);1202-1203- wxBoxSizer* bSizer23;1204- bSizer23 = new wxBoxSizer(wxHORIZONTAL);1205-1206-1207- bSizer23->Add(0, 0, 1, wxEXPAND, 5);1208-1209- m_buttonSend = new wxButton(this, wxID_BUTTONSEND, wxT("&Send"), wxDefaultPosition, wxSize(-1,-1), 0);1210- m_buttonSend->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString));1211- m_buttonSend->SetMinSize(wxSize(85,25));1212-1213- bSizer23->Add(m_buttonSend, 0, wxALL, 5);1214-1215- m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize(-1,-1), 0);1216- m_buttonCancel->SetMinSize(wxSize(85,25));1217-1218- bSizer23->Add(m_buttonCancel, 0, wxALL, 5);1219-1220- bSizer21->Add(bSizer23, 0, wxEXPAND, 5);1221-1222- this->SetSizer(bSizer21);1223- this->Layout();1224-1225- // Connect Events1226- m_textCtrlAddress->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CSendDialogBase::OnKeyDown), NULL, this);1227- m_textCtrlAddress->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(CSendDialogBase::OnTextAddress), NULL, this);1228- m_buttonPaste->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendDialogBase::OnButtonPaste), NULL, this);1229- m_buttonAddress->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendDialogBase::OnButtonAddressBook), NULL, this);1230- m_textCtrlAmount->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CSendDialogBase::OnKeyDown), NULL, this);1231- m_textCtrlAmount->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(CSendDialogBase::OnKillFocusAmount), NULL, this);1232- m_textCtrlFrom->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CSendDialogBase::OnKeyDown), NULL, this);1233- m_textCtrlMessage->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CSendDialogBase::OnKeyDown), NULL, this);1234- m_buttonSend->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendDialogBase::OnButtonSend), NULL, this);1235- m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendDialogBase::OnButtonCancel), NULL, this);1236+ // Disconnect Events1237+ m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAboutDialogBase::OnButtonOK ), NULL, this );1238+}1239+1240+CSendDialogBase::CSendDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )1241+{1242+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );1243+ 1244+ wxBoxSizer* bSizer21;1245+ bSizer21 = new wxBoxSizer( wxVERTICAL );1246+ 1247+ 1248+ bSizer21->Add( 0, 5, 0, wxEXPAND, 5 );1249+ 1250+ wxFlexGridSizer* fgSizer1;1251+ fgSizer1 = new wxFlexGridSizer( 3, 2, 0, 0 );1252+ fgSizer1->AddGrowableCol( 1 );1253+ fgSizer1->SetFlexibleDirection( wxBOTH );1254+ fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );1255+ 1256+ 1257+ fgSizer1->Add( 0, 0, 0, wxEXPAND, 5 );1258+ 1259+ m_staticTextInstructions = new wxStaticText( this, wxID_ANY, wxT("Enter the recipient's IP address (e.g. 123.45.6.7) for online transfer with comments and confirmation, \nor Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) if recipient is not online."), wxDefaultPosition, wxDefaultSize, 0 );1260+ m_staticTextInstructions->Wrap( -1 );1261+ fgSizer1->Add( m_staticTextInstructions, 0, wxTOP|wxRIGHT|wxLEFT, 5 );1262+ 1263+ wxBoxSizer* bSizer47;1264+ bSizer47 = new wxBoxSizer( wxHORIZONTAL );1265+ 1266+ bSizer47->SetMinSize( wxSize( 70,-1 ) ); 1267+ 1268+ bSizer47->Add( 0, 0, 1, wxEXPAND, 5 );1269+ 1270+ m_bitmapCheckMark = new wxStaticBitmap( this, wxID_ANY, wxBitmap( check_xpm ), wxDefaultPosition, wxSize( 16,16 ), 0 );1271+ bSizer47->Add( m_bitmapCheckMark, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );1272+ 1273+ m_staticText36 = new wxStaticText( this, wxID_ANY, wxT("Pay &To:"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_RIGHT );1274+ m_staticText36->Wrap( -1 );1275+ bSizer47->Add( m_staticText36, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );1276+ 1277+ fgSizer1->Add( bSizer47, 1, wxEXPAND|wxLEFT, 5 );1278+ 1279+ wxBoxSizer* bSizer19;1280+ bSizer19 = new wxBoxSizer( wxHORIZONTAL );1281+ 1282+ m_textCtrlAddress = new wxTextCtrl( this, wxID_TEXTCTRLPAYTO, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );1283+ bSizer19->Add( m_textCtrlAddress, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );1284+ 1285+ wxBoxSizer* bSizer66;1286+ bSizer66 = new wxBoxSizer( wxHORIZONTAL );1287+ 1288+ m_buttonPaste = new wxButton( this, wxID_BUTTONPASTE, wxT("&Paste"), wxDefaultPosition, wxSize( -1,-1 ), wxBU_EXACTFIT );1289+ bSizer66->Add( m_buttonPaste, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND, 5 );1290+ 1291+ m_buttonAddress = new wxButton( this, wxID_BUTTONADDRESSBOOK, wxT(" Address &Book..."), wxDefaultPosition, wxDefaultSize, 0 );1292+ bSizer66->Add( m_buttonAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND, 5 );1293+ 1294+ bSizer19->Add( bSizer66, 0, wxALIGN_CENTER_VERTICAL, 5 );1295+ 1296+ fgSizer1->Add( bSizer19, 1, wxEXPAND|wxRIGHT, 5 );1297+ 1298+ m_staticText19 = new wxStaticText( this, wxID_ANY, wxT("&Amount:"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_RIGHT );1299+ m_staticText19->Wrap( -1 );1300+ fgSizer1->Add( m_staticText19, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxALIGN_RIGHT, 5 );1301+ 1302+ m_textCtrlAmount = new wxTextCtrl( this, wxID_TEXTCTRLAMOUNT, wxEmptyString, wxDefaultPosition, wxSize( 145,-1 ), 0 );1303+ m_textCtrlAmount->SetMaxLength( 20 ); 1304+ m_textCtrlAmount->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );1305+ 1306+ fgSizer1->Add( m_textCtrlAmount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );1307+ 1308+ m_staticText20 = new wxStaticText( this, wxID_ANY, wxT("T&ransfer:"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_RIGHT );1309+ m_staticText20->Wrap( -1 );1310+ m_staticText20->Hide();1311+ 1312+ fgSizer1->Add( m_staticText20, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );1313+ 1314+ wxString m_choiceTransferTypeChoices[] = { wxT(" Standard") };1315+ int m_choiceTransferTypeNChoices = sizeof( m_choiceTransferTypeChoices ) / sizeof( wxString );1316+ m_choiceTransferType = new wxChoice( this, wxID_CHOICETRANSFERTYPE, wxDefaultPosition, wxDefaultSize, m_choiceTransferTypeNChoices, m_choiceTransferTypeChoices, 0 );1317+ m_choiceTransferType->SetSelection( 0 );1318+ m_choiceTransferType->Hide();1319+ 1320+ fgSizer1->Add( m_choiceTransferType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );1321+ 1322+ 1323+ fgSizer1->Add( 0, 3, 0, wxEXPAND, 5 );1324+ 1325+ 1326+ fgSizer1->Add( 0, 0, 0, wxEXPAND, 5 );1327+ 1328+ bSizer21->Add( fgSizer1, 0, wxEXPAND|wxLEFT, 5 );1329+ 1330+ wxBoxSizer* bSizer672;1331+ bSizer672 = new wxBoxSizer( wxHORIZONTAL );1332+ 1333+ wxBoxSizer* bSizer681;1334+ bSizer681 = new wxBoxSizer( wxVERTICAL );1335+ 1336+ m_staticTextFrom = new wxStaticText( this, wxID_ANY, wxT("&From:"), wxDefaultPosition, wxDefaultSize, 0 );1337+ m_staticTextFrom->Wrap( -1 );1338+ bSizer681->Add( m_staticTextFrom, 0, wxBOTTOM|wxLEFT, 5 );1339+ 1340+ m_textCtrlFrom = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );1341+ bSizer681->Add( m_textCtrlFrom, 0, wxLEFT|wxEXPAND, 5 );1342+ 1343+ bSizer672->Add( bSizer681, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );1344+ 1345+ bSizer21->Add( bSizer672, 0, wxEXPAND, 5 );1346+ 1347+ wxBoxSizer* bSizer67;1348+ bSizer67 = new wxBoxSizer( wxHORIZONTAL );1349+ 1350+ wxBoxSizer* bSizer68;1351+ bSizer68 = new wxBoxSizer( wxVERTICAL );1352+ 1353+ m_staticTextMessage = new wxStaticText( this, wxID_ANY, wxT("&Message:"), wxDefaultPosition, wxDefaultSize, 0 );1354+ m_staticTextMessage->Wrap( -1 );1355+ bSizer68->Add( m_staticTextMessage, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );1356+ 1357+ m_textCtrlMessage = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );1358+ bSizer68->Add( m_textCtrlMessage, 1, wxEXPAND|wxLEFT, 5 );1359+ 1360+ bSizer67->Add( bSizer68, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );1361+ 1362+ bSizer21->Add( bSizer67, 1, wxEXPAND, 5 );1363+ 1364+ wxBoxSizer* bSizer23;1365+ bSizer23 = new wxBoxSizer( wxHORIZONTAL );1366+ 1367+ 1368+ bSizer23->Add( 0, 0, 1, wxEXPAND, 5 );1369+ 1370+ m_buttonSend = new wxButton( this, wxID_BUTTONSEND, wxT("&Send"), wxDefaultPosition, wxSize( -1,-1 ), 0 );1371+ m_buttonSend->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );1372+ 1373+ bSizer23->Add( m_buttonSend, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1374+ 1375+ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );1376+ bSizer23->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1377+ 1378+ bSizer21->Add( bSizer23, 0, wxEXPAND, 5 );1379+ 1380+ this->SetSizer( bSizer21 );1381+ this->Layout();1382+ 1383+ // Connect Events1384+ m_textCtrlAddress->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this );1385+ m_textCtrlAddress->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( CSendDialogBase::OnTextAddress ), NULL, this );1386+ m_buttonPaste->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonPaste ), NULL, this );1387+ m_buttonAddress->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonAddressBook ), NULL, this );1388+ m_textCtrlAmount->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this );1389+ m_textCtrlAmount->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( CSendDialogBase::OnKillFocusAmount ), NULL, this );1390+ m_textCtrlFrom->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this );1391+ m_textCtrlMessage->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this );1392+ m_buttonSend->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonSend ), NULL, this );1393+ m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonCancel ), NULL, this );1394 }1395 1396 CSendDialogBase::~CSendDialogBase()1397 {1398- // Disconnect Events1399- m_textCtrlAddress->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CSendDialogBase::OnKeyDown), NULL, this);1400- m_textCtrlAddress->Disconnect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(CSendDialogBase::OnTextAddress), NULL, this);1401- m_buttonPaste->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendDialogBase::OnButtonPaste), NULL, this);1402- m_buttonAddress->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendDialogBase::OnButtonAddressBook), NULL, this);1403- m_textCtrlAmount->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CSendDialogBase::OnKeyDown), NULL, this);1404- m_textCtrlAmount->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(CSendDialogBase::OnKillFocusAmount), NULL, this);1405- m_textCtrlFrom->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CSendDialogBase::OnKeyDown), NULL, this);1406- m_textCtrlMessage->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CSendDialogBase::OnKeyDown), NULL, this);1407- m_buttonSend->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendDialogBase::OnButtonSend), NULL, this);1408- m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendDialogBase::OnButtonCancel), NULL, this);1409-}1410-1411-CSendingDialogBase::CSendingDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)1412-{1413- this->SetSizeHints(wxDefaultSize, wxDefaultSize);1414-1415- wxBoxSizer* bSizer68;1416- bSizer68 = new wxBoxSizer(wxVERTICAL);1417-1418- m_staticTextSending = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,14), 0);1419- m_staticTextSending->Wrap(-1);1420- bSizer68->Add(m_staticTextSending, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8);1421-1422- m_textCtrlStatus = new wxTextCtrl(this, wxID_ANY, wxT("\n\nConnecting..."), wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE|wxTE_NO_VSCROLL|wxTE_READONLY|wxNO_BORDER);1423- m_textCtrlStatus->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));1424-1425- bSizer68->Add(m_textCtrlStatus, 1, wxEXPAND|wxRIGHT|wxLEFT, 10);1426-1427- wxBoxSizer* bSizer69;1428- bSizer69 = new wxBoxSizer(wxHORIZONTAL);1429-1430-1431- bSizer69->Add(0, 0, 1, wxEXPAND, 5);1432-1433- m_buttonOK = new wxButton(this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0);1434- m_buttonOK->Enable(false);1435- m_buttonOK->SetMinSize(wxSize(85,25));1436-1437- bSizer69->Add(m_buttonOK, 0, wxALL, 5);1438-1439- m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize(-1,-1), 0);1440- m_buttonCancel->SetMinSize(wxSize(85,25));1441-1442- bSizer69->Add(m_buttonCancel, 0, wxALL, 5);1443-1444- bSizer68->Add(bSizer69, 0, wxEXPAND, 5);1445-1446- this->SetSizer(bSizer68);1447- this->Layout();1448-1449- // Connect Events1450- this->Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CSendingDialogBase::OnClose));1451- this->Connect(wxEVT_PAINT, wxPaintEventHandler(CSendingDialogBase::OnPaint));1452- m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendingDialogBase::OnButtonOK), NULL, this);1453- m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendingDialogBase::OnButtonCancel), NULL, this);1454+ // Disconnect Events1455+ m_textCtrlAddress->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this );1456+ m_textCtrlAddress->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( CSendDialogBase::OnTextAddress ), NULL, this );1457+ m_buttonPaste->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonPaste ), NULL, this );1458+ m_buttonAddress->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonAddressBook ), NULL, this );1459+ m_textCtrlAmount->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this );1460+ m_textCtrlAmount->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( CSendDialogBase::OnKillFocusAmount ), NULL, this );1461+ m_textCtrlFrom->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this );1462+ m_textCtrlMessage->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this );1463+ m_buttonSend->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonSend ), NULL, this );1464+ m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonCancel ), NULL, this );1465+}1466+1467+CSendingDialogBase::CSendingDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )1468+{1469+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );1470+ 1471+ wxBoxSizer* bSizer68;1472+ bSizer68 = new wxBoxSizer( wxVERTICAL );1473+ 1474+ m_staticTextSending = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,14 ), 0 );1475+ m_staticTextSending->Wrap( -1 );1476+ bSizer68->Add( m_staticTextSending, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 );1477+ 1478+ m_textCtrlStatus = new wxTextCtrl( this, wxID_ANY, wxT("\n\nConnecting..."), wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE|wxTE_NO_VSCROLL|wxTE_READONLY|wxNO_BORDER );1479+ m_textCtrlStatus->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );1480+ 1481+ bSizer68->Add( m_textCtrlStatus, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 );1482+ 1483+ wxBoxSizer* bSizer69;1484+ bSizer69 = new wxBoxSizer( wxHORIZONTAL );1485+ 1486+ 1487+ bSizer69->Add( 0, 0, 1, wxEXPAND, 5 );1488+ 1489+ m_buttonOK = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );1490+ m_buttonOK->Enable( false );1491+ 1492+ bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1493+ 1494+ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );1495+ bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1496+ 1497+ bSizer68->Add( bSizer69, 0, wxEXPAND, 5 );1498+ 1499+ this->SetSizer( bSizer68 );1500+ this->Layout();1501+ 1502+ // Connect Events1503+ this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CSendingDialogBase::OnClose ) );1504+ this->Connect( wxEVT_PAINT, wxPaintEventHandler( CSendingDialogBase::OnPaint ) );1505+ m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendingDialogBase::OnButtonOK ), NULL, this );1506+ m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendingDialogBase::OnButtonCancel ), NULL, this );1507 }1508 1509 CSendingDialogBase::~CSendingDialogBase()1510 {1511- // Disconnect Events1512- this->Disconnect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CSendingDialogBase::OnClose));1513- this->Disconnect(wxEVT_PAINT, wxPaintEventHandler(CSendingDialogBase::OnPaint));1514- m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendingDialogBase::OnButtonOK), NULL, this);1515- m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CSendingDialogBase::OnButtonCancel), NULL, this);1516-}1517-1518-CYourAddressDialogBase::CYourAddressDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)1519-{1520- this->SetSizeHints(wxDefaultSize, wxDefaultSize);1521-1522- wxBoxSizer* bSizer68;1523- bSizer68 = new wxBoxSizer(wxVERTICAL);1524-1525-1526- bSizer68->Add(0, 5, 0, wxEXPAND, 5);1527-1528- m_staticText45 = new wxStaticText(this, wxID_ANY, wxT("These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. The highlighted address is displayed in the main window."), wxDefaultPosition, wxDefaultSize, 0);1529- m_staticText45->Wrap(590);1530- bSizer68->Add(m_staticText45, 0, wxALL, 5);1531-1532- m_listCtrl = new wxListCtrl(this, wxID_LISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING);1533- bSizer68->Add(m_listCtrl, 1, wxALL|wxEXPAND, 5);1534-1535- wxBoxSizer* bSizer69;1536- bSizer69 = new wxBoxSizer(wxHORIZONTAL);1537-1538-1539- bSizer69->Add(0, 0, 1, wxEXPAND, 5);1540-1541- m_buttonRename = new wxButton(this, wxID_BUTTONRENAME, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0);1542- m_buttonRename->SetMinSize(wxSize(85,25));1543-1544- bSizer69->Add(m_buttonRename, 0, wxALL, 5);1545-1546- m_buttonNew = new wxButton(this, wxID_BUTTONNEW, wxT("&New Address..."), wxDefaultPosition, wxSize(-1,-1), 0);1547- m_buttonNew->SetMinSize(wxSize(110,25));1548-1549- bSizer69->Add(m_buttonNew, 0, wxALL, 5);1550-1551- m_buttonCopy = new wxButton(this, wxID_BUTTONCOPY, wxT("&Copy to Clipboard"), wxDefaultPosition, wxSize(-1,-1), 0);1552- m_buttonCopy->SetMinSize(wxSize(120,25));1553-1554- bSizer69->Add(m_buttonCopy, 0, wxALL, 5);1555-1556- m_buttonOK = new wxButton(this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0);1557- m_buttonOK->SetMinSize(wxSize(85,25));1558-1559- bSizer69->Add(m_buttonOK, 0, wxALL, 5);1560-1561- m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize(-1,-1), 0);1562- m_buttonCancel->Hide();1563- m_buttonCancel->SetMinSize(wxSize(85,25));1564-1565- bSizer69->Add(m_buttonCancel, 0, wxALL, 5);1566-1567- bSizer68->Add(bSizer69, 0, wxEXPAND, 5);1568-1569- this->SetSizer(bSizer68);1570- this->Layout();1571-1572- // Connect Events1573- this->Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CYourAddressDialogBase::OnClose));1574- m_listCtrl->Connect(wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler(CYourAddressDialogBase::OnListEndLabelEdit), NULL, this);1575- m_listCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CYourAddressDialogBase::OnListItemActivated), NULL, this);1576- m_listCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler(CYourAddressDialogBase::OnListItemSelected), NULL, this);1577- m_buttonRename->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonRename), NULL, this);1578- m_buttonNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonNew), NULL, this);1579- m_buttonCopy->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonCopy), NULL, this);1580- m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonOK), NULL, this);1581- m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonCancel), NULL, this);1582+ // Disconnect Events1583+ this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CSendingDialogBase::OnClose ) );1584+ this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CSendingDialogBase::OnPaint ) );1585+ m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendingDialogBase::OnButtonOK ), NULL, this );1586+ m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendingDialogBase::OnButtonCancel ), NULL, this );1587+}1588+1589+CYourAddressDialogBase::CYourAddressDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )1590+{1591+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );1592+ 1593+ wxBoxSizer* bSizer68;1594+ bSizer68 = new wxBoxSizer( wxVERTICAL );1595+ 1596+ 1597+ bSizer68->Add( 0, 5, 0, wxEXPAND, 5 );1598+ 1599+ m_staticText45 = new wxStaticText( this, wxID_ANY, wxT("These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. The highlighted address is displayed in the main window."), wxDefaultPosition, wxDefaultSize, 0 );1600+ m_staticText45->Wrap( 590 );1601+ bSizer68->Add( m_staticText45, 0, wxALL, 5 );1602+ 1603+ m_listCtrl = new wxListCtrl( this, wxID_LISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING );1604+ bSizer68->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );1605+ 1606+ wxBoxSizer* bSizer69;1607+ bSizer69 = new wxBoxSizer( wxHORIZONTAL );1608+ 1609+ 1610+ bSizer69->Add( 0, 0, 1, wxEXPAND, 5 );1611+ 1612+ m_buttonRename = new wxButton( this, wxID_BUTTONRENAME, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );1613+ bSizer69->Add( m_buttonRename, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1614+ 1615+ m_buttonNew = new wxButton( this, wxID_BUTTONNEW, wxT(" &New Address... "), wxDefaultPosition, wxSize( -1,-1 ), 0 );1616+ bSizer69->Add( m_buttonNew, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1617+ 1618+ m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, wxT(" &Copy to Clipboard "), wxDefaultPosition, wxSize( -1,-1 ), 0 );1619+ bSizer69->Add( m_buttonCopy, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1620+ 1621+ m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );1622+ bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1623+ 1624+ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );1625+ m_buttonCancel->Hide();1626+ 1627+ bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1628+ 1629+ bSizer68->Add( bSizer69, 0, wxEXPAND, 5 );1630+ 1631+ this->SetSizer( bSizer68 );1632+ this->Layout();1633+ 1634+ // Connect Events1635+ this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CYourAddressDialogBase::OnClose ) );1636+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CYourAddressDialogBase::OnListEndLabelEdit ), NULL, this );1637+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CYourAddressDialogBase::OnListItemActivated ), NULL, this );1638+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CYourAddressDialogBase::OnListItemSelected ), NULL, this );1639+ m_buttonRename->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonRename ), NULL, this );1640+ m_buttonNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonNew ), NULL, this );1641+ m_buttonCopy->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonCopy ), NULL, this );1642+ m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonOK ), NULL, this );1643+ m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonCancel ), NULL, this );1644 }1645 1646 CYourAddressDialogBase::~CYourAddressDialogBase()1647 {1648- // Disconnect Events1649- this->Disconnect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CYourAddressDialogBase::OnClose));1650- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler(CYourAddressDialogBase::OnListEndLabelEdit), NULL, this);1651- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CYourAddressDialogBase::OnListItemActivated), NULL, this);1652- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler(CYourAddressDialogBase::OnListItemSelected), NULL, this);1653- m_buttonRename->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonRename), NULL, this);1654- m_buttonNew->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonNew), NULL, this);1655- m_buttonCopy->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonCopy), NULL, this);1656- m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonOK), NULL, this);1657- m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CYourAddressDialogBase::OnButtonCancel), NULL, this);1658-}1659-1660-CAddressBookDialogBase::CAddressBookDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)1661-{1662- this->SetSizeHints(wxDefaultSize, wxDefaultSize);1663-1664- wxBoxSizer* bSizer68;1665- bSizer68 = new wxBoxSizer(wxVERTICAL);1666-1667-1668- bSizer68->Add(0, 5, 0, wxEXPAND, 5);1669-1670- m_staticText55 = new wxStaticText(this, wxID_ANY, wxT("Bitcoin Address"), wxDefaultPosition, wxDefaultSize, 0);1671- m_staticText55->Wrap(-1);1672- m_staticText55->Hide();1673-1674- bSizer68->Add(m_staticText55, 0, wxTOP|wxRIGHT|wxLEFT, 5);1675-1676- m_listCtrl = new wxListCtrl(this, wxID_LISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING);1677- bSizer68->Add(m_listCtrl, 1, wxALL|wxEXPAND, 5);1678-1679- wxBoxSizer* bSizer69;1680- bSizer69 = new wxBoxSizer(wxHORIZONTAL);1681-1682-1683- bSizer69->Add(0, 0, 1, wxEXPAND, 5);1684-1685- m_buttonEdit = new wxButton(this, wxID_BUTTONEDIT, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0);1686- m_buttonEdit->SetMinSize(wxSize(85,25));1687-1688- bSizer69->Add(m_buttonEdit, 0, wxALL, 5);1689-1690- m_buttonNew = new wxButton(this, wxID_BUTTONNEW, wxT("&New Address..."), wxDefaultPosition, wxDefaultSize, 0);1691- m_buttonNew->SetMinSize(wxSize(110,25));1692-1693- bSizer69->Add(m_buttonNew, 0, wxALL, 5);1694-1695- m_buttonDelete = new wxButton(this, wxID_BUTTONDELETE, wxT("&Delete"), wxDefaultPosition, wxDefaultSize, 0);1696- m_buttonDelete->SetMinSize(wxSize(85,25));1697-1698- bSizer69->Add(m_buttonDelete, 0, wxALL, 5);1699-1700- m_buttonOK = new wxButton(this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize(-1,-1), 0);1701- m_buttonOK->SetMinSize(wxSize(85,25));1702-1703- bSizer69->Add(m_buttonOK, 0, wxALL, 5);1704-1705- m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize(-1,-1), 0);1706- m_buttonCancel->SetMinSize(wxSize(85,25));1707-1708- bSizer69->Add(m_buttonCancel, 0, wxALL, 5);1709-1710- bSizer68->Add(bSizer69, 0, wxEXPAND, 5);1711-1712- this->SetSizer(bSizer68);1713- this->Layout();1714-1715- // Connect Events1716- this->Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CAddressBookDialogBase::OnClose));1717- m_listCtrl->Connect(wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler(CAddressBookDialogBase::OnListEndLabelEdit), NULL, this);1718- m_listCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CAddressBookDialogBase::OnListItemActivated), NULL, this);1719- m_listCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler(CAddressBookDialogBase::OnListItemSelected), NULL, this);1720- m_buttonEdit->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonEdit), NULL, this);1721- m_buttonNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonNew), NULL, this);1722- m_buttonDelete->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonDelete), NULL, this);1723- m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonOK), NULL, this);1724- m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonCancel), NULL, this);1725+ // Disconnect Events1726+ this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CYourAddressDialogBase::OnClose ) );1727+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CYourAddressDialogBase::OnListEndLabelEdit ), NULL, this );1728+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CYourAddressDialogBase::OnListItemActivated ), NULL, this );1729+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CYourAddressDialogBase::OnListItemSelected ), NULL, this );1730+ m_buttonRename->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonRename ), NULL, this );1731+ m_buttonNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonNew ), NULL, this );1732+ m_buttonCopy->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonCopy ), NULL, this );1733+ m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonOK ), NULL, this );1734+ m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CYourAddressDialogBase::OnButtonCancel ), NULL, this );1735+}1736+1737+CAddressBookDialogBase::CAddressBookDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )1738+{1739+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );1740+ 1741+ wxBoxSizer* bSizer68;1742+ bSizer68 = new wxBoxSizer( wxVERTICAL );1743+ 1744+ 1745+ bSizer68->Add( 0, 5, 0, wxEXPAND, 5 );1746+ 1747+ m_staticText55 = new wxStaticText( this, wxID_ANY, wxT("Bitcoin Address"), wxDefaultPosition, wxDefaultSize, 0 );1748+ m_staticText55->Wrap( -1 );1749+ m_staticText55->Hide();1750+ 1751+ bSizer68->Add( m_staticText55, 0, wxTOP|wxRIGHT|wxLEFT, 5 );1752+ 1753+ m_listCtrl = new wxListCtrl( this, wxID_LISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING );1754+ bSizer68->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );1755+ 1756+ wxBoxSizer* bSizer69;1757+ bSizer69 = new wxBoxSizer( wxHORIZONTAL );1758+ 1759+ 1760+ bSizer69->Add( 0, 0, 1, wxEXPAND, 5 );1761+ 1762+ m_buttonEdit = new wxButton( this, wxID_BUTTONEDIT, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );1763+ bSizer69->Add( m_buttonEdit, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1764+ 1765+ m_buttonNew = new wxButton( this, wxID_BUTTONNEW, wxT(" &New Address... "), wxDefaultPosition, wxDefaultSize, 0 );1766+ bSizer69->Add( m_buttonNew, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1767+ 1768+ m_buttonDelete = new wxButton( this, wxID_BUTTONDELETE, wxT("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );1769+ bSizer69->Add( m_buttonDelete, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1770+ 1771+ m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );1772+ bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1773+ 1774+ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );1775+ bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1776+ 1777+ bSizer68->Add( bSizer69, 0, wxEXPAND, 5 );1778+ 1779+ this->SetSizer( bSizer68 );1780+ this->Layout();1781+ 1782+ // Connect Events1783+ this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CAddressBookDialogBase::OnClose ) );1784+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );1785+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );1786+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );1787+ m_buttonEdit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonEdit ), NULL, this );1788+ m_buttonNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonNew ), NULL, this );1789+ m_buttonDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );1790+ m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonOK ), NULL, this );1791+ m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCancel ), NULL, this );1792 }1793 1794 CAddressBookDialogBase::~CAddressBookDialogBase()1795 {1796- // Disconnect Events1797- this->Disconnect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CAddressBookDialogBase::OnClose));1798- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler(CAddressBookDialogBase::OnListEndLabelEdit), NULL, this);1799- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CAddressBookDialogBase::OnListItemActivated), NULL, this);1800- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler(CAddressBookDialogBase::OnListItemSelected), NULL, this);1801- m_buttonEdit->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonEdit), NULL, this);1802- m_buttonNew->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonNew), NULL, this);1803- m_buttonDelete->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonDelete), NULL, this);1804- m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonOK), NULL, this);1805- m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CAddressBookDialogBase::OnButtonCancel), NULL, this);1806-}1807-1808-CProductsDialogBase::CProductsDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)1809-{1810- this->SetSizeHints(wxDefaultSize, wxDefaultSize);1811-1812- wxBoxSizer* bSizer22;1813- bSizer22 = new wxBoxSizer(wxVERTICAL);1814-1815- wxBoxSizer* bSizer23;1816- bSizer23 = new wxBoxSizer(wxHORIZONTAL);1817-1818- m_comboBoxCategory = new wxComboBox(this, wxID_ANY, wxT("(Any Category)"), wxDefaultPosition, wxSize(150,-1), 0, NULL, 0);1819- m_comboBoxCategory->Append(wxT("(Any Category)"));1820- bSizer23->Add(m_comboBoxCategory, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);1821-1822- m_textCtrlSearch = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);1823- bSizer23->Add(m_textCtrlSearch, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5);1824-1825- m_buttonSearch = new wxButton(this, wxID_ANY, wxT("&Search"), wxDefaultPosition, wxDefaultSize, 0);1826- bSizer23->Add(m_buttonSearch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);1827-1828- bSizer22->Add(bSizer23, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5);1829-1830- m_listCtrl = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT);1831- bSizer22->Add(m_listCtrl, 1, wxALL|wxEXPAND, 5);1832-1833- this->SetSizer(bSizer22);1834- this->Layout();1835-1836- // Connect Events1837- m_comboBoxCategory->Connect(wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(CProductsDialogBase::OnCombobox), NULL, this);1838- m_textCtrlSearch->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CProductsDialogBase::OnKeyDown), NULL, this);1839- m_buttonSearch->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CProductsDialogBase::OnButtonSearch), NULL, this);1840- m_listCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CProductsDialogBase::OnListItemActivated), NULL, this);1841+ // Disconnect Events1842+ this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CAddressBookDialogBase::OnClose ) );1843+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );1844+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );1845+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );1846+ m_buttonEdit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonEdit ), NULL, this );1847+ m_buttonNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonNew ), NULL, this );1848+ m_buttonDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );1849+ m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonOK ), NULL, this );1850+ m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCancel ), NULL, this );1851+}1852+1853+CProductsDialogBase::CProductsDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )1854+{1855+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );1856+ 1857+ wxBoxSizer* bSizer22;1858+ bSizer22 = new wxBoxSizer( wxVERTICAL );1859+ 1860+ wxBoxSizer* bSizer23;1861+ bSizer23 = new wxBoxSizer( wxHORIZONTAL );1862+ 1863+ m_comboBoxCategory = new wxComboBox( this, wxID_ANY, wxT("(Any Category)"), wxDefaultPosition, wxSize( 150,-1 ), 0, NULL, 0 );1864+ m_comboBoxCategory->Append( wxT("(Any Category)") );1865+ bSizer23->Add( m_comboBoxCategory, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );1866+ 1867+ m_textCtrlSearch = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );1868+ bSizer23->Add( m_textCtrlSearch, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );1869+ 1870+ m_buttonSearch = new wxButton( this, wxID_ANY, wxT("&Search"), wxDefaultPosition, wxDefaultSize, 0 );1871+ bSizer23->Add( m_buttonSearch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );1872+ 1873+ bSizer22->Add( bSizer23, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );1874+ 1875+ m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );1876+ bSizer22->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );1877+ 1878+ this->SetSizer( bSizer22 );1879+ this->Layout();1880+ 1881+ // Connect Events1882+ m_comboBoxCategory->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( CProductsDialogBase::OnCombobox ), NULL, this );1883+ m_textCtrlSearch->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CProductsDialogBase::OnKeyDown ), NULL, this );1884+ m_buttonSearch->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CProductsDialogBase::OnButtonSearch ), NULL, this );1885+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CProductsDialogBase::OnListItemActivated ), NULL, this );1886 }1887 1888 CProductsDialogBase::~CProductsDialogBase()1889 {1890- // Disconnect Events1891- m_comboBoxCategory->Disconnect(wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(CProductsDialogBase::OnCombobox), NULL, this);1892- m_textCtrlSearch->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CProductsDialogBase::OnKeyDown), NULL, this);1893- m_buttonSearch->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CProductsDialogBase::OnButtonSearch), NULL, this);1894- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CProductsDialogBase::OnListItemActivated), NULL, this);1895-}1896-1897-CEditProductDialogBase::CEditProductDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style)1898-{1899- this->SetSizeHints(wxDefaultSize, wxDefaultSize);1900- this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENU));1901-1902- wxBoxSizer* bSizer20;1903- bSizer20 = new wxBoxSizer(wxVERTICAL);1904-1905- m_scrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL);1906- m_scrolledWindow->SetScrollRate(5, 5);1907- m_scrolledWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));1908-1909- wxBoxSizer* bSizer21;1910- bSizer21 = new wxBoxSizer(wxVERTICAL);1911-1912- wxFlexGridSizer* fgSizer8;1913- fgSizer8 = new wxFlexGridSizer(0, 2, 0, 0);1914- fgSizer8->AddGrowableCol(1);1915- fgSizer8->SetFlexibleDirection(wxBOTH);1916- fgSizer8->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);1917-1918- m_staticText106 = new wxStaticText(m_scrolledWindow, wxID_ANY, wxT("Category"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);1919- m_staticText106->Wrap(-1);1920- fgSizer8->Add(m_staticText106, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5);1921-1922- m_comboBoxCategory = new wxComboBox(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0);1923- m_comboBoxCategory->SetMinSize(wxSize(180,-1));1924-1925- fgSizer8->Add(m_comboBoxCategory, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);1926-1927- m_staticText108 = new wxStaticText(m_scrolledWindow, wxID_ANY, wxT("Title"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);1928- m_staticText108->Wrap(-1);1929- fgSizer8->Add(m_staticText108, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5);1930-1931- m_textCtrlTitle = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);1932- fgSizer8->Add(m_textCtrlTitle, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5);1933-1934- m_staticText107 = new wxStaticText(m_scrolledWindow, wxID_ANY, wxT("Price"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);1935- m_staticText107->Wrap(-1);1936- fgSizer8->Add(m_staticText107, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5);1937-1938- m_textCtrlPrice = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);1939- m_textCtrlPrice->SetMinSize(wxSize(105,-1));1940-1941- fgSizer8->Add(m_textCtrlPrice, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);1942-1943- bSizer21->Add(fgSizer8, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5);1944-1945- m_staticText22 = new wxStaticText(m_scrolledWindow, wxID_ANY, wxT("Page 1: Description"), wxDefaultPosition, wxDefaultSize, 0);1946- m_staticText22->Wrap(-1);1947- bSizer21->Add(m_staticText22, 0, wxTOP|wxRIGHT|wxLEFT, 5);1948-1949- m_textCtrlDescription = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);1950- m_textCtrlDescription->SetMinSize(wxSize(-1,170));1951-1952- bSizer21->Add(m_textCtrlDescription, 0, wxALL|wxEXPAND, 5);1953-1954- m_staticText23 = new wxStaticText(m_scrolledWindow, wxID_ANY, wxT("Page 2: Order Form"), wxDefaultPosition, wxDefaultSize, 0);1955- m_staticText23->Wrap(-1);1956- bSizer21->Add(m_staticText23, 0, wxTOP|wxRIGHT|wxLEFT, 5);1957-1958- m_textCtrlInstructions = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);1959- m_textCtrlInstructions->SetMinSize(wxSize(-1,120));1960-1961- bSizer21->Add(m_textCtrlInstructions, 0, wxEXPAND|wxALL, 5);1962-1963- fgSizer5 = new wxFlexGridSizer(0, 3, 0, 0);1964- fgSizer5->AddGrowableCol(1);1965- fgSizer5->SetFlexibleDirection(wxBOTH);1966- fgSizer5->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);1967-1968- m_staticText24 = new wxStaticText(m_scrolledWindow, wxID_ANY, wxT("Label"), wxDefaultPosition, wxDefaultSize, 0);1969- m_staticText24->Wrap(-1);1970- fgSizer5->Add(m_staticText24, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5);1971-1972- m_staticText25 = new wxStaticText(m_scrolledWindow, wxID_ANY, wxT("Comma separated list of choices, or leave blank for text field"), wxDefaultPosition, wxDefaultSize, 0);1973- m_staticText25->Wrap(-1);1974- fgSizer5->Add(m_staticText25, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5);1975-1976-1977- fgSizer5->Add(0, 0, 1, wxEXPAND, 5);1978-1979- m_textCtrlLabel0 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);1980- m_textCtrlLabel0->SetMinSize(wxSize(150,-1));1981-1982- fgSizer5->Add(m_textCtrlLabel0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);1983-1984- m_textCtrlField0 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);1985- fgSizer5->Add(m_textCtrlField0, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);1986-1987- m_buttonDel0 = new wxButton(m_scrolledWindow, wxID_DEL0, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);1988- fgSizer5->Add(m_buttonDel0, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5);1989-1990- m_textCtrlLabel1 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);1991- m_textCtrlLabel1->SetMinSize(wxSize(150,-1));1992-1993- fgSizer5->Add(m_textCtrlLabel1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);1994-1995- m_textCtrlField1 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);1996- fgSizer5->Add(m_textCtrlField1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);1997-1998- m_buttonDel1 = new wxButton(m_scrolledWindow, wxID_DEL1, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);1999- fgSizer5->Add(m_buttonDel1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2000-2001- m_textCtrlLabel2 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2002- m_textCtrlLabel2->SetMinSize(wxSize(150,-1));2003-2004- fgSizer5->Add(m_textCtrlLabel2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2005-2006- m_textCtrlField2 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2007- fgSizer5->Add(m_textCtrlField2, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2008-2009- m_buttonDel2 = new wxButton(m_scrolledWindow, wxID_DEL2, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2010- fgSizer5->Add(m_buttonDel2, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2011-2012- m_textCtrlLabel3 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2013- m_textCtrlLabel3->SetMinSize(wxSize(150,-1));2014-2015- fgSizer5->Add(m_textCtrlLabel3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2016-2017- m_textCtrlField3 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2018- fgSizer5->Add(m_textCtrlField3, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2019-2020- m_buttonDel3 = new wxButton(m_scrolledWindow, wxID_DEL3, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2021- fgSizer5->Add(m_buttonDel3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2022-2023- m_textCtrlLabel4 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2024- m_textCtrlLabel4->SetMinSize(wxSize(150,-1));2025-2026- fgSizer5->Add(m_textCtrlLabel4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2027-2028- m_textCtrlField4 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2029- fgSizer5->Add(m_textCtrlField4, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2030-2031- m_buttonDel4 = new wxButton(m_scrolledWindow, wxID_DEL4, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2032- fgSizer5->Add(m_buttonDel4, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2033-2034- m_textCtrlLabel5 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2035- m_textCtrlLabel5->SetMinSize(wxSize(150,-1));2036-2037- fgSizer5->Add(m_textCtrlLabel5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2038-2039- m_textCtrlField5 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2040- fgSizer5->Add(m_textCtrlField5, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2041-2042- m_buttonDel5 = new wxButton(m_scrolledWindow, wxID_DEL5, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2043- fgSizer5->Add(m_buttonDel5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2044-2045- m_textCtrlLabel6 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2046- m_textCtrlLabel6->SetMinSize(wxSize(150,-1));2047-2048- fgSizer5->Add(m_textCtrlLabel6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2049-2050- m_textCtrlField6 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2051- fgSizer5->Add(m_textCtrlField6, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2052-2053- m_buttonDel6 = new wxButton(m_scrolledWindow, wxID_DEL6, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2054- fgSizer5->Add(m_buttonDel6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2055-2056- m_textCtrlLabel7 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2057- m_textCtrlLabel7->SetMinSize(wxSize(150,-1));2058-2059- fgSizer5->Add(m_textCtrlLabel7, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2060-2061- m_textCtrlField7 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2062- fgSizer5->Add(m_textCtrlField7, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2063-2064- m_buttonDel7 = new wxButton(m_scrolledWindow, wxID_DEL7, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2065- fgSizer5->Add(m_buttonDel7, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2066-2067- m_textCtrlLabel8 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2068- m_textCtrlLabel8->SetMinSize(wxSize(150,-1));2069-2070- fgSizer5->Add(m_textCtrlLabel8, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2071-2072- m_textCtrlField8 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2073- fgSizer5->Add(m_textCtrlField8, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2074-2075- m_buttonDel8 = new wxButton(m_scrolledWindow, wxID_DEL8, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2076- fgSizer5->Add(m_buttonDel8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2077-2078- m_textCtrlLabel9 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2079- m_textCtrlLabel9->SetMinSize(wxSize(150,-1));2080-2081- fgSizer5->Add(m_textCtrlLabel9, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2082-2083- m_textCtrlField9 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2084- fgSizer5->Add(m_textCtrlField9, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2085-2086- m_buttonDel9 = new wxButton(m_scrolledWindow, wxID_DEL9, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2087- fgSizer5->Add(m_buttonDel9, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2088-2089- m_textCtrlLabel10 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2090- m_textCtrlLabel10->SetMinSize(wxSize(150,-1));2091-2092- fgSizer5->Add(m_textCtrlLabel10, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2093-2094- m_textCtrlField10 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2095- fgSizer5->Add(m_textCtrlField10, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2096-2097- m_buttonDel10 = new wxButton(m_scrolledWindow, wxID_DEL10, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2098- fgSizer5->Add(m_buttonDel10, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2099-2100- m_textCtrlLabel11 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2101- m_textCtrlLabel11->SetMinSize(wxSize(150,-1));2102-2103- fgSizer5->Add(m_textCtrlLabel11, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2104-2105- m_textCtrlField11 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2106- fgSizer5->Add(m_textCtrlField11, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2107-2108- m_buttonDel11 = new wxButton(m_scrolledWindow, wxID_DEL11, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2109- fgSizer5->Add(m_buttonDel11, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2110-2111- m_textCtrlLabel12 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2112- m_textCtrlLabel12->SetMinSize(wxSize(150,-1));2113-2114- fgSizer5->Add(m_textCtrlLabel12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2115-2116- m_textCtrlField12 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2117- fgSizer5->Add(m_textCtrlField12, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2118-2119- m_buttonDel12 = new wxButton(m_scrolledWindow, wxID_DEL12, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2120- fgSizer5->Add(m_buttonDel12, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2121-2122- m_textCtrlLabel13 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2123- m_textCtrlLabel13->SetMinSize(wxSize(150,-1));2124-2125- fgSizer5->Add(m_textCtrlLabel13, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2126-2127- m_textCtrlField13 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2128- fgSizer5->Add(m_textCtrlField13, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2129-2130- m_buttonDel13 = new wxButton(m_scrolledWindow, wxID_DEL13, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2131- fgSizer5->Add(m_buttonDel13, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2132-2133- m_textCtrlLabel14 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2134- m_textCtrlLabel14->SetMinSize(wxSize(150,-1));2135-2136- fgSizer5->Add(m_textCtrlLabel14, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2137-2138- m_textCtrlField14 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2139- fgSizer5->Add(m_textCtrlField14, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2140-2141- m_buttonDel14 = new wxButton(m_scrolledWindow, wxID_DEL14, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2142- fgSizer5->Add(m_buttonDel14, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2143-2144- m_textCtrlLabel15 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2145- m_textCtrlLabel15->SetMinSize(wxSize(150,-1));2146-2147- fgSizer5->Add(m_textCtrlLabel15, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2148-2149- m_textCtrlField15 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2150- fgSizer5->Add(m_textCtrlField15, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2151-2152- m_buttonDel15 = new wxButton(m_scrolledWindow, wxID_DEL15, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2153- fgSizer5->Add(m_buttonDel15, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2154-2155- m_textCtrlLabel16 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2156- m_textCtrlLabel16->SetMinSize(wxSize(150,-1));2157-2158- fgSizer5->Add(m_textCtrlLabel16, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2159-2160- m_textCtrlField16 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2161- fgSizer5->Add(m_textCtrlField16, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2162-2163- m_buttonDel16 = new wxButton(m_scrolledWindow, wxID_DEL16, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2164- fgSizer5->Add(m_buttonDel16, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2165-2166- m_textCtrlLabel17 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2167- m_textCtrlLabel17->SetMinSize(wxSize(150,-1));2168-2169- fgSizer5->Add(m_textCtrlLabel17, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2170-2171- m_textCtrlField17 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2172- fgSizer5->Add(m_textCtrlField17, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2173-2174- m_buttonDel17 = new wxButton(m_scrolledWindow, wxID_DEL17, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2175- fgSizer5->Add(m_buttonDel17, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2176-2177- m_textCtrlLabel18 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2178- m_textCtrlLabel18->SetMinSize(wxSize(150,-1));2179-2180- fgSizer5->Add(m_textCtrlLabel18, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2181-2182- m_textCtrlField18 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2183- fgSizer5->Add(m_textCtrlField18, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2184-2185- m_buttonDel18 = new wxButton(m_scrolledWindow, wxID_DEL18, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2186- fgSizer5->Add(m_buttonDel18, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2187-2188- m_textCtrlLabel19 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);2189- m_textCtrlLabel19->SetMinSize(wxSize(150,-1));2190-2191- fgSizer5->Add(m_textCtrlLabel19, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);2192-2193- m_textCtrlField19 = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), 0);2194- fgSizer5->Add(m_textCtrlField19, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);2195-2196- m_buttonDel19 = new wxButton(m_scrolledWindow, wxID_DEL19, wxT("Delete"), wxDefaultPosition, wxSize(60,20), 0);2197- fgSizer5->Add(m_buttonDel19, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5);2198-2199- bSizer21->Add(fgSizer5, 0, wxEXPAND, 5);2200-2201- wxBoxSizer* bSizer25;2202- bSizer25 = new wxBoxSizer(wxHORIZONTAL);2203-2204- m_buttonAddField = new wxButton(m_scrolledWindow, wxID_ANY, wxT("&Add Field"), wxDefaultPosition, wxDefaultSize, 0);2205- bSizer25->Add(m_buttonAddField, 0, wxALL, 5);2206-2207- bSizer21->Add(bSizer25, 0, wxALIGN_CENTER_HORIZONTAL, 5);2208-2209- m_scrolledWindow->SetSizer(bSizer21);2210- m_scrolledWindow->Layout();2211- bSizer21->Fit(m_scrolledWindow);2212- bSizer20->Add(m_scrolledWindow, 1, wxEXPAND|wxALL, 5);2213-2214- wxBoxSizer* bSizer26;2215- bSizer26 = new wxBoxSizer(wxHORIZONTAL);2216-2217- m_buttonOK = new wxButton(this, wxID_BUTTONSEND, wxT("&Send"), wxDefaultPosition, wxDefaultSize, 0);2218- m_buttonOK->SetMinSize(wxSize(85,25));2219-2220- bSizer26->Add(m_buttonOK, 0, wxALL, 5);2221-2222- m_buttonPreview = new wxButton(this, wxID_BUTTONPREVIEW, wxT("&Preview"), wxDefaultPosition, wxDefaultSize, 0);2223- m_buttonPreview->SetMinSize(wxSize(85,25));2224-2225- bSizer26->Add(m_buttonPreview, 0, wxALL, 5);2226-2227- m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0);2228- m_buttonCancel->SetMinSize(wxSize(85,25));2229-2230- bSizer26->Add(m_buttonCancel, 0, wxALL, 5);2231-2232- bSizer20->Add(bSizer26, 0, wxALIGN_RIGHT, 5);2233-2234- this->SetSizer(bSizer20);2235- this->Layout();2236-2237- // Connect Events2238- m_textCtrlTitle->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2239- m_textCtrlPrice->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2240- m_textCtrlDescription->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2241- m_textCtrlInstructions->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2242- m_textCtrlLabel0->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2243- m_textCtrlField0->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2244- m_buttonDel0->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel0), NULL, this);2245- m_textCtrlLabel1->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2246- m_textCtrlField1->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2247- m_buttonDel1->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel1), NULL, this);2248- m_textCtrlLabel2->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2249- m_textCtrlField2->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2250- m_buttonDel2->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel2), NULL, this);2251- m_textCtrlLabel3->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2252- m_textCtrlField3->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2253- m_buttonDel3->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel3), NULL, this);2254- m_textCtrlLabel4->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2255- m_textCtrlField4->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2256- m_buttonDel4->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel4), NULL, this);2257- m_textCtrlLabel5->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2258- m_textCtrlField5->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2259- m_buttonDel5->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel5), NULL, this);2260- m_textCtrlLabel6->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2261- m_textCtrlField6->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2262- m_buttonDel6->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel6), NULL, this);2263- m_textCtrlLabel7->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2264- m_textCtrlField7->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2265- m_buttonDel7->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel7), NULL, this);2266- m_textCtrlLabel8->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2267- m_textCtrlField8->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2268- m_buttonDel8->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel8), NULL, this);2269- m_textCtrlLabel9->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2270- m_textCtrlField9->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2271- m_buttonDel9->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel9), NULL, this);2272- m_textCtrlLabel10->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2273- m_textCtrlField10->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2274- m_buttonDel10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel10), NULL, this);2275- m_textCtrlLabel11->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2276- m_textCtrlField11->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2277- m_buttonDel11->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel11), NULL, this);2278- m_textCtrlLabel12->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2279- m_textCtrlField12->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2280- m_buttonDel12->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel12), NULL, this);2281- m_textCtrlLabel13->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2282- m_textCtrlField13->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2283- m_buttonDel13->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel13), NULL, this);2284- m_textCtrlLabel14->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2285- m_textCtrlField14->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2286- m_buttonDel14->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel14), NULL, this);2287- m_textCtrlLabel15->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2288- m_textCtrlField15->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2289- m_buttonDel15->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel15), NULL, this);2290- m_textCtrlLabel16->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2291- m_textCtrlField16->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2292- m_buttonDel16->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel16), NULL, this);2293- m_textCtrlLabel17->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2294- m_textCtrlField17->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2295- m_buttonDel17->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel17), NULL, this);2296- m_textCtrlLabel18->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2297- m_textCtrlField18->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2298- m_buttonDel18->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel18), NULL, this);2299- m_textCtrlLabel19->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2300- m_textCtrlField19->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2301- m_buttonDel19->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel19), NULL, this);2302- m_buttonAddField->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonAddField), NULL, this);2303- m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonSend), NULL, this);2304- m_buttonPreview->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonPreview), NULL, this);2305- m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonCancel), NULL, this);2306+ // Disconnect Events2307+ m_comboBoxCategory->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( CProductsDialogBase::OnCombobox ), NULL, this );2308+ m_textCtrlSearch->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CProductsDialogBase::OnKeyDown ), NULL, this );2309+ m_buttonSearch->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CProductsDialogBase::OnButtonSearch ), NULL, this );2310+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CProductsDialogBase::OnListItemActivated ), NULL, this );2311+}2312+2313+CEditProductDialogBase::CEditProductDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )2314+{2315+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );2316+ this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );2317+ 2318+ wxBoxSizer* bSizer20;2319+ bSizer20 = new wxBoxSizer( wxVERTICAL );2320+ 2321+ m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL );2322+ m_scrolledWindow->SetScrollRate( 5, 5 );2323+ m_scrolledWindow->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );2324+ 2325+ wxBoxSizer* bSizer21;2326+ bSizer21 = new wxBoxSizer( wxVERTICAL );2327+ 2328+ wxFlexGridSizer* fgSizer8;2329+ fgSizer8 = new wxFlexGridSizer( 0, 2, 0, 0 );2330+ fgSizer8->AddGrowableCol( 1 );2331+ fgSizer8->SetFlexibleDirection( wxBOTH );2332+ fgSizer8->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );2333+ 2334+ m_staticText106 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Category"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );2335+ m_staticText106->Wrap( -1 );2336+ fgSizer8->Add( m_staticText106, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );2337+ 2338+ m_comboBoxCategory = new wxComboBox( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); 2339+ m_comboBoxCategory->SetMinSize( wxSize( 180,-1 ) );2340+ 2341+ fgSizer8->Add( m_comboBoxCategory, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2342+ 2343+ m_staticText108 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Title"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );2344+ m_staticText108->Wrap( -1 );2345+ fgSizer8->Add( m_staticText108, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );2346+ 2347+ m_textCtrlTitle = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2348+ fgSizer8->Add( m_textCtrlTitle, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );2349+ 2350+ m_staticText107 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Price"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );2351+ m_staticText107->Wrap( -1 );2352+ fgSizer8->Add( m_staticText107, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );2353+ 2354+ m_textCtrlPrice = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2355+ m_textCtrlPrice->SetMinSize( wxSize( 105,-1 ) );2356+ 2357+ fgSizer8->Add( m_textCtrlPrice, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2358+ 2359+ bSizer21->Add( fgSizer8, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );2360+ 2361+ m_staticText22 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Page 1: Description"), wxDefaultPosition, wxDefaultSize, 0 );2362+ m_staticText22->Wrap( -1 );2363+ bSizer21->Add( m_staticText22, 0, wxTOP|wxRIGHT|wxLEFT, 5 );2364+ 2365+ m_textCtrlDescription = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );2366+ m_textCtrlDescription->SetMinSize( wxSize( -1,170 ) );2367+ 2368+ bSizer21->Add( m_textCtrlDescription, 0, wxALL|wxEXPAND, 5 );2369+ 2370+ m_staticText23 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Page 2: Order Form"), wxDefaultPosition, wxDefaultSize, 0 );2371+ m_staticText23->Wrap( -1 );2372+ bSizer21->Add( m_staticText23, 0, wxTOP|wxRIGHT|wxLEFT, 5 );2373+ 2374+ m_textCtrlInstructions = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );2375+ m_textCtrlInstructions->SetMinSize( wxSize( -1,120 ) );2376+ 2377+ bSizer21->Add( m_textCtrlInstructions, 0, wxEXPAND|wxALL, 5 );2378+ 2379+ fgSizer5 = new wxFlexGridSizer( 0, 3, 0, 0 );2380+ fgSizer5->AddGrowableCol( 1 );2381+ fgSizer5->SetFlexibleDirection( wxBOTH );2382+ fgSizer5->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );2383+ 2384+ m_staticText24 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Label"), wxDefaultPosition, wxDefaultSize, 0 );2385+ m_staticText24->Wrap( -1 );2386+ fgSizer5->Add( m_staticText24, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );2387+ 2388+ m_staticText25 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Comma separated list of choices, or leave blank for text field"), wxDefaultPosition, wxDefaultSize, 0 );2389+ m_staticText25->Wrap( -1 );2390+ fgSizer5->Add( m_staticText25, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );2391+ 2392+ 2393+ fgSizer5->Add( 0, 0, 1, wxEXPAND, 5 );2394+ 2395+ m_textCtrlLabel0 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2396+ m_textCtrlLabel0->SetMinSize( wxSize( 150,-1 ) );2397+ 2398+ fgSizer5->Add( m_textCtrlLabel0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2399+ 2400+ m_textCtrlField0 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2401+ fgSizer5->Add( m_textCtrlField0, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2402+ 2403+ m_buttonDel0 = new wxButton( m_scrolledWindow, wxID_DEL0, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2404+ fgSizer5->Add( m_buttonDel0, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );2405+ 2406+ m_textCtrlLabel1 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2407+ m_textCtrlLabel1->SetMinSize( wxSize( 150,-1 ) );2408+ 2409+ fgSizer5->Add( m_textCtrlLabel1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2410+ 2411+ m_textCtrlField1 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2412+ fgSizer5->Add( m_textCtrlField1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2413+ 2414+ m_buttonDel1 = new wxButton( m_scrolledWindow, wxID_DEL1, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2415+ fgSizer5->Add( m_buttonDel1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2416+ 2417+ m_textCtrlLabel2 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2418+ m_textCtrlLabel2->SetMinSize( wxSize( 150,-1 ) );2419+ 2420+ fgSizer5->Add( m_textCtrlLabel2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2421+ 2422+ m_textCtrlField2 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2423+ fgSizer5->Add( m_textCtrlField2, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2424+ 2425+ m_buttonDel2 = new wxButton( m_scrolledWindow, wxID_DEL2, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2426+ fgSizer5->Add( m_buttonDel2, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2427+ 2428+ m_textCtrlLabel3 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2429+ m_textCtrlLabel3->SetMinSize( wxSize( 150,-1 ) );2430+ 2431+ fgSizer5->Add( m_textCtrlLabel3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2432+ 2433+ m_textCtrlField3 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2434+ fgSizer5->Add( m_textCtrlField3, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2435+ 2436+ m_buttonDel3 = new wxButton( m_scrolledWindow, wxID_DEL3, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2437+ fgSizer5->Add( m_buttonDel3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2438+ 2439+ m_textCtrlLabel4 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2440+ m_textCtrlLabel4->SetMinSize( wxSize( 150,-1 ) );2441+ 2442+ fgSizer5->Add( m_textCtrlLabel4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2443+ 2444+ m_textCtrlField4 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2445+ fgSizer5->Add( m_textCtrlField4, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2446+ 2447+ m_buttonDel4 = new wxButton( m_scrolledWindow, wxID_DEL4, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2448+ fgSizer5->Add( m_buttonDel4, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2449+ 2450+ m_textCtrlLabel5 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2451+ m_textCtrlLabel5->SetMinSize( wxSize( 150,-1 ) );2452+ 2453+ fgSizer5->Add( m_textCtrlLabel5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2454+ 2455+ m_textCtrlField5 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2456+ fgSizer5->Add( m_textCtrlField5, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2457+ 2458+ m_buttonDel5 = new wxButton( m_scrolledWindow, wxID_DEL5, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2459+ fgSizer5->Add( m_buttonDel5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2460+ 2461+ m_textCtrlLabel6 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2462+ m_textCtrlLabel6->SetMinSize( wxSize( 150,-1 ) );2463+ 2464+ fgSizer5->Add( m_textCtrlLabel6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2465+ 2466+ m_textCtrlField6 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2467+ fgSizer5->Add( m_textCtrlField6, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2468+ 2469+ m_buttonDel6 = new wxButton( m_scrolledWindow, wxID_DEL6, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2470+ fgSizer5->Add( m_buttonDel6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2471+ 2472+ m_textCtrlLabel7 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2473+ m_textCtrlLabel7->SetMinSize( wxSize( 150,-1 ) );2474+ 2475+ fgSizer5->Add( m_textCtrlLabel7, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2476+ 2477+ m_textCtrlField7 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2478+ fgSizer5->Add( m_textCtrlField7, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2479+ 2480+ m_buttonDel7 = new wxButton( m_scrolledWindow, wxID_DEL7, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2481+ fgSizer5->Add( m_buttonDel7, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2482+ 2483+ m_textCtrlLabel8 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2484+ m_textCtrlLabel8->SetMinSize( wxSize( 150,-1 ) );2485+ 2486+ fgSizer5->Add( m_textCtrlLabel8, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2487+ 2488+ m_textCtrlField8 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2489+ fgSizer5->Add( m_textCtrlField8, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2490+ 2491+ m_buttonDel8 = new wxButton( m_scrolledWindow, wxID_DEL8, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2492+ fgSizer5->Add( m_buttonDel8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2493+ 2494+ m_textCtrlLabel9 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2495+ m_textCtrlLabel9->SetMinSize( wxSize( 150,-1 ) );2496+ 2497+ fgSizer5->Add( m_textCtrlLabel9, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2498+ 2499+ m_textCtrlField9 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2500+ fgSizer5->Add( m_textCtrlField9, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2501+ 2502+ m_buttonDel9 = new wxButton( m_scrolledWindow, wxID_DEL9, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2503+ fgSizer5->Add( m_buttonDel9, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2504+ 2505+ m_textCtrlLabel10 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2506+ m_textCtrlLabel10->SetMinSize( wxSize( 150,-1 ) );2507+ 2508+ fgSizer5->Add( m_textCtrlLabel10, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2509+ 2510+ m_textCtrlField10 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2511+ fgSizer5->Add( m_textCtrlField10, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2512+ 2513+ m_buttonDel10 = new wxButton( m_scrolledWindow, wxID_DEL10, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2514+ fgSizer5->Add( m_buttonDel10, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2515+ 2516+ m_textCtrlLabel11 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2517+ m_textCtrlLabel11->SetMinSize( wxSize( 150,-1 ) );2518+ 2519+ fgSizer5->Add( m_textCtrlLabel11, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2520+ 2521+ m_textCtrlField11 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2522+ fgSizer5->Add( m_textCtrlField11, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2523+ 2524+ m_buttonDel11 = new wxButton( m_scrolledWindow, wxID_DEL11, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2525+ fgSizer5->Add( m_buttonDel11, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2526+ 2527+ m_textCtrlLabel12 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2528+ m_textCtrlLabel12->SetMinSize( wxSize( 150,-1 ) );2529+ 2530+ fgSizer5->Add( m_textCtrlLabel12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2531+ 2532+ m_textCtrlField12 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2533+ fgSizer5->Add( m_textCtrlField12, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2534+ 2535+ m_buttonDel12 = new wxButton( m_scrolledWindow, wxID_DEL12, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2536+ fgSizer5->Add( m_buttonDel12, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2537+ 2538+ m_textCtrlLabel13 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2539+ m_textCtrlLabel13->SetMinSize( wxSize( 150,-1 ) );2540+ 2541+ fgSizer5->Add( m_textCtrlLabel13, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2542+ 2543+ m_textCtrlField13 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2544+ fgSizer5->Add( m_textCtrlField13, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2545+ 2546+ m_buttonDel13 = new wxButton( m_scrolledWindow, wxID_DEL13, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2547+ fgSizer5->Add( m_buttonDel13, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2548+ 2549+ m_textCtrlLabel14 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2550+ m_textCtrlLabel14->SetMinSize( wxSize( 150,-1 ) );2551+ 2552+ fgSizer5->Add( m_textCtrlLabel14, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2553+ 2554+ m_textCtrlField14 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2555+ fgSizer5->Add( m_textCtrlField14, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2556+ 2557+ m_buttonDel14 = new wxButton( m_scrolledWindow, wxID_DEL14, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2558+ fgSizer5->Add( m_buttonDel14, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2559+ 2560+ m_textCtrlLabel15 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2561+ m_textCtrlLabel15->SetMinSize( wxSize( 150,-1 ) );2562+ 2563+ fgSizer5->Add( m_textCtrlLabel15, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2564+ 2565+ m_textCtrlField15 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2566+ fgSizer5->Add( m_textCtrlField15, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2567+ 2568+ m_buttonDel15 = new wxButton( m_scrolledWindow, wxID_DEL15, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2569+ fgSizer5->Add( m_buttonDel15, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2570+ 2571+ m_textCtrlLabel16 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2572+ m_textCtrlLabel16->SetMinSize( wxSize( 150,-1 ) );2573+ 2574+ fgSizer5->Add( m_textCtrlLabel16, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2575+ 2576+ m_textCtrlField16 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2577+ fgSizer5->Add( m_textCtrlField16, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2578+ 2579+ m_buttonDel16 = new wxButton( m_scrolledWindow, wxID_DEL16, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2580+ fgSizer5->Add( m_buttonDel16, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2581+ 2582+ m_textCtrlLabel17 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2583+ m_textCtrlLabel17->SetMinSize( wxSize( 150,-1 ) );2584+ 2585+ fgSizer5->Add( m_textCtrlLabel17, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2586+ 2587+ m_textCtrlField17 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2588+ fgSizer5->Add( m_textCtrlField17, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2589+ 2590+ m_buttonDel17 = new wxButton( m_scrolledWindow, wxID_DEL17, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2591+ fgSizer5->Add( m_buttonDel17, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2592+ 2593+ m_textCtrlLabel18 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2594+ m_textCtrlLabel18->SetMinSize( wxSize( 150,-1 ) );2595+ 2596+ fgSizer5->Add( m_textCtrlLabel18, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2597+ 2598+ m_textCtrlField18 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2599+ fgSizer5->Add( m_textCtrlField18, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2600+ 2601+ m_buttonDel18 = new wxButton( m_scrolledWindow, wxID_DEL18, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2602+ fgSizer5->Add( m_buttonDel18, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2603+ 2604+ m_textCtrlLabel19 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );2605+ m_textCtrlLabel19->SetMinSize( wxSize( 150,-1 ) );2606+ 2607+ fgSizer5->Add( m_textCtrlLabel19, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );2608+ 2609+ m_textCtrlField19 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );2610+ fgSizer5->Add( m_textCtrlField19, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );2611+ 2612+ m_buttonDel19 = new wxButton( m_scrolledWindow, wxID_DEL19, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );2613+ fgSizer5->Add( m_buttonDel19, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );2614+ 2615+ bSizer21->Add( fgSizer5, 0, wxEXPAND, 5 );2616+ 2617+ wxBoxSizer* bSizer25;2618+ bSizer25 = new wxBoxSizer( wxHORIZONTAL );2619+ 2620+ m_buttonAddField = new wxButton( m_scrolledWindow, wxID_ANY, wxT("&Add Field"), wxDefaultPosition, wxDefaultSize, 0 );2621+ bSizer25->Add( m_buttonAddField, 0, wxALL, 5 );2622+ 2623+ bSizer21->Add( bSizer25, 0, wxALIGN_CENTER_HORIZONTAL, 5 );2624+ 2625+ m_scrolledWindow->SetSizer( bSizer21 );2626+ m_scrolledWindow->Layout();2627+ bSizer21->Fit( m_scrolledWindow );2628+ bSizer20->Add( m_scrolledWindow, 1, wxEXPAND|wxALL, 5 );2629+ 2630+ wxBoxSizer* bSizer26;2631+ bSizer26 = new wxBoxSizer( wxHORIZONTAL );2632+ 2633+ m_buttonOK = new wxButton( this, wxID_BUTTONSEND, wxT("&Send"), wxDefaultPosition, wxDefaultSize, 0 );2634+ bSizer26->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );2635+ 2636+ m_buttonPreview = new wxButton( this, wxID_BUTTONPREVIEW, wxT("&Preview"), wxDefaultPosition, wxDefaultSize, 0 );2637+ bSizer26->Add( m_buttonPreview, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );2638+ 2639+ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );2640+ bSizer26->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );2641+ 2642+ bSizer20->Add( bSizer26, 0, wxALIGN_RIGHT, 5 );2643+ 2644+ this->SetSizer( bSizer20 );2645+ this->Layout();2646+ 2647+ // Connect Events2648+ m_textCtrlTitle->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2649+ m_textCtrlPrice->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2650+ m_textCtrlDescription->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2651+ m_textCtrlInstructions->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2652+ m_textCtrlLabel0->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2653+ m_textCtrlField0->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2654+ m_buttonDel0->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel0 ), NULL, this );2655+ m_textCtrlLabel1->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2656+ m_textCtrlField1->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2657+ m_buttonDel1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel1 ), NULL, this );2658+ m_textCtrlLabel2->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2659+ m_textCtrlField2->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2660+ m_buttonDel2->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel2 ), NULL, this );2661+ m_textCtrlLabel3->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2662+ m_textCtrlField3->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2663+ m_buttonDel3->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel3 ), NULL, this );2664+ m_textCtrlLabel4->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2665+ m_textCtrlField4->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2666+ m_buttonDel4->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel4 ), NULL, this );2667+ m_textCtrlLabel5->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2668+ m_textCtrlField5->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2669+ m_buttonDel5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel5 ), NULL, this );2670+ m_textCtrlLabel6->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2671+ m_textCtrlField6->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2672+ m_buttonDel6->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel6 ), NULL, this );2673+ m_textCtrlLabel7->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2674+ m_textCtrlField7->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2675+ m_buttonDel7->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel7 ), NULL, this );2676+ m_textCtrlLabel8->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2677+ m_textCtrlField8->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2678+ m_buttonDel8->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel8 ), NULL, this );2679+ m_textCtrlLabel9->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2680+ m_textCtrlField9->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2681+ m_buttonDel9->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel9 ), NULL, this );2682+ m_textCtrlLabel10->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2683+ m_textCtrlField10->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2684+ m_buttonDel10->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel10 ), NULL, this );2685+ m_textCtrlLabel11->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2686+ m_textCtrlField11->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2687+ m_buttonDel11->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel11 ), NULL, this );2688+ m_textCtrlLabel12->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2689+ m_textCtrlField12->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2690+ m_buttonDel12->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel12 ), NULL, this );2691+ m_textCtrlLabel13->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2692+ m_textCtrlField13->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2693+ m_buttonDel13->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel13 ), NULL, this );2694+ m_textCtrlLabel14->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2695+ m_textCtrlField14->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2696+ m_buttonDel14->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel14 ), NULL, this );2697+ m_textCtrlLabel15->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2698+ m_textCtrlField15->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2699+ m_buttonDel15->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel15 ), NULL, this );2700+ m_textCtrlLabel16->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2701+ m_textCtrlField16->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2702+ m_buttonDel16->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel16 ), NULL, this );2703+ m_textCtrlLabel17->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2704+ m_textCtrlField17->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2705+ m_buttonDel17->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel17 ), NULL, this );2706+ m_textCtrlLabel18->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2707+ m_textCtrlField18->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2708+ m_buttonDel18->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel18 ), NULL, this );2709+ m_textCtrlLabel19->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2710+ m_textCtrlField19->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2711+ m_buttonDel19->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel19 ), NULL, this );2712+ m_buttonAddField->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonAddField ), NULL, this );2713+ m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonSend ), NULL, this );2714+ m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonPreview ), NULL, this );2715+ m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonCancel ), NULL, this );2716 }2717 2718 CEditProductDialogBase::~CEditProductDialogBase()2719 {2720- // Disconnect Events2721- m_textCtrlTitle->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2722- m_textCtrlPrice->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2723- m_textCtrlDescription->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2724- m_textCtrlInstructions->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2725- m_textCtrlLabel0->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2726- m_textCtrlField0->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2727- m_buttonDel0->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel0), NULL, this);2728- m_textCtrlLabel1->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2729- m_textCtrlField1->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2730- m_buttonDel1->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel1), NULL, this);2731- m_textCtrlLabel2->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2732- m_textCtrlField2->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2733- m_buttonDel2->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel2), NULL, this);2734- m_textCtrlLabel3->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2735- m_textCtrlField3->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2736- m_buttonDel3->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel3), NULL, this);2737- m_textCtrlLabel4->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2738- m_textCtrlField4->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2739- m_buttonDel4->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel4), NULL, this);2740- m_textCtrlLabel5->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2741- m_textCtrlField5->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2742- m_buttonDel5->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel5), NULL, this);2743- m_textCtrlLabel6->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2744- m_textCtrlField6->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2745- m_buttonDel6->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel6), NULL, this);2746- m_textCtrlLabel7->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2747- m_textCtrlField7->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2748- m_buttonDel7->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel7), NULL, this);2749- m_textCtrlLabel8->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2750- m_textCtrlField8->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2751- m_buttonDel8->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel8), NULL, this);2752- m_textCtrlLabel9->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2753- m_textCtrlField9->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2754- m_buttonDel9->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel9), NULL, this);2755- m_textCtrlLabel10->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2756- m_textCtrlField10->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2757- m_buttonDel10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel10), NULL, this);2758- m_textCtrlLabel11->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2759- m_textCtrlField11->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2760- m_buttonDel11->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel11), NULL, this);2761- m_textCtrlLabel12->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2762- m_textCtrlField12->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2763- m_buttonDel12->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel12), NULL, this);2764- m_textCtrlLabel13->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2765- m_textCtrlField13->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2766- m_buttonDel13->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel13), NULL, this);2767- m_textCtrlLabel14->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2768- m_textCtrlField14->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2769- m_buttonDel14->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel14), NULL, this);2770- m_textCtrlLabel15->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2771- m_textCtrlField15->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2772- m_buttonDel15->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel15), NULL, this);2773- m_textCtrlLabel16->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2774- m_textCtrlField16->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2775- m_buttonDel16->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel16), NULL, this);2776- m_textCtrlLabel17->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2777- m_textCtrlField17->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2778- m_buttonDel17->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel17), NULL, this);2779- m_textCtrlLabel18->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2780- m_textCtrlField18->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2781- m_buttonDel18->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel18), NULL, this);2782- m_textCtrlLabel19->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2783- m_textCtrlField19->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditProductDialogBase::OnKeyDown), NULL, this);2784- m_buttonDel19->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonDel19), NULL, this);2785- m_buttonAddField->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonAddField), NULL, this);2786- m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonSend), NULL, this);2787- m_buttonPreview->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonPreview), NULL, this);2788- m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditProductDialogBase::OnButtonCancel), NULL, this);2789-}2790-2791-CViewProductDialogBase::CViewProductDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style)2792-{2793- this->SetSizeHints(wxDefaultSize, wxDefaultSize);2794- this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENU));2795-2796- wxBoxSizer* bSizer20;2797- bSizer20 = new wxBoxSizer(wxVERTICAL);2798-2799- wxBoxSizer* bSizer116;2800- bSizer116 = new wxBoxSizer(wxHORIZONTAL);2801-2802- m_htmlWinReviews = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);2803- m_htmlWinReviews->Hide();2804-2805- bSizer116->Add(m_htmlWinReviews, 1, wxALL|wxEXPAND, 5);2806-2807- m_scrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL);2808- m_scrolledWindow->SetScrollRate(5, 5);2809- m_scrolledWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));2810-2811- wxBoxSizer* bSizer21;2812- bSizer21 = new wxBoxSizer(wxVERTICAL);2813-2814- m_richTextHeading = new wxRichTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,50), wxTE_READONLY|wxNO_BORDER);2815- bSizer21->Add(m_richTextHeading, 0, wxEXPAND, 5);2816-2817- m_staticTextInstructions = new wxStaticText(m_scrolledWindow, wxID_ANY, wxT("Order Form instructions here\nmultiple lines\n1\n2\n3\n4\n5\n6"), wxDefaultPosition, wxDefaultSize, 0);2818- m_staticTextInstructions->Wrap(-1);2819- bSizer21->Add(m_staticTextInstructions, 0, wxALL|wxEXPAND, 5);2820-2821- wxBoxSizer* bSizer25;2822- bSizer25 = new wxBoxSizer(wxHORIZONTAL);2823-2824- m_buttonSubmitForm = new wxButton(m_scrolledWindow, wxID_BUTTONSAMPLE, wxT("&Submit"), wxDefaultPosition, wxDefaultSize, 0);2825- bSizer25->Add(m_buttonSubmitForm, 0, wxALL, 5);2826-2827- m_buttonCancelForm = new wxButton(m_scrolledWindow, wxID_CANCEL2, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0);2828- bSizer25->Add(m_buttonCancelForm, 0, wxALL, 5);2829-2830- bSizer21->Add(bSizer25, 0, wxALIGN_CENTER_HORIZONTAL, 5);2831-2832- m_scrolledWindow->SetSizer(bSizer21);2833- m_scrolledWindow->Layout();2834- bSizer21->Fit(m_scrolledWindow);2835- bSizer116->Add(m_scrolledWindow, 1, wxEXPAND|wxALL, 5);2836-2837- bSizer20->Add(bSizer116, 1, wxEXPAND, 5);2838-2839- wxBoxSizer* bSizer26;2840- bSizer26 = new wxBoxSizer(wxHORIZONTAL);2841-2842- m_buttonBack = new wxButton(this, wxID_BUTTONBACK, wxT("< &Back "), wxDefaultPosition, wxDefaultSize, 0);2843- m_buttonBack->Enable(false);2844- m_buttonBack->SetMinSize(wxSize(85,25));2845-2846- bSizer26->Add(m_buttonBack, 0, wxALL, 5);2847-2848- m_buttonNext = new wxButton(this, wxID_BUTTONNEXT, wxT(" &Next >"), wxDefaultPosition, wxDefaultSize, 0);2849- m_buttonNext->SetMinSize(wxSize(85,25));2850-2851- bSizer26->Add(m_buttonNext, 0, wxALL, 5);2852-2853- m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0);2854- m_buttonCancel->SetMinSize(wxSize(85,25));2855-2856- bSizer26->Add(m_buttonCancel, 0, wxALL, 5);2857-2858- bSizer20->Add(bSizer26, 0, wxALIGN_RIGHT, 5);2859-2860- this->SetSizer(bSizer20);2861- this->Layout();2862-2863- // Connect Events2864- m_buttonSubmitForm->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonSubmitForm), NULL, this);2865- m_buttonCancelForm->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonCancelForm), NULL, this);2866- m_buttonBack->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonBack), NULL, this);2867- m_buttonNext->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonNext), NULL, this);2868- m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonCancel), NULL, this);2869+ // Disconnect Events2870+ m_textCtrlTitle->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2871+ m_textCtrlPrice->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2872+ m_textCtrlDescription->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2873+ m_textCtrlInstructions->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2874+ m_textCtrlLabel0->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2875+ m_textCtrlField0->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2876+ m_buttonDel0->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel0 ), NULL, this );2877+ m_textCtrlLabel1->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2878+ m_textCtrlField1->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2879+ m_buttonDel1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel1 ), NULL, this );2880+ m_textCtrlLabel2->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2881+ m_textCtrlField2->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2882+ m_buttonDel2->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel2 ), NULL, this );2883+ m_textCtrlLabel3->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2884+ m_textCtrlField3->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2885+ m_buttonDel3->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel3 ), NULL, this );2886+ m_textCtrlLabel4->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2887+ m_textCtrlField4->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2888+ m_buttonDel4->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel4 ), NULL, this );2889+ m_textCtrlLabel5->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2890+ m_textCtrlField5->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2891+ m_buttonDel5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel5 ), NULL, this );2892+ m_textCtrlLabel6->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2893+ m_textCtrlField6->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2894+ m_buttonDel6->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel6 ), NULL, this );2895+ m_textCtrlLabel7->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2896+ m_textCtrlField7->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2897+ m_buttonDel7->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel7 ), NULL, this );2898+ m_textCtrlLabel8->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2899+ m_textCtrlField8->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2900+ m_buttonDel8->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel8 ), NULL, this );2901+ m_textCtrlLabel9->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2902+ m_textCtrlField9->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2903+ m_buttonDel9->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel9 ), NULL, this );2904+ m_textCtrlLabel10->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2905+ m_textCtrlField10->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2906+ m_buttonDel10->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel10 ), NULL, this );2907+ m_textCtrlLabel11->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2908+ m_textCtrlField11->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2909+ m_buttonDel11->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel11 ), NULL, this );2910+ m_textCtrlLabel12->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2911+ m_textCtrlField12->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2912+ m_buttonDel12->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel12 ), NULL, this );2913+ m_textCtrlLabel13->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2914+ m_textCtrlField13->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2915+ m_buttonDel13->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel13 ), NULL, this );2916+ m_textCtrlLabel14->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2917+ m_textCtrlField14->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2918+ m_buttonDel14->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel14 ), NULL, this );2919+ m_textCtrlLabel15->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2920+ m_textCtrlField15->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2921+ m_buttonDel15->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel15 ), NULL, this );2922+ m_textCtrlLabel16->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2923+ m_textCtrlField16->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2924+ m_buttonDel16->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel16 ), NULL, this );2925+ m_textCtrlLabel17->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2926+ m_textCtrlField17->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2927+ m_buttonDel17->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel17 ), NULL, this );2928+ m_textCtrlLabel18->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2929+ m_textCtrlField18->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2930+ m_buttonDel18->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel18 ), NULL, this );2931+ m_textCtrlLabel19->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2932+ m_textCtrlField19->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );2933+ m_buttonDel19->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel19 ), NULL, this );2934+ m_buttonAddField->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonAddField ), NULL, this );2935+ m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonSend ), NULL, this );2936+ m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonPreview ), NULL, this );2937+ m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonCancel ), NULL, this );2938+}2939+2940+CViewProductDialogBase::CViewProductDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )2941+{2942+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );2943+ this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );2944+ 2945+ wxBoxSizer* bSizer20;2946+ bSizer20 = new wxBoxSizer( wxVERTICAL );2947+ 2948+ wxBoxSizer* bSizer116;2949+ bSizer116 = new wxBoxSizer( wxHORIZONTAL );2950+ 2951+ m_htmlWinReviews = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );2952+ m_htmlWinReviews->Hide();2953+ 2954+ bSizer116->Add( m_htmlWinReviews, 1, wxALL|wxEXPAND, 5 );2955+ 2956+ m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL );2957+ m_scrolledWindow->SetScrollRate( 5, 5 );2958+ m_scrolledWindow->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );2959+ 2960+ wxBoxSizer* bSizer21;2961+ bSizer21 = new wxBoxSizer( wxVERTICAL );2962+ 2963+ m_richTextHeading = new wxRichTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,50 ), wxTE_READONLY|wxNO_BORDER );2964+ bSizer21->Add( m_richTextHeading, 0, wxEXPAND, 5 );2965+ 2966+ m_staticTextInstructions = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Order Form instructions here\nmultiple lines\n1\n2\n3\n4\n5\n6"), wxDefaultPosition, wxDefaultSize, 0 );2967+ m_staticTextInstructions->Wrap( -1 );2968+ bSizer21->Add( m_staticTextInstructions, 0, wxALL|wxEXPAND, 5 );2969+ 2970+ wxBoxSizer* bSizer25;2971+ bSizer25 = new wxBoxSizer( wxHORIZONTAL );2972+ 2973+ m_buttonSubmitForm = new wxButton( m_scrolledWindow, wxID_BUTTONSAMPLE, wxT("&Submit"), wxDefaultPosition, wxDefaultSize, 0 );2974+ bSizer25->Add( m_buttonSubmitForm, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );2975+ 2976+ m_buttonCancelForm = new wxButton( m_scrolledWindow, wxID_CANCEL2, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );2977+ bSizer25->Add( m_buttonCancelForm, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );2978+ 2979+ bSizer21->Add( bSizer25, 0, wxALIGN_CENTER_HORIZONTAL, 5 );2980+ 2981+ m_scrolledWindow->SetSizer( bSizer21 );2982+ m_scrolledWindow->Layout();2983+ bSizer21->Fit( m_scrolledWindow );2984+ bSizer116->Add( m_scrolledWindow, 1, wxEXPAND|wxALL, 5 );2985+ 2986+ bSizer20->Add( bSizer116, 1, wxEXPAND, 5 );2987+ 2988+ wxBoxSizer* bSizer26;2989+ bSizer26 = new wxBoxSizer( wxHORIZONTAL );2990+ 2991+ m_buttonBack = new wxButton( this, wxID_BUTTONBACK, wxT("< &Back "), wxDefaultPosition, wxDefaultSize, 0 );2992+ m_buttonBack->Enable( false );2993+ 2994+ bSizer26->Add( m_buttonBack, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );2995+ 2996+ m_buttonNext = new wxButton( this, wxID_BUTTONNEXT, wxT(" &Next >"), wxDefaultPosition, wxDefaultSize, 0 );2997+ bSizer26->Add( m_buttonNext, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );2998+ 2999+ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );3000+ bSizer26->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );3001+ 3002+ bSizer20->Add( bSizer26, 0, wxALIGN_RIGHT, 5 );3003+ 3004+ this->SetSizer( bSizer20 );3005+ this->Layout();3006+ 3007+ // Connect Events3008+ m_buttonSubmitForm->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonSubmitForm ), NULL, this );3009+ m_buttonCancelForm->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonCancelForm ), NULL, this );3010+ m_buttonBack->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonBack ), NULL, this );3011+ m_buttonNext->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonNext ), NULL, this );3012+ m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonCancel ), NULL, this );3013 }3014 3015 CViewProductDialogBase::~CViewProductDialogBase()3016 {3017- // Disconnect Events3018- m_buttonSubmitForm->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonSubmitForm), NULL, this);3019- m_buttonCancelForm->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonCancelForm), NULL, this);3020- m_buttonBack->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonBack), NULL, this);3021- m_buttonNext->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonNext), NULL, this);3022- m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewProductDialogBase::OnButtonCancel), NULL, this);3023-}3024-3025-CViewOrderDialogBase::CViewOrderDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style)3026-{3027- this->SetSizeHints(wxDefaultSize, wxDefaultSize);3028- this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENU));3029-3030- wxBoxSizer* bSizer20;3031- bSizer20 = new wxBoxSizer(wxVERTICAL);3032-3033- wxBoxSizer* bSizer116;3034- bSizer116 = new wxBoxSizer(wxHORIZONTAL);3035-3036- m_htmlWin = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);3037- bSizer116->Add(m_htmlWin, 1, wxALL|wxEXPAND, 5);3038-3039- bSizer20->Add(bSizer116, 1, wxEXPAND, 5);3040-3041- wxBoxSizer* bSizer26;3042- bSizer26 = new wxBoxSizer(wxHORIZONTAL);3043-3044- m_buttonOK = new wxButton(this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0);3045- m_buttonOK->SetMinSize(wxSize(85,25));3046-3047- bSizer26->Add(m_buttonOK, 0, wxALL, 5);3048-3049- bSizer20->Add(bSizer26, 0, wxALIGN_RIGHT, 5);3050-3051- this->SetSizer(bSizer20);3052- this->Layout();3053-3054- // Connect Events3055- m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewOrderDialogBase::OnButtonOK), NULL, this);3056+ // Disconnect Events3057+ m_buttonSubmitForm->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonSubmitForm ), NULL, this );3058+ m_buttonCancelForm->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonCancelForm ), NULL, this );3059+ m_buttonBack->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonBack ), NULL, this );3060+ m_buttonNext->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonNext ), NULL, this );3061+ m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonCancel ), NULL, this );3062+}3063+3064+CViewOrderDialogBase::CViewOrderDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )3065+{3066+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );3067+ this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );3068+ 3069+ wxBoxSizer* bSizer20;3070+ bSizer20 = new wxBoxSizer( wxVERTICAL );3071+ 3072+ wxBoxSizer* bSizer116;3073+ bSizer116 = new wxBoxSizer( wxHORIZONTAL );3074+ 3075+ m_htmlWin = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );3076+ bSizer116->Add( m_htmlWin, 1, wxALL|wxEXPAND, 5 );3077+ 3078+ bSizer20->Add( bSizer116, 1, wxEXPAND, 5 );3079+ 3080+ wxBoxSizer* bSizer26;3081+ bSizer26 = new wxBoxSizer( wxHORIZONTAL );3082+ 3083+ m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );3084+ bSizer26->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );3085+ 3086+ bSizer20->Add( bSizer26, 0, wxALIGN_RIGHT, 5 );3087+ 3088+ this->SetSizer( bSizer20 );3089+ this->Layout();3090+ 3091+ // Connect Events3092+ m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewOrderDialogBase::OnButtonOK ), NULL, this );3093 }3094 3095 CViewOrderDialogBase::~CViewOrderDialogBase()3096 {3097- // Disconnect Events3098- m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CViewOrderDialogBase::OnButtonOK), NULL, this);3099-}3100-3101-CEditReviewDialogBase::CEditReviewDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style)3102-{3103- this->SetSizeHints(wxDefaultSize, wxDefaultSize);3104- this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENU));3105-3106- wxBoxSizer* bSizer112;3107- bSizer112 = new wxBoxSizer(wxVERTICAL);3108-3109-3110- bSizer112->Add(0, 3, 0, 0, 5);3111-3112- m_staticTextSeller = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);3113- m_staticTextSeller->Wrap(-1);3114- bSizer112->Add(m_staticTextSeller, 0, wxALL|wxEXPAND, 5);3115-3116-3117- bSizer112->Add(0, 3, 0, 0, 5);3118-3119- m_staticText110 = new wxStaticText(this, wxID_ANY, wxT("Rating"), wxDefaultPosition, wxDefaultSize, 0);3120- m_staticText110->Wrap(-1);3121- bSizer112->Add(m_staticText110, 0, wxTOP|wxRIGHT|wxLEFT, 5);3122-3123- wxString m_choiceStarsChoices[] = { wxT(" 1 star"), wxT(" 2 stars"), wxT(" 3 stars"), wxT(" 4 stars"), wxT(" 5 stars") };3124- int m_choiceStarsNChoices = sizeof(m_choiceStarsChoices) / sizeof(wxString);3125- m_choiceStars = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceStarsNChoices, m_choiceStarsChoices, 0);3126- m_choiceStars->SetSelection(0);3127- bSizer112->Add(m_choiceStars, 0, wxALL, 5);3128-3129- m_staticText43 = new wxStaticText(this, wxID_ANY, wxT("Review"), wxDefaultPosition, wxDefaultSize, 0);3130- m_staticText43->Wrap(-1);3131- bSizer112->Add(m_staticText43, 0, wxTOP|wxRIGHT|wxLEFT, 5);3132-3133- m_textCtrlReview = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);3134- bSizer112->Add(m_textCtrlReview, 1, wxALL|wxEXPAND, 5);3135-3136- wxBoxSizer* bSizer113;3137- bSizer113 = new wxBoxSizer(wxHORIZONTAL);3138-3139- m_buttonSubmit = new wxButton(this, wxID_SUBMIT, wxT("&Submit"), wxDefaultPosition, wxDefaultSize, 0);3140- m_buttonSubmit->SetMinSize(wxSize(85,25));3141-3142- bSizer113->Add(m_buttonSubmit, 0, wxALL, 5);3143-3144- m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0);3145- m_buttonCancel->SetMinSize(wxSize(85,25));3146-3147- bSizer113->Add(m_buttonCancel, 0, wxALL, 5);3148-3149- bSizer112->Add(bSizer113, 0, wxALIGN_RIGHT, 5);3150-3151- this->SetSizer(bSizer112);3152- this->Layout();3153-3154- // Connect Events3155- m_textCtrlReview->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditReviewDialogBase::OnKeyDown), NULL, this);3156- m_buttonSubmit->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditReviewDialogBase::OnButtonSubmit), NULL, this);3157- m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditReviewDialogBase::OnButtonCancel), NULL, this);3158+ // Disconnect Events3159+ m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewOrderDialogBase::OnButtonOK ), NULL, this );3160+}3161+3162+CEditReviewDialogBase::CEditReviewDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )3163+{3164+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );3165+ this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );3166+ 3167+ wxBoxSizer* bSizer112;3168+ bSizer112 = new wxBoxSizer( wxVERTICAL );3169+ 3170+ 3171+ bSizer112->Add( 0, 3, 0, 0, 5 );3172+ 3173+ m_staticTextSeller = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );3174+ m_staticTextSeller->Wrap( -1 );3175+ bSizer112->Add( m_staticTextSeller, 0, wxALL|wxEXPAND, 5 );3176+ 3177+ 3178+ bSizer112->Add( 0, 3, 0, 0, 5 );3179+ 3180+ m_staticText110 = new wxStaticText( this, wxID_ANY, wxT("Rating"), wxDefaultPosition, wxDefaultSize, 0 );3181+ m_staticText110->Wrap( -1 );3182+ bSizer112->Add( m_staticText110, 0, wxTOP|wxRIGHT|wxLEFT, 5 );3183+ 3184+ wxString m_choiceStarsChoices[] = { wxT(" 1 star"), wxT(" 2 stars"), wxT(" 3 stars"), wxT(" 4 stars"), wxT(" 5 stars") };3185+ int m_choiceStarsNChoices = sizeof( m_choiceStarsChoices ) / sizeof( wxString );3186+ m_choiceStars = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceStarsNChoices, m_choiceStarsChoices, 0 );3187+ m_choiceStars->SetSelection( 0 );3188+ bSizer112->Add( m_choiceStars, 0, wxALL, 5 );3189+ 3190+ m_staticText43 = new wxStaticText( this, wxID_ANY, wxT("Review"), wxDefaultPosition, wxDefaultSize, 0 );3191+ m_staticText43->Wrap( -1 );3192+ bSizer112->Add( m_staticText43, 0, wxTOP|wxRIGHT|wxLEFT, 5 );3193+ 3194+ m_textCtrlReview = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );3195+ bSizer112->Add( m_textCtrlReview, 1, wxALL|wxEXPAND, 5 );3196+ 3197+ wxBoxSizer* bSizer113;3198+ bSizer113 = new wxBoxSizer( wxHORIZONTAL );3199+ 3200+ m_buttonSubmit = new wxButton( this, wxID_SUBMIT, wxT("&Submit"), wxDefaultPosition, wxDefaultSize, 0 );3201+ bSizer113->Add( m_buttonSubmit, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );3202+ 3203+ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );3204+ bSizer113->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );3205+ 3206+ bSizer112->Add( bSizer113, 0, wxALIGN_RIGHT, 5 );3207+ 3208+ this->SetSizer( bSizer112 );3209+ this->Layout();3210+ 3211+ // Connect Events3212+ m_textCtrlReview->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditReviewDialogBase::OnKeyDown ), NULL, this );3213+ m_buttonSubmit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditReviewDialogBase::OnButtonSubmit ), NULL, this );3214+ m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditReviewDialogBase::OnButtonCancel ), NULL, this );3215 }3216 3217 CEditReviewDialogBase::~CEditReviewDialogBase()3218 {3219- // Disconnect Events3220- m_textCtrlReview->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CEditReviewDialogBase::OnKeyDown), NULL, this);3221- m_buttonSubmit->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditReviewDialogBase::OnButtonSubmit), NULL, this);3222- m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CEditReviewDialogBase::OnButtonCancel), NULL, this);3223-}3224-3225-CPokerLobbyDialogBase::CPokerLobbyDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style)3226-{3227- this->SetSizeHints(wxDefaultSize, wxDefaultSize);3228- this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));3229-3230- wxBoxSizer* bSizer156;3231- bSizer156 = new wxBoxSizer(wxHORIZONTAL);3232-3233- m_treeCtrl = new wxTreeCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS|wxTR_HIDE_ROOT|wxTR_LINES_AT_ROOT);3234- m_treeCtrl->SetMinSize(wxSize(130,-1));3235-3236- bSizer156->Add(m_treeCtrl, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5);3237-3238- wxBoxSizer* bSizer172;3239- bSizer172 = new wxBoxSizer(wxVERTICAL);3240-3241- m_listCtrl = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT);3242- bSizer172->Add(m_listCtrl, 1, wxEXPAND|wxALL, 5);3243-3244- m_buttonNewTable = new wxButton(this, wxID_OPENNEWTABLE, wxT("&Open New Table"), wxDefaultPosition, wxDefaultSize, 0);3245- bSizer172->Add(m_buttonNewTable, 0, wxALL, 5);3246-3247- bSizer156->Add(bSizer172, 1, wxEXPAND, 5);3248-3249- this->SetSizer(bSizer156);3250- this->Layout();3251-3252- // Connect Events3253- m_treeCtrl->Connect(wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler(CPokerLobbyDialogBase::OnTreeSelChanged), NULL, this);3254- m_listCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CPokerLobbyDialogBase::OnListItemActivated), NULL, this);3255- m_listCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler(CPokerLobbyDialogBase::OnListItemSelected), NULL, this);3256- m_buttonNewTable->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerLobbyDialogBase::OnButtonNewTable), NULL, this);3257-}3258-3259-CPokerLobbyDialogBase::~CPokerLobbyDialogBase()3260-{3261- // Disconnect Events3262- m_treeCtrl->Disconnect(wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler(CPokerLobbyDialogBase::OnTreeSelChanged), NULL, this);3263- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(CPokerLobbyDialogBase::OnListItemActivated), NULL, this);3264- m_listCtrl->Disconnect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler(CPokerLobbyDialogBase::OnListItemSelected), NULL, this);3265- m_buttonNewTable->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerLobbyDialogBase::OnButtonNewTable), NULL, this);3266-}3267-3268-CPokerDialogBase::CPokerDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style)3269-{3270- this->SetSizeHints(wxDefaultSize, wxDefaultSize);3271-3272- wxBoxSizer* bSizer174;3273- bSizer174 = new wxBoxSizer(wxVERTICAL);3274-3275- m_checkSitOut = new wxCheckBox(this, wxID_ANY, wxT("Deal Me Out"), wxDefaultPosition, wxDefaultSize, 0);3276-3277- bSizer174->Add(m_checkSitOut, 0, wxALL, 5);3278-3279- m_buttonDealHand = new wxButton(this, wxID_DEALHAND, wxT("&Deal Hand"), wxDefaultPosition, wxSize(150,25), 0);3280- bSizer174->Add(m_buttonDealHand, 0, wxALL, 5);3281-3282- m_buttonFold = new wxButton(this, wxID_FOLD, wxT("&Fold"), wxDefaultPosition, wxSize(80,25), 0);3283- bSizer174->Add(m_buttonFold, 0, wxALL, 5);3284-3285- m_buttonCall = new wxButton(this, wxID_CALL, wxT("&Call"), wxDefaultPosition, wxSize(80,25), 0);3286- bSizer174->Add(m_buttonCall, 0, wxALL, 5);3287-3288- m_buttonRaise = new wxButton(this, wxID_RAISE, wxT("&Raise"), wxDefaultPosition, wxSize(80,25), 0);3289- bSizer174->Add(m_buttonRaise, 0, wxALL, 5);3290-3291- m_buttonLeaveTable = new wxButton(this, wxID_LEAVETABLE, wxT("&Leave Table"), wxDefaultPosition, wxSize(90,25), 0);3292- bSizer174->Add(m_buttonLeaveTable, 0, wxALL, 5);3293-3294- m_textDitchPlayer = new wxTextCtrl(this, wxID_DITCHPLAYER, wxEmptyString, wxDefaultPosition, wxSize(45,-1), wxTE_PROCESS_ENTER);3295- bSizer174->Add(m_textDitchPlayer, 0, wxALL, 5);3296-3297- m_checkPreFold = new wxCheckBox(this, wxID_ANY, wxT("FOLD"), wxDefaultPosition, wxSize(100,-1), 0);3298-3299- bSizer174->Add(m_checkPreFold, 0, wxALL, 5);3300-3301- m_checkPreCall = new wxCheckBox(this, wxID_ANY, wxT("CALL"), wxDefaultPosition, wxSize(100,-1), 0);3302-3303- bSizer174->Add(m_checkPreCall, 0, wxALL, 5);3304-3305- m_checkPreCallAny = new wxCheckBox(this, wxID_ANY, wxT("CALL ANY"), wxDefaultPosition, wxSize(100,-1), 0);3306-3307- bSizer174->Add(m_checkPreCallAny, 0, wxALL, 5);3308-3309- m_checkPreRaise = new wxCheckBox(this, wxID_ANY, wxT("RAISE"), wxDefaultPosition, wxSize(100,-1), 0);3310-3311- bSizer174->Add(m_checkPreRaise, 0, wxALL, 5);3312-3313- m_checkPreRaiseAny = new wxCheckBox(this, wxID_ANY, wxT("RAISE ANY"), wxDefaultPosition, wxSize(100,-1), 0);3314-3315- bSizer174->Add(m_checkPreRaiseAny, 0, wxALL, 5);3316-3317- this->SetSizer(bSizer174);3318- this->Layout();3319- m_statusBar = this->CreateStatusBar(1, wxST_SIZEGRIP, wxID_ANY);3320-3321- // Connect Events3322- this->Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CPokerDialogBase::OnClose));3323- this->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3324- this->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3325- this->Connect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3326- this->Connect(wxEVT_MIDDLE_UP, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3327- this->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3328- this->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3329- this->Connect(wxEVT_MOTION, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3330- this->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3331- this->Connect(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3332- this->Connect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3333- this->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3334- this->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3335- this->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3336- this->Connect(wxEVT_PAINT, wxPaintEventHandler(CPokerDialogBase::OnPaint));3337- this->Connect(wxEVT_SIZE, wxSizeEventHandler(CPokerDialogBase::OnSize));3338- m_checkSitOut->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckSitOut), NULL, this);3339- m_buttonDealHand->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonDealHand), NULL, this);3340- m_buttonFold->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonFold), NULL, this);3341- m_buttonCall->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonCall), NULL, this);3342- m_buttonRaise->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonRaise), NULL, this);3343- m_buttonLeaveTable->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonLeaveTable), NULL, this);3344- m_textDitchPlayer->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(CPokerDialogBase::OnDitchPlayer), NULL, this);3345- m_checkPreFold->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreFold), NULL, this);3346- m_checkPreCall->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreCall), NULL, this);3347- m_checkPreCallAny->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreCallAny), NULL, this);3348- m_checkPreRaise->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreRaise), NULL, this);3349- m_checkPreRaiseAny->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreRaiseAny), NULL, this);3350-}3351-3352-CPokerDialogBase::~CPokerDialogBase()3353-{3354- // Disconnect Events3355- this->Disconnect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CPokerDialogBase::OnClose));3356- this->Disconnect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3357- this->Disconnect(wxEVT_LEFT_UP, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3358- this->Disconnect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3359- this->Disconnect(wxEVT_MIDDLE_UP, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3360- this->Disconnect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3361- this->Disconnect(wxEVT_RIGHT_UP, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3362- this->Disconnect(wxEVT_MOTION, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3363- this->Disconnect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3364- this->Disconnect(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3365- this->Disconnect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3366- this->Disconnect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3367- this->Disconnect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3368- this->Disconnect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(CPokerDialogBase::OnMouseEvents));3369- this->Disconnect(wxEVT_PAINT, wxPaintEventHandler(CPokerDialogBase::OnPaint));3370- this->Disconnect(wxEVT_SIZE, wxSizeEventHandler(CPokerDialogBase::OnSize));3371- m_checkSitOut->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckSitOut), NULL, this);3372- m_buttonDealHand->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonDealHand), NULL, this);3373- m_buttonFold->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonFold), NULL, this);3374- m_buttonCall->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonCall), NULL, this);3375- m_buttonRaise->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonRaise), NULL, this);3376- m_buttonLeaveTable->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnButtonLeaveTable), NULL, this);3377- m_textDitchPlayer->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(CPokerDialogBase::OnDitchPlayer), NULL, this);3378- m_checkPreFold->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreFold), NULL, this);3379- m_checkPreCall->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreCall), NULL, this);3380- m_checkPreCallAny->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreCallAny), NULL, this);3381- m_checkPreRaise->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreRaise), NULL, this);3382- m_checkPreRaiseAny->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(CPokerDialogBase::OnCheckPreRaiseAny), NULL, this);3383-}3384-3385-CGetTextFromUserDialogBase::CGetTextFromUserDialogBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)3386-{3387- this->SetSizeHints(wxDefaultSize, wxDefaultSize);3388-3389- wxBoxSizer* bSizer79;3390- bSizer79 = new wxBoxSizer(wxVERTICAL);3391-3392- wxBoxSizer* bSizer81;3393- bSizer81 = new wxBoxSizer(wxVERTICAL);3394-3395-3396- bSizer81->Add(0, 0, 1, wxEXPAND, 5);3397-3398- m_staticTextMessage1 = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);3399- m_staticTextMessage1->Wrap(-1);3400- bSizer81->Add(m_staticTextMessage1, 0, wxTOP|wxRIGHT|wxLEFT, 5);3401-3402- m_textCtrl1 = new wxTextCtrl(this, wxID_TEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);3403- bSizer81->Add(m_textCtrl1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5);3404-3405- m_staticTextMessage2 = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);3406- m_staticTextMessage2->Wrap(-1);3407- m_staticTextMessage2->Hide();3408-3409- bSizer81->Add(m_staticTextMessage2, 0, wxTOP|wxRIGHT|wxLEFT, 5);3410-3411- m_textCtrl2 = new wxTextCtrl(this, wxID_TEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);3412- m_textCtrl2->Hide();3413-3414- bSizer81->Add(m_textCtrl2, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5);3415-3416-3417- bSizer81->Add(0, 0, 1, wxEXPAND, 5);3418-3419- bSizer79->Add(bSizer81, 1, wxEXPAND|wxALL, 10);3420-3421- wxBoxSizer* bSizer80;3422- bSizer80 = new wxBoxSizer(wxHORIZONTAL);3423-3424-3425- bSizer80->Add(0, 0, 1, wxEXPAND, 5);3426-3427- m_buttonOK = new wxButton(this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize(-1,-1), 0);3428- m_buttonOK->SetMinSize(wxSize(85,25));3429-3430- bSizer80->Add(m_buttonOK, 0, wxALL, 5);3431-3432- m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0);3433- m_buttonCancel->SetMinSize(wxSize(85,25));3434-3435- bSizer80->Add(m_buttonCancel, 0, wxALL, 5);3436-3437- bSizer79->Add(bSizer80, 0, wxEXPAND, 5);3438-3439- this->SetSizer(bSizer79);3440- this->Layout();3441-3442- // Connect Events3443- this->Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CGetTextFromUserDialogBase::OnClose));3444- m_textCtrl1->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CGetTextFromUserDialogBase::OnKeyDown), NULL, this);3445- m_textCtrl2->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CGetTextFromUserDialogBase::OnKeyDown), NULL, this);3446- m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CGetTextFromUserDialogBase::OnButtonOK), NULL, this);3447- m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CGetTextFromUserDialogBase::OnButtonCancel), NULL, this);3448+ // Disconnect Events3449+ m_textCtrlReview->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditReviewDialogBase::OnKeyDown ), NULL, this );3450+ m_buttonSubmit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditReviewDialogBase::OnButtonSubmit ), NULL, this );3451+ m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditReviewDialogBase::OnButtonCancel ), NULL, this );3452+}3453+3454+CGetTextFromUserDialogBase::CGetTextFromUserDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )3455+{3456+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );3457+ 3458+ wxBoxSizer* bSizer79;3459+ bSizer79 = new wxBoxSizer( wxVERTICAL );3460+ 3461+ wxBoxSizer* bSizer81;3462+ bSizer81 = new wxBoxSizer( wxVERTICAL );3463+ 3464+ 3465+ bSizer81->Add( 0, 0, 1, wxEXPAND, 5 );3466+ 3467+ m_staticTextMessage1 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );3468+ m_staticTextMessage1->Wrap( -1 );3469+ bSizer81->Add( m_staticTextMessage1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );3470+ 3471+ m_textCtrl1 = new wxTextCtrl( this, wxID_TEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );3472+ bSizer81->Add( m_textCtrl1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );3473+ 3474+ m_staticTextMessage2 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );3475+ m_staticTextMessage2->Wrap( -1 );3476+ m_staticTextMessage2->Hide();3477+ 3478+ bSizer81->Add( m_staticTextMessage2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );3479+ 3480+ m_textCtrl2 = new wxTextCtrl( this, wxID_TEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );3481+ m_textCtrl2->Hide();3482+ 3483+ bSizer81->Add( m_textCtrl2, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );3484+ 3485+ 3486+ bSizer81->Add( 0, 0, 1, wxEXPAND, 5 );3487+ 3488+ bSizer79->Add( bSizer81, 1, wxEXPAND|wxALL, 10 );3489+ 3490+ wxBoxSizer* bSizer80;3491+ bSizer80 = new wxBoxSizer( wxHORIZONTAL );3492+ 3493+ 3494+ bSizer80->Add( 0, 0, 1, wxEXPAND, 5 );3495+ 3496+ m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );3497+ bSizer80->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );3498+ 3499+ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );3500+ bSizer80->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );3501+ 3502+ bSizer79->Add( bSizer80, 0, wxEXPAND, 5 );3503+ 3504+ this->SetSizer( bSizer79 );3505+ this->Layout();3506+ 3507+ // Connect Events3508+ this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CGetTextFromUserDialogBase::OnClose ) );3509+ m_textCtrl1->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CGetTextFromUserDialogBase::OnKeyDown ), NULL, this );3510+ m_textCtrl2->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CGetTextFromUserDialogBase::OnKeyDown ), NULL, this );3511+ m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CGetTextFromUserDialogBase::OnButtonOK ), NULL, this );3512+ m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CGetTextFromUserDialogBase::OnButtonCancel ), NULL, this );3513 }3514 3515 CGetTextFromUserDialogBase::~CGetTextFromUserDialogBase()3516 {3517- // Disconnect Events3518- this->Disconnect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(CGetTextFromUserDialogBase::OnClose));3519- m_textCtrl1->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CGetTextFromUserDialogBase::OnKeyDown), NULL, this);3520- m_textCtrl2->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(CGetTextFromUserDialogBase::OnKeyDown), NULL, this);3521- m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CGetTextFromUserDialogBase::OnButtonOK), NULL, this);3522- m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CGetTextFromUserDialogBase::OnButtonCancel), NULL, this);3523-}3524-3525+ // Disconnect Events3526+ this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CGetTextFromUserDialogBase::OnClose ) );3527+ m_textCtrl1->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CGetTextFromUserDialogBase::OnKeyDown ), NULL, this );3528+ m_textCtrl2->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CGetTextFromUserDialogBase::OnKeyDown ), NULL, this );3529+ m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CGetTextFromUserDialogBase::OnButtonOK ), NULL, this );3530+ m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CGetTextFromUserDialogBase::OnButtonCancel ), NULL, this );3531+}3532+
uibase.h (modified)
1--- v0.1.5/uibase.h2+++ v0.2.0/uibase.h3@@ -1,7 +1,3 @@4-// Copyright (c) 2009 Satoshi Nakamoto5-// Distributed under the MIT/X11 software license, see the accompanying6-// file license.txt or http://www.opensource.org/licenses/mit-license.php.7-8 ///////////////////////////////////////////////////////////////////////////9 // C++ code generated with wxFormBuilder (version Apr 16 2008)10 // http://www.wxformbuilder.org/11@@ -34,690 +30,649 @@12 #include <wx/frame.h>13 #include <wx/html/htmlwin.h>14 #include <wx/dialog.h>15+#include <wx/listbox.h>16+#include <wx/checkbox.h>17+#include <wx/spinctrl.h>18+#include <wx/scrolwin.h>19 #include <wx/statbmp.h>20 #include <wx/combobox.h>21-#include <wx/scrolwin.h>22 #include <wx/richtext/richtextctrl.h>23-#include <wx/treectrl.h>24-#include <wx/checkbox.h>25 26 ///////////////////////////////////////////////////////////////////////////27 28 #define wxID_MAINFRAME 100029-#define wxID_OPTIONSGENERATEBITCOINS 100130-#define wxID_BUTTONSEND 100231-#define wxID_BUTTONRECEIVE 100332-#define wxID_TEXTCTRLADDRESS 100433-#define wxID_BUTTONCOPY 100534-#define wxID_BUTTONCHANGE 100635-#define wxID_TRANSACTIONFEE 100736-#define wxID_TEXTCTRLPAYTO 100837-#define wxID_BUTTONPASTE 100938-#define wxID_BUTTONADDRESSBOOK 101039-#define wxID_TEXTCTRLAMOUNT 101140-#define wxID_CHOICETRANSFERTYPE 101241-#define wxID_LISTCTRL 101342-#define wxID_BUTTONRENAME 101443-#define wxID_BUTTONNEW 101544-#define wxID_BUTTONEDIT 101645-#define wxID_BUTTONDELETE 101746-#define wxID_DEL0 101847-#define wxID_DEL1 101948-#define wxID_DEL2 102049-#define wxID_DEL3 102150-#define wxID_DEL4 102251-#define wxID_DEL5 102352-#define wxID_DEL6 102453-#define wxID_DEL7 102554-#define wxID_DEL8 102655-#define wxID_DEL9 102756-#define wxID_DEL10 102857-#define wxID_DEL11 102958-#define wxID_DEL12 103059-#define wxID_DEL13 103160-#define wxID_DEL14 103261-#define wxID_DEL15 103362-#define wxID_DEL16 103463-#define wxID_DEL17 103564-#define wxID_DEL18 103665-#define wxID_DEL19 103766-#define wxID_BUTTONPREVIEW 103867-#define wxID_BUTTONSAMPLE 103968-#define wxID_CANCEL2 104069-#define wxID_BUTTONBACK 104170-#define wxID_BUTTONNEXT 104271-#define wxID_SUBMIT 104372-#define wxID_OPENNEWTABLE 104473-#define wxID_DEALHAND 104574-#define wxID_FOLD 104675-#define wxID_CALL 104776-#define wxID_RAISE 104877-#define wxID_LEAVETABLE 104978-#define wxID_DITCHPLAYER 105079-#define wxID_TEXTCTRL 105180+#define wxID_VIEWSHOWGENERATED 100181+#define wxID_OPTIONSGENERATEBITCOINS 100282+#define wxID_MENUOPTIONSOPTIONS 100383+#define wxID_BUTTONSEND 100484+#define wxID_BUTTONRECEIVE 100585+#define wxID_TEXTCTRLADDRESS 100686+#define wxID_BUTTONCOPY 100787+#define wxID_BUTTONCHANGE 100888+#define wxID_TRANSACTIONFEE 100989+#define wxID_PROXYIP 101090+#define wxID_PROXYPORT 101191+#define wxID_TEXTCTRLPAYTO 101292+#define wxID_BUTTONPASTE 101393+#define wxID_BUTTONADDRESSBOOK 101494+#define wxID_TEXTCTRLAMOUNT 101595+#define wxID_CHOICETRANSFERTYPE 101696+#define wxID_LISTCTRL 101797+#define wxID_BUTTONRENAME 101898+#define wxID_BUTTONNEW 101999+#define wxID_BUTTONEDIT 1020100+#define wxID_BUTTONDELETE 1021101+#define wxID_DEL0 1022102+#define wxID_DEL1 1023103+#define wxID_DEL2 1024104+#define wxID_DEL3 1025105+#define wxID_DEL4 1026106+#define wxID_DEL5 1027107+#define wxID_DEL6 1028108+#define wxID_DEL7 1029109+#define wxID_DEL8 1030110+#define wxID_DEL9 1031111+#define wxID_DEL10 1032112+#define wxID_DEL11 1033113+#define wxID_DEL12 1034114+#define wxID_DEL13 1035115+#define wxID_DEL14 1036116+#define wxID_DEL15 1037117+#define wxID_DEL16 1038118+#define wxID_DEL17 1039119+#define wxID_DEL18 1040120+#define wxID_DEL19 1041121+#define wxID_BUTTONPREVIEW 1042122+#define wxID_BUTTONSAMPLE 1043123+#define wxID_CANCEL2 1044124+#define wxID_BUTTONBACK 1045125+#define wxID_BUTTONNEXT 1046126+#define wxID_SUBMIT 1047127+#define wxID_TEXTCTRL 1048128 129 ///////////////////////////////////////////////////////////////////////////////130 /// Class CMainFrameBase131 ///////////////////////////////////////////////////////////////////////////////132-class CMainFrameBase : public wxFrame133-{134-private:135-136-protected:137- wxMenuBar* m_menubar;138- wxMenu* m_menuFile;139- wxMenu* m_menuHelp;140- wxToolBar* m_toolBar;141- wxStatusBar* m_statusBar;142-143- wxStaticText* m_staticText32;144- wxTextCtrl* m_textCtrlAddress;145- wxButton* m_buttonCopy;146- wxButton* m_button91;147-148- wxPanel* m_panel14;149- wxStaticText* m_staticText41;150- wxStaticText* m_staticTextBalance;151-152- wxChoice* m_choiceFilter;153- wxNotebook* m_notebook;154- wxPanel* m_panel7;155- wxPanel* m_panel9;156- wxPanel* m_panel8;157- wxPanel* m_panel10;158- wxPanel* m_panel11;159-160- // Virtual event handlers, overide them in your derived class161- virtual void OnClose(wxCloseEvent& event){ event.Skip(); }162- virtual void OnIdle(wxIdleEvent& event){ event.Skip(); }163- virtual void OnMouseEvents(wxMouseEvent& event){ event.Skip(); }164- virtual void OnPaint(wxPaintEvent& event){ event.Skip(); }165- virtual void OnMenuFileExit(wxCommandEvent& event){ event.Skip(); }166- virtual void OnMenuOptionsGenerate(wxCommandEvent& event){ event.Skip(); }167- virtual void OnMenuOptionsChangeYourAddress(wxCommandEvent& event){ event.Skip(); }168- virtual void OnMenuOptionsOptions(wxCommandEvent& event){ event.Skip(); }169- virtual void OnMenuHelpAbout(wxCommandEvent& event){ event.Skip(); }170- virtual void OnButtonSend(wxCommandEvent& event){ event.Skip(); }171- virtual void OnButtonAddressBook(wxCommandEvent& event){ event.Skip(); }172- virtual void OnKeyDown(wxKeyEvent& event){ event.Skip(); }173- virtual void OnMouseEventsAddress(wxMouseEvent& event){ event.Skip(); }174- virtual void OnSetFocusAddress(wxFocusEvent& event){ event.Skip(); }175- virtual void OnButtonCopy(wxCommandEvent& event){ event.Skip(); }176- virtual void OnButtonChange(wxCommandEvent& event){ event.Skip(); }177- virtual void OnListColBeginDrag(wxListEvent& event){ event.Skip(); }178- virtual void OnListItemActivatedAllTransactions(wxListEvent& event){ event.Skip(); }179- virtual void OnPaintListCtrl(wxPaintEvent& event){ event.Skip(); }180- virtual void OnListItemActivatedOrdersSent(wxListEvent& event){ event.Skip(); }181- virtual void OnListItemActivatedProductsSent(wxListEvent& event){ event.Skip(); }182- virtual void OnListItemActivatedOrdersReceived(wxListEvent& event){ event.Skip(); }183-184-185-public:186- wxMenu* m_menuOptions;187- wxListCtrl* m_listCtrl;188- wxListCtrl* m_listCtrlEscrows;189- wxListCtrl* m_listCtrlOrdersSent;190- wxListCtrl* m_listCtrlProductsSent;191- wxListCtrl* m_listCtrlOrdersReceived;192- CMainFrameBase(wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = wxT("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(705,484), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL);193- ~CMainFrameBase();194-195+class CMainFrameBase : public wxFrame 196+{197+ private:198+ 199+ protected:200+ wxMenuBar* m_menubar;201+ wxMenu* m_menuFile;202+ wxMenu* m_menuView;203+ wxMenu* m_menuHelp;204+ wxToolBar* m_toolBar;205+ wxStatusBar* m_statusBar;206+ 207+ wxStaticText* m_staticText32;208+ wxTextCtrl* m_textCtrlAddress;209+ wxButton* m_buttonCopy;210+ wxButton* m_button91;211+ 212+ wxPanel* m_panel14;213+ wxStaticText* m_staticText41;214+ wxStaticText* m_staticTextBalance;215+ 216+ wxChoice* m_choiceFilter;217+ wxNotebook* m_notebook;218+ wxPanel* m_panel7;219+ wxPanel* m_panel9;220+ wxPanel* m_panel8;221+ wxPanel* m_panel10;222+ wxPanel* m_panel11;223+ 224+ // Virtual event handlers, overide them in your derived class225+ virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }226+ virtual void OnIconize( wxIconizeEvent& event ){ event.Skip(); }227+ virtual void OnIdle( wxIdleEvent& event ){ event.Skip(); }228+ virtual void OnMouseEvents( wxMouseEvent& event ){ event.Skip(); }229+ virtual void OnPaint( wxPaintEvent& event ){ event.Skip(); }230+ virtual void OnMenuFileExit( wxCommandEvent& event ){ event.Skip(); }231+ virtual void OnMenuViewShowGenerated( wxCommandEvent& event ){ event.Skip(); }232+ virtual void OnUpdateUIViewShowGenerated( wxUpdateUIEvent& event ){ event.Skip(); }233+ virtual void OnMenuOptionsGenerate( wxCommandEvent& event ){ event.Skip(); }234+ virtual void OnUpdateUIOptionsGenerate( wxUpdateUIEvent& event ){ event.Skip(); }235+ virtual void OnMenuOptionsChangeYourAddress( wxCommandEvent& event ){ event.Skip(); }236+ virtual void OnMenuOptionsOptions( wxCommandEvent& event ){ event.Skip(); }237+ virtual void OnMenuHelpAbout( wxCommandEvent& event ){ event.Skip(); }238+ virtual void OnButtonSend( wxCommandEvent& event ){ event.Skip(); }239+ virtual void OnButtonAddressBook( wxCommandEvent& event ){ event.Skip(); }240+ virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }241+ virtual void OnMouseEventsAddress( wxMouseEvent& event ){ event.Skip(); }242+ virtual void OnSetFocusAddress( wxFocusEvent& event ){ event.Skip(); }243+ virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }244+ virtual void OnButtonChange( wxCommandEvent& event ){ event.Skip(); }245+ virtual void OnListColBeginDrag( wxListEvent& event ){ event.Skip(); }246+ virtual void OnListItemActivatedAllTransactions( wxListEvent& event ){ event.Skip(); }247+ virtual void OnPaintListCtrl( wxPaintEvent& event ){ event.Skip(); }248+ virtual void OnListItemActivatedOrdersSent( wxListEvent& event ){ event.Skip(); }249+ virtual void OnListItemActivatedProductsSent( wxListEvent& event ){ event.Skip(); }250+ virtual void OnListItemActivatedOrdersReceived( wxListEvent& event ){ event.Skip(); }251+ 252+ 253+ public:254+ wxMenu* m_menuOptions;255+ wxListCtrl* m_listCtrl;256+ wxListCtrl* m_listCtrlEscrows;257+ wxListCtrl* m_listCtrlOrdersSent;258+ wxListCtrl* m_listCtrlProductsSent;259+ wxListCtrl* m_listCtrlOrdersReceived;260+ CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = wxT("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 705,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );261+ ~CMainFrameBase();262+ 263 };264 265 ///////////////////////////////////////////////////////////////////////////////266 /// Class CTxDetailsDialogBase267 ///////////////////////////////////////////////////////////////////////////////268-class CTxDetailsDialogBase : public wxDialog269-{270-private:271-272-protected:273- wxHtmlWindow* m_htmlWin;274- wxButton* m_buttonOK;275-276- // Virtual event handlers, overide them in your derived class277- virtual void OnButtonOK(wxCommandEvent& event){ event.Skip(); }278-279-280-public:281- CTxDetailsDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Transaction Details"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(620,450), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);282- ~CTxDetailsDialogBase();283-284+class CTxDetailsDialogBase : public wxDialog 285+{286+ private:287+ 288+ protected:289+ wxHtmlWindow* m_htmlWin;290+ wxButton* m_buttonOK;291+ 292+ // Virtual event handlers, overide them in your derived class293+ virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }294+ 295+ 296+ public:297+ CTxDetailsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Transaction Details"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 620,450 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );298+ ~CTxDetailsDialogBase();299+ 300 };301 302 ///////////////////////////////////////////////////////////////////////////////303 /// Class COptionsDialogBase304 ///////////////////////////////////////////////////////////////////////////////305-class COptionsDialogBase : public wxDialog306-{307-private:308-309-protected:310-311- wxStaticText* m_staticText32;312- wxStaticText* m_staticText31;313- wxTextCtrl* m_textCtrlTransactionFee;314- wxButton* m_buttonOK;315- wxButton* m_buttonCancel;316-317- // Virtual event handlers, overide them in your derived class318- virtual void OnKillFocusTransactionFee(wxFocusEvent& event){ event.Skip(); }319- virtual void OnButtonOK(wxCommandEvent& event){ event.Skip(); }320- virtual void OnButtonCancel(wxCommandEvent& event){ event.Skip(); }321-322-323-public:324- COptionsDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(500,261), long style = wxDEFAULT_DIALOG_STYLE);325- ~COptionsDialogBase();326-327+class COptionsDialogBase : public wxDialog 328+{329+ private:330+ 331+ protected:332+ wxListBox* m_listBox;333+ wxScrolledWindow* m_scrolledWindow;334+ wxPanel* m_panelMain;335+ 336+ wxStaticText* m_staticText32;337+ wxStaticText* m_staticText31;338+ wxTextCtrl* m_textCtrlTransactionFee;339+ wxCheckBox* m_checkBoxLimitProcessors;340+ wxSpinCtrl* m_spinCtrlLimitProcessors;341+ wxStaticText* m_staticText35;342+ wxCheckBox* m_checkBoxStartOnSystemStartup;343+ wxCheckBox* m_checkBoxMinimizeToTray;344+ wxCheckBox* m_checkBoxMinimizeOnClose;345+ wxCheckBox* m_checkBoxUseProxy;346+ 347+ wxStaticText* m_staticTextProxyIP;348+ wxTextCtrl* m_textCtrlProxyIP;349+ wxStaticText* m_staticTextProxyPort;350+ wxTextCtrl* m_textCtrlProxyPort;351+ wxPanel* m_panelTest2;352+ 353+ wxStaticText* m_staticText321;354+ wxStaticText* m_staticText69;355+ wxStaticText* m_staticText70;356+ wxStaticText* m_staticText71;357+ wxButton* m_buttonOK;358+ wxButton* m_buttonCancel;359+ wxButton* m_buttonApply;360+ 361+ // Virtual event handlers, overide them in your derived class362+ virtual void OnListBox( wxCommandEvent& event ){ event.Skip(); }363+ virtual void OnKillFocusTransactionFee( wxFocusEvent& event ){ event.Skip(); }364+ virtual void OnCheckBoxLimitProcessors( wxCommandEvent& event ){ event.Skip(); }365+ virtual void OnCheckBoxMinimizeToTray( wxCommandEvent& event ){ event.Skip(); }366+ virtual void OnCheckBoxUseProxy( wxCommandEvent& event ){ event.Skip(); }367+ virtual void OnKillFocusProxy( wxFocusEvent& event ){ event.Skip(); }368+ virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }369+ virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }370+ virtual void OnButtonApply( wxCommandEvent& event ){ event.Skip(); }371+ 372+ 373+ public:374+ COptionsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 540,360 ), long style = wxDEFAULT_DIALOG_STYLE );375+ ~COptionsDialogBase();376+ 377 };378 379 ///////////////////////////////////////////////////////////////////////////////380 /// Class CAboutDialogBase381 ///////////////////////////////////////////////////////////////////////////////382-class CAboutDialogBase : public wxDialog383-{384-private:385-386-protected:387-388-389- wxStaticText* m_staticText40;390-391- wxStaticText* m_staticTextMain;392-393-394- wxButton* m_buttonOK;395-396- // Virtual event handlers, overide them in your derived class397- virtual void OnButtonOK(wxCommandEvent& event){ event.Skip(); }398-399-400-public:401- wxStaticText* m_staticTextVersion;402- CAboutDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(507,298), long style = wxDEFAULT_DIALOG_STYLE);403- ~CAboutDialogBase();404-405+class CAboutDialogBase : public wxDialog 406+{407+ private:408+ 409+ protected:410+ 411+ 412+ wxStaticText* m_staticText40;413+ 414+ wxStaticText* m_staticTextMain;415+ 416+ 417+ wxButton* m_buttonOK;418+ 419+ // Virtual event handlers, overide them in your derived class420+ virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }421+ 422+ 423+ public:424+ wxStaticText* m_staticTextVersion;425+ CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 507,298 ), long style = wxDEFAULT_DIALOG_STYLE );426+ ~CAboutDialogBase();427+ 428 };429 430 ///////////////////////////////////////////////////////////////////////////////431 /// Class CSendDialogBase432 ///////////////////////////////////////////////////////////////////////////////433-class CSendDialogBase : public wxDialog434-{435-private:436-437-protected:438-439-440- wxStaticText* m_staticText14;441-442- wxStaticBitmap* m_bitmapCheckMark;443- wxStaticText* m_staticText36;444- wxTextCtrl* m_textCtrlAddress;445- wxButton* m_buttonPaste;446- wxButton* m_buttonAddress;447- wxStaticText* m_staticText19;448- wxTextCtrl* m_textCtrlAmount;449- wxStaticText* m_staticText20;450- wxChoice* m_choiceTransferType;451-452-453- wxStaticText* m_staticTextFrom;454- wxTextCtrl* m_textCtrlFrom;455- wxStaticText* m_staticTextMessage;456- wxTextCtrl* m_textCtrlMessage;457-458- wxButton* m_buttonSend;459- wxButton* m_buttonCancel;460-461- // Virtual event handlers, overide them in your derived class462- virtual void OnKeyDown(wxKeyEvent& event){ event.Skip(); }463- virtual void OnTextAddress(wxCommandEvent& event){ event.Skip(); }464- virtual void OnButtonPaste(wxCommandEvent& event){ event.Skip(); }465- virtual void OnButtonAddressBook(wxCommandEvent& event){ event.Skip(); }466- virtual void OnKillFocusAmount(wxFocusEvent& event){ event.Skip(); }467- virtual void OnButtonSend(wxCommandEvent& event){ event.Skip(); }468- virtual void OnButtonCancel(wxCommandEvent& event){ event.Skip(); }469-470-471-public:472- CSendDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(675,312), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);473- ~CSendDialogBase();474-475+class CSendDialogBase : public wxDialog 476+{477+ private:478+ 479+ protected:480+ 481+ 482+ wxStaticText* m_staticTextInstructions;483+ 484+ wxStaticBitmap* m_bitmapCheckMark;485+ wxStaticText* m_staticText36;486+ wxTextCtrl* m_textCtrlAddress;487+ wxButton* m_buttonPaste;488+ wxButton* m_buttonAddress;489+ wxStaticText* m_staticText19;490+ wxTextCtrl* m_textCtrlAmount;491+ wxStaticText* m_staticText20;492+ wxChoice* m_choiceTransferType;493+ 494+ 495+ wxStaticText* m_staticTextFrom;496+ wxTextCtrl* m_textCtrlFrom;497+ wxStaticText* m_staticTextMessage;498+ wxTextCtrl* m_textCtrlMessage;499+ 500+ wxButton* m_buttonSend;501+ wxButton* m_buttonCancel;502+ 503+ // Virtual event handlers, overide them in your derived class504+ virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }505+ virtual void OnTextAddress( wxCommandEvent& event ){ event.Skip(); }506+ virtual void OnButtonPaste( wxCommandEvent& event ){ event.Skip(); }507+ virtual void OnButtonAddressBook( wxCommandEvent& event ){ event.Skip(); }508+ virtual void OnKillFocusAmount( wxFocusEvent& event ){ event.Skip(); }509+ virtual void OnButtonSend( wxCommandEvent& event ){ event.Skip(); }510+ virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }511+ 512+ 513+ public:514+ CSendDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 675,312 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );515+ ~CSendDialogBase();516+ 517 };518 519 ///////////////////////////////////////////////////////////////////////////////520 /// Class CSendingDialogBase521 ///////////////////////////////////////////////////////////////////////////////522-class CSendingDialogBase : public wxDialog523-{524-private:525-526-protected:527- wxStaticText* m_staticTextSending;528- wxTextCtrl* m_textCtrlStatus;529-530- wxButton* m_buttonOK;531- wxButton* m_buttonCancel;532-533- // Virtual event handlers, overide them in your derived class534- virtual void OnClose(wxCloseEvent& event){ event.Skip(); }535- virtual void OnPaint(wxPaintEvent& event){ event.Skip(); }536- virtual void OnButtonOK(wxCommandEvent& event){ event.Skip(); }537- virtual void OnButtonCancel(wxCommandEvent& event){ event.Skip(); }538-539-540-public:541- CSendingDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Sending..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(442,151), long style = wxDEFAULT_DIALOG_STYLE);542- ~CSendingDialogBase();543-544+class CSendingDialogBase : public wxDialog 545+{546+ private:547+ 548+ protected:549+ wxStaticText* m_staticTextSending;550+ wxTextCtrl* m_textCtrlStatus;551+ 552+ wxButton* m_buttonOK;553+ wxButton* m_buttonCancel;554+ 555+ // Virtual event handlers, overide them in your derived class556+ virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }557+ virtual void OnPaint( wxPaintEvent& event ){ event.Skip(); }558+ virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }559+ virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }560+ 561+ 562+ public:563+ CSendingDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Sending..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 442,151 ), long style = wxDEFAULT_DIALOG_STYLE );564+ ~CSendingDialogBase();565+ 566 };567 568 ///////////////////////////////////////////////////////////////////////////////569 /// Class CYourAddressDialogBase570 ///////////////////////////////////////////////////////////////////////////////571-class CYourAddressDialogBase : public wxDialog572-{573-private:574-575-protected:576-577- wxStaticText* m_staticText45;578- wxListCtrl* m_listCtrl;579-580- wxButton* m_buttonRename;581- wxButton* m_buttonNew;582- wxButton* m_buttonCopy;583- wxButton* m_buttonOK;584- wxButton* m_buttonCancel;585-586- // Virtual event handlers, overide them in your derived class587- virtual void OnClose(wxCloseEvent& event){ event.Skip(); }588- virtual void OnListEndLabelEdit(wxListEvent& event){ event.Skip(); }589- virtual void OnListItemActivated(wxListEvent& event){ event.Skip(); }590- virtual void OnListItemSelected(wxListEvent& event){ event.Skip(); }591- virtual void OnButtonRename(wxCommandEvent& event){ event.Skip(); }592- virtual void OnButtonNew(wxCommandEvent& event){ event.Skip(); }593- virtual void OnButtonCopy(wxCommandEvent& event){ event.Skip(); }594- virtual void OnButtonOK(wxCommandEvent& event){ event.Skip(); }595- virtual void OnButtonCancel(wxCommandEvent& event){ event.Skip(); }596-597-598-public:599- CYourAddressDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Your Bitcoin Addresses"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(610,390), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);600- ~CYourAddressDialogBase();601-602+class CYourAddressDialogBase : public wxDialog 603+{604+ private:605+ 606+ protected:607+ 608+ wxStaticText* m_staticText45;609+ wxListCtrl* m_listCtrl;610+ 611+ wxButton* m_buttonRename;612+ wxButton* m_buttonNew;613+ wxButton* m_buttonCopy;614+ wxButton* m_buttonOK;615+ wxButton* m_buttonCancel;616+ 617+ // Virtual event handlers, overide them in your derived class618+ virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }619+ virtual void OnListEndLabelEdit( wxListEvent& event ){ event.Skip(); }620+ virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }621+ virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); }622+ virtual void OnButtonRename( wxCommandEvent& event ){ event.Skip(); }623+ virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); }624+ virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }625+ virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }626+ virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }627+ 628+ 629+ public:630+ CYourAddressDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Your Bitcoin Addresses"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );631+ ~CYourAddressDialogBase();632+ 633 };634 635 ///////////////////////////////////////////////////////////////////////////////636 /// Class CAddressBookDialogBase637 ///////////////////////////////////////////////////////////////////////////////638-class CAddressBookDialogBase : public wxDialog639-{640-private:641-642-protected:643-644- wxStaticText* m_staticText55;645- wxListCtrl* m_listCtrl;646-647- wxButton* m_buttonEdit;648- wxButton* m_buttonNew;649- wxButton* m_buttonDelete;650- wxButton* m_buttonOK;651-652- // Virtual event handlers, overide them in your derived class653- virtual void OnClose(wxCloseEvent& event){ event.Skip(); }654- virtual void OnListEndLabelEdit(wxListEvent& event){ event.Skip(); }655- virtual void OnListItemActivated(wxListEvent& event){ event.Skip(); }656- virtual void OnListItemSelected(wxListEvent& event){ event.Skip(); }657- virtual void OnButtonEdit(wxCommandEvent& event){ event.Skip(); }658- virtual void OnButtonNew(wxCommandEvent& event){ event.Skip(); }659- virtual void OnButtonDelete(wxCommandEvent& event){ event.Skip(); }660- virtual void OnButtonOK(wxCommandEvent& event){ event.Skip(); }661- virtual void OnButtonCancel(wxCommandEvent& event){ event.Skip(); }662-663-664-public:665- wxButton* m_buttonCancel;666- CAddressBookDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Address Book"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(610,390), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);667- ~CAddressBookDialogBase();668-669+class CAddressBookDialogBase : public wxDialog 670+{671+ private:672+ 673+ protected:674+ 675+ wxStaticText* m_staticText55;676+ wxListCtrl* m_listCtrl;677+ 678+ wxButton* m_buttonEdit;679+ wxButton* m_buttonNew;680+ wxButton* m_buttonDelete;681+ wxButton* m_buttonOK;682+ 683+ // Virtual event handlers, overide them in your derived class684+ virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }685+ virtual void OnListEndLabelEdit( wxListEvent& event ){ event.Skip(); }686+ virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }687+ virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); }688+ virtual void OnButtonEdit( wxCommandEvent& event ){ event.Skip(); }689+ virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); }690+ virtual void OnButtonDelete( wxCommandEvent& event ){ event.Skip(); }691+ virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }692+ virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }693+ 694+ 695+ public:696+ wxButton* m_buttonCancel;697+ CAddressBookDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Address Book"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );698+ ~CAddressBookDialogBase();699+ 700 };701 702 ///////////////////////////////////////////////////////////////////////////////703 /// Class CProductsDialogBase704 ///////////////////////////////////////////////////////////////////////////////705-class CProductsDialogBase : public wxDialog706-{707-private:708-709-protected:710- wxComboBox* m_comboBoxCategory;711- wxTextCtrl* m_textCtrlSearch;712- wxButton* m_buttonSearch;713- wxListCtrl* m_listCtrl;714-715- // Virtual event handlers, overide them in your derived class716- virtual void OnCombobox(wxCommandEvent& event){ event.Skip(); }717- virtual void OnKeyDown(wxKeyEvent& event){ event.Skip(); }718- virtual void OnButtonSearch(wxCommandEvent& event){ event.Skip(); }719- virtual void OnListItemActivated(wxListEvent& event){ event.Skip(); }720-721-722-public:723- CProductsDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Marketplace"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(708,535), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);724- ~CProductsDialogBase();725-726+class CProductsDialogBase : public wxDialog 727+{728+ private:729+ 730+ protected:731+ wxComboBox* m_comboBoxCategory;732+ wxTextCtrl* m_textCtrlSearch;733+ wxButton* m_buttonSearch;734+ wxListCtrl* m_listCtrl;735+ 736+ // Virtual event handlers, overide them in your derived class737+ virtual void OnCombobox( wxCommandEvent& event ){ event.Skip(); }738+ virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }739+ virtual void OnButtonSearch( wxCommandEvent& event ){ event.Skip(); }740+ virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }741+ 742+ 743+ public:744+ CProductsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Marketplace"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 708,535 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );745+ ~CProductsDialogBase();746+ 747 };748 749 ///////////////////////////////////////////////////////////////////////////////750 /// Class CEditProductDialogBase751 ///////////////////////////////////////////////////////////////////////////////752-class CEditProductDialogBase : public wxFrame753-{754-private:755-756-protected:757- wxScrolledWindow* m_scrolledWindow;758- wxStaticText* m_staticText106;759- wxComboBox* m_comboBoxCategory;760- wxStaticText* m_staticText108;761- wxTextCtrl* m_textCtrlTitle;762- wxStaticText* m_staticText107;763- wxTextCtrl* m_textCtrlPrice;764- wxStaticText* m_staticText22;765- wxTextCtrl* m_textCtrlDescription;766- wxStaticText* m_staticText23;767- wxTextCtrl* m_textCtrlInstructions;768- wxStaticText* m_staticText24;769- wxStaticText* m_staticText25;770-771- wxTextCtrl* m_textCtrlLabel0;772- wxTextCtrl* m_textCtrlField0;773- wxButton* m_buttonDel0;774- wxTextCtrl* m_textCtrlLabel1;775- wxTextCtrl* m_textCtrlField1;776- wxButton* m_buttonDel1;777- wxTextCtrl* m_textCtrlLabel2;778- wxTextCtrl* m_textCtrlField2;779- wxButton* m_buttonDel2;780- wxTextCtrl* m_textCtrlLabel3;781- wxTextCtrl* m_textCtrlField3;782- wxButton* m_buttonDel3;783- wxTextCtrl* m_textCtrlLabel4;784- wxTextCtrl* m_textCtrlField4;785- wxButton* m_buttonDel4;786- wxTextCtrl* m_textCtrlLabel5;787- wxTextCtrl* m_textCtrlField5;788- wxButton* m_buttonDel5;789- wxTextCtrl* m_textCtrlLabel6;790- wxTextCtrl* m_textCtrlField6;791- wxButton* m_buttonDel6;792- wxTextCtrl* m_textCtrlLabel7;793- wxTextCtrl* m_textCtrlField7;794- wxButton* m_buttonDel7;795- wxTextCtrl* m_textCtrlLabel8;796- wxTextCtrl* m_textCtrlField8;797- wxButton* m_buttonDel8;798- wxTextCtrl* m_textCtrlLabel9;799- wxTextCtrl* m_textCtrlField9;800- wxButton* m_buttonDel9;801- wxTextCtrl* m_textCtrlLabel10;802- wxTextCtrl* m_textCtrlField10;803- wxButton* m_buttonDel10;804- wxTextCtrl* m_textCtrlLabel11;805- wxTextCtrl* m_textCtrlField11;806- wxButton* m_buttonDel11;807- wxTextCtrl* m_textCtrlLabel12;808- wxTextCtrl* m_textCtrlField12;809- wxButton* m_buttonDel12;810- wxTextCtrl* m_textCtrlLabel13;811- wxTextCtrl* m_textCtrlField13;812- wxButton* m_buttonDel13;813- wxTextCtrl* m_textCtrlLabel14;814- wxTextCtrl* m_textCtrlField14;815- wxButton* m_buttonDel14;816- wxTextCtrl* m_textCtrlLabel15;817- wxTextCtrl* m_textCtrlField15;818- wxButton* m_buttonDel15;819- wxTextCtrl* m_textCtrlLabel16;820- wxTextCtrl* m_textCtrlField16;821- wxButton* m_buttonDel16;822- wxTextCtrl* m_textCtrlLabel17;823- wxTextCtrl* m_textCtrlField17;824- wxButton* m_buttonDel17;825- wxTextCtrl* m_textCtrlLabel18;826- wxTextCtrl* m_textCtrlField18;827- wxButton* m_buttonDel18;828- wxTextCtrl* m_textCtrlLabel19;829- wxTextCtrl* m_textCtrlField19;830- wxButton* m_buttonDel19;831- wxButton* m_buttonAddField;832- wxButton* m_buttonOK;833- wxButton* m_buttonPreview;834- wxButton* m_buttonCancel;835-836- // Virtual event handlers, overide them in your derived class837- virtual void OnKeyDown(wxKeyEvent& event){ event.Skip(); }838- virtual void OnButtonDel0(wxCommandEvent& event){ event.Skip(); }839- virtual void OnButtonDel1(wxCommandEvent& event){ event.Skip(); }840- virtual void OnButtonDel2(wxCommandEvent& event){ event.Skip(); }841- virtual void OnButtonDel3(wxCommandEvent& event){ event.Skip(); }842- virtual void OnButtonDel4(wxCommandEvent& event){ event.Skip(); }843- virtual void OnButtonDel5(wxCommandEvent& event){ event.Skip(); }844- virtual void OnButtonDel6(wxCommandEvent& event){ event.Skip(); }845- virtual void OnButtonDel7(wxCommandEvent& event){ event.Skip(); }846- virtual void OnButtonDel8(wxCommandEvent& event){ event.Skip(); }847- virtual void OnButtonDel9(wxCommandEvent& event){ event.Skip(); }848- virtual void OnButtonDel10(wxCommandEvent& event){ event.Skip(); }849- virtual void OnButtonDel11(wxCommandEvent& event){ event.Skip(); }850- virtual void OnButtonDel12(wxCommandEvent& event){ event.Skip(); }851- virtual void OnButtonDel13(wxCommandEvent& event){ event.Skip(); }852- virtual void OnButtonDel14(wxCommandEvent& event){ event.Skip(); }853- virtual void OnButtonDel15(wxCommandEvent& event){ event.Skip(); }854- virtual void OnButtonDel16(wxCommandEvent& event){ event.Skip(); }855- virtual void OnButtonDel17(wxCommandEvent& event){ event.Skip(); }856- virtual void OnButtonDel18(wxCommandEvent& event){ event.Skip(); }857- virtual void OnButtonDel19(wxCommandEvent& event){ event.Skip(); }858- virtual void OnButtonAddField(wxCommandEvent& event){ event.Skip(); }859- virtual void OnButtonSend(wxCommandEvent& event){ event.Skip(); }860- virtual void OnButtonPreview(wxCommandEvent& event){ event.Skip(); }861- virtual void OnButtonCancel(wxCommandEvent& event){ event.Skip(); }862-863-864-public:865- wxFlexGridSizer* fgSizer5;866- CEditProductDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Edit Product"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(660,640), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL);867- ~CEditProductDialogBase();868-869+class CEditProductDialogBase : public wxFrame 870+{871+ private:872+ 873+ protected:874+ wxScrolledWindow* m_scrolledWindow;875+ wxStaticText* m_staticText106;876+ wxComboBox* m_comboBoxCategory;877+ wxStaticText* m_staticText108;878+ wxTextCtrl* m_textCtrlTitle;879+ wxStaticText* m_staticText107;880+ wxTextCtrl* m_textCtrlPrice;881+ wxStaticText* m_staticText22;882+ wxTextCtrl* m_textCtrlDescription;883+ wxStaticText* m_staticText23;884+ wxTextCtrl* m_textCtrlInstructions;885+ wxStaticText* m_staticText24;886+ wxStaticText* m_staticText25;887+ 888+ wxTextCtrl* m_textCtrlLabel0;889+ wxTextCtrl* m_textCtrlField0;890+ wxButton* m_buttonDel0;891+ wxTextCtrl* m_textCtrlLabel1;892+ wxTextCtrl* m_textCtrlField1;893+ wxButton* m_buttonDel1;894+ wxTextCtrl* m_textCtrlLabel2;895+ wxTextCtrl* m_textCtrlField2;896+ wxButton* m_buttonDel2;897+ wxTextCtrl* m_textCtrlLabel3;898+ wxTextCtrl* m_textCtrlField3;899+ wxButton* m_buttonDel3;900+ wxTextCtrl* m_textCtrlLabel4;901+ wxTextCtrl* m_textCtrlField4;902+ wxButton* m_buttonDel4;903+ wxTextCtrl* m_textCtrlLabel5;904+ wxTextCtrl* m_textCtrlField5;905+ wxButton* m_buttonDel5;906+ wxTextCtrl* m_textCtrlLabel6;907+ wxTextCtrl* m_textCtrlField6;908+ wxButton* m_buttonDel6;909+ wxTextCtrl* m_textCtrlLabel7;910+ wxTextCtrl* m_textCtrlField7;911+ wxButton* m_buttonDel7;912+ wxTextCtrl* m_textCtrlLabel8;913+ wxTextCtrl* m_textCtrlField8;914+ wxButton* m_buttonDel8;915+ wxTextCtrl* m_textCtrlLabel9;916+ wxTextCtrl* m_textCtrlField9;917+ wxButton* m_buttonDel9;918+ wxTextCtrl* m_textCtrlLabel10;919+ wxTextCtrl* m_textCtrlField10;920+ wxButton* m_buttonDel10;921+ wxTextCtrl* m_textCtrlLabel11;922+ wxTextCtrl* m_textCtrlField11;923+ wxButton* m_buttonDel11;924+ wxTextCtrl* m_textCtrlLabel12;925+ wxTextCtrl* m_textCtrlField12;926+ wxButton* m_buttonDel12;927+ wxTextCtrl* m_textCtrlLabel13;928+ wxTextCtrl* m_textCtrlField13;929+ wxButton* m_buttonDel13;930+ wxTextCtrl* m_textCtrlLabel14;931+ wxTextCtrl* m_textCtrlField14;932+ wxButton* m_buttonDel14;933+ wxTextCtrl* m_textCtrlLabel15;934+ wxTextCtrl* m_textCtrlField15;935+ wxButton* m_buttonDel15;936+ wxTextCtrl* m_textCtrlLabel16;937+ wxTextCtrl* m_textCtrlField16;938+ wxButton* m_buttonDel16;939+ wxTextCtrl* m_textCtrlLabel17;940+ wxTextCtrl* m_textCtrlField17;941+ wxButton* m_buttonDel17;942+ wxTextCtrl* m_textCtrlLabel18;943+ wxTextCtrl* m_textCtrlField18;944+ wxButton* m_buttonDel18;945+ wxTextCtrl* m_textCtrlLabel19;946+ wxTextCtrl* m_textCtrlField19;947+ wxButton* m_buttonDel19;948+ wxButton* m_buttonAddField;949+ wxButton* m_buttonOK;950+ wxButton* m_buttonPreview;951+ wxButton* m_buttonCancel;952+ 953+ // Virtual event handlers, overide them in your derived class954+ virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }955+ virtual void OnButtonDel0( wxCommandEvent& event ){ event.Skip(); }956+ virtual void OnButtonDel1( wxCommandEvent& event ){ event.Skip(); }957+ virtual void OnButtonDel2( wxCommandEvent& event ){ event.Skip(); }958+ virtual void OnButtonDel3( wxCommandEvent& event ){ event.Skip(); }959+ virtual void OnButtonDel4( wxCommandEvent& event ){ event.Skip(); }960+ virtual void OnButtonDel5( wxCommandEvent& event ){ event.Skip(); }961+ virtual void OnButtonDel6( wxCommandEvent& event ){ event.Skip(); }962+ virtual void OnButtonDel7( wxCommandEvent& event ){ event.Skip(); }963+ virtual void OnButtonDel8( wxCommandEvent& event ){ event.Skip(); }964+ virtual void OnButtonDel9( wxCommandEvent& event ){ event.Skip(); }965+ virtual void OnButtonDel10( wxCommandEvent& event ){ event.Skip(); }966+ virtual void OnButtonDel11( wxCommandEvent& event ){ event.Skip(); }967+ virtual void OnButtonDel12( wxCommandEvent& event ){ event.Skip(); }968+ virtual void OnButtonDel13( wxCommandEvent& event ){ event.Skip(); }969+ virtual void OnButtonDel14( wxCommandEvent& event ){ event.Skip(); }970+ virtual void OnButtonDel15( wxCommandEvent& event ){ event.Skip(); }971+ virtual void OnButtonDel16( wxCommandEvent& event ){ event.Skip(); }972+ virtual void OnButtonDel17( wxCommandEvent& event ){ event.Skip(); }973+ virtual void OnButtonDel18( wxCommandEvent& event ){ event.Skip(); }974+ virtual void OnButtonDel19( wxCommandEvent& event ){ event.Skip(); }975+ virtual void OnButtonAddField( wxCommandEvent& event ){ event.Skip(); }976+ virtual void OnButtonSend( wxCommandEvent& event ){ event.Skip(); }977+ virtual void OnButtonPreview( wxCommandEvent& event ){ event.Skip(); }978+ virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }979+ 980+ 981+ public:982+ wxFlexGridSizer* fgSizer5;983+ CEditProductDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Edit Product"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 660,640 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );984+ ~CEditProductDialogBase();985+ 986 };987 988 ///////////////////////////////////////////////////////////////////////////////989 /// Class CViewProductDialogBase990 ///////////////////////////////////////////////////////////////////////////////991-class CViewProductDialogBase : public wxFrame992-{993-private:994-995-protected:996- wxHtmlWindow* m_htmlWinReviews;997- wxScrolledWindow* m_scrolledWindow;998- wxRichTextCtrl* m_richTextHeading;999- wxStaticText* m_staticTextInstructions;1000- wxButton* m_buttonSubmitForm;1001- wxButton* m_buttonCancelForm;1002- wxButton* m_buttonBack;1003- wxButton* m_buttonNext;1004- wxButton* m_buttonCancel;1005-1006- // Virtual event handlers, overide them in your derived class1007- virtual void OnButtonSubmitForm(wxCommandEvent& event){ event.Skip(); }1008- virtual void OnButtonCancelForm(wxCommandEvent& event){ event.Skip(); }1009- virtual void OnButtonBack(wxCommandEvent& event){ event.Skip(); }1010- virtual void OnButtonNext(wxCommandEvent& event){ event.Skip(); }1011- virtual void OnButtonCancel(wxCommandEvent& event){ event.Skip(); }1012-1013-1014-public:1015- CViewProductDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Order Form"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(630,520), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL);1016- ~CViewProductDialogBase();1017-1018+class CViewProductDialogBase : public wxFrame 1019+{1020+ private:1021+ 1022+ protected:1023+ wxHtmlWindow* m_htmlWinReviews;1024+ wxScrolledWindow* m_scrolledWindow;1025+ wxRichTextCtrl* m_richTextHeading;1026+ wxStaticText* m_staticTextInstructions;1027+ wxButton* m_buttonSubmitForm;1028+ wxButton* m_buttonCancelForm;1029+ wxButton* m_buttonBack;1030+ wxButton* m_buttonNext;1031+ wxButton* m_buttonCancel;1032+ 1033+ // Virtual event handlers, overide them in your derived class1034+ virtual void OnButtonSubmitForm( wxCommandEvent& event ){ event.Skip(); }1035+ virtual void OnButtonCancelForm( wxCommandEvent& event ){ event.Skip(); }1036+ virtual void OnButtonBack( wxCommandEvent& event ){ event.Skip(); }1037+ virtual void OnButtonNext( wxCommandEvent& event ){ event.Skip(); }1038+ virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }1039+ 1040+ 1041+ public:1042+ CViewProductDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Order Form"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 630,520 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );1043+ ~CViewProductDialogBase();1044+ 1045 };1046 1047 ///////////////////////////////////////////////////////////////////////////////1048 /// Class CViewOrderDialogBase1049 ///////////////////////////////////////////////////////////////////////////////1050-class CViewOrderDialogBase : public wxFrame1051-{1052-private:1053-1054-protected:1055- wxHtmlWindow* m_htmlWin;1056- wxButton* m_buttonOK;1057-1058- // Virtual event handlers, overide them in your derived class1059- virtual void OnButtonOK(wxCommandEvent& event){ event.Skip(); }1060-1061-1062-public:1063- CViewOrderDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("View Order"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(630,520), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL);1064- ~CViewOrderDialogBase();1065-1066+class CViewOrderDialogBase : public wxFrame 1067+{1068+ private:1069+ 1070+ protected:1071+ wxHtmlWindow* m_htmlWin;1072+ wxButton* m_buttonOK;1073+ 1074+ // Virtual event handlers, overide them in your derived class1075+ virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }1076+ 1077+ 1078+ public:1079+ CViewOrderDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("View Order"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 630,520 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );1080+ ~CViewOrderDialogBase();1081+ 1082 };1083 1084 ///////////////////////////////////////////////////////////////////////////////1085 /// Class CEditReviewDialogBase1086 ///////////////////////////////////////////////////////////////////////////////1087-class CEditReviewDialogBase : public wxFrame1088-{1089-private:1090-1091-protected:1092-1093- wxStaticText* m_staticTextSeller;1094-1095- wxStaticText* m_staticText110;1096- wxChoice* m_choiceStars;1097- wxStaticText* m_staticText43;1098- wxTextCtrl* m_textCtrlReview;1099- wxButton* m_buttonSubmit;1100- wxButton* m_buttonCancel;1101-1102- // Virtual event handlers, overide them in your derived class1103- virtual void OnKeyDown(wxKeyEvent& event){ event.Skip(); }1104- virtual void OnButtonSubmit(wxCommandEvent& event){ event.Skip(); }1105- virtual void OnButtonCancel(wxCommandEvent& event){ event.Skip(); }1106-1107-1108-public:1109- CEditReviewDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Enter Review"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(630,440), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL);1110- ~CEditReviewDialogBase();1111-1112-};1113-1114-///////////////////////////////////////////////////////////////////////////////1115-/// Class CPokerLobbyDialogBase1116-///////////////////////////////////////////////////////////////////////////////1117-class CPokerLobbyDialogBase : public wxFrame1118-{1119-private:1120-1121-protected:1122- wxTreeCtrl* m_treeCtrl;1123- wxListCtrl* m_listCtrl;1124- wxButton* m_buttonNewTable;1125-1126- // Virtual event handlers, overide them in your derived class1127- virtual void OnTreeSelChanged(wxTreeEvent& event){ event.Skip(); }1128- virtual void OnListItemActivated(wxListEvent& event){ event.Skip(); }1129- virtual void OnListItemSelected(wxListEvent& event){ event.Skip(); }1130- virtual void OnButtonNewTable(wxCommandEvent& event){ event.Skip(); }1131-1132-1133-public:1134- CPokerLobbyDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Poker Lobby"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(586,457), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL);1135- ~CPokerLobbyDialogBase();1136-1137-};1138-1139-///////////////////////////////////////////////////////////////////////////////1140-/// Class CPokerDialogBase1141-///////////////////////////////////////////////////////////////////////////////1142-class CPokerDialogBase : public wxFrame1143-{1144-private:1145-1146-protected:1147- wxButton* m_buttonDealHand;1148- wxButton* m_buttonFold;1149- wxButton* m_buttonCall;1150- wxButton* m_buttonRaise;1151- wxButton* m_buttonLeaveTable;1152- wxTextCtrl* m_textDitchPlayer;1153-1154- // Virtual event handlers, overide them in your derived class1155- virtual void OnClose(wxCloseEvent& event){ event.Skip(); }1156- virtual void OnMouseEvents(wxMouseEvent& event){ event.Skip(); }1157- virtual void OnPaint(wxPaintEvent& event){ event.Skip(); }1158- virtual void OnSize(wxSizeEvent& event){ event.Skip(); }1159- virtual void OnCheckSitOut(wxCommandEvent& event){ event.Skip(); }1160- virtual void OnButtonDealHand(wxCommandEvent& event){ event.Skip(); }1161- virtual void OnButtonFold(wxCommandEvent& event){ event.Skip(); }1162- virtual void OnButtonCall(wxCommandEvent& event){ event.Skip(); }1163- virtual void OnButtonRaise(wxCommandEvent& event){ event.Skip(); }1164- virtual void OnButtonLeaveTable(wxCommandEvent& event){ event.Skip(); }1165- virtual void OnDitchPlayer(wxCommandEvent& event){ event.Skip(); }1166- virtual void OnCheckPreFold(wxCommandEvent& event){ event.Skip(); }1167- virtual void OnCheckPreCall(wxCommandEvent& event){ event.Skip(); }1168- virtual void OnCheckPreCallAny(wxCommandEvent& event){ event.Skip(); }1169- virtual void OnCheckPreRaise(wxCommandEvent& event){ event.Skip(); }1170- virtual void OnCheckPreRaiseAny(wxCommandEvent& event){ event.Skip(); }1171-1172-1173-public:1174- wxCheckBox* m_checkSitOut;1175- wxCheckBox* m_checkPreFold;1176- wxCheckBox* m_checkPreCall;1177- wxCheckBox* m_checkPreCallAny;1178- wxCheckBox* m_checkPreRaise;1179- wxCheckBox* m_checkPreRaiseAny;1180- wxStatusBar* m_statusBar;1181- CPokerDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Poker"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(806,550), long style = wxDEFAULT_FRAME_STYLE|wxFRAME_NO_TASKBAR|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL);1182- ~CPokerDialogBase();1183-1184+class CEditReviewDialogBase : public wxFrame 1185+{1186+ private:1187+ 1188+ protected:1189+ 1190+ wxStaticText* m_staticTextSeller;1191+ 1192+ wxStaticText* m_staticText110;1193+ wxChoice* m_choiceStars;1194+ wxStaticText* m_staticText43;1195+ wxTextCtrl* m_textCtrlReview;1196+ wxButton* m_buttonSubmit;1197+ wxButton* m_buttonCancel;1198+ 1199+ // Virtual event handlers, overide them in your derived class1200+ virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }1201+ virtual void OnButtonSubmit( wxCommandEvent& event ){ event.Skip(); }1202+ virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }1203+ 1204+ 1205+ public:1206+ CEditReviewDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Enter Review"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 630,440 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );1207+ ~CEditReviewDialogBase();1208+ 1209 };1210 1211 ///////////////////////////////////////////////////////////////////////////////1212 /// Class CGetTextFromUserDialogBase1213 ///////////////////////////////////////////////////////////////////////////////1214-class CGetTextFromUserDialogBase : public wxDialog1215-{1216-private:1217-1218-protected:1219-1220- wxStaticText* m_staticTextMessage1;1221- wxTextCtrl* m_textCtrl1;1222- wxStaticText* m_staticTextMessage2;1223- wxTextCtrl* m_textCtrl2;1224-1225-1226- wxButton* m_buttonOK;1227- wxButton* m_buttonCancel;1228-1229- // Virtual event handlers, overide them in your derived class1230- virtual void OnClose(wxCloseEvent& event){ event.Skip(); }1231- virtual void OnKeyDown(wxKeyEvent& event){ event.Skip(); }1232- virtual void OnButtonOK(wxCommandEvent& event){ event.Skip(); }1233- virtual void OnButtonCancel(wxCommandEvent& event){ event.Skip(); }1234-1235-1236-public:1237- CGetTextFromUserDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(403,138), long style = wxDEFAULT_DIALOG_STYLE);1238- ~CGetTextFromUserDialogBase();1239-1240+class CGetTextFromUserDialogBase : public wxDialog 1241+{1242+ private:1243+ 1244+ protected:1245+ 1246+ wxStaticText* m_staticTextMessage1;1247+ wxTextCtrl* m_textCtrl1;1248+ wxStaticText* m_staticTextMessage2;1249+ wxTextCtrl* m_textCtrl2;1250+ 1251+ 1252+ wxButton* m_buttonOK;1253+ wxButton* m_buttonCancel;1254+ 1255+ // Virtual event handlers, overide them in your derived class1256+ virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }1257+ virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }1258+ virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }1259+ virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }1260+ 1261+ 1262+ public:1263+ CGetTextFromUserDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 403,138 ), long style = wxDEFAULT_DIALOG_STYLE );1264+ ~CGetTextFromUserDialogBase();1265+ 1266 };1267 1268 #endif //__uibase__
util.cpp (modified)
1--- v0.1.5/util.cpp2+++ v0.2.0/util.cpp3@@ -5,21 +5,26 @@4 #include "headers.h"5 6 7-8+map<string, string> mapArgs;9+map<string, vector<string> > mapMultiArgs;10 bool fDebug = false;11+bool fPrintToDebugger = false;12+bool fPrintToConsole = false;13+char pszSetDataDir[MAX_PATH] = "";14+bool fShutdown = false;15+16 17 18 19 20 // Init openssl library multithreading support21-static HANDLE* lock_cs;22-23-void win32_locking_callback(int mode, int type, const char* file, int line)24+static wxMutex** ppmutexOpenSSL;25+void locking_callback(int mode, int i, const char* file, int line)26 {27 if (mode & CRYPTO_LOCK)28- WaitForSingleObject(lock_cs[type], INFINITE);29+ ppmutexOpenSSL[i]->Lock();30 else31- ReleaseMutex(lock_cs[type]);32+ ppmutexOpenSSL[i]->Unlock();33 }34 35 // Init36@@ -29,24 +34,26 @@37 CInit()38 {39 // Init openssl library multithreading support40- lock_cs = (HANDLE*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE));41+ ppmutexOpenSSL = (wxMutex**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(wxMutex*));42 for (int i = 0; i < CRYPTO_num_locks(); i++)43- lock_cs[i] = CreateMutex(NULL,FALSE,NULL);44- CRYPTO_set_locking_callback(win32_locking_callback);45-46+ ppmutexOpenSSL[i] = new wxMutex();47+ CRYPTO_set_locking_callback(locking_callback);48+49+#ifdef __WXMSW__50 // Seed random number generator with screen scrape and other hardware sources51 RAND_screen();52-53- // Seed random number generator with perfmon data54- RandAddSeed(true);55+#endif56+57+ // Seed random number generator with performance counter58+ RandAddSeed();59 }60 ~CInit()61 {62 // Shutdown openssl library multithreading support63 CRYPTO_set_locking_callback(NULL);64- for (int i =0 ; i < CRYPTO_num_locks(); i++)65- CloseHandle(lock_cs[i]);66- OPENSSL_free(lock_cs);67+ for (int i = 0; i < CRYPTO_num_locks(); i++)68+ delete ppmutexOpenSSL[i];69+ OPENSSL_free(ppmutexOpenSSL);70 }71 }72 instance_of_cinit;73@@ -54,42 +61,66 @@74 75 76 77-void RandAddSeed(bool fPerfmon)78+79+80+81+82+void RandAddSeed()83 {84 // Seed with CPU performance counter85- LARGE_INTEGER PerformanceCount;86- QueryPerformanceCounter(&PerformanceCount);87- RAND_add(&PerformanceCount, sizeof(PerformanceCount), 1.5);88- memset(&PerformanceCount, 0, sizeof(PerformanceCount));89-90+ int64 nCounter = PerformanceCounter();91+ RAND_add(&nCounter, sizeof(nCounter), 1.5);92+ memset(&nCounter, 0, sizeof(nCounter));93+}94+95+void RandAddSeedPerfmon()96+{97+ // This can take up to 2 seconds, so only do it every 10 minutes98 static int64 nLastPerfmon;99- if (fPerfmon || GetTime() > nLastPerfmon + 5 * 60)100- {101- nLastPerfmon = GetTime();102-103- // Seed with the entire set of perfmon data104- unsigned char pdata[250000];105- memset(pdata, 0, sizeof(pdata));106- unsigned long nSize = sizeof(pdata);107- long ret = RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);108- RegCloseKey(HKEY_PERFORMANCE_DATA);109- if (ret == ERROR_SUCCESS)110- {111- uint256 hash;112- SHA256(pdata, nSize, (unsigned char*)&hash);113- RAND_add(&hash, sizeof(hash), min(nSize/500.0, (double)sizeof(hash)));114- hash = 0;115- memset(pdata, 0, nSize);116-117- time_t nTime;118- time(&nTime);119- struct tm* ptmTime = gmtime(&nTime);120- char pszTime[200];121- strftime(pszTime, sizeof(pszTime), "%x %H:%M:%S", ptmTime);122- printf("%s RandAddSeed() got %d bytes of performance data\n", pszTime, nSize);123- }124- }125-}126+ if (GetTime() < nLastPerfmon + 10 * 60)127+ return;128+ nLastPerfmon = GetTime();129+130+#ifdef __WXMSW__131+ // Don't need this on Linux, OpenSSL automatically uses /dev/urandom132+ // Seed with the entire set of perfmon data133+ unsigned char pdata[250000];134+ memset(pdata, 0, sizeof(pdata));135+ unsigned long nSize = sizeof(pdata);136+ long ret = RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);137+ RegCloseKey(HKEY_PERFORMANCE_DATA);138+ if (ret == ERROR_SUCCESS)139+ {140+ uint256 hash;141+ SHA256(pdata, nSize, (unsigned char*)&hash);142+ RAND_add(&hash, sizeof(hash), min(nSize/500.0, (double)sizeof(hash)));143+ hash = 0;144+ memset(pdata, 0, nSize);145+146+ printf("%s RandAddSeed() %d bytes\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str(), nSize);147+ }148+#else149+ printf("%s RandAddSeed()\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());150+#endif151+}152+153+uint64 GetRand(uint64 nMax)154+{155+ if (nMax == 0)156+ return 0;157+158+ // The range of the random source must be a multiple of the modulus159+ // to give every possible output value an equal possibility160+ uint64 nRange = (UINT64_MAX / nMax) * nMax;161+ uint64 nRand = 0;162+ do163+ RAND_bytes((unsigned char*)&nRand, sizeof(nRand));164+ while (nRand >= nRange);165+ return (nRand % nMax);166+}167+168+169+170 171 172 173@@ -172,27 +203,6 @@174 }175 176 177-void PrintException(std::exception* pex, const char* pszThread)178-{179- char pszModule[260];180- pszModule[0] = '\0';181- GetModuleFileName(NULL, pszModule, sizeof(pszModule));182- _strlwr(pszModule);183- char pszMessage[1000];184- if (pex)185- snprintf(pszMessage, sizeof(pszMessage),186- "EXCEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread);187- else188- snprintf(pszMessage, sizeof(pszMessage),189- "UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread);190- printf("\n\n************************\n%s", pszMessage);191- if (wxTheApp)192- wxMessageBox(pszMessage, "Error", wxOK | wxICON_ERROR);193- throw;194- //DebugBreak();195-}196-197-198 void ParseString(const string& str, char c, vector<string>& v)199 {200 unsigned int i1 = 0;201@@ -210,7 +220,7 @@202 string FormatMoney(int64 n, bool fPlus)203 {204 n /= CENT;205- string str = strprintf("%I64d.%02I64d", (n > 0 ? n : -n)/100, (n > 0 ? n : -n)%100);206+ string str = strprintf("%"PRI64d".%02"PRI64d, (n > 0 ? n : -n)/100, (n > 0 ? n : -n)%100);207 for (int i = 6; i < str.size(); i += 4)208 if (isdigit(str[str.size() - i - 1]))209 str.insert(str.size() - i, 1, ',');210@@ -268,21 +278,169 @@211 }212 213 214-215-216-217-218-219-220-221-222-bool FileExists(const char* psz)223-{224-#ifdef WIN32225- return GetFileAttributes(psz) != -1;226+vector<unsigned char> ParseHex(const char* psz)227+{228+ vector<unsigned char> vch;229+ while (isspace(*psz))230+ psz++;231+ vch.reserve((strlen(psz)+1)/3);232+233+ static char phexdigit[256] =234+ { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,235+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,236+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,237+ 0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,238+ -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1,239+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,240+ -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1241+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,242+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,243+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,244+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,245+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,246+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,247+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,248+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,249+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, };250+251+ while (*psz)252+ {253+ char c = phexdigit[(unsigned char)*psz++];254+ if (c == -1)255+ break;256+ unsigned char n = (c << 4);257+ if (*psz)258+ {259+ char c = phexdigit[(unsigned char)*psz++];260+ if (c == -1)261+ break;262+ n |= c;263+ vch.push_back(n);264+ }265+ while (isspace(*psz))266+ psz++;267+ }268+269+ return vch;270+}271+272+vector<unsigned char> ParseHex(const std::string& str)273+{274+ return ParseHex(str.c_str());275+}276+277+278+void ParseParameters(int argc, char* argv[])279+{280+ mapArgs.clear();281+ mapMultiArgs.clear();282+ for (int i = 0; i < argc; i++)283+ {284+ char psz[10000];285+ strlcpy(psz, argv[i], sizeof(psz));286+ char* pszValue = (char*)"";287+ if (strchr(psz, '='))288+ {289+ pszValue = strchr(psz, '=');290+ *pszValue++ = '\0';291+ }292+ #ifdef __WXMSW__293+ _strlwr(psz);294+ if (psz[0] == '/')295+ psz[0] = '-';296+ #endif297+ mapArgs[psz] = pszValue;298+ mapMultiArgs[psz].push_back(pszValue);299+ }300+}301+302+303+304+305+306+307+308+void FormatException(char* pszMessage, std::exception* pex, const char* pszThread)309+{310+#ifdef __WXMSW__311+ char pszModule[MAX_PATH];312+ pszModule[0] = '\0';313+ GetModuleFileName(NULL, pszModule, sizeof(pszModule));314 #else315- return access(psz, 0) != -1;316+ // might not be thread safe, uses wxString317+ //const char* pszModule = wxStandardPaths::Get().GetExecutablePath().mb_str();318+ const char* pszModule = "bitcoin";319 #endif320+ if (pex)321+ snprintf(pszMessage, 1000,322+ "EXCEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread);323+ else324+ snprintf(pszMessage, 1000,325+ "UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread);326+}327+328+void LogException(std::exception* pex, const char* pszThread)329+{330+ char pszMessage[1000];331+ FormatException(pszMessage, pex, pszThread);332+ printf("\n%s", pszMessage);333+}334+335+void PrintException(std::exception* pex, const char* pszThread)336+{337+ char pszMessage[1000];338+ FormatException(pszMessage, pex, pszThread);339+ printf("\n\n************************\n%s\n", pszMessage);340+ if (wxTheApp)341+ wxMessageBox(pszMessage, "Error", wxOK | wxICON_ERROR);342+ throw;343+ //DebugBreak();344+}345+346+347+348+349+350+351+352+353+void GetDataDir(char* pszDir)354+{355+ // pszDir must be at least MAX_PATH length.356+ if (pszSetDataDir[0] != 0)357+ {358+ strlcpy(pszDir, pszSetDataDir, MAX_PATH);359+ static bool fMkdirDone;360+ if (!fMkdirDone)361+ {362+ fMkdirDone = true;363+ _mkdir(pszDir);364+ }365+ }366+ else367+ {368+ // This can be called during exceptions by printf, so we cache the369+ // value so we don't have to do memory allocations after that.370+ // wxStandardPaths::GetUserDataDir371+ // Return the directory for the user-dependent application data files:372+ // Unix: ~/.appname373+ // Windows: C:\Documents and Settings\username\Application Data\appname374+ // Mac: ~/Library/Application Support/appname375+ static char pszCachedDir[MAX_PATH];376+ if (pszCachedDir[0] == 0)377+ {378+ strlcpy(pszCachedDir, wxStandardPaths::Get().GetUserDataDir().c_str(), sizeof(pszCachedDir));379+ _mkdir(pszCachedDir);380+ }381+ strlcpy(pszDir, pszCachedDir, MAX_PATH);382+ }383+}384+385+string GetDataDir()386+{387+ char pszDir[MAX_PATH];388+ GetDataDir(pszDir);389+ return pszDir;390 }391 392 int GetFilesize(FILE* file)393@@ -295,27 +453,26 @@394 return nFilesize;395 }396 397-398-399-400-401-402-403-404-uint64 GetRand(uint64 nMax)405-{406- if (nMax == 0)407- return 0;408-409- // The range of the random source must be a multiple of the modulus410- // to give every possible output value an equal possibility411- uint64 nRange = (_UI64_MAX / nMax) * nMax;412- uint64 nRand = 0;413- do414- RAND_bytes((unsigned char*)&nRand, sizeof(nRand));415- while (nRand >= nRange);416- return (nRand % nMax);417-}418+void ShrinkDebugFile()419+{420+ // Scroll debug.log if it's getting too big421+ string strFile = GetDataDir() + "/debug.log";422+ FILE* file = fopen(strFile.c_str(), "r");423+ if (file && GetFilesize(file) > 10 * 1000000)424+ {425+ // Restart the file with some of the end426+ char pch[200000];427+ fseek(file, -sizeof(pch), SEEK_END);428+ int nBytes = fread(pch, 1, sizeof(pch), file);429+ fclose(file);430+ if (file = fopen(strFile.c_str(), "w"))431+ {432+ fwrite(pch, 1, nBytes, file);433+ fclose(file);434+ }435+ }436+}437+438 439 440 441@@ -336,7 +493,6 @@442 // note: NTP isn't implemented yet, so until then we just use the median443 // of other nodes clocks to correct ours.444 //445-446 int64 GetTime()447 {448 return time(NULL);449@@ -363,7 +519,7 @@450 if (vTimeOffsets.empty())451 vTimeOffsets.push_back(0);452 vTimeOffsets.push_back(nOffsetSample);453- printf("Added time data, samples %d, ip %08x, offset %+I64d (%+I64d minutes)\n", vTimeOffsets.size(), ip, vTimeOffsets.back(), vTimeOffsets.back()/60);454+ printf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), vTimeOffsets.back(), vTimeOffsets.back()/60);455 if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)456 {457 sort(vTimeOffsets.begin(), vTimeOffsets.end());458@@ -377,8 +533,8 @@459 /// to make sure it doesn't get changed again460 }461 foreach(int64 n, vTimeOffsets)462- printf("%+I64d ", n);463- printf("| nTimeOffset = %+I64d (%+I64d minutes)\n", nTimeOffset, nTimeOffset/60);464- }465-}466-467+ printf("%+"PRI64d" ", n);468+ printf("| nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60);469+ }470+}471+
util.h (modified)
1--- v0.1.5/util.h2+++ v0.2.0/util.h3@@ -13,7 +13,6 @@4 #if defined(_MSC_VER) && _MSC_VER < 13005 #define for if (false) ; else for6 #endif7-8 #ifndef _MSC_VER9 #define __forceinline inline10 #endif11@@ -25,25 +24,22 @@12 #define UBEGIN(a) ((unsigned char*)&(a))13 #define UEND(a) ((unsigned char*)&((&(a))[1]))14 #define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))15-16-#ifdef _WINDOWS17 #define printf OutputDebugStringF18-#endif19 20 #ifdef snprintf21 #undef snprintf22 #endif23 #define snprintf my_snprintf24 25-#ifndef PRId6426+#ifndef PRI64d27 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MSVCRT__)28-#define PRId64 "I64d"29-#define PRIu64 "I64u"30-#define PRIx64 "I64x"31-#else32-#define PRId64 "lld"33-#define PRIu64 "llu"34-#define PRIx64 "llx"35+#define PRI64d "I64d"36+#define PRI64u "I64u"37+#define PRI64x "I64x"38+#else39+#define PRI64d "lld"40+#define PRI64u "llu"41+#define PRI64x "llx"42 #endif43 #endif44 45@@ -58,26 +54,86 @@46 return (T&)val;47 }48 49-50-51-52-53-54-55-56-57+#ifdef __WXMSW__58+#define MSG_NOSIGNAL 059+#define MSG_DONTWAIT 060+#ifndef UINT64_MAX61+#define UINT64_MAX _UI64_MAX62+#define INT64_MAX _I64_MAX63+#define INT64_MIN _I64_MIN64+#endif65+#ifndef S_IRUSR66+#define S_IRUSR 040067+#define S_IWUSR 020068+#endif69+#else70+#define WSAGetLastError() errno71+#define WSAEWOULDBLOCK EWOULDBLOCK72+#define WSAEMSGSIZE EMSGSIZE73+#define WSAEINTR EINTR74+#define WSAEINPROGRESS EINPROGRESS75+#define WSAEADDRINUSE EADDRINUSE76+#define WSAENOTSOCK EBADF77+#define INVALID_SOCKET (SOCKET)(~0)78+#define SOCKET_ERROR -179+typedef u_int SOCKET;80+#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)81+#define strlwr(psz) to_lower(psz)82+#define _strlwr(psz) to_lower(psz)83+#define _mkdir(psz) filesystem::create_directory(psz)84+#define MAX_PATH 102485+#define Sleep(n) wxMilliSleep(n)86+#define Beep(n1,n2) (0)87+#endif88+89+inline int myclosesocket(SOCKET& hSocket)90+{91+ if (hSocket == INVALID_SOCKET)92+ return WSAENOTSOCK;93+#ifdef __WXMSW__94+ int ret = closesocket(hSocket);95+#else96+ int ret = close(hSocket);97+#endif98+ hSocket = INVALID_SOCKET;99+ return ret;100+}101+#define closesocket(s) myclosesocket(s)102+103+104+105+106+107+108+109+110+111+112+extern map<string, string> mapArgs;113+extern map<string, vector<string> > mapMultiArgs;114 extern bool fDebug;115-116-void RandAddSeed(bool fPerfmon=false);117+extern bool fPrintToDebugger;118+extern bool fPrintToConsole;119+extern char pszSetDataDir[MAX_PATH];120+extern bool fShutdown;121+122+void RandAddSeed();123+void RandAddSeedPerfmon();124 int my_snprintf(char* buffer, size_t limit, const char* format, ...);125 string strprintf(const char* format, ...);126 bool error(const char* format, ...);127 void PrintException(std::exception* pex, const char* pszThread);128+void LogException(std::exception* pex, const char* pszThread);129 void ParseString(const string& str, char c, vector<string>& v);130 string FormatMoney(int64 n, bool fPlus=false);131 bool ParseMoney(const char* pszIn, int64& nRet);132-bool FileExists(const char* psz);133+vector<unsigned char> ParseHex(const char* psz);134+vector<unsigned char> ParseHex(const std::string& str);135+void ParseParameters(int argc, char* argv[]);136 int GetFilesize(FILE* file);137+void GetDataDir(char* pszDirRet);138+string GetDataDir();139+void ShrinkDebugFile();140 uint64 GetRand(uint64 nMax);141 int64 GetTime();142 int64 GetAdjustedTime();143@@ -94,32 +150,42 @@144 145 146 147-// Wrapper to automatically initialize critical section148-// Could use wxCriticalSection for portability, but it doesn't support TryEnterCriticalSection149+150+// Wrapper to automatically initialize critical sections151 class CCriticalSection152 {153+#ifdef __WXMSW__154 protected:155 CRITICAL_SECTION cs;156 public:157- char* pszFile;158- int nLine;159 explicit CCriticalSection() { InitializeCriticalSection(&cs); }160 ~CCriticalSection() { DeleteCriticalSection(&cs); }161 void Enter() { EnterCriticalSection(&cs); }162 void Leave() { LeaveCriticalSection(&cs); }163 bool TryEnter() { return TryEnterCriticalSection(&cs); }164- CRITICAL_SECTION* operator&() { return &cs; }165+#else166+protected:167+ wxMutex mutex;168+public:169+ explicit CCriticalSection() : mutex(wxMUTEX_RECURSIVE) { }170+ ~CCriticalSection() { }171+ void Enter() { mutex.Lock(); }172+ void Leave() { mutex.Unlock(); }173+ bool TryEnter() { return mutex.TryLock() == wxMUTEX_NO_ERROR; }174+#endif175+public:176+ const char* pszFile;177+ int nLine;178 };179 180 // Automatically leave critical section when leaving block, needed for exception safety181 class CCriticalBlock182 {183 protected:184- CRITICAL_SECTION* pcs;185+ CCriticalSection* pcs;186 public:187- CCriticalBlock(CRITICAL_SECTION& csIn) { pcs = &csIn; EnterCriticalSection(pcs); }188- CCriticalBlock(CCriticalSection& csIn) { pcs = &csIn; EnterCriticalSection(pcs); }189- ~CCriticalBlock() { LeaveCriticalSection(pcs); }190+ CCriticalBlock(CCriticalSection& csIn) { pcs = &csIn; pcs->Enter(); }191+ ~CCriticalBlock() { pcs->Leave(); }192 };193 194 // WARNING: This will catch continue and break!195@@ -133,11 +199,10 @@196 class CTryCriticalBlock197 {198 protected:199- CRITICAL_SECTION* pcs;200+ CCriticalSection* pcs;201 public:202- CTryCriticalBlock(CRITICAL_SECTION& csIn) { pcs = (TryEnterCriticalSection(&csIn) ? &csIn : NULL); }203- CTryCriticalBlock(CCriticalSection& csIn) { pcs = (TryEnterCriticalSection(&csIn) ? &csIn : NULL); }204- ~CTryCriticalBlock() { if (pcs) LeaveCriticalSection(pcs); }205+ CTryCriticalBlock(CCriticalSection& csIn) { pcs = (csIn.TryEnter() ? &csIn : NULL); }206+ ~CTryCriticalBlock() { if (pcs) pcs->Leave(); }207 bool Entered() { return pcs != NULL; }208 };209 210@@ -154,11 +219,95 @@211 212 213 214+inline int OutputDebugStringF(const char* pszFormat, ...)215+{216+ int ret = 0;217+#ifdef __WXDEBUG__218+ if (!fPrintToConsole)219+ {220+ // print to debug.log221+ char pszFile[MAX_PATH+100];222+ GetDataDir(pszFile);223+ strlcat(pszFile, "/debug.log", sizeof(pszFile));224+ FILE* fileout = fopen(pszFile, "a");225+ if (fileout)226+ {227+ //// Debug print useful for profiling228+ //fprintf(fileout, " %"PRI64d" ", wxGetLocalTimeMillis().GetValue());229+ va_list arg_ptr;230+ va_start(arg_ptr, pszFormat);231+ ret = vfprintf(fileout, pszFormat, arg_ptr);232+ va_end(arg_ptr);233+ fclose(fileout);234+ }235+ }236+237+#ifdef __WXMSW__238+ if (fPrintToDebugger)239+ {240+ // accumulate a line at a time241+ static CCriticalSection cs_OutputDebugStringF;242+ CRITICAL_BLOCK(cs_OutputDebugStringF)243+ {244+ static char pszBuffer[50000];245+ static char* pend;246+ if (pend == NULL)247+ pend = pszBuffer;248+ va_list arg_ptr;249+ va_start(arg_ptr, pszFormat);250+ int limit = END(pszBuffer) - pend - 2;251+ int ret = _vsnprintf(pend, limit, pszFormat, arg_ptr);252+ va_end(arg_ptr);253+ if (ret < 0 || ret >= limit)254+ {255+ pend = END(pszBuffer) - 2;256+ *pend++ = '\n';257+ }258+ else259+ pend += ret;260+ *pend = '\0';261+ char* p1 = pszBuffer;262+ char* p2;263+ while (p2 = strchr(p1, '\n'))264+ {265+ p2++;266+ char c = *p2;267+ *p2 = '\0';268+ OutputDebugString(p1);269+ *p2 = c;270+ p1 = p2;271+ }272+ if (p1 != pszBuffer)273+ memmove(pszBuffer, p1, pend - p1 + 1);274+ pend -= (p1 - pszBuffer);275+ }276+ }277+#endif278+#endif279+280+ if (fPrintToConsole)281+ {282+ // print to console283+ va_list arg_ptr;284+ va_start(arg_ptr, pszFormat);285+ ret = vprintf(pszFormat, arg_ptr);286+ va_end(arg_ptr);287+ }288+ return ret;289+}290+291+292+293+294+295+296+297+298 299 300 inline string i64tostr(int64 n)301 {302- return strprintf("%"PRId64, n);303+ return strprintf("%"PRI64d, n);304 }305 306 inline string itostr(int n)307@@ -205,6 +354,11 @@308 return str;309 }310 311+inline string HexStr(vector<unsigned char> vch, bool fSpaces=true)312+{313+ return HexStr(vch.begin(), vch.end(), fSpaces);314+}315+316 template<typename T>317 string HexNumStr(const T itbegin, const T itend, bool f0x=true)318 {319@@ -222,77 +376,37 @@320 printf(pszFormat, HexStr(pbegin, pend, fSpaces).c_str());321 }322 323-324-325-326-327-328-329-330-inline int OutputDebugStringF(const char* pszFormat, ...)331-{332-#ifdef __WXDEBUG__333- // log file334- FILE* fileout = fopen("debug.log", "a");335- if (fileout)336- {337- va_list arg_ptr;338- va_start(arg_ptr, pszFormat);339- vfprintf(fileout, pszFormat, arg_ptr);340- va_end(arg_ptr);341- fclose(fileout);342- }343-344- // accumulate a line at a time345- static CCriticalSection cs_OutputDebugStringF;346- CRITICAL_BLOCK(cs_OutputDebugStringF)347- {348- static char pszBuffer[50000];349- static char* pend;350- if (pend == NULL)351- pend = pszBuffer;352- va_list arg_ptr;353- va_start(arg_ptr, pszFormat);354- int limit = END(pszBuffer) - pend - 2;355- int ret = _vsnprintf(pend, limit, pszFormat, arg_ptr);356- va_end(arg_ptr);357- if (ret < 0 || ret >= limit)358- {359- pend = END(pszBuffer) - 2;360- *pend++ = '\n';361- }362- else363- pend += ret;364- *pend = '\0';365- char* p1 = pszBuffer;366- char* p2;367- while (p2 = strchr(p1, '\n'))368- {369- p2++;370- char c = *p2;371- *p2 = '\0';372- OutputDebugString(p1);373- *p2 = c;374- p1 = p2;375- }376- if (p1 != pszBuffer)377- memmove(pszBuffer, p1, pend - p1 + 1);378- pend -= (p1 - pszBuffer);379- return ret;380- }381-#endif382-383- if (!wxTheApp)384- {385- // print to console386- va_list arg_ptr;387- va_start(arg_ptr, pszFormat);388- vprintf(pszFormat, arg_ptr);389- va_end(arg_ptr);390- }391- return 0;392-}393-394+inline void PrintHex(vector<unsigned char> vch, const char* pszFormat="%s", bool fSpaces=true)395+{396+ printf(pszFormat, HexStr(vch, fSpaces).c_str());397+}398+399+inline int64 PerformanceCounter()400+{401+ int64 nCounter = 0;402+#ifdef __WXMSW__403+ QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);404+#else405+ timeval t;406+ gettimeofday(&t, NULL);407+ nCounter = t.tv_sec * 1000000 + t.tv_usec;408+#endif409+ return nCounter;410+}411+412+inline int64 GetTimeMillis()413+{414+ return wxGetLocalTimeMillis().GetValue();415+}416+417+inline string DateTimeStrFormat(const char* pszFormat, int64 nTime)418+{419+ time_t n = nTime;420+ struct tm* ptmTime = gmtime(&n);421+ char pszTime[200];422+ strftime(pszTime, sizeof(pszTime), pszFormat, ptmTime);423+ return pszTime;424+}425 426 427 428@@ -303,8 +417,10 @@429 430 inline void heapchk()431 {432+#ifdef __WXMSW__433 if (_heapchk() != _HEAPOK)434 DebugBreak();435+#endif436 }437 438 // Randomize the stack to help protect against buffer overrun exploits439@@ -312,7 +428,7 @@440 { \441 static char nLoops; \442 if (nLoops <= 0) \443- nLoops = GetRand(50) + 1; \444+ nLoops = GetRand(20) + 1; \445 if (nLoops-- > 1) \446 { \447 ThreadFn; \448@@ -326,6 +442,7 @@449 } catch (...) { \450 PrintException(NULL, (pszFn)); \451 }452+453 454 455 456@@ -398,3 +515,83 @@457 return hash2;458 }459 460+461+462+463+464+465+466+467+468+469+470+// Note: It turns out we might have been able to use boost::thread471+// by using TerminateThread(boost::thread.native_handle(), 0);472+#ifdef __WXMSW__473+typedef HANDLE pthread_t;474+475+inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)476+{477+ DWORD nUnused = 0;478+ HANDLE hthread =479+ CreateThread(480+ NULL, // default security481+ 0, // inherit stack size from parent482+ (LPTHREAD_START_ROUTINE)pfn, // function pointer483+ parg, // argument484+ 0, // creation option, start immediately485+ &nUnused); // thread identifier486+ if (hthread == NULL)487+ {488+ printf("Error: CreateThread() returned %d\n", GetLastError());489+ return (pthread_t)0;490+ }491+ if (!fWantHandle)492+ {493+ CloseHandle(hthread);494+ return (pthread_t)-1;495+ }496+ return hthread;497+}498+499+inline void SetThreadPriority(int nPriority)500+{501+ SetThreadPriority(GetCurrentThread(), nPriority);502+}503+#else504+inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)505+{506+ pthread_t hthread = 0;507+ int ret = pthread_create(&hthread, NULL, (void*(*)(void*))pfn, parg);508+ if (ret != 0)509+ {510+ printf("Error: pthread_create() returned %d\n", ret);511+ return (pthread_t)0;512+ }513+ if (!fWantHandle)514+ return (pthread_t)-1;515+ return hthread;516+}517+518+#define THREAD_PRIORITY_LOWEST PRIO_MIN519+#define THREAD_PRIORITY_BELOW_NORMAL 2520+#define THREAD_PRIORITY_NORMAL 0521+#define THREAD_PRIORITY_ABOVE_NORMAL 0522+523+inline void SetThreadPriority(int nPriority)524+{525+ // threads are processes on linux, so PRIO_PROCESS affects just the one thread526+ setpriority(PRIO_PROCESS, getpid(), nPriority);527+}528+529+inline bool TerminateThread(pthread_t hthread, unsigned int nExitCode)530+{531+ return (pthread_cancel(hthread) == 0);532+}533+534+inline void ExitThread(unsigned int nExitCode)535+{536+ pthread_exit((void*)nExitCode);537+}538+#endif539+
