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 void UIThreadCall(boost::function0<void>);
15 int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
16 bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);
17 void CalledSetStatusBar(const string& strText, int nField);
18 void MainFrameRepaint();
19 void CreateMainWindow();
20 void SetStartOnSystemStartup(bool fAutoStart);
25 inline int MyMessageBox(const wxString& message, const wxString& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
29 return wxMessageBox(message, caption, style, parent, x, y);
31 printf("wxMessageBox %s: %s\n", string(caption).c_str(), string(message).c_str());
32 fprintf(stderr, "%s: %s\n", string(caption).c_str(), string(message).c_str());
35 #define wxMessageBox MyMessageBox
42 class CMainFrame : public CMainFrameBase
46 void OnNotebookPageChanged(wxNotebookEvent& event);
47 void OnClose(wxCloseEvent& event);
48 void OnIconize(wxIconizeEvent& event);
49 void OnMouseEvents(wxMouseEvent& event);
50 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
51 void OnIdle(wxIdleEvent& event);
52 void OnPaint(wxPaintEvent& event);
53 void OnPaintListCtrl(wxPaintEvent& event);
54 void OnMenuFileExit(wxCommandEvent& event);
55 void OnMenuOptionsGenerate(wxCommandEvent& event);
56 void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);
57 void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);
58 void OnMenuOptionsOptions(wxCommandEvent& event);
59 void OnMenuHelpAbout(wxCommandEvent& event);
60 void OnButtonSend(wxCommandEvent& event);
61 void OnButtonAddressBook(wxCommandEvent& event);
62 void OnSetFocusAddress(wxFocusEvent& event);
63 void OnMouseEventsAddress(wxMouseEvent& event);
64 void OnButtonNew(wxCommandEvent& event);
65 void OnButtonCopy(wxCommandEvent& event);
66 void OnListColBeginDrag(wxListEvent& event);
67 void OnListItemActivated(wxListEvent& event);
68 void OnListItemActivatedProductsSent(wxListEvent& event);
69 void OnListItemActivatedOrdersSent(wxListEvent& event);
70 void OnListItemActivatedOrdersReceived(wxListEvent& event);
74 CMainFrame(wxWindow* parent);
86 wxListCtrl* m_listCtrl;
90 bool fRefreshListCtrl;
91 bool fRefreshListCtrlRunning;
92 bool fOnSetFocusAddress;
93 unsigned int nListViewUpdated;
96 void OnUIThreadCall(wxCommandEvent& event);
97 int GetSortIndex(const string& strSort);
98 void InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxColour& colour, const wxString& str1, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5);
99 bool DeleteLine(uint256 hashKey);
100 bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);
101 void RefreshListCtrl();
102 void RefreshStatusColumn();
108 class CTxDetailsDialog : public CTxDetailsDialogBase
112 void OnButtonOK(wxCommandEvent& event);
116 CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);
124 class COptionsDialog : public COptionsDialogBase
128 void OnListBox(wxCommandEvent& event);
129 void OnKillFocusTransactionFee(wxFocusEvent& event);
130 void OnCheckBoxLimitProcessors(wxCommandEvent& event);
131 void OnCheckBoxUseProxy(wxCommandEvent& event);
132 void OnKillFocusProxy(wxFocusEvent& event);
134 void OnButtonOK(wxCommandEvent& event);
135 void OnButtonCancel(wxCommandEvent& event);
136 void OnButtonApply(wxCommandEvent& event);
140 COptionsDialog(wxWindow* parent);
143 bool fTmpStartOnSystemStartup;
144 bool fTmpMinimizeOnClose;
145 void SelectPage(int nPage);
146 CAddress GetProxyAddr();
151 class CAboutDialog : public CAboutDialogBase
155 void OnButtonOK(wxCommandEvent& event);
159 CAboutDialog(wxWindow* parent);
164 class CSendDialog : public CSendDialogBase
168 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
169 void OnKillFocusAmount(wxFocusEvent& event);
170 void OnButtonAddressBook(wxCommandEvent& event);
171 void OnButtonPaste(wxCommandEvent& event);
172 void OnButtonSend(wxCommandEvent& event);
173 void OnButtonCancel(wxCommandEvent& event);
177 CSendDialog(wxWindow* parent, const wxString& strAddress="");
182 string strMessageSave;
187 class CSendingDialog : public CSendingDialogBase
191 void OnClose(wxCloseEvent& event);
192 void OnButtonOK(wxCommandEvent& event);
193 void OnButtonCancel(wxCommandEvent& event);
194 void OnPaint(wxPaintEvent& event);
198 CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);
206 char pszStatus[10000];
216 bool Status(const string& str);
217 bool Error(const string& str);
218 void StartTransfer();
219 void OnReply2(CDataStream& vRecv);
220 void OnReply3(CDataStream& vRecv);
223 void SendingDialogStartTransfer(void* parg);
224 void SendingDialogOnReply2(void* parg, CDataStream& vRecv);
225 void SendingDialogOnReply3(void* parg, CDataStream& vRecv);
229 class CAddressBookDialog : public CAddressBookDialogBase
233 void OnNotebookPageChanged(wxNotebookEvent& event);
234 void OnListEndLabelEdit(wxListEvent& event);
235 void OnListItemSelected(wxListEvent& event);
236 void OnListItemActivated(wxListEvent& event);
237 void OnButtonDelete(wxCommandEvent& event);
238 void OnButtonCopy(wxCommandEvent& event);
239 void OnButtonEdit(wxCommandEvent& event);
240 void OnButtonNew(wxCommandEvent& event);
241 void OnButtonOK(wxCommandEvent& event);
242 void OnButtonCancel(wxCommandEvent& event);
243 void OnClose(wxCloseEvent& event);
247 CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);
256 wxListCtrl* m_listCtrl;
258 wxString GetAddress();
259 wxString GetSelectedAddress();
260 wxString GetSelectedSendingAddress();
261 wxString GetSelectedReceivingAddress();
262 bool CheckIfMine(const string& strAddress, const string& strTitle);
267 class CGetTextFromUserDialog : public CGetTextFromUserDialogBase
271 void OnButtonOK(wxCommandEvent& event) { EndModal(true); }
272 void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }
273 void OnClose(wxCloseEvent& event) { EndModal(false); }
275 void OnKeyDown(wxKeyEvent& event)
277 if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)
285 CGetTextFromUserDialog(wxWindow* parent,
286 const string& strCaption,
287 const string& strMessage1,
288 const string& strValue1="",
289 const string& strMessage2="",
290 const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)
292 int x = GetSize().GetWidth();
293 int y = GetSize().GetHeight();
294 m_staticTextMessage1->SetLabel(strMessage1);
295 m_textCtrl1->SetValue(strValue1);
296 y += wxString(strMessage1).Freq('\n') * 14;
297 if (!strMessage2.empty())
299 m_staticTextMessage2->Show(true);
300 m_staticTextMessage2->SetLabel(strMessage2);
301 m_textCtrl2->Show(true);
302 m_textCtrl2->SetValue(strValue2);
303 y += 46 + wxString(strMessage2).Freq('\n') * 14;
313 string GetValue() { return (string)m_textCtrl1->GetValue(); }
314 string GetValue1() { return (string)m_textCtrl1->GetValue(); }
315 string GetValue2() { return (string)m_textCtrl2->GetValue(); }
320 class CMyTaskBarIcon : public wxTaskBarIcon
324 void OnLeftButtonDClick(wxTaskBarIconEvent& event);
325 void OnMenuRestore(wxCommandEvent& event);
326 void OnMenuOptions(wxCommandEvent& event);
327 void OnUpdateUIGenerate(wxUpdateUIEvent& event);
328 void OnMenuGenerate(wxCommandEvent& event);
329 void OnMenuExit(wxCommandEvent& event);
332 CMyTaskBarIcon() : wxTaskBarIcon()
337 void Show(bool fShow=true);
340 void UpdateTooltip();
341 virtual wxMenu* CreatePopupMenu();
343 DECLARE_EVENT_TABLE()