Bitcoin v0.1.0 · 2009-01-08
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();29303132333435class CMainFrame : public CMainFrameBase36{37protected:38 // Event handlers39 void OnClose(wxCloseEvent& event);40 void OnMouseEvents(wxMouseEvent& event);41 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }42 void OnIdle(wxIdleEvent& event);43 void OnPaint(wxPaintEvent& event);44 void OnPaintListCtrl(wxPaintEvent& event);45 void OnMenuFileExit(wxCommandEvent& event);46 void OnMenuOptionsGenerate(wxCommandEvent& event);47 void OnMenuOptionsOptions(wxCommandEvent& event);48 void OnMenuHelpAbout(wxCommandEvent& event);49 void OnButtonSend(wxCommandEvent& event);50 void OnButtonAddressBook(wxCommandEvent& event);51 void OnSetFocusAddress(wxFocusEvent& event);52 void OnMouseEventsAddress(wxMouseEvent& event);53 void OnButtonCopy(wxCommandEvent& event);54 void OnButtonChange(wxCommandEvent& event);55 void OnListColBeginDrag(wxListEvent& event);56 void OnListItemActivatedAllTransactions(wxListEvent& event);57 void OnListItemActivatedProductsSent(wxListEvent& event);58 void OnListItemActivatedOrdersSent(wxListEvent& event);59 void OnListItemActivatedOrdersReceived(wxListEvent& event);60 61public:62 /** Constructor */63 CMainFrame(wxWindow* parent);64 ~CMainFrame();6566 // Custom67 bool fRefreshListCtrl;68 bool fRefreshListCtrlRunning;69 bool fOnSetFocusAddress;70 CBlockIndex* pindexBestLast;71 set<uint256> setUnmaturedDisplayed;7273 void OnCrossThreadCall(wxCommandEvent& event);74 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);75 void InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);76 void RefreshListCtrl();77 void RefreshStatus();78};7980818283class CTxDetailsDialog : public CTxDetailsDialogBase84{85protected:86 // Event handlers87 void OnButtonOK(wxCommandEvent& event);8889public:90 /** Constructor */91 CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);9293 // State94 CWalletTx wtx;95};96979899class COptionsDialog : public COptionsDialogBase100{101protected:102 // Event handlers103 void OnKillFocusTransactionFee(wxFocusEvent& event);104 void OnButtonOK(wxCommandEvent& event);105 void OnButtonCancel(wxCommandEvent& event);106107public:108 /** Constructor */109 COptionsDialog(wxWindow* parent);110};111112113114class CAboutDialog : public CAboutDialogBase115{116protected:117 // Event handlers118 void OnButtonOK(wxCommandEvent& event);119120public:121 /** Constructor */122 CAboutDialog(wxWindow* parent);123};124125126127class CSendDialog : public CSendDialogBase128{129protected:130 // Event handlers131 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }132 void OnTextAddress(wxCommandEvent& event);133 void OnKillFocusAmount(wxFocusEvent& event);134 void OnButtonAddressBook(wxCommandEvent& event);135 void OnButtonPaste(wxCommandEvent& event);136 void OnButtonSend(wxCommandEvent& event);137 void OnButtonCancel(wxCommandEvent& event);138 139public:140 /** Constructor */141 CSendDialog(wxWindow* parent, const wxString& strAddress="");142};143144145146class CSendingDialog : public CSendingDialogBase147{148public:149 // Event handlers150 void OnClose(wxCloseEvent& event);151 void OnButtonOK(wxCommandEvent& event);152 void OnButtonCancel(wxCommandEvent& event);153 void OnPaint(wxPaintEvent& event);154 155public:156 /** Constructor */157 CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);158 ~CSendingDialog();159160 // State161 CAddress addr;162 int64 nPrice;163 CWalletTx wtx;164 wxDateTime start;165 string strStatus;166 bool fCanCancel;167 bool fAbort;168 bool fSuccess;169 bool fUIDone;170 bool fWorkDone;171172 void Close();173 void Repaint();174 bool Status();175 bool Status(const string& str);176 bool Error(const string& str);177 void StartTransfer();178 void OnReply2(CDataStream& vRecv);179 void OnReply3(CDataStream& vRecv);180};181182void SendingDialogStartTransfer(void* parg);183void SendingDialogOnReply2(void* parg, CDataStream& vRecv);184void SendingDialogOnReply3(void* parg, CDataStream& vRecv);185186187188class CYourAddressDialog : public CYourAddressDialogBase189{190protected:191 // Event handlers192 void OnListEndLabelEdit(wxListEvent& event);193 void OnListItemSelected(wxListEvent& event);194 void OnListItemActivated(wxListEvent& event);195 void OnButtonRename(wxCommandEvent& event);196 void OnButtonNew(wxCommandEvent& event);197 void OnButtonCopy(wxCommandEvent& event);198 void OnButtonOK(wxCommandEvent& event);199 void OnButtonCancel(wxCommandEvent& event);200 void OnClose(wxCloseEvent& event);201202public:203 /** Constructor */204 CYourAddressDialog(wxWindow* parent);205 CYourAddressDialog(wxWindow* parent, const string& strInitSelected);206207 // Custom208 wxString GetAddress();209};210211212213class CAddressBookDialog : public CAddressBookDialogBase214{215protected:216 // Event handlers217 void OnListEndLabelEdit(wxListEvent& event);218 void OnListItemSelected(wxListEvent& event);219 void OnListItemActivated(wxListEvent& event);220 void OnButtonEdit(wxCommandEvent& event);221 void OnButtonDelete(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 CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, bool fSendingIn);231232 // Custom233 bool fSending;234 wxString GetAddress();235};236237238239class CProductsDialog : public CProductsDialogBase240{241protected:242 // Event handlers243 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }244 void OnCombobox(wxCommandEvent& event);245 void OnButtonSearch(wxCommandEvent& event);246 void OnListItemActivated(wxListEvent& event);247248public:249 /** Constructor */250 CProductsDialog(wxWindow* parent);251252 // Custom253 vector<CProduct> m_vProduct;254};255256257258class CEditProductDialog : public CEditProductDialogBase259{260protected:261 // Event handlers262 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }263 void OnButtonDel0(wxCommandEvent& event);264 void OnButtonDel1(wxCommandEvent& event);265 void OnButtonDel2(wxCommandEvent& event);266 void OnButtonDel3(wxCommandEvent& event);267 void OnButtonDel4(wxCommandEvent& event);268 void OnButtonDel5(wxCommandEvent& event);269 void OnButtonDel6(wxCommandEvent& event);270 void OnButtonDel7(wxCommandEvent& event);271 void OnButtonDel8(wxCommandEvent& event);272 void OnButtonDel9(wxCommandEvent& event);273 void OnButtonDel10(wxCommandEvent& event);274 void OnButtonDel11(wxCommandEvent& event);275 void OnButtonDel12(wxCommandEvent& event);276 void OnButtonDel13(wxCommandEvent& event);277 void OnButtonDel14(wxCommandEvent& event);278 void OnButtonDel15(wxCommandEvent& event);279 void OnButtonDel16(wxCommandEvent& event);280 void OnButtonDel17(wxCommandEvent& event);281 void OnButtonDel18(wxCommandEvent& event);282 void OnButtonDel19(wxCommandEvent& event);283 void OnButtonAddField(wxCommandEvent& event);284 void OnButtonSend(wxCommandEvent& event);285 void OnButtonPreview(wxCommandEvent& event);286 void OnButtonCancel(wxCommandEvent& event);287288public:289 /** Constructor */290 CEditProductDialog(wxWindow* parent);291292 // Custom293 enum { FIELDS_MAX = 20 };294 wxTextCtrl* m_textCtrlLabel[FIELDS_MAX];295 wxTextCtrl* m_textCtrlField[FIELDS_MAX];296 wxButton* m_buttonDel[FIELDS_MAX];297298 void LayoutAll();299 void ShowLine(int i, bool fShow=true);300 void OnButtonDel(wxCommandEvent& event, int n);301 void SetProduct(const CProduct& productIn);302 void GetProduct(CProduct& product);303304};305306307308class CViewProductDialog : public CViewProductDialogBase309{310protected:311 // Event handlers312 void OnButtonSubmitForm(wxCommandEvent& event);313 void OnButtonCancelForm(wxCommandEvent& event);314 void OnButtonBack(wxCommandEvent& event);315 void OnButtonNext(wxCommandEvent& event);316 void OnButtonCancel(wxCommandEvent& event);317318public:319 /** Constructor */320 CViewProductDialog(wxWindow* parent, const CProduct& productIn);321 ~CViewProductDialog();322323 // Custom324 CProduct product;325 enum { FIELDS_MAX = 20 };326 wxStaticText* m_staticTextLabel[FIELDS_MAX];327 wxTextCtrl* m_textCtrlField[FIELDS_MAX];328 wxChoice* m_choiceField[FIELDS_MAX];329330 void GetOrder(CWalletTx& order);331 void UpdateProductDisplay(bool fDetails);332 void OnReply1(wxCommandEvent& event);333};334335336337class CViewOrderDialog : public CViewOrderDialogBase338{339protected:340 // Event handlers341 void OnButtonOK(wxCommandEvent& event);342343public:344 /** Constructor */345 CViewOrderDialog(wxWindow* parent, CWalletTx order, bool fReceived);346347 // Custom348 bool fReceived;349};350351352353class CEditReviewDialog : public CEditReviewDialogBase354{355protected:356 // Event handlers357 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }358 void OnButtonSubmit(wxCommandEvent& event);359 void OnButtonCancel(wxCommandEvent& event);360361public:362 /** Constructor */363 CEditReviewDialog(wxWindow* parent);364365 // Custom366 void GetReview(CReview& review);367};368369370371class CGetTextFromUserDialog : public CGetTextFromUserDialogBase372{373protected:374 // Event handlers375 void OnButtonOK(wxCommandEvent& event) { EndModal(true); }376 void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }377 void OnClose(wxCloseEvent& event) { EndModal(false); }378379 void OnKeyDown(wxKeyEvent& event)380 {381 if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)382 EndModal(true);383 else384 HandleCtrlA(event);385 }386387public:388 /** Constructor */389 CGetTextFromUserDialog(wxWindow* parent,390 const string& strCaption,391 const string& strMessage1,392 const string& strValue1="",393 const string& strMessage2="",394 const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)395 {396 m_staticTextMessage1->SetLabel(strMessage1);397 m_textCtrl1->SetValue(strValue1);398 if (!strMessage2.empty())399 {400 m_staticTextMessage2->Show(true);401 m_staticTextMessage2->SetLabel(strMessage2);402 m_textCtrl2->Show(true);403 m_textCtrl2->SetValue(strValue2);404 SetSize(wxDefaultCoord, 180);405 }406 }407408 // Custom409 string GetValue() { return (string)m_textCtrl1->GetValue(); }410 string GetValue1() { return (string)m_textCtrl1->GetValue(); }411 string GetValue2() { return (string)m_textCtrl2->GetValue(); }412};413414415416417
Click a line number to link to it; use #L10-L20 for a range. "=" next to a version means the file is identical there.
