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 OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);
56 void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);
57 void OnMenuOptionsOptions(wxCommandEvent& event);
58 void OnMenuHelpAbout(wxCommandEvent& event);
59 void OnButtonSend(wxCommandEvent& event);
60 void OnButtonAddressBook(wxCommandEvent& event);
61 void OnSetFocusAddress(wxFocusEvent& event);
62 void OnMouseEventsAddress(wxMouseEvent& event);
63 void OnButtonNew(wxCommandEvent& event);
64 void OnButtonCopy(wxCommandEvent& event);
65 void OnListColBeginDrag(wxListEvent& event);
66 void OnListItemActivated(wxListEvent& event);
67 void OnListItemActivatedProductsSent(wxListEvent& event);
68 void OnListItemActivatedOrdersSent(wxListEvent& event);
69 void OnListItemActivatedOrdersReceived(wxListEvent& event);
73 CMainFrame(wxWindow* parent);
85 wxListCtrl* m_listCtrl;
89 bool fRefreshListCtrl;
90 bool fRefreshListCtrlRunning;
91 bool fOnSetFocusAddress;
92 unsigned int nListViewUpdated;
95 void OnUIThreadCall(wxCommandEvent& event);
96 int GetSortIndex(const string& strSort);
97 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);
98 bool DeleteLine(uint256 hashKey);
99 bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);
100 void RefreshListCtrl();
101 void RefreshStatusColumn();
107 class CTxDetailsDialog : public CTxDetailsDialogBase
111 void OnButtonOK(wxCommandEvent& event);
115 CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);
123 class COptionsDialog : public COptionsDialogBase
127 void OnListBox(wxCommandEvent& event);
128 void OnKillFocusTransactionFee(wxFocusEvent& event);
129 void OnCheckBoxUseProxy(wxCommandEvent& event);
130 void OnKillFocusProxy(wxFocusEvent& event);
132 void OnButtonOK(wxCommandEvent& event);
133 void OnButtonCancel(wxCommandEvent& event);
134 void OnButtonApply(wxCommandEvent& event);
138 COptionsDialog(wxWindow* parent);
141 bool fTmpStartOnSystemStartup;
142 bool fTmpMinimizeOnClose;
143 void SelectPage(int nPage);
144 CAddress GetProxyAddr();
149 class CAboutDialog : public CAboutDialogBase
153 void OnButtonOK(wxCommandEvent& event);
157 CAboutDialog(wxWindow* parent);
162 class CSendDialog : public CSendDialogBase
166 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
167 void OnKillFocusAmount(wxFocusEvent& event);
168 void OnButtonAddressBook(wxCommandEvent& event);
169 void OnButtonPaste(wxCommandEvent& event);
170 void OnButtonSend(wxCommandEvent& event);
171 void OnButtonCancel(wxCommandEvent& event);
175 CSendDialog(wxWindow* parent, const wxString& strAddress="");
180 string strMessageSave;
185 class CSendingDialog : public CSendingDialogBase
189 void OnClose(wxCloseEvent& event);
190 void OnButtonOK(wxCommandEvent& event);
191 void OnButtonCancel(wxCommandEvent& event);
192 void OnPaint(wxPaintEvent& event);
196 CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);
204 char pszStatus[10000];
214 bool Status(const string& str);
215 bool Error(const string& str);
216 void StartTransfer();
217 void OnReply2(CDataStream& vRecv);
218 void OnReply3(CDataStream& vRecv);
221 void SendingDialogStartTransfer(void* parg);
222 void SendingDialogOnReply2(void* parg, CDataStream& vRecv);
223 void SendingDialogOnReply3(void* parg, CDataStream& vRecv);
227 class CAddressBookDialog : public CAddressBookDialogBase
231 void OnNotebookPageChanged(wxNotebookEvent& event);
232 void OnListEndLabelEdit(wxListEvent& event);
233 void OnListItemSelected(wxListEvent& event);
234 void OnListItemActivated(wxListEvent& event);
235 void OnButtonDelete(wxCommandEvent& event);
236 void OnButtonCopy(wxCommandEvent& event);
237 void OnButtonEdit(wxCommandEvent& event);
238 void OnButtonNew(wxCommandEvent& event);
239 void OnButtonOK(wxCommandEvent& event);
240 void OnButtonCancel(wxCommandEvent& event);
241 void OnClose(wxCloseEvent& event);
245 CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);
254 wxListCtrl* m_listCtrl;
256 wxString GetAddress();
257 wxString GetSelectedAddress();
258 wxString GetSelectedSendingAddress();
259 wxString GetSelectedReceivingAddress();
260 bool CheckIfMine(const string& strAddress, const string& strTitle);
265 class CGetTextFromUserDialog : public CGetTextFromUserDialogBase
269 void OnButtonOK(wxCommandEvent& event) { EndModal(true); }
270 void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }
271 void OnClose(wxCloseEvent& event) { EndModal(false); }
273 void OnKeyDown(wxKeyEvent& event)
275 if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)
283 CGetTextFromUserDialog(wxWindow* parent,
284 const string& strCaption,
285 const string& strMessage1,
286 const string& strValue1="",
287 const string& strMessage2="",
288 const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)
290 int x = GetSize().GetWidth();
291 int y = GetSize().GetHeight();
292 m_staticTextMessage1->SetLabel(strMessage1);
293 m_textCtrl1->SetValue(strValue1);
294 y += wxString(strMessage1).Freq('\n') * 14;
295 if (!strMessage2.empty())
297 m_staticTextMessage2->Show(true);
298 m_staticTextMessage2->SetLabel(strMessage2);
299 m_textCtrl2->Show(true);
300 m_textCtrl2->SetValue(strValue2);
301 y += 46 + wxString(strMessage2).Freq('\n') * 14;
311 string GetValue() { return (string)m_textCtrl1->GetValue(); }
312 string GetValue1() { return (string)m_textCtrl1->GetValue(); }
313 string GetValue2() { return (string)m_textCtrl2->GetValue(); }
318 class CMyTaskBarIcon : public wxTaskBarIcon
322 void OnLeftButtonDClick(wxTaskBarIconEvent& event);
323 void OnMenuRestore(wxCommandEvent& event);
324 void OnMenuSend(wxCommandEvent& event);
325 void OnMenuOptions(wxCommandEvent& event);
326 void OnUpdateUIGenerate(wxUpdateUIEvent& event);
327 void OnMenuGenerate(wxCommandEvent& event);
328 void OnMenuExit(wxCommandEvent& event);
331 CMyTaskBarIcon() : wxTaskBarIcon()
336 void Show(bool fShow=true);
339 void UpdateTooltip();
340 virtual wxMenu* CreatePopupMenu();
342 DECLARE_EVENT_TABLE()