What changed
Bitcoin v0.2.2 → v0.2.4
Release commit message: Address Book with tabs instead of separate Your Address book, with live update of default address in main window, New... button on main window for creating new receiving address, made receiving address labels more visible, ask user before paying transaction fee, when sending to bitcoin address also use a bitcoin address for the change, added some event.Skip() to fix UI glitches -- version 0.2.4
Previous diff: v0.2.0 → v0.2.2. Next: v0.2.4 → v0.2.5.
- main.cpp modified · +65 −63
- main.h modified · +4 −3
- script.h modified · +5 −0
- serialize.h modified · +1 −1
- ui.cpp modified · +310 −330
- ui.h modified · +34 −42
- uibase.cpp modified · +73 −31
- uibase.h modified · +26 −12
- util.cpp modified · +33 −0
- util.h modified · +4 −5
main.cpp (modified)
1--- v0.2.2/main.cpp2+++ v0.2.4/main.cpp3@@ -2645,7 +2645,12 @@4 do5 {6 pindexTmp = pindexBest;7- Sleep(10000);8+ for (int i = 0; i < 10; i++)9+ {10+ Sleep(1000);11+ if (fShutdown)12+ return;13+ }14 }15 while (pindexTmp != pindexBest);16 }17@@ -2852,10 +2857,13 @@18 if (keyRet.IsNull())19 keyRet.MakeNewKey();20 21- // Fill a vout to ourself22- CScript scriptPubKey;23- scriptPubKey << keyRet.GetPubKey() << OP_CHECKSIG;24- wtxNew.vout.push_back(CTxOut(nValueIn - nTotalValue, scriptPubKey));25+ // Fill a vout to ourself, using same address type as the payment26+ CScript scriptChange;27+ if (scriptPubKey.GetBitcoinAddressHash160() != 0)28+ scriptChange.SetBitcoinAddress(keyRet.GetPubKey());29+ else30+ scriptChange << keyRet.GetPubKey() << OP_CHECKSIG;31+ wtxNew.vout.push_back(CTxOut(nValueIn - nTotalValue, scriptChange));32 }33 34 // Fill a vout to the payee35@@ -2894,42 +2902,50 @@36 }37 38 // Call after CreateTransaction unless you want to abort39-bool CommitTransactionSpent(const CWalletTx& wtxNew, const CKey& key)40+bool CommitTransaction(CWalletTx& wtxNew, const CKey& key)41 {42 CRITICAL_BLOCK(cs_main)43- CRITICAL_BLOCK(cs_mapWallet)44- {45- //// old: eventually should make this transactional, never want to add a46- //// transaction without marking spent transactions, although the risk of47- //// interruption during this step is remote.48- //// update: This matters even less now that fSpent can get corrected49- //// when transactions are seen in VerifySignature. The remote chance of50- //// unmarked fSpent will be handled by that. Don't need to make this51- //// transactional. Pls delete this comment block later.52-53- // This is only to keep the database open to defeat the auto-flush for the54- // duration of this scope. This is the only place where this optimization55- // maybe makes sense; please don't do it anywhere else.56- CWalletDB walletdb("r");57-58- // Add the change's private key to wallet59- if (!key.IsNull() && !AddKey(key))60- throw runtime_error("CommitTransactionSpent() : AddKey failed\n");61-62- // Add tx to wallet, because if it has change it's also ours,63- // otherwise just for transaction history.64- AddToWallet(wtxNew);65-66- // Mark old coins as spent67- set<CWalletTx*> setCoins;68- foreach(const CTxIn& txin, wtxNew.vin)69- setCoins.insert(&mapWallet[txin.prevout.hash]);70- foreach(CWalletTx* pcoin, setCoins)71- {72- pcoin->fSpent = true;73- pcoin->WriteToDisk();74- vWalletUpdated.push_back(pcoin->GetHash());75- }76+ {77+ printf("CommitTransaction:\n%s", wtxNew.ToString().c_str());78+ CRITICAL_BLOCK(cs_mapWallet)79+ {80+ // This is only to keep the database open to defeat the auto-flush for the81+ // duration of this scope. This is the only place where this optimization82+ // maybe makes sense; please don't do it anywhere else.83+ CWalletDB walletdb("r");84+85+ // Add the change's private key to wallet86+ if (!key.IsNull() && !AddKey(key))87+ throw runtime_error("CommitTransaction() : AddKey failed\n");88+89+ // Add tx to wallet, because if it has change it's also ours,90+ // otherwise just for transaction history.91+ AddToWallet(wtxNew);92+93+ // Mark old coins as spent94+ set<CWalletTx*> setCoins;95+ foreach(const CTxIn& txin, wtxNew.vin)96+ setCoins.insert(&mapWallet[txin.prevout.hash]);97+ foreach(CWalletTx* pcoin, setCoins)98+ {99+ pcoin->fSpent = true;100+ pcoin->WriteToDisk();101+ vWalletUpdated.push_back(pcoin->GetHash());102+ }103+ }104+105+ // Track how many getdata requests our transaction gets106+ CRITICAL_BLOCK(cs_mapRequestCount)107+ mapRequestCount[wtxNew.GetHash()] = 0;108+109+ // Broadcast110+ if (!wtxNew.AcceptTransaction())111+ {112+ // This must not fail. The transaction has already been signed and recorded.113+ printf("CommitTransaction() : Error: Transaction not valid");114+ return false;115+ }116+ wtxNew.RelayWalletTransaction();117 }118 MainFrameRepaint();119 return true;120@@ -2938,7 +2954,7 @@121 122 123 124-string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew)125+string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee)126 {127 CRITICAL_BLOCK(cs_main)128 {129@@ -2954,26 +2970,12 @@130 printf("SendMoney() : %s", strError.c_str());131 return strError;132 }133- if (!CommitTransactionSpent(wtxNew, key))134- {135- printf("SendMoney() : Error finalizing transaction");136- return _("Error finalizing transaction");137- }138-139- // Track how many getdata requests our transaction gets140- CRITICAL_BLOCK(cs_mapRequestCount)141- mapRequestCount[wtxNew.GetHash()] = 0;142-143- printf("SendMoney: %s\n", wtxNew.GetHash().ToString().substr(0,6).c_str());144-145- // Broadcast146- if (!wtxNew.AcceptTransaction())147- {148- // This must not fail. The transaction has already been signed and recorded.149- printf("SendMoney() : Error: Transaction not valid");150+151+ if (fAskFee && !ThreadSafeAskFee(nFeeRequired, _("Sending..."), NULL))152+ return "ABORTED";153+154+ if (!CommitTransaction(wtxNew, key))155 return _("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");156- }157- wtxNew.RelayWalletTransaction();158 }159 MainFrameRepaint();160 return "";161@@ -2981,7 +2983,7 @@162 163 164 165-string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew)166+string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew, bool fAskFee)167 {168 // Check amount169 if (nValue <= 0)170@@ -2994,6 +2996,6 @@171 if (!scriptPubKey.SetBitcoinAddress(strAddress))172 return _("Invalid bitcoin address");173 174- return SendMoney(scriptPubKey, nValue, wtxNew);175-}176-177+ return SendMoney(scriptPubKey, nValue, wtxNew, fAskFee);178+}179+
main.h (modified)
1--- v0.2.2/main.h2+++ v0.2.4/main.h3@@ -67,9 +67,10 @@4 bool SendMessages(CNode* pto);5 int64 GetBalance();6 bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CKey& keyRet, int64& nFeeRequiredRet);7-bool CommitTransactionSpent(const CWalletTx& wtxNew, const CKey& key);8-string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew);9-string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew);10+bool CommitTransaction(CWalletTx& wtxNew, const CKey& key);11+bool BroadcastTransaction(CWalletTx& wtxNew);12+string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);13+string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);14 void GenerateBitcoins(bool fGenerate);15 void ThreadBitcoinMiner(void* parg);16 void BitcoinMiner();
script.h (modified)
1--- v0.2.2/script.h2+++ v0.2.4/script.h3@@ -580,6 +580,11 @@4 *this << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;5 }6 7+ void SetBitcoinAddress(const vector<unsigned char>& vchPubKey)8+ {9+ SetBitcoinAddress(Hash160(vchPubKey));10+ }11+12 bool SetBitcoinAddress(const string& strAddress)13 {14 this->clear();
serialize.h (modified)
1--- v0.2.2/serialize.h2+++ v0.2.4/serialize.h3@@ -19,7 +19,7 @@4 class CDataStream;5 class CAutoFile;6 7-static const int VERSION = 202;8+static const int VERSION = 204;9 static const char* pszSubVer = ".0";10 11
ui.cpp (modified)
1--- v0.2.2/ui.cpp2+++ v0.2.4/ui.cpp3@@ -35,13 +35,54 @@4 // Util5 //6 7+void ExitTimeout(void* parg)8+{9+#ifdef __WXMSW__10+ Sleep(5000);11+ ExitProcess(0);12+#endif13+}14+15+void Shutdown(void* parg)16+{17+ static CCriticalSection cs_Shutdown;18+ static bool fTaken;19+ bool fFirstThread;20+ CRITICAL_BLOCK(cs_Shutdown)21+ {22+ fFirstThread = !fTaken;23+ fTaken = true;24+ }25+ static bool fExit;26+ if (fFirstThread)27+ {28+ fShutdown = true;29+ nTransactionsUpdated++;30+ DBFlush(false);31+ StopNode();32+ DBFlush(true);33+ CreateThread(ExitTimeout, NULL);34+ Sleep(50);35+ printf("Bitcoin exiting\n\n");36+ fExit = true;37+ exit(0);38+ }39+ else40+ {41+ while (!fExit)42+ Sleep(500);43+ Sleep(100);44+ ExitThread(0);45+ }46+}47+48 void HandleCtrlA(wxKeyEvent& event)49 {50 // Ctrl-a select all51+ event.Skip();52 wxTextCtrl* textCtrl = (wxTextCtrl*)event.GetEventObject();53 if (event.GetModifiers() == wxMOD_CONTROL && event.GetKeyCode() == 'A')54 textCtrl->SetSelection(-1, -1);55- event.Skip();56 }57 58 bool Is24HourTime()59@@ -192,6 +233,35 @@60 return nRet;61 }62 #endif63+}64+65+bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent)66+{67+ if (nFeeRequired == 0 || fDaemon)68+ return true;69+ string strMessage = strprintf(70+ _("This transaction is over the size limit. You can still send it for a fee of %s, "71+ "which goes to the nodes that process your transaction and helps to support the network. "72+ "Do you want to pay the fee?"),73+ FormatMoney(nFeeRequired).c_str());74+ return (ThreadSafeMessageBox(strMessage, strCaption, wxYES_NO, parent) == wxYES);75+}76+77+void SetDefaultReceivingAddress(const string& strAddress)78+{79+ // Update main window address and database80+ if (pframeMain == NULL)81+ return;82+ if (strAddress != pframeMain->m_textCtrlAddress->GetValue())83+ {84+ uint160 hash160;85+ if (!AddressToHash160(strAddress, hash160))86+ return;87+ if (!mapPubKeys.count(hash160))88+ return;89+ CWalletDB().WriteDefaultKey(mapPubKeys[hash160]);90+ pframeMain->m_textCtrlAddress->SetValue(strAddress);91+ }92 }93 94 95@@ -227,11 +297,6 @@96 fontTmp.SetFamily(wxFONTFAMILY_TELETYPE);97 m_staticTextBalance->SetFont(fontTmp);98 m_staticTextBalance->SetSize(140, 17);99- // & underlines don't work on the toolbar buttons on gtk100- m_toolBar->ClearTools();101- m_toolBar->AddTool(wxID_BUTTONSEND, _("Send Coins"), wxBitmap(send20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);102- m_toolBar->AddTool(wxID_BUTTONRECEIVE, _("Address Book"), wxBitmap(addressbook20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);103- m_toolBar->Realize();104 // resize to fit ubuntu's huge default font105 dResize = 1.20;106 SetSize((dResize + 0.02) * GetSize().GetWidth(), 1.09 * GetSize().GetHeight());107@@ -276,47 +341,6 @@108 ptaskbaricon = NULL;109 }110 111-void ExitTimeout(void* parg)112-{113-#ifdef __WXMSW__114- Sleep(5000);115- ExitProcess(0);116-#endif117-}118-119-void Shutdown(void* parg)120-{121- static CCriticalSection cs_Shutdown;122- static bool fTaken;123- bool fFirstThread;124- CRITICAL_BLOCK(cs_Shutdown)125- {126- fFirstThread = !fTaken;127- fTaken = true;128- }129- static bool fExit;130- if (fFirstThread)131- {132- fShutdown = true;133- nTransactionsUpdated++;134- DBFlush(false);135- StopNode();136- DBFlush(true);137- CreateThread(ExitTimeout, NULL);138- Sleep(50);139- printf("Bitcoin exiting\n\n");140- fExit = true;141- exit(0);142- }143- else144- {145- while (!fExit)146- Sleep(500);147- Sleep(100);148- ExitThread(0);149- }150-}151-152 void CMainFrame::OnClose(wxCloseEvent& event)153 {154 if (fMinimizeOnClose && event.CanVeto() && !IsIconized())155@@ -335,6 +359,7 @@156 157 void CMainFrame::OnIconize(wxIconizeEvent& event)158 {159+ event.Skip();160 // Hide the task bar button when minimized.161 // Event is sent when the frame is minimized or restored.162 // wxWidgets 2.8.9 doesn't have IsIconized() so there's no way163@@ -342,7 +367,7 @@164 if (!event.Iconized())165 fClosedToTray = false;166 #ifndef __WXMSW__167- // Tray is not reliable on Linux gnome168+ // Tray is not reliable on ubuntu 9.10 gnome169 fClosedToTray = false;170 #endif171 if (fMinimizeToTray && event.Iconized())172@@ -353,6 +378,7 @@173 174 void CMainFrame::OnMouseEvents(wxMouseEvent& event)175 {176+ event.Skip();177 RandAddSeed();178 RAND_add(&event.m_x, sizeof(event.m_x), 0.25);179 RAND_add(&event.m_y, sizeof(event.m_y), 0.25);180@@ -360,9 +386,11 @@181 182 void CMainFrame::OnListColBeginDrag(wxListEvent& event)183 {184- // Hidden columns not resizeable185- if (event.GetColumn() <= 1 && !fDebug)186+ // Hidden columns not resizeable187+ if (event.GetColumn() <= 1 && !fDebug)188 event.Veto();189+ else190+ event.Skip();191 }192 193 int CMainFrame::GetSortIndex(const string& strSort)194@@ -546,7 +574,7 @@195 196 if (wtx.IsCoinBase())197 {198- // Coinbase199+ // Generated200 strDescription = _("Generated");201 if (nCredit == 0)202 {203@@ -569,7 +597,7 @@204 }205 else if (!mapValue["from"].empty() || !mapValue["message"].empty())206 {207- // Online transaction208+ // Received by IP connection209 if (!mapValue["from"].empty())210 strDescription += _("From: ") + mapValue["from"];211 if (!mapValue["message"].empty())212@@ -581,7 +609,7 @@213 }214 else215 {216- // Offline transaction217+ // Received by Bitcoin Address218 foreach(const CTxOut& txout, wtx.vout)219 {220 if (txout.IsMine())221@@ -591,20 +619,19 @@222 {223 CRITICAL_BLOCK(cs_mapAddressBook)224 {225+ //strDescription += _("Received payment to ");226+ //strDescription += _("Received with address ");227+ strDescription += _("From: unknown, Received with: ");228 string strAddress = PubKeyToAddress(vchPubKey);229- if (mapAddressBook.count(strAddress))230+ map<string, string>::iterator mi = mapAddressBook.find(strAddress);231+ if (mi != mapAddressBook.end() && !(*mi).second.empty())232 {233- //strDescription += _("Received payment to ");234- //strDescription += _("Received with address ");235- strDescription += _("From: unknown, To: ");236+ string strLabel = (*mi).second;237+ strDescription += strAddress.substr(0,12) + "... ";238+ strDescription += "(" + strLabel + ")";239+ }240+ else241 strDescription += strAddress;242- /// The labeling feature is just too confusing, so I hid it243- /// by putting it at the end where it runs off the screen.244- /// It can still be seen by widening the column, or in the245- /// details dialog.246- if (!mapAddressBook[strAddress].empty())247- strDescription += " (" + mapAddressBook[strAddress] + ")";248- }249 }250 }251 break;252@@ -659,12 +686,12 @@253 string strAddress;254 if (!mapValue["to"].empty())255 {256- // Online transaction257+ // Sent to IP258 strAddress = mapValue["to"];259 }260 else261 {262- // Offline transaction263+ // Sent to Bitcoin Address264 uint160 hash160;265 if (ExtractHash160(txout.scriptPubKey, hash160))266 strAddress = Hash160ToAddress(hash160);267@@ -683,8 +710,11 @@268 }269 270 int64 nValue = txout.nValue;271- if (nOut == 0 && nTxFee > 0)272+ if (nTxFee > 0)273+ {274 nValue += nTxFee;275+ nTxFee = 0;276+ }277 278 InsertLine(fNew, nIndex, hash, strprintf("%s-%d", strSort.c_str(), nOut),279 strStatus,280@@ -846,12 +876,12 @@281 282 void CMainFrame::OnPaint(wxPaintEvent& event)283 {284+ event.Skip();285 if (fRefresh)286 {287 fRefresh = false;288 Refresh();289 }290- event.Skip();291 }292 293 294@@ -903,6 +933,9 @@295 296 void CMainFrame::OnPaintListCtrl(wxPaintEvent& event)297 {298+ // Skip lets the listctrl do the paint, we're just hooking the message299+ event.Skip();300+301 if (ptaskbaricon)302 ptaskbaricon->UpdateTooltip();303 304@@ -970,11 +1003,6 @@305 306 if (fDebug && GetTime() - nThreadSocketHandlerHeartbeat > 60)307 m_statusBar->SetStatusText(" ERROR: ThreadSocketHandler has stopped", 0);308-309- // Pass through to listctrl to actually do the paint, we're just hooking the message310- m_listCtrl->Disconnect(wxEVT_PAINT, (wxObjectEventFunction)NULL, NULL, this);311- m_listCtrl->GetEventHandler()->ProcessEvent(event);312- m_listCtrl->Connect(wxEVT_PAINT, wxPaintEventHandler(CMainFrame::OnPaintListCtrl), NULL, this);313 }314 315 316@@ -1033,8 +1061,10 @@317 318 void CMainFrame::OnMenuOptionsChangeYourAddress(wxCommandEvent& event)319 {320- // Options->Change Your Address321- OnButtonChange(event);322+ // Options->Your Receiving Addresses323+ CAddressBookDialog dialog(this, "", CAddressBookDialog::RECEIVING, false);324+ if (!dialog.ShowModal())325+ return;326 }327 328 void CMainFrame::OnMenuOptionsOptions(wxCommandEvent& event)329@@ -1061,11 +1091,11 @@330 void CMainFrame::OnButtonAddressBook(wxCommandEvent& event)331 {332 // Toolbar: Address Book333- CAddressBookDialog dialogAddr(this, "", false);334+ CAddressBookDialog dialogAddr(this, "", CAddressBookDialog::SENDING, false);335 if (dialogAddr.ShowModal() == 2)336 {337 // Send338- CSendDialog dialogSend(this, dialogAddr.GetAddress());339+ CSendDialog dialogSend(this, dialogAddr.GetSelectedAddress());340 dialogSend.ShowModal();341 }342 }343@@ -1073,35 +1103,36 @@344 void CMainFrame::OnSetFocusAddress(wxFocusEvent& event)345 {346 // Automatically select-all when entering window347+ event.Skip();348 m_textCtrlAddress->SetSelection(-1, -1);349 fOnSetFocusAddress = true;350+}351+352+void CMainFrame::OnMouseEventsAddress(wxMouseEvent& event)353+{354 event.Skip();355-}356-357-void CMainFrame::OnMouseEventsAddress(wxMouseEvent& event)358-{359 if (fOnSetFocusAddress)360 m_textCtrlAddress->SetSelection(-1, -1);361 fOnSetFocusAddress = false;362- event.Skip();363-}364-365-void CMainFrame::OnButtonChange(wxCommandEvent& event)366-{367- CYourAddressDialog dialog(this, string(m_textCtrlAddress->GetValue()));368+}369+370+void CMainFrame::OnButtonNew(wxCommandEvent& event)371+{372+ // Ask name373+ CGetTextFromUserDialog dialog(this,374+ _("New Receiving Address"),375+ _("It's good policy to use a new address for each payment you receive.\n\nLabel"),376+ "");377 if (!dialog.ShowModal())378 return;379- string strAddress = (string)dialog.GetAddress();380- if (strAddress != m_textCtrlAddress->GetValue())381- {382- uint160 hash160;383- if (!AddressToHash160(strAddress, hash160))384- return;385- if (!mapPubKeys.count(hash160))386- return;387- CWalletDB().WriteDefaultKey(mapPubKeys[hash160]);388- m_textCtrlAddress->SetValue(strAddress);389- }390+ string strName = dialog.GetValue();391+392+ // Generate new key393+ string strAddress = PubKeyToAddress(GenerateNewKey());394+395+ // Save396+ SetAddressBookName(strAddress, strName);397+ SetDefaultReceivingAddress(strAddress);398 }399 400 void CMainFrame::OnButtonCopy(wxCommandEvent& event)401@@ -1133,7 +1164,6 @@402 //CTxDetailsDialog* pdialog = new CTxDetailsDialog(this, wtx);403 //pdialog->Show();404 }405-406 407 408 409@@ -1452,6 +1482,7 @@410 411 void COptionsDialog::OnKillFocusTransactionFee(wxFocusEvent& event)412 {413+ event.Skip();414 int64 nTmp = nTransactionFee;415 ParseMoney(m_textCtrlTransactionFee->GetValue(), nTmp);416 m_textCtrlTransactionFee->SetValue(FormatMoney(nTmp));417@@ -1485,6 +1516,7 @@418 419 void COptionsDialog::OnKillFocusProxy(wxFocusEvent& event)420 {421+ event.Skip();422 m_textCtrlProxyIP->SetValue(GetProxyAddr().ToStringIP());423 m_textCtrlProxyPort->SetValue(GetProxyAddr().ToStringPort());424 }425@@ -1632,6 +1664,7 @@426 void CSendDialog::OnTextAddress(wxCommandEvent& event)427 {428 // Check mark429+ event.Skip();430 bool fBitcoinAddress = IsValidBitcoinAddress(m_textCtrlAddress->GetValue());431 m_bitmapCheckMark->Show(fBitcoinAddress);432 433@@ -1660,6 +1693,7 @@434 void CSendDialog::OnKillFocusAmount(wxFocusEvent& event)435 {436 // Reformat the amount437+ event.Skip();438 if (m_textCtrlAmount->GetValue().Trim().empty())439 return;440 int64 nTmp;441@@ -1670,9 +1704,9 @@442 void CSendDialog::OnButtonAddressBook(wxCommandEvent& event)443 {444 // Open address book445- CAddressBookDialog dialog(this, m_textCtrlAddress->GetValue(), true);446+ CAddressBookDialog dialog(this, m_textCtrlAddress->GetValue(), CAddressBookDialog::SENDING, true);447 if (dialog.ShowModal())448- m_textCtrlAddress->SetValue(dialog.GetAddress());449+ m_textCtrlAddress->SetValue(dialog.GetSelectedAddress());450 }451 452 void CSendDialog::OnButtonPaste(wxCommandEvent& event)453@@ -1723,11 +1757,11 @@454 CScript scriptPubKey;455 scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;456 457- string strError = SendMoney(scriptPubKey, nValue, wtx);458- if (strError != "")459+ string strError = SendMoney(scriptPubKey, nValue, wtx, true);460+ if (strError == "")461+ wxMessageBox(_("Payment sent "), _("Sending..."));462+ else if (strError != "ABORTED")463 wxMessageBox(strError + " ", _("Sending..."));464- else465- wxMessageBox(_("Payment sent "), _("Sending..."));466 }467 else468 {469@@ -1846,6 +1880,7 @@470 471 void CSendingDialog::OnPaint(wxPaintEvent& event)472 {473+ event.Skip();474 if (strlen(pszStatus) > 130)475 m_textCtrlStatus->SetValue(string("\n") + pszStatus);476 else477@@ -1869,7 +1904,6 @@478 Close();479 wxMessageBox(_("Transfer cancelled "), _("Sending..."), wxOK, this);480 }481- event.Skip();482 }483 484 485@@ -2013,6 +2047,13 @@486 Error(strprintf(_("This is an oversized transaction that requires a transaction fee of %s"), FormatMoney(nFeeRequired).c_str()));487 else488 Error(_("Transaction creation failed"));489+ return;490+ }491+492+ // Transaction fee493+ if (!ThreadSafeAskFee(nFeeRequired, _("Sending..."), this))494+ {495+ Error(_("Transaction aborted"));496 return;497 }498 499@@ -2040,19 +2081,14 @@500 return;501 502 // Commit503- if (!CommitTransactionSpent(wtx, key))504- {505- Error(_("Error finalizing payment"));506+ if (!CommitTransaction(wtx, key))507+ {508+ Error(_("The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."));509 return;510 }511 512 // Send payment tx to seller, with response going to OnReply3 via event handler513 pnode->PushRequest("submitorder", wtx, SendingDialogOnReply3, this);514-515- // Accept and broadcast transaction516- if (!wtx.AcceptTransaction())517- printf("ERROR: CSendingDialog : wtxNew.AcceptTransaction() %s failed\n", wtx.GetHash().ToString().c_str());518- wtx.RelayWalletTransaction();519 520 Status(_("Waiting for confirmation..."));521 MainFrameRepaint();522@@ -2097,37 +2133,54 @@523 524 //////////////////////////////////////////////////////////////////////////////525 //526-// CYourAddressDialog527+// CAddressBookDialog528 //529 530-CYourAddressDialog::CYourAddressDialog(wxWindow* parent, const string& strInitSelected) : CYourAddressDialogBase(parent)531-{532+CAddressBookDialog::CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn) : CAddressBookDialogBase(parent)533+{534+ // Set initially selected page535+ wxNotebookEvent event;536+ event.SetSelection(nPageIn);537+ OnNotebookPageChanged(event);538+ m_notebook->ChangeSelection(nPageIn);539+540+ fDuringSend = fDuringSendIn;541+ if (!fDuringSend)542+ m_buttonCancel->Show(false);543+544+ // Set Icon545+ wxIcon iconAddressBook;546+ iconAddressBook.CopyFromBitmap(wxBitmap(addressbook16_xpm));547+ SetIcon(iconAddressBook);548+549 // Init column headers550- m_listCtrl->InsertColumn(0, _("Label"), wxLIST_FORMAT_LEFT, 200);551- m_listCtrl->InsertColumn(1, _("Bitcoin Address"), wxLIST_FORMAT_LEFT, 350);552- m_listCtrl->SetFocus();553+ m_listCtrlSending->InsertColumn(0, _("Name"), wxLIST_FORMAT_LEFT, 200);554+ m_listCtrlSending->InsertColumn(1, _("Address"), wxLIST_FORMAT_LEFT, 350);555+ m_listCtrlSending->SetFocus();556+ m_listCtrlReceiving->InsertColumn(0, _("Label"), wxLIST_FORMAT_LEFT, 200);557+ m_listCtrlReceiving->InsertColumn(1, _("Bitcoin Address"), wxLIST_FORMAT_LEFT, 350);558+ m_listCtrlReceiving->SetFocus();559 560 // Fill listctrl with address book data561 CRITICAL_BLOCK(cs_mapKeys)562 CRITICAL_BLOCK(cs_mapAddressBook)563 {564+ string strDefaultReceiving = (string)pframeMain->m_textCtrlAddress->GetValue();565 foreach(const PAIRTYPE(string, string)& item, mapAddressBook)566 {567 string strAddress = item.first;568 string strName = item.second;569 uint160 hash160;570 bool fMine = (AddressToHash160(strAddress, hash160) && mapPubKeys.count(hash160));571- if (fMine)572- {573- int nIndex = InsertLine(m_listCtrl, strName, strAddress);574- if (strAddress == strInitSelected)575- m_listCtrl->SetItemState(nIndex, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);576- }577- }578- }579-}580-581-wxString CYourAddressDialog::GetAddress()582+ wxListCtrl* plistCtrl = fMine ? m_listCtrlReceiving : m_listCtrlSending;583+ int nIndex = InsertLine(plistCtrl, strName, strAddress);584+ if (strAddress == (fMine ? strDefaultReceiving : strInitSelected))585+ plistCtrl->SetItemState(nIndex, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);586+ }587+ }588+}589+590+wxString CAddressBookDialog::GetSelectedAddress()591 {592 int nIndex = GetSelection(m_listCtrl);593 if (nIndex == -1)594@@ -2135,9 +2188,40 @@595 return GetItemText(m_listCtrl, nIndex, 1);596 }597 598-void CYourAddressDialog::OnListEndLabelEdit(wxListEvent& event)599+wxString CAddressBookDialog::GetSelectedSendingAddress()600+{601+ int nIndex = GetSelection(m_listCtrlSending);602+ if (nIndex == -1)603+ return "";604+ return GetItemText(m_listCtrlSending, nIndex, 1);605+}606+607+wxString CAddressBookDialog::GetSelectedReceivingAddress()608+{609+ int nIndex = GetSelection(m_listCtrlReceiving);610+ if (nIndex == -1)611+ return "";612+ return GetItemText(m_listCtrlReceiving, nIndex, 1);613+}614+615+void CAddressBookDialog::OnNotebookPageChanged(wxNotebookEvent& event)616+{617+ event.Skip();618+ nPage = event.GetSelection();619+ if (nPage == SENDING)620+ m_listCtrl = m_listCtrlSending;621+ else if (nPage == RECEIVING)622+ m_listCtrl = m_listCtrlReceiving;623+ m_buttonDelete->Show(nPage == SENDING);624+ m_buttonCopy->Show(nPage == RECEIVING);625+ this->Layout();626+ m_listCtrl->SetFocus();627+}628+629+void CAddressBookDialog::OnListEndLabelEdit(wxListEvent& event)630 {631 // Update address book with edited name632+ event.Skip();633 if (event.IsEditCancelled())634 return;635 string strAddress = (string)GetItemText(m_listCtrl, event.GetIndex(), 1);636@@ -2145,162 +2229,51 @@637 pframeMain->RefreshListCtrl();638 }639 640-void CYourAddressDialog::OnListItemSelected(wxListEvent& event)641-{642-}643-644-void CYourAddressDialog::OnListItemActivated(wxListEvent& event)645-{646+void CAddressBookDialog::OnListItemSelected(wxListEvent& event)647+{648+ event.Skip();649+ if (nPage == RECEIVING)650+ SetDefaultReceivingAddress((string)GetSelectedReceivingAddress());651+}652+653+void CAddressBookDialog::OnListItemActivated(wxListEvent& event)654+{655+ event.Skip();656+ if (fDuringSend)657+ {658+ // Doubleclick returns selection659+ EndModal(GetSelectedAddress() != "" ? 2 : 0);660+ return;661+ }662+663 // Doubleclick edits item664 wxCommandEvent event2;665- OnButtonRename(event2);666-}667-668-void CYourAddressDialog::OnButtonRename(wxCommandEvent& event)669-{670- // Ask new name671- int nIndex = GetSelection(m_listCtrl);672- if (nIndex == -1)673+ OnButtonEdit(event2);674+}675+676+void CAddressBookDialog::OnButtonDelete(wxCommandEvent& event)677+{678+ if (nPage != SENDING)679 return;680- string strName = (string)m_listCtrl->GetItemText(nIndex);681- string strAddress = (string)GetItemText(m_listCtrl, nIndex, 1);682- CGetTextFromUserDialog dialog(this, _("Edit Address Label"), _("New Label"), strName);683- if (!dialog.ShowModal())684- return;685- strName = dialog.GetValue();686-687- // Change name688- SetAddressBookName(strAddress, strName);689- m_listCtrl->SetItemText(nIndex, strName);690+ for (int nIndex = m_listCtrl->GetItemCount()-1; nIndex >= 0; nIndex--)691+ {692+ if (m_listCtrl->GetItemState(nIndex, wxLIST_STATE_SELECTED))693+ {694+ string strAddress = (string)GetItemText(m_listCtrl, nIndex, 1);695+ CWalletDB().EraseName(strAddress);696+ m_listCtrl->DeleteItem(nIndex);697+ }698+ }699 pframeMain->RefreshListCtrl();700 }701 702-void CYourAddressDialog::OnButtonNew(wxCommandEvent& event)703-{704- // Ask name705- CGetTextFromUserDialog dialog(this, _("New Bitcoin Address"), _("Label"), "");706- if (!dialog.ShowModal())707- return;708- string strName = dialog.GetValue();709-710- // Generate new key711- string strAddress = PubKeyToAddress(GenerateNewKey());712- SetAddressBookName(strAddress, strName);713-714- // Add to list and select it715- int nIndex = InsertLine(m_listCtrl, strName, strAddress);716- SetSelection(m_listCtrl, nIndex);717- m_listCtrl->SetFocus();718-}719-720-void CYourAddressDialog::OnButtonCopy(wxCommandEvent& event)721+void CAddressBookDialog::OnButtonCopy(wxCommandEvent& event)722 {723 // Copy address box to clipboard724 if (wxTheClipboard->Open())725 {726- wxTheClipboard->SetData(new wxTextDataObject(GetAddress()));727+ wxTheClipboard->SetData(new wxTextDataObject(GetSelectedAddress()));728 wxTheClipboard->Close();729- }730-}731-732-void CYourAddressDialog::OnButtonOK(wxCommandEvent& event)733-{734- // OK735- EndModal(true);736-}737-738-void CYourAddressDialog::OnButtonCancel(wxCommandEvent& event)739-{740- // Cancel741- EndModal(false);742-}743-744-void CYourAddressDialog::OnClose(wxCloseEvent& event)745-{746- // Close747- EndModal(false);748-}749-750-751-752-753-754-755-//////////////////////////////////////////////////////////////////////////////756-//757-// CAddressBookDialog758-//759-760-CAddressBookDialog::CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, bool fSendingIn) : CAddressBookDialogBase(parent)761-{762- fSending = fSendingIn;763- if (!fSending)764- m_buttonCancel->Show(false);765-766- // Init column headers767- m_listCtrl->InsertColumn(0, _("Name"), wxLIST_FORMAT_LEFT, 200);768- m_listCtrl->InsertColumn(1, _("Address"), wxLIST_FORMAT_LEFT, 350);769- m_listCtrl->SetFocus();770-771- // Set Icon772- wxIcon iconAddressBook;773- iconAddressBook.CopyFromBitmap(wxBitmap(addressbook16_xpm));774- SetIcon(iconAddressBook);775-776- // Fill listctrl with address book data777- CRITICAL_BLOCK(cs_mapKeys)778- CRITICAL_BLOCK(cs_mapAddressBook)779- {780- foreach(const PAIRTYPE(string, string)& item, mapAddressBook)781- {782- string strAddress = item.first;783- string strName = item.second;784- uint160 hash160;785- bool fMine = (AddressToHash160(strAddress, hash160) && mapPubKeys.count(hash160));786- if (!fMine)787- {788- int nIndex = InsertLine(m_listCtrl, strName, strAddress);789- if (strAddress == strInitSelected)790- m_listCtrl->SetItemState(nIndex, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);791- }792- }793- }794-}795-796-wxString CAddressBookDialog::GetAddress()797-{798- int nIndex = GetSelection(m_listCtrl);799- if (nIndex == -1)800- return "";801- return GetItemText(m_listCtrl, nIndex, 1);802-}803-804-void CAddressBookDialog::OnListEndLabelEdit(wxListEvent& event)805-{806- // Update address book with edited name807- if (event.IsEditCancelled())808- return;809- string strAddress = (string)GetItemText(m_listCtrl, event.GetIndex(), 1);810- SetAddressBookName(strAddress, string(event.GetText()));811- pframeMain->RefreshListCtrl();812-}813-814-void CAddressBookDialog::OnListItemSelected(wxListEvent& event)815-{816-}817-818-void CAddressBookDialog::OnListItemActivated(wxListEvent& event)819-{820- if (fSending)821- {822- // Doubleclick returns selection823- EndModal(GetAddress() != "" ? 2 : 0);824- }825- else826- {827- // Doubleclick edits item828- wxCommandEvent event2;829- OnButtonEdit(event2);830 }831 }832 833@@ -2315,24 +2288,37 @@834 835 void CAddressBookDialog::OnButtonEdit(wxCommandEvent& event)836 {837- // Ask new name838 int nIndex = GetSelection(m_listCtrl);839 if (nIndex == -1)840 return;841 string strName = (string)m_listCtrl->GetItemText(nIndex);842 string strAddress = (string)GetItemText(m_listCtrl, nIndex, 1);843 string strAddressOrg = strAddress;844- do845- {846- CGetTextFromUserDialog dialog(this, _("Edit Address"), _("Name"), strName, _("Address"), strAddress);847+848+ if (nPage == SENDING)849+ {850+ // Ask name and address851+ do852+ {853+ CGetTextFromUserDialog dialog(this, _("Edit Address"), _("Name"), strName, _("Address"), strAddress);854+ if (!dialog.ShowModal())855+ return;856+ strName = dialog.GetValue1();857+ strAddress = dialog.GetValue2();858+ }859+ while (CheckIfMine(strAddress, _("Edit Address")));860+861+ }862+ else if (nPage == RECEIVING)863+ {864+ // Ask name865+ CGetTextFromUserDialog dialog(this, _("Edit Address Label"), _("Label"), strName);866 if (!dialog.ShowModal())867 return;868- strName = dialog.GetValue1();869- strAddress = dialog.GetValue2();870- }871- while (CheckIfMine(strAddress, _("Edit Address")));872-873- // Change name874+ strName = dialog.GetValue();875+ }876+877+ // Write back878 if (strAddress != strAddressOrg)879 CWalletDB().EraseName(strAddressOrg);880 SetAddressBookName(strAddress, strName);881@@ -2343,55 +2329,50 @@882 883 void CAddressBookDialog::OnButtonNew(wxCommandEvent& event)884 {885- // Ask name886 string strName;887 string strAddress;888- do889- {890- CGetTextFromUserDialog dialog(this, _("New Address"), _("Name"), strName, _("Address"), strAddress);891+892+ if (nPage == SENDING)893+ {894+ // Ask name and address895+ do896+ {897+ CGetTextFromUserDialog dialog(this, _("Add Address"), _("Name"), strName, _("Address"), strAddress);898+ if (!dialog.ShowModal())899+ return;900+ strName = dialog.GetValue1();901+ strAddress = dialog.GetValue2();902+ }903+ while (CheckIfMine(strAddress, _("Add Address")));904+ }905+ else if (nPage == RECEIVING)906+ {907+ // Ask name908+ CGetTextFromUserDialog dialog(this,909+ _("New Receiving Address"),910+ _("It's good policy to use a new address for each payment you receive.\n\nLabel"),911+ "");912 if (!dialog.ShowModal())913 return;914- strName = dialog.GetValue1();915- strAddress = dialog.GetValue2();916- }917- while (CheckIfMine(strAddress, _("New Address")));918+ strName = dialog.GetValue();919+920+ // Generate new key921+ strAddress = PubKeyToAddress(GenerateNewKey());922+ }923 924 // Add to list and select it925 SetAddressBookName(strAddress, strName);926 int nIndex = InsertLine(m_listCtrl, strName, strAddress);927 SetSelection(m_listCtrl, nIndex);928 m_listCtrl->SetFocus();929- pframeMain->RefreshListCtrl();930-}931-932-void CAddressBookDialog::OnButtonDelete(wxCommandEvent& event)933-{934- for (int nIndex = m_listCtrl->GetItemCount()-1; nIndex >= 0; nIndex--)935- {936- if (m_listCtrl->GetItemState(nIndex, wxLIST_STATE_SELECTED))937- {938- string strAddress = (string)GetItemText(m_listCtrl, nIndex, 1);939- CWalletDB().EraseName(strAddress);940- m_listCtrl->DeleteItem(nIndex);941- }942- }943- pframeMain->RefreshListCtrl();944-}945-946-void CAddressBookDialog::OnButtonCopy(wxCommandEvent& event)947-{948- // Copy address box to clipboard949- if (wxTheClipboard->Open())950- {951- wxTheClipboard->SetData(new wxTextDataObject(GetAddress()));952- wxTheClipboard->Close();953- }954+ if (nPage == SENDING)955+ pframeMain->RefreshListCtrl();956 }957 958 void CAddressBookDialog::OnButtonOK(wxCommandEvent& event)959 {960 // OK961- EndModal(GetAddress() != "" ? 1 : 0);962+ EndModal(GetSelectedAddress() != "" ? 1 : 0);963 }964 965 void CAddressBookDialog::OnButtonCancel(wxCommandEvent& event)966@@ -2644,14 +2625,14 @@967 wxString strUsage = string() +968 _("Usage: bitcoin [options]") + "\t\t\t\t\t\t\n" +969 _("Options:\n") +970- " -gen \t\t " + _("Generate coins\n") +971- " -gen=0 \t\t " + _("Don't generate coins\n") +972- " -min \t\t " + _("Start minimized\n") +973- " -datadir=<dir> \t " + _("Specify data directory\n") +974- " -proxy=<ip:port>\t " + _("Connect through socks4 proxy\n") +975- " -addnode=<ip> \t " + _("Add a node to connect to\n") +976- " -connect=<ip> \t " + _("Connect only to the specified node\n") +977- " -? \t\t " + _("This help message\n");978+ " -gen \t\t " + _("Generate coins\n") +979+ " -gen=0 \t\t " + _("Don't generate coins\n") +980+ " -min \t\t " + _("Start minimized\n") +981+ " -datadir=<dir> \t " + _("Specify data directory\n") +982+ " -proxy=<ip:port>\t " + _("Connect through socks4 proxy\n") +983+ " -addnode=<ip> \t " + _("Add a node to connect to\n") +984+ " -connect=<ip> \t " + _("Connect only to the specified node\n") +985+ " -? \t\t " + _("This help message\n");986 987 if (fWindows)988 {989@@ -2947,7 +2928,6 @@990 Sleep(1000);991 throw;992 }993-994 return true;995 }996
ui.h (modified)
1--- v0.2.2/ui.h2+++ v0.2.4/ui.h3@@ -2,10 +2,8 @@4 // Distributed under the MIT/X11 software license, see the accompanying5 // file license.txt or http://www.opensource.org/licenses/mit-license.php.6 7-8-9-10 DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)11+12 13 extern map<string, string> mapArgs;14 15@@ -22,6 +20,7 @@16 void MainFrameRepaint();17 void Shutdown(void* parg);18 int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);19+bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);20 21 22 23@@ -51,7 +50,7 @@24 void OnButtonAddressBook(wxCommandEvent& event);25 void OnSetFocusAddress(wxFocusEvent& event);26 void OnMouseEventsAddress(wxMouseEvent& event);27- void OnButtonChange(wxCommandEvent& event);28+ void OnButtonNew(wxCommandEvent& event);29 void OnButtonCopy(wxCommandEvent& event);30 void OnListColBeginDrag(wxListEvent& event);31 void OnListItemActivated(wxListEvent& event);32@@ -205,53 +204,39 @@33 34 35 36-class CYourAddressDialog : public CYourAddressDialogBase37-{38-protected:39- // Event handlers40+class CAddressBookDialog : public CAddressBookDialogBase41+{42+protected:43+ // Event handlers44+ void OnNotebookPageChanged(wxNotebookEvent& event);45 void OnListEndLabelEdit(wxListEvent& event);46 void OnListItemSelected(wxListEvent& event);47 void OnListItemActivated(wxListEvent& event);48- void OnButtonRename(wxCommandEvent& event);49+ void OnButtonDelete(wxCommandEvent& event);50+ void OnButtonCopy(wxCommandEvent& event);51+ void OnButtonEdit(wxCommandEvent& event);52 void OnButtonNew(wxCommandEvent& event);53- void OnButtonCopy(wxCommandEvent& event);54 void OnButtonOK(wxCommandEvent& event);55 void OnButtonCancel(wxCommandEvent& event);56 void OnClose(wxCloseEvent& event);57 58 public:59 /** Constructor */60- CYourAddressDialog(wxWindow* parent);61- CYourAddressDialog(wxWindow* parent, const string& strInitSelected);62-63- // Custom64+ CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);65+66+ // Custom67+ enum68+ {69+ SENDING = 0,70+ RECEIVING = 1,71+ };72+ int nPage;73+ wxListCtrl* m_listCtrl;74+ bool fDuringSend;75 wxString GetAddress();76-};77-78-79-80-class CAddressBookDialog : public CAddressBookDialogBase81-{82-protected:83- // Event handlers84- void OnListEndLabelEdit(wxListEvent& event);85- void OnListItemSelected(wxListEvent& event);86- void OnListItemActivated(wxListEvent& event);87- void OnButtonEdit(wxCommandEvent& event);88- void OnButtonDelete(wxCommandEvent& event);89- void OnButtonNew(wxCommandEvent& event);90- void OnButtonCopy(wxCommandEvent& event);91- void OnButtonOK(wxCommandEvent& event);92- void OnButtonCancel(wxCommandEvent& event);93- void OnClose(wxCloseEvent& event);94-95-public:96- /** Constructor */97- CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, bool fSendingIn);98-99- // Custom100- bool fSending;101- wxString GetAddress();102+ wxString GetSelectedAddress();103+ wxString GetSelectedSendingAddress();104+ wxString GetSelectedReceivingAddress();105 bool CheckIfMine(const string& strAddress, const string& strTitle);106 };107 108@@ -282,18 +267,25 @@109 const string& strMessage2="",110 const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)111 {112+ int x = GetSize().GetWidth();113+ int y = GetSize().GetHeight();114 m_staticTextMessage1->SetLabel(strMessage1);115 m_textCtrl1->SetValue(strValue1);116+ y += wxString(strMessage1).Freq('\n') * 14;117 if (!strMessage2.empty())118 {119 m_staticTextMessage2->Show(true);120 m_staticTextMessage2->SetLabel(strMessage2);121 m_textCtrl2->Show(true);122 m_textCtrl2->SetValue(strValue2);123- SetSize(wxDefaultCoord, 180);124+ y += 46 + wxString(strMessage2).Freq('\n') * 14;125 }126 if (!fWindows)127- SetSize(1.14 * GetSize().GetWidth(), 1.14 * GetSize().GetHeight());128+ {129+ x *= 1.14;130+ y *= 1.14;131+ }132+ SetSize(x, y);133 }134 135 // Custom
uibase.cpp (modified)
1--- v0.2.2/uibase.cpp2+++ v0.2.4/uibase.cpp3@@ -42,14 +42,14 @@4 m_menuOptions->Append( m_menuOptionsGenerateBitcoins );5 6 wxMenuItem* m_menuOptionsChangeYourAddress;7- m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Change Your Address...") ) , wxEmptyString, wxITEM_NORMAL );8+ m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Your Receiving Addresses...") ) , wxEmptyString, wxITEM_NORMAL );9 m_menuOptions->Append( m_menuOptionsChangeYourAddress );10 11 wxMenuItem* m_menuOptionsOptions;12 m_menuOptionsOptions = new wxMenuItem( m_menuOptions, wxID_MENUOPTIONSOPTIONS, wxString( _("&Options...") ) , wxEmptyString, wxITEM_NORMAL );13 m_menuOptions->Append( m_menuOptionsOptions );14 15- m_menubar->Append( m_menuOptions, _("&Options") );16+ m_menubar->Append( m_menuOptions, _("&Settings") );17 18 m_menuHelp = new wxMenu();19 wxMenuItem* m_menuHelpAbout;20@@ -65,8 +65,8 @@21 m_toolBar->SetToolSeparation( 1 );22 m_toolBar->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );23 24- m_toolBar->AddTool( wxID_BUTTONSEND, _("&Send Coins"), wxBitmap( send20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );25- m_toolBar->AddTool( wxID_BUTTONRECEIVE, _("&Address Book"), wxBitmap( addressbook20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );26+ m_toolBar->AddTool( wxID_BUTTONSEND, _("Send Coins"), wxBitmap( send20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );27+ m_toolBar->AddTool( wxID_BUTTONRECEIVE, _("Address Book"), wxBitmap( addressbook20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );28 m_toolBar->Realize();29 30 m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );31@@ -86,14 +86,10 @@32 bSizer85->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );33 34 m_textCtrlAddress = new wxTextCtrl( this, wxID_TEXTCTRLADDRESS, wxEmptyString, wxDefaultPosition, wxSize( 340,-1 ), wxTE_READONLY );35- m_textCtrlAddress->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );36- 37 bSizer85->Add( m_textCtrlAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );38 39- m_buttonNew = new wxButton( this, wxID_BUTTONCHANGE, _("&New..."), wxDefaultPosition, wxDefaultSize, 0 );40- m_buttonNew->Hide();41- 42- bSizer85->Add( m_buttonNew, 0, wxRIGHT, 5 );43+ m_buttonNew = new wxButton( this, wxID_BUTTONNEW, _(" &New... "), wxDefaultPosition, wxSize( -1,-1 ), wxBU_EXACTFIT );44+ bSizer85->Add( m_buttonNew, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );45 46 m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, _(" &Copy to Clipboard "), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );47 bSizer85->Add( m_buttonCopy, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );48@@ -188,7 +184,7 @@49 m_textCtrlAddress->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );50 m_textCtrlAddress->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );51 m_textCtrlAddress->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( CMainFrameBase::OnSetFocusAddress ), NULL, this );52- m_buttonNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );53+ m_buttonNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonNew ), NULL, this );54 m_buttonCopy->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonCopy ), NULL, this );55 m_listCtrl->Connect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );56 m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );57@@ -240,7 +236,7 @@58 m_textCtrlAddress->Disconnect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );59 m_textCtrlAddress->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );60 m_textCtrlAddress->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( CMainFrameBase::OnSetFocusAddress ), NULL, this );61- m_buttonNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );62+ m_buttonNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonNew ), NULL, this );63 m_buttonCopy->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonCopy ), NULL, this );64 m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );65 m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );66@@ -844,20 +840,53 @@67 {68 this->SetSizeHints( wxDefaultSize, wxDefaultSize );69 70+ wxBoxSizer* bSizer58;71+ bSizer58 = new wxBoxSizer( wxVERTICAL );72+ 73+ m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );74+ m_panelSending = new wxPanel( m_notebook, wxID_PANELSENDING, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );75 wxBoxSizer* bSizer68;76 bSizer68 = new wxBoxSizer( wxVERTICAL );77 78 79- bSizer68->Add( 0, 5, 0, wxEXPAND, 5 );80- 81- m_staticText55 = new wxStaticText( this, wxID_ANY, _("Bitcoin Address"), wxDefaultPosition, wxDefaultSize, 0 );82+ bSizer68->Add( 0, 0, 0, wxEXPAND, 5 );83+ 84+ m_staticText55 = new wxStaticText( m_panelSending, wxID_ANY, _("Bitcoin Address"), wxDefaultPosition, wxDefaultSize, 0 );85 m_staticText55->Wrap( -1 );86 m_staticText55->Hide();87 88 bSizer68->Add( m_staticText55, 0, wxTOP|wxRIGHT|wxLEFT, 5 );89 90- m_listCtrl = new wxListCtrl( this, wxID_LISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING );91- bSizer68->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );92+ m_listCtrlSending = new wxListCtrl( m_panelSending, wxID_LISTCTRLSENDING, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING );93+ bSizer68->Add( m_listCtrlSending, 1, wxALL|wxEXPAND, 5 );94+ 95+ m_panelSending->SetSizer( bSizer68 );96+ m_panelSending->Layout();97+ bSizer68->Fit( m_panelSending );98+ m_notebook->AddPage( m_panelSending, _("Sending"), false );99+ m_panelReceiving = new wxPanel( m_notebook, wxID_PANELRECEIVING, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );100+ wxBoxSizer* bSizer681;101+ bSizer681 = new wxBoxSizer( wxVERTICAL );102+ 103+ 104+ bSizer681->Add( 0, 0, 0, wxEXPAND, 5 );105+ 106+ m_staticText45 = new wxStaticText( m_panelReceiving, wxID_ANY, _("These are your Bitcoin addresses for receiving payments. You can give a different one to each sender to keep track of who is paying you. The highlighted address will be displayed in the main window."), wxDefaultPosition, wxDefaultSize, 0 );107+ m_staticText45->Wrap( 570 );108+ bSizer681->Add( m_staticText45, 0, wxTOP|wxRIGHT|wxLEFT, 6 );109+ 110+ 111+ bSizer681->Add( 0, 2, 0, wxEXPAND, 5 );112+ 113+ m_listCtrlReceiving = new wxListCtrl( m_panelReceiving, wxID_LISTCTRLRECEIVING, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING );114+ bSizer681->Add( m_listCtrlReceiving, 1, wxALL|wxEXPAND, 5 );115+ 116+ m_panelReceiving->SetSizer( bSizer681 );117+ m_panelReceiving->Layout();118+ bSizer681->Fit( m_panelReceiving );119+ m_notebook->AddPage( m_panelReceiving, _("Receiving"), true );120+ 121+ bSizer58->Add( m_notebook, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );122 123 wxBoxSizer* bSizer69;124 bSizer69 = new wxBoxSizer( wxHORIZONTAL );125@@ -865,34 +894,42 @@126 127 bSizer69->Add( 0, 0, 1, wxEXPAND, 5 );128 129+ m_buttonDelete = new wxButton( this, wxID_BUTTONDELETE, _("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );130+ bSizer69->Add( m_buttonDelete, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );131+ 132+ m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, _(" &Copy to Clipboard "), wxDefaultPosition, wxSize( -1,-1 ), 0 );133+ bSizer69->Add( m_buttonCopy, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );134+ 135 m_buttonEdit = new wxButton( this, wxID_BUTTONEDIT, _("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );136 bSizer69->Add( m_buttonEdit, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );137 138 m_buttonNew = new wxButton( this, wxID_BUTTONNEW, _(" &New Address... "), wxDefaultPosition, wxDefaultSize, 0 );139 bSizer69->Add( m_buttonNew, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );140 141- m_buttonDelete = new wxButton( this, wxID_BUTTONDELETE, _("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );142- bSizer69->Add( m_buttonDelete, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );143- 144 m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );145 bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );146 147 m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );148 bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );149 150- bSizer68->Add( bSizer69, 0, wxEXPAND, 5 );151- 152- this->SetSizer( bSizer68 );153+ bSizer58->Add( bSizer69, 0, wxEXPAND, 5 );154+ 155+ this->SetSizer( bSizer58 );156 this->Layout();157 158 // Connect Events159 this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CAddressBookDialogBase::OnClose ) );160- m_listCtrl->Connect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );161- m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );162- m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );163+ m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( CAddressBookDialogBase::OnNotebookPageChanged ), NULL, this );164+ m_listCtrlSending->Connect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );165+ m_listCtrlSending->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );166+ m_listCtrlSending->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );167+ m_listCtrlReceiving->Connect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );168+ m_listCtrlReceiving->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );169+ m_listCtrlReceiving->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );170+ m_buttonDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );171+ m_buttonCopy->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCopy ), NULL, this );172 m_buttonEdit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonEdit ), NULL, this );173 m_buttonNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonNew ), NULL, this );174- m_buttonDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );175 m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonOK ), NULL, this );176 m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCancel ), NULL, this );177 }178@@ -901,12 +938,17 @@179 {180 // Disconnect Events181 this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CAddressBookDialogBase::OnClose ) );182- m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );183- m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );184- m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );185+ m_notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( CAddressBookDialogBase::OnNotebookPageChanged ), NULL, this );186+ m_listCtrlSending->Disconnect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );187+ m_listCtrlSending->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );188+ m_listCtrlSending->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );189+ m_listCtrlReceiving->Disconnect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );190+ m_listCtrlReceiving->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );191+ m_listCtrlReceiving->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );192+ m_buttonDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );193+ m_buttonCopy->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCopy ), NULL, this );194 m_buttonEdit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonEdit ), NULL, this );195 m_buttonNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonNew ), NULL, this );196- m_buttonDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );197 m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonOK ), NULL, this );198 m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCancel ), NULL, this );199 }
uibase.h (modified)
1--- v0.2.2/uibase.h2+++ v0.2.4/uibase.h3@@ -36,6 +36,7 @@4 #include <wx/spinctrl.h>5 #include <wx/scrolwin.h>6 #include <wx/statbmp.h>7+#include <wx/notebook.h>8 9 ///////////////////////////////////////////////////////////////////////////10 11@@ -46,7 +47,7 @@12 #define wxID_BUTTONSEND 100413 #define wxID_BUTTONRECEIVE 100514 #define wxID_TEXTCTRLADDRESS 100615-#define wxID_BUTTONCHANGE 100716+#define wxID_BUTTONNEW 100717 #define wxID_BUTTONCOPY 100818 #define wxID_TRANSACTIONFEE 100919 #define wxID_PROXYIP 101020@@ -58,10 +59,13 @@21 #define wxID_CHOICETRANSFERTYPE 101622 #define wxID_LISTCTRL 101723 #define wxID_BUTTONRENAME 101824-#define wxID_BUTTONNEW 101925-#define wxID_BUTTONEDIT 102026-#define wxID_BUTTONDELETE 102127-#define wxID_TEXTCTRL 102228+#define wxID_PANELSENDING 101929+#define wxID_LISTCTRLSENDING 102030+#define wxID_PANELRECEIVING 102131+#define wxID_LISTCTRLRECEIVING 102232+#define wxID_BUTTONDELETE 102333+#define wxID_BUTTONEDIT 102434+#define wxID_TEXTCTRL 102535 36 ///////////////////////////////////////////////////////////////////////////////37 /// Class CMainFrameBase38@@ -79,7 +83,6 @@39 wxStatusBar* m_statusBar;40 41 wxStaticText* m_staticText32;42- wxTextCtrl* m_textCtrlAddress;43 wxButton* m_buttonNew;44 wxButton* m_buttonCopy;45 46@@ -108,7 +111,7 @@47 virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }48 virtual void OnMouseEventsAddress( wxMouseEvent& event ){ event.Skip(); }49 virtual void OnSetFocusAddress( wxFocusEvent& event ){ event.Skip(); }50- virtual void OnButtonChange( wxCommandEvent& event ){ event.Skip(); }51+ virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); }52 virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }53 virtual void OnListColBeginDrag( wxListEvent& event ){ event.Skip(); }54 virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }55@@ -117,6 +120,7 @@56 57 public:58 wxMenu* m_menuOptions;59+ wxTextCtrl* m_textCtrlAddress;60 wxListCtrl* m_listCtrl;61 CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = _("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 712,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );62 ~CMainFrameBase();63@@ -343,23 +347,33 @@64 private:65 66 protected:67+ wxNotebook* m_notebook;68+ wxPanel* m_panelSending;69 70 wxStaticText* m_staticText55;71- wxListCtrl* m_listCtrl;72- 73+ wxListCtrl* m_listCtrlSending;74+ wxPanel* m_panelReceiving;75+ 76+ wxStaticText* m_staticText45;77+ 78+ wxListCtrl* m_listCtrlReceiving;79+ 80+ wxButton* m_buttonDelete;81+ wxButton* m_buttonCopy;82 wxButton* m_buttonEdit;83 wxButton* m_buttonNew;84- wxButton* m_buttonDelete;85 wxButton* m_buttonOK;86 87 // Virtual event handlers, overide them in your derived class88 virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }89+ virtual void OnNotebookPageChanged( wxNotebookEvent& event ){ event.Skip(); }90 virtual void OnListEndLabelEdit( wxListEvent& event ){ event.Skip(); }91 virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }92 virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); }93+ virtual void OnButtonDelete( wxCommandEvent& event ){ event.Skip(); }94+ virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }95 virtual void OnButtonEdit( wxCommandEvent& event ){ event.Skip(); }96 virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); }97- virtual void OnButtonDelete( wxCommandEvent& event ){ event.Skip(); }98 virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }99 virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }100 101@@ -397,7 +411,7 @@102 103 104 public:105- 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 );106+ CGetTextFromUserDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 440,138 ), long style = wxDEFAULT_DIALOG_STYLE );107 ~CGetTextFromUserDialogBase();108 109 };
util.cpp (modified)
1--- v0.2.2/util.cpp2+++ v0.2.4/util.cpp3@@ -431,6 +431,39 @@4 }5 6 7+const char* wxGetTranslation(const char* pszEnglish)8+{9+ // Wrapper of wxGetTranslation returning the same const char* type as was passed in10+ static CCriticalSection cs;11+ CRITICAL_BLOCK(cs)12+ {13+ // Look in cache14+ static map<string, char*> mapCache;15+ map<string, char*>::iterator mi = mapCache.find(pszEnglish);16+ if (mi != mapCache.end())17+ return (*mi).second;18+19+ // wxWidgets translation20+ const char* pszTranslated = wxGetTranslation(wxString(pszEnglish, wxConvUTF8)).utf8_str();21+22+ // We don't cache unknown strings because caller might be passing in a23+ // dynamic string and we would keep allocating memory for each variation.24+ if (strcmp(pszEnglish, pszTranslated) == 0)25+ return pszEnglish;26+27+ // Add to cache, memory doesn't need to be freed. We only cache because28+ // we must pass back a pointer to permanently allocated memory.29+ char* pszCached = new char[strlen(pszTranslated)+1];30+ strcpy(pszCached, pszTranslated);31+ mapCache[pszEnglish] = pszCached;32+ return pszCached;33+ }34+}35+36+37+38+39+40 41 42
util.h (modified)
1--- v0.2.2/util.h2+++ v0.2.4/util.h3@@ -136,6 +136,7 @@4 vector<unsigned char> ParseHex(const char* psz);5 vector<unsigned char> ParseHex(const std::string& str);6 void ParseParameters(int argc, char* argv[]);7+const char* wxGetTranslation(const char* psz);8 int GetFilesize(FILE* file);9 void GetDataDir(char* pszDirRet);10 string GetDataDir();11@@ -340,11 +341,9 @@12 ++it;13 }14 15-inline const char* wxGetTranslation(const char* psz)16-{17- // Return translated UTF-8 const char*18- return wxGetTranslation(wxString(psz, wxConvUTF8)).utf8_str();19-}20+21+22+23 24 25
