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