Bitcoin v0.2.0 · 2009-12-16
ui.h
1// Copyright (c) 2009 Satoshi Nakamoto2// Distributed under the MIT/X11 software license, see the accompanying3// file license.txt or http://www.opensource.org/licenses/mit-license.php.45678DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)9DECLARE_EVENT_TYPE(wxEVT_REPLY1, -1)10DECLARE_EVENT_TYPE(wxEVT_REPLY2, -1)11DECLARE_EVENT_TYPE(wxEVT_REPLY3, -1)1213141516extern map<string, string> mapArgs;1718// Settings19extern int fShowGenerated;20extern int fMinimizeToTray;21extern int fMinimizeOnClose;22232425extern void HandleCtrlA(wxKeyEvent& event);26extern string FormatTxStatus(const CWalletTx& wtx);27extern void UIThreadCall(boost::function0<void>);28extern void MainFrameRepaint();29extern void Shutdown(void* parg);30extern int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);31323334353637class CMainFrame : public CMainFrameBase38{39protected:40 // Event handlers41 void OnClose(wxCloseEvent& event);42 void OnIconize(wxIconizeEvent& event);43 void OnMouseEvents(wxMouseEvent& event);44 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }45 void OnIdle(wxIdleEvent& event);46 void OnPaint(wxPaintEvent& event);47 void OnPaintListCtrl(wxPaintEvent& event);48 void OnMenuFileExit(wxCommandEvent& event);49 void OnMenuViewShowGenerated(wxCommandEvent& event);50 void OnUpdateUIViewShowGenerated(wxUpdateUIEvent& event);51 void OnMenuOptionsGenerate(wxCommandEvent& event);52 void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);53 void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);54 void OnMenuOptionsOptions(wxCommandEvent& event);55 void OnMenuHelpAbout(wxCommandEvent& event);56 void OnButtonSend(wxCommandEvent& event);57 void OnButtonAddressBook(wxCommandEvent& event);58 void OnSetFocusAddress(wxFocusEvent& event);59 void OnMouseEventsAddress(wxMouseEvent& event);60 void OnButtonCopy(wxCommandEvent& event);61 void OnButtonChange(wxCommandEvent& event);62 void OnListColBeginDrag(wxListEvent& event);63 void OnListItemActivatedAllTransactions(wxListEvent& event);64 void OnListItemActivatedProductsSent(wxListEvent& event);65 void OnListItemActivatedOrdersSent(wxListEvent& event);66 void OnListItemActivatedOrdersReceived(wxListEvent& event);67 68public:69 /** Constructor */70 CMainFrame(wxWindow* parent);71 ~CMainFrame();7273 // Custom74 bool fRefreshListCtrl;75 bool fRefreshListCtrlRunning;76 bool fOnSetFocusAddress;77 unsigned int nListViewUpdated;78 bool fRefresh;7980 void OnUIThreadCall(wxCommandEvent& event);81 int GetSortIndex(const string& strSort);82 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);83 bool DeleteLine(uint256 hashKey);84 bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);85 void RefreshListCtrl();86 void RefreshStatusColumn();87};8889909192class CTxDetailsDialog : public CTxDetailsDialogBase93{94protected:95 // Event handlers96 void OnButtonOK(wxCommandEvent& event);9798public:99 /** Constructor */100 CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);101102 // State103 CWalletTx wtx;104};105106107108class COptionsDialog : public COptionsDialogBase109{110protected:111 // Event handlers112 void OnListBox(wxCommandEvent& event);113 void OnKillFocusTransactionFee(wxFocusEvent& event);114 void OnCheckBoxLimitProcessors(wxCommandEvent& event);115 void OnCheckBoxUseProxy(wxCommandEvent& event);116 void OnKillFocusProxy(wxFocusEvent& event);117118 void OnButtonOK(wxCommandEvent& event);119 void OnButtonCancel(wxCommandEvent& event);120 void OnButtonApply(wxCommandEvent& event);121122public:123 /** Constructor */124 COptionsDialog(wxWindow* parent);125126 // Custom127 bool fTmpStartOnSystemStartup;128 bool fTmpMinimizeOnClose;129 void SelectPage(int nPage);130 CAddress GetProxyAddr();131};132133134135class CAboutDialog : public CAboutDialogBase136{137protected:138 // Event handlers139 void OnButtonOK(wxCommandEvent& event);140141public:142 /** Constructor */143 CAboutDialog(wxWindow* parent);144};145146147148class CSendDialog : public CSendDialogBase149{150protected:151 // Event handlers152 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }153 void OnTextAddress(wxCommandEvent& event);154 void OnKillFocusAmount(wxFocusEvent& event);155 void OnButtonAddressBook(wxCommandEvent& event);156 void OnButtonPaste(wxCommandEvent& event);157 void OnButtonSend(wxCommandEvent& event);158 void OnButtonCancel(wxCommandEvent& event);159 160public:161 /** Constructor */162 CSendDialog(wxWindow* parent, const wxString& strAddress="");163164 // Custom165 bool fEnabledPrev;166 string strFromSave;167 string strMessageSave;168};169170171172class CSendingDialog : public CSendingDialogBase173{174public:175 // Event handlers176 void OnClose(wxCloseEvent& event);177 void OnButtonOK(wxCommandEvent& event);178 void OnButtonCancel(wxCommandEvent& event);179 void OnPaint(wxPaintEvent& event);180 181public:182 /** Constructor */183 CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);184 ~CSendingDialog();185186 // State187 CAddress addr;188 int64 nPrice;189 CWalletTx wtx;190 wxDateTime start;191 char pszStatus[10000];192 bool fCanCancel;193 bool fAbort;194 bool fSuccess;195 bool fUIDone;196 bool fWorkDone;197198 void Close();199 void Repaint();200 bool Status();201 bool Status(const string& str);202 bool Error(const string& str);203 void StartTransfer();204 void OnReply2(CDataStream& vRecv);205 void OnReply3(CDataStream& vRecv);206};207208void SendingDialogStartTransfer(void* parg);209void SendingDialogOnReply2(void* parg, CDataStream& vRecv);210void SendingDialogOnReply3(void* parg, CDataStream& vRecv);211212213214class CYourAddressDialog : public CYourAddressDialogBase215{216protected:217 // Event handlers218 void OnListEndLabelEdit(wxListEvent& event);219 void OnListItemSelected(wxListEvent& event);220 void OnListItemActivated(wxListEvent& event);221 void OnButtonRename(wxCommandEvent& event);222 void OnButtonNew(wxCommandEvent& event);223 void OnButtonCopy(wxCommandEvent& event);224 void OnButtonOK(wxCommandEvent& event);225 void OnButtonCancel(wxCommandEvent& event);226 void OnClose(wxCloseEvent& event);227228public:229 /** Constructor */230 CYourAddressDialog(wxWindow* parent);231 CYourAddressDialog(wxWindow* parent, const string& strInitSelected);232233 // Custom234 wxString GetAddress();235};236237238239class CAddressBookDialog : public CAddressBookDialogBase240{241protected:242 // Event handlers243 void OnListEndLabelEdit(wxListEvent& event);244 void OnListItemSelected(wxListEvent& event);245 void OnListItemActivated(wxListEvent& event);246 void OnButtonEdit(wxCommandEvent& event);247 void OnButtonDelete(wxCommandEvent& event);248 void OnButtonNew(wxCommandEvent& event);249 void OnButtonCopy(wxCommandEvent& event);250 void OnButtonOK(wxCommandEvent& event);251 void OnButtonCancel(wxCommandEvent& event);252 void OnClose(wxCloseEvent& event);253254public:255 /** Constructor */256 CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, bool fSendingIn);257258 // Custom259 bool fSending;260 wxString GetAddress();261 bool CheckIfMine(const string& strAddress, const string& strTitle);262};263264265266class CProductsDialog : public CProductsDialogBase267{268protected:269 // Event handlers270 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }271 void OnCombobox(wxCommandEvent& event);272 void OnButtonSearch(wxCommandEvent& event);273 void OnListItemActivated(wxListEvent& event);274275public:276 /** Constructor */277 CProductsDialog(wxWindow* parent);278279 // Custom280 vector<CProduct> m_vProduct;281};282283284285class CEditProductDialog : public CEditProductDialogBase286{287protected:288 // Event handlers289 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }290 void OnButtonDel0(wxCommandEvent& event);291 void OnButtonDel1(wxCommandEvent& event);292 void OnButtonDel2(wxCommandEvent& event);293 void OnButtonDel3(wxCommandEvent& event);294 void OnButtonDel4(wxCommandEvent& event);295 void OnButtonDel5(wxCommandEvent& event);296 void OnButtonDel6(wxCommandEvent& event);297 void OnButtonDel7(wxCommandEvent& event);298 void OnButtonDel8(wxCommandEvent& event);299 void OnButtonDel9(wxCommandEvent& event);300 void OnButtonDel10(wxCommandEvent& event);301 void OnButtonDel11(wxCommandEvent& event);302 void OnButtonDel12(wxCommandEvent& event);303 void OnButtonDel13(wxCommandEvent& event);304 void OnButtonDel14(wxCommandEvent& event);305 void OnButtonDel15(wxCommandEvent& event);306 void OnButtonDel16(wxCommandEvent& event);307 void OnButtonDel17(wxCommandEvent& event);308 void OnButtonDel18(wxCommandEvent& event);309 void OnButtonDel19(wxCommandEvent& event);310 void OnButtonAddField(wxCommandEvent& event);311 void OnButtonSend(wxCommandEvent& event);312 void OnButtonPreview(wxCommandEvent& event);313 void OnButtonCancel(wxCommandEvent& event);314315public:316 /** Constructor */317 CEditProductDialog(wxWindow* parent);318319 // Custom320 enum { FIELDS_MAX = 20 };321 wxTextCtrl* m_textCtrlLabel[FIELDS_MAX];322 wxTextCtrl* m_textCtrlField[FIELDS_MAX];323 wxButton* m_buttonDel[FIELDS_MAX];324325 void LayoutAll();326 void ShowLine(int i, bool fShow=true);327 void OnButtonDel(wxCommandEvent& event, int n);328 void SetProduct(const CProduct& productIn);329 void GetProduct(CProduct& product);330331};332333334335class CViewProductDialog : public CViewProductDialogBase336{337protected:338 // Event handlers339 void OnButtonSubmitForm(wxCommandEvent& event);340 void OnButtonCancelForm(wxCommandEvent& event);341 void OnButtonBack(wxCommandEvent& event);342 void OnButtonNext(wxCommandEvent& event);343 void OnButtonCancel(wxCommandEvent& event);344345public:346 /** Constructor */347 CViewProductDialog(wxWindow* parent, const CProduct& productIn);348 ~CViewProductDialog();349350 // Custom351 CProduct product;352 enum { FIELDS_MAX = 20 };353 wxStaticText* m_staticTextLabel[FIELDS_MAX];354 wxTextCtrl* m_textCtrlField[FIELDS_MAX];355 wxChoice* m_choiceField[FIELDS_MAX];356357 void GetOrder(CWalletTx& order);358 void UpdateProductDisplay(bool fDetails);359 void OnReply1(wxCommandEvent& event);360};361362363364class CViewOrderDialog : public CViewOrderDialogBase365{366protected:367 // Event handlers368 void OnButtonOK(wxCommandEvent& event);369370public:371 /** Constructor */372 CViewOrderDialog(wxWindow* parent, CWalletTx order, bool fReceived);373374 // Custom375 bool fReceived;376};377378379380class CEditReviewDialog : public CEditReviewDialogBase381{382protected:383 // Event handlers384 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }385 void OnButtonSubmit(wxCommandEvent& event);386 void OnButtonCancel(wxCommandEvent& event);387388public:389 /** Constructor */390 CEditReviewDialog(wxWindow* parent);391392 // Custom393 void GetReview(CReview& review);394};395396397398class CGetTextFromUserDialog : public CGetTextFromUserDialogBase399{400protected:401 // Event handlers402 void OnButtonOK(wxCommandEvent& event) { EndModal(true); }403 void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }404 void OnClose(wxCloseEvent& event) { EndModal(false); }405406 void OnKeyDown(wxKeyEvent& event)407 {408 if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)409 EndModal(true);410 else411 HandleCtrlA(event);412 }413414public:415 /** Constructor */416 CGetTextFromUserDialog(wxWindow* parent,417 const string& strCaption,418 const string& strMessage1,419 const string& strValue1="",420 const string& strMessage2="",421 const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)422 {423 m_staticTextMessage1->SetLabel(strMessage1);424 m_textCtrl1->SetValue(strValue1);425 if (!strMessage2.empty())426 {427 m_staticTextMessage2->Show(true);428 m_staticTextMessage2->SetLabel(strMessage2);429 m_textCtrl2->Show(true);430 m_textCtrl2->SetValue(strValue2);431 SetSize(wxDefaultCoord, 180);432 }433 }434435 // Custom436 string GetValue() { return (string)m_textCtrl1->GetValue(); }437 string GetValue1() { return (string)m_textCtrl1->GetValue(); }438 string GetValue2() { return (string)m_textCtrl2->GetValue(); }439};440441442443class CMyTaskBarIcon : public wxTaskBarIcon444{445protected:446 // Event handlers447 void OnLeftButtonDClick(wxTaskBarIconEvent& event);448 void OnMenuRestore(wxCommandEvent& event);449 void OnMenuOptions(wxCommandEvent& event);450 void OnUpdateUIGenerate(wxUpdateUIEvent& event);451 void OnMenuGenerate(wxCommandEvent& event);452 void OnMenuExit(wxCommandEvent& event);453454public:455 CMyTaskBarIcon() : wxTaskBarIcon()456 {457 Show(true);458 }459460 void Show(bool fShow=true);461 void Hide();462 void Restore();463 void UpdateTooltip();464 virtual wxMenu* CreatePopupMenu();465466DECLARE_EVENT_TABLE()467};
Click a line number to link to it; use #L10-L20 for a range. "=" next to a version means the file is identical there.
