1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
5 DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)
9 extern wxLocale g_locale;
13 void HandleCtrlA(wxKeyEvent& event);
14 string FormatTxStatus(const CWalletTx& wtx);
15 void UIThreadCall(boost::function0<void>);
16 int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
17 bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);
18 void CalledSetStatusBar(const string& strText, int nField);
19 void MainFrameRepaint();
20 void CreateMainWindow();
21 void SetStartOnSystemStartup(bool fAutoStart);
26 inline int MyMessageBox(const wxString& message, const wxString& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
30 return wxMessageBox(message, caption, style, parent, x, y);
32 printf("wxMessageBox %s: %s\n", string(caption).c_str(), string(message).c_str());
33 fprintf(stderr, "%s: %s\n", string(caption).c_str(), string(message).c_str());
36 #define wxMessageBox MyMessageBox
43 class CMainFrame : public CMainFrameBase
47 void OnNotebookPageChanged(wxNotebookEvent& event);
48 void OnClose(wxCloseEvent& event);
49 void OnIconize(wxIconizeEvent& event);
50 void OnMouseEvents(wxMouseEvent& event);
51 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
52 void OnIdle(wxIdleEvent& event);
53 void OnPaint(wxPaintEvent& event);
54 void OnPaintListCtrl(wxPaintEvent& event);
55 void OnMenuFileExit(wxCommandEvent& event);
56 void OnMenuOptionsGenerate(wxCommandEvent& event);
57 void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);
58 void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);
59 void OnMenuOptionsOptions(wxCommandEvent& event);
60 void OnMenuHelpAbout(wxCommandEvent& event);
61 void OnButtonSend(wxCommandEvent& event);
62 void OnButtonAddressBook(wxCommandEvent& event);
63 void OnSetFocusAddress(wxFocusEvent& event);
64 void OnMouseEventsAddress(wxMouseEvent& event);
65 void OnButtonNew(wxCommandEvent& event);
66 void OnButtonCopy(wxCommandEvent& event);
67 void OnListColBeginDrag(wxListEvent& event);
68 void OnListItemActivated(wxListEvent& event);
69 void OnListItemActivatedProductsSent(wxListEvent& event);
70 void OnListItemActivatedOrdersSent(wxListEvent& event);
71 void OnListItemActivatedOrdersReceived(wxListEvent& event);
75 CMainFrame(wxWindow* parent);
87 wxListCtrl* m_listCtrl;
91 bool fRefreshListCtrl;
92 bool fRefreshListCtrlRunning;
93 bool fOnSetFocusAddress;
94 unsigned int nListViewUpdated;
97 void OnUIThreadCall(wxCommandEvent& event);
98 int GetSortIndex(const string& strSort);
99 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);
100 bool DeleteLine(uint256 hashKey);
101 bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);
102 void RefreshListCtrl();
103 void RefreshStatusColumn();
109 class CTxDetailsDialog : public CTxDetailsDialogBase
113 void OnButtonOK(wxCommandEvent& event);
117 CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);
125 class COptionsDialog : public COptionsDialogBase
129 void OnListBox(wxCommandEvent& event);
130 void OnKillFocusTransactionFee(wxFocusEvent& event);
131 void OnCheckBoxLimitProcessors(wxCommandEvent& event);
132 void OnCheckBoxUseProxy(wxCommandEvent& event);
133 void OnKillFocusProxy(wxFocusEvent& event);
135 void OnButtonOK(wxCommandEvent& event);
136 void OnButtonCancel(wxCommandEvent& event);
137 void OnButtonApply(wxCommandEvent& event);
141 COptionsDialog(wxWindow* parent);
144 bool fTmpStartOnSystemStartup;
145 bool fTmpMinimizeOnClose;
146 void SelectPage(int nPage);
147 CAddress GetProxyAddr();
152 class CAboutDialog : public CAboutDialogBase
156 void OnButtonOK(wxCommandEvent& event);
160 CAboutDialog(wxWindow* parent);
165 class CSendDialog : public CSendDialogBase
169 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
170 void OnTextAddress(wxCommandEvent& event);
171 void OnKillFocusAmount(wxFocusEvent& event);
172 void OnButtonAddressBook(wxCommandEvent& event);
173 void OnButtonPaste(wxCommandEvent& event);
174 void OnButtonSend(wxCommandEvent& event);
175 void OnButtonCancel(wxCommandEvent& event);
179 CSendDialog(wxWindow* parent, const wxString& strAddress="");
184 string strMessageSave;
189 class CSendingDialog : public CSendingDialogBase
193 void OnClose(wxCloseEvent& event);
194 void OnButtonOK(wxCommandEvent& event);
195 void OnButtonCancel(wxCommandEvent& event);
196 void OnPaint(wxPaintEvent& event);
200 CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);
208 char pszStatus[10000];
218 bool Status(const string& str);
219 bool Error(const string& str);
220 void StartTransfer();
221 void OnReply2(CDataStream& vRecv);
222 void OnReply3(CDataStream& vRecv);
225 void SendingDialogStartTransfer(void* parg);
226 void SendingDialogOnReply2(void* parg, CDataStream& vRecv);
227 void SendingDialogOnReply3(void* parg, CDataStream& vRecv);
231 class CAddressBookDialog : public CAddressBookDialogBase
235 void OnNotebookPageChanged(wxNotebookEvent& event);
236 void OnListEndLabelEdit(wxListEvent& event);
237 void OnListItemSelected(wxListEvent& event);
238 void OnListItemActivated(wxListEvent& event);
239 void OnButtonDelete(wxCommandEvent& event);
240 void OnButtonCopy(wxCommandEvent& event);
241 void OnButtonEdit(wxCommandEvent& event);
242 void OnButtonNew(wxCommandEvent& event);
243 void OnButtonOK(wxCommandEvent& event);
244 void OnButtonCancel(wxCommandEvent& event);
245 void OnClose(wxCloseEvent& event);
249 CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);
258 wxListCtrl* m_listCtrl;
260 wxString GetAddress();
261 wxString GetSelectedAddress();
262 wxString GetSelectedSendingAddress();
263 wxString GetSelectedReceivingAddress();
264 bool CheckIfMine(const string& strAddress, const string& strTitle);
269 class CGetTextFromUserDialog : public CGetTextFromUserDialogBase
273 void OnButtonOK(wxCommandEvent& event) { EndModal(true); }
274 void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }
275 void OnClose(wxCloseEvent& event) { EndModal(false); }
277 void OnKeyDown(wxKeyEvent& event)
279 if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)
287 CGetTextFromUserDialog(wxWindow* parent,
288 const string& strCaption,
289 const string& strMessage1,
290 const string& strValue1="",
291 const string& strMessage2="",
292 const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)
294 int x = GetSize().GetWidth();
295 int y = GetSize().GetHeight();
296 m_staticTextMessage1->SetLabel(strMessage1);
297 m_textCtrl1->SetValue(strValue1);
298 y += wxString(strMessage1).Freq('\n') * 14;
299 if (!strMessage2.empty())
301 m_staticTextMessage2->Show(true);
302 m_staticTextMessage2->SetLabel(strMessage2);
303 m_textCtrl2->Show(true);
304 m_textCtrl2->SetValue(strValue2);
305 y += 46 + wxString(strMessage2).Freq('\n') * 14;
315 string GetValue() { return (string)m_textCtrl1->GetValue(); }
316 string GetValue1() { return (string)m_textCtrl1->GetValue(); }
317 string GetValue2() { return (string)m_textCtrl2->GetValue(); }
322 class CMyTaskBarIcon : public wxTaskBarIcon
326 void OnLeftButtonDClick(wxTaskBarIconEvent& event);
327 void OnMenuRestore(wxCommandEvent& event);
328 void OnMenuOptions(wxCommandEvent& event);
329 void OnUpdateUIGenerate(wxUpdateUIEvent& event);
330 void OnMenuGenerate(wxCommandEvent& event);
331 void OnMenuExit(wxCommandEvent& event);
334 CMyTaskBarIcon() : wxTaskBarIcon()
339 void Show(bool fShow=true);
342 void UpdateTooltip();
343 virtual wxMenu* CreatePopupMenu();
345 DECLARE_EVENT_TABLE()