Bitcoin v0.1.5 · 2009-02-04
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_CROSSTHREADCALL, -1)9DECLARE_EVENT_TYPE(wxEVT_REPLY1, -1)10DECLARE_EVENT_TYPE(wxEVT_REPLY2, -1)11DECLARE_EVENT_TYPE(wxEVT_REPLY3, -1)12DECLARE_EVENT_TYPE(wxEVT_TABLEADDED, -1)13DECLARE_EVENT_TYPE(wxEVT_TABLEUPDATED, -1)14DECLARE_EVENT_TYPE(wxEVT_TABLEDELETED, -1)1516enum17{18 UICALL_ADDORDER = 1,19 UICALL_UPDATEORDER,20};21222324extern void HandleCtrlA(wxKeyEvent& event);25extern string DateTimeStr(int64 nTime);26extern string FormatTxStatus(const CWalletTx& wtx);27extern void CrossThreadCall(int nID, void* pdata);28extern void MainFrameRepaint();29extern void Shutdown(void* parg);30313233343536class CMainFrame : public CMainFrameBase37{38protected:39 // Event handlers40 void OnClose(wxCloseEvent& event);41 void OnMouseEvents(wxMouseEvent& event);42 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }43 void OnIdle(wxIdleEvent& event);44 void OnPaint(wxPaintEvent& event);45 void OnPaintListCtrl(wxPaintEvent& event);46 void OnMenuFileExit(wxCommandEvent& event);47 void OnMenuOptionsGenerate(wxCommandEvent& event);48 void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);49 void OnMenuOptionsOptions(wxCommandEvent& event);50 void OnMenuHelpAbout(wxCommandEvent& event);51 void OnButtonSend(wxCommandEvent& event);52 void OnButtonAddressBook(wxCommandEvent& event);53 void OnSetFocusAddress(wxFocusEvent& event);54 void OnMouseEventsAddress(wxMouseEvent& event);55 void OnButtonCopy(wxCommandEvent& event);56 void OnButtonChange(wxCommandEvent& event);57 void OnListColBeginDrag(wxListEvent& event);58 void OnListItemActivatedAllTransactions(wxListEvent& event);59 void OnListItemActivatedProductsSent(wxListEvent& event);60 void OnListItemActivatedOrdersSent(wxListEvent& event);61 void OnListItemActivatedOrdersReceived(wxListEvent& event);62 63public:64 /** Constructor */65 CMainFrame(wxWindow* parent);66 ~CMainFrame();6768 // Custom69 bool fRefreshListCtrl;70 bool fRefreshListCtrlRunning;71 bool fOnSetFocusAddress;72 CBlockIndex* pindexBestLast;73 set<uint256> setUnmaturedDisplayed;7475 void OnCrossThreadCall(wxCommandEvent& event);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 void RefreshListCtrl();79 void RefreshStatus();80};8182838485class CTxDetailsDialog : public CTxDetailsDialogBase86{87protected:88 // Event handlers89 void OnButtonOK(wxCommandEvent& event);9091public:92 /** Constructor */93 CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);9495 // State96 CWalletTx wtx;97};9899100101class COptionsDialog : public COptionsDialogBase102{103protected:104 // Event handlers105 void OnKillFocusTransactionFee(wxFocusEvent& event);106 void OnButtonOK(wxCommandEvent& event);107 void OnButtonCancel(wxCommandEvent& event);108109public:110 /** Constructor */111 COptionsDialog(wxWindow* parent);112};113114115116class CAboutDialog : public CAboutDialogBase117{118protected:119 // Event handlers120 void OnButtonOK(wxCommandEvent& event);121122public:123 /** Constructor */124 CAboutDialog(wxWindow* parent);125};126127128129class CSendDialog : public CSendDialogBase130{131protected:132 // Event handlers133 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }134 void OnTextAddress(wxCommandEvent& event);135 void OnKillFocusAmount(wxFocusEvent& event);136 void OnButtonAddressBook(wxCommandEvent& event);137 void OnButtonPaste(wxCommandEvent& event);138 void OnButtonSend(wxCommandEvent& event);139 void OnButtonCancel(wxCommandEvent& event);140 141public:142 /** Constructor */143 CSendDialog(wxWindow* parent, const wxString& strAddress="");144};145146147148class CSendingDialog : public CSendingDialogBase149{150public:151 // Event handlers152 void OnClose(wxCloseEvent& event);153 void OnButtonOK(wxCommandEvent& event);154 void OnButtonCancel(wxCommandEvent& event);155 void OnPaint(wxPaintEvent& event);156 157public:158 /** Constructor */159 CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);160 ~CSendingDialog();161162 // State163 CAddress addr;164 int64 nPrice;165 CWalletTx wtx;166 wxDateTime start;167 string strStatus;168 bool fCanCancel;169 bool fAbort;170 bool fSuccess;171 bool fUIDone;172 bool fWorkDone;173174 void Close();175 void Repaint();176 bool Status();177 bool Status(const string& str);178 bool Error(const string& str);179 void StartTransfer();180 void OnReply2(CDataStream& vRecv);181 void OnReply3(CDataStream& vRecv);182};183184void SendingDialogStartTransfer(void* parg);185void SendingDialogOnReply2(void* parg, CDataStream& vRecv);186void SendingDialogOnReply3(void* parg, CDataStream& vRecv);187188189190class CYourAddressDialog : public CYourAddressDialogBase191{192protected:193 // Event handlers194 void OnListEndLabelEdit(wxListEvent& event);195 void OnListItemSelected(wxListEvent& event);196 void OnListItemActivated(wxListEvent& event);197 void OnButtonRename(wxCommandEvent& event);198 void OnButtonNew(wxCommandEvent& event);199 void OnButtonCopy(wxCommandEvent& event);200 void OnButtonOK(wxCommandEvent& event);201 void OnButtonCancel(wxCommandEvent& event);202 void OnClose(wxCloseEvent& event);203204public:205 /** Constructor */206 CYourAddressDialog(wxWindow* parent);207 CYourAddressDialog(wxWindow* parent, const string& strInitSelected);208209 // Custom210 wxString GetAddress();211};212213214215class CAddressBookDialog : public CAddressBookDialogBase216{217protected:218 // Event handlers219 void OnListEndLabelEdit(wxListEvent& event);220 void OnListItemSelected(wxListEvent& event);221 void OnListItemActivated(wxListEvent& event);222 void OnButtonEdit(wxCommandEvent& event);223 void OnButtonDelete(wxCommandEvent& event);224 void OnButtonNew(wxCommandEvent& event);225 void OnButtonCopy(wxCommandEvent& event);226 void OnButtonOK(wxCommandEvent& event);227 void OnButtonCancel(wxCommandEvent& event);228 void OnClose(wxCloseEvent& event);229230public:231 /** Constructor */232 CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, bool fSendingIn);233234 // Custom235 bool fSending;236 wxString GetAddress();237 bool CheckIfMine(const string& strAddress, const string& strTitle);238};239240241242class CProductsDialog : public CProductsDialogBase243{244protected:245 // Event handlers246 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }247 void OnCombobox(wxCommandEvent& event);248 void OnButtonSearch(wxCommandEvent& event);249 void OnListItemActivated(wxListEvent& event);250251public:252 /** Constructor */253 CProductsDialog(wxWindow* parent);254255 // Custom256 vector<CProduct> m_vProduct;257};258259260261class CEditProductDialog : public CEditProductDialogBase262{263protected:264 // Event handlers265 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }266 void OnButtonDel0(wxCommandEvent& event);267 void OnButtonDel1(wxCommandEvent& event);268 void OnButtonDel2(wxCommandEvent& event);269 void OnButtonDel3(wxCommandEvent& event);270 void OnButtonDel4(wxCommandEvent& event);271 void OnButtonDel5(wxCommandEvent& event);272 void OnButtonDel6(wxCommandEvent& event);273 void OnButtonDel7(wxCommandEvent& event);274 void OnButtonDel8(wxCommandEvent& event);275 void OnButtonDel9(wxCommandEvent& event);276 void OnButtonDel10(wxCommandEvent& event);277 void OnButtonDel11(wxCommandEvent& event);278 void OnButtonDel12(wxCommandEvent& event);279 void OnButtonDel13(wxCommandEvent& event);280 void OnButtonDel14(wxCommandEvent& event);281 void OnButtonDel15(wxCommandEvent& event);282 void OnButtonDel16(wxCommandEvent& event);283 void OnButtonDel17(wxCommandEvent& event);284 void OnButtonDel18(wxCommandEvent& event);285 void OnButtonDel19(wxCommandEvent& event);286 void OnButtonAddField(wxCommandEvent& event);287 void OnButtonSend(wxCommandEvent& event);288 void OnButtonPreview(wxCommandEvent& event);289 void OnButtonCancel(wxCommandEvent& event);290291public:292 /** Constructor */293 CEditProductDialog(wxWindow* parent);294295 // Custom296 enum { FIELDS_MAX = 20 };297 wxTextCtrl* m_textCtrlLabel[FIELDS_MAX];298 wxTextCtrl* m_textCtrlField[FIELDS_MAX];299 wxButton* m_buttonDel[FIELDS_MAX];300301 void LayoutAll();302 void ShowLine(int i, bool fShow=true);303 void OnButtonDel(wxCommandEvent& event, int n);304 void SetProduct(const CProduct& productIn);305 void GetProduct(CProduct& product);306307};308309310311class CViewProductDialog : public CViewProductDialogBase312{313protected:314 // Event handlers315 void OnButtonSubmitForm(wxCommandEvent& event);316 void OnButtonCancelForm(wxCommandEvent& event);317 void OnButtonBack(wxCommandEvent& event);318 void OnButtonNext(wxCommandEvent& event);319 void OnButtonCancel(wxCommandEvent& event);320321public:322 /** Constructor */323 CViewProductDialog(wxWindow* parent, const CProduct& productIn);324 ~CViewProductDialog();325326 // Custom327 CProduct product;328 enum { FIELDS_MAX = 20 };329 wxStaticText* m_staticTextLabel[FIELDS_MAX];330 wxTextCtrl* m_textCtrlField[FIELDS_MAX];331 wxChoice* m_choiceField[FIELDS_MAX];332333 void GetOrder(CWalletTx& order);334 void UpdateProductDisplay(bool fDetails);335 void OnReply1(wxCommandEvent& event);336};337338339340class CViewOrderDialog : public CViewOrderDialogBase341{342protected:343 // Event handlers344 void OnButtonOK(wxCommandEvent& event);345346public:347 /** Constructor */348 CViewOrderDialog(wxWindow* parent, CWalletTx order, bool fReceived);349350 // Custom351 bool fReceived;352};353354355356class CEditReviewDialog : public CEditReviewDialogBase357{358protected:359 // Event handlers360 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }361 void OnButtonSubmit(wxCommandEvent& event);362 void OnButtonCancel(wxCommandEvent& event);363364public:365 /** Constructor */366 CEditReviewDialog(wxWindow* parent);367368 // Custom369 void GetReview(CReview& review);370};371372373374class CGetTextFromUserDialog : public CGetTextFromUserDialogBase375{376protected:377 // Event handlers378 void OnButtonOK(wxCommandEvent& event) { EndModal(true); }379 void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }380 void OnClose(wxCloseEvent& event) { EndModal(false); }381382 void OnKeyDown(wxKeyEvent& event)383 {384 if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)385 EndModal(true);386 else387 HandleCtrlA(event);388 }389390public:391 /** Constructor */392 CGetTextFromUserDialog(wxWindow* parent,393 const string& strCaption,394 const string& strMessage1,395 const string& strValue1="",396 const string& strMessage2="",397 const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)398 {399 m_staticTextMessage1->SetLabel(strMessage1);400 m_textCtrl1->SetValue(strValue1);401 if (!strMessage2.empty())402 {403 m_staticTextMessage2->Show(true);404 m_staticTextMessage2->SetLabel(strMessage2);405 m_textCtrl2->Show(true);406 m_textCtrl2->SetValue(strValue2);407 SetSize(wxDefaultCoord, 180);408 }409 }410411 // Custom412 string GetValue() { return (string)m_textCtrl1->GetValue(); }413 string GetValue1() { return (string)m_textCtrl1->GetValue(); }414 string GetValue2() { return (string)m_textCtrl2->GetValue(); }415};416417418419420
Click a line number to link to it; use #L10-L20 for a range. "=" next to a version means the file is identical there.
