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
8 static const bool fGUI=true;
\r
10 static const bool fGUI=false;
\r
13 inline int MyMessageBox(const wxString& message, const wxString& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
\r
17 return wxMessageBox(message, caption, style, parent, x, y);
\r
19 printf("wxMessageBox %s: %s\n", string(caption).c_str(), string(message).c_str());
\r
20 fprintf(stderr, "%s: %s\n", string(caption).c_str(), string(message).c_str());
\r
23 #define wxMessageBox MyMessageBox
\r
28 void HandleCtrlA(wxKeyEvent& event);
\r
29 string FormatTxStatus(const CWalletTx& wtx);
\r
30 void UIThreadCall(boost::function0<void>);
\r
31 int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
\r
32 bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);
\r
33 void MainFrameRepaint();
\r
34 void CreateMainWindow();
\r
41 inline int ThreadSafeMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y)
\r
43 return MyMessageBox(message, caption, style, parent, x, y);
\r
46 inline bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent)
\r
51 inline void MainFrameRepaint()
\r
55 inline void CreateMainWindow()
\r
64 class CMainFrame : public CMainFrameBase
\r
68 void OnNotebookPageChanged(wxNotebookEvent& event);
\r
69 void OnClose(wxCloseEvent& event);
\r
70 void OnIconize(wxIconizeEvent& event);
\r
71 void OnMouseEvents(wxMouseEvent& event);
\r
72 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
\r
73 void OnIdle(wxIdleEvent& event);
\r
74 void OnPaint(wxPaintEvent& event);
\r
75 void OnPaintListCtrl(wxPaintEvent& event);
\r
76 void OnMenuFileExit(wxCommandEvent& event);
\r
77 void OnMenuOptionsGenerate(wxCommandEvent& event);
\r
78 void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);
\r
79 void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);
\r
80 void OnMenuOptionsOptions(wxCommandEvent& event);
\r
81 void OnMenuHelpAbout(wxCommandEvent& event);
\r
82 void OnButtonSend(wxCommandEvent& event);
\r
83 void OnButtonAddressBook(wxCommandEvent& event);
\r
84 void OnSetFocusAddress(wxFocusEvent& event);
\r
85 void OnMouseEventsAddress(wxMouseEvent& event);
\r
86 void OnButtonNew(wxCommandEvent& event);
\r
87 void OnButtonCopy(wxCommandEvent& event);
\r
88 void OnListColBeginDrag(wxListEvent& event);
\r
89 void OnListItemActivated(wxListEvent& event);
\r
90 void OnListItemActivatedProductsSent(wxListEvent& event);
\r
91 void OnListItemActivatedOrdersSent(wxListEvent& event);
\r
92 void OnListItemActivatedOrdersReceived(wxListEvent& event);
\r
96 CMainFrame(wxWindow* parent);
\r
108 wxListCtrl* m_listCtrl;
\r
109 bool fShowGenerated;
\r
111 bool fShowReceived;
\r
112 bool fRefreshListCtrl;
\r
113 bool fRefreshListCtrlRunning;
\r
114 bool fOnSetFocusAddress;
\r
115 unsigned int nListViewUpdated;
\r
118 void OnUIThreadCall(wxCommandEvent& event);
\r
119 int GetSortIndex(const string& strSort);
\r
120 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
121 bool DeleteLine(uint256 hashKey);
\r
122 bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);
\r
123 void RefreshListCtrl();
\r
124 void RefreshStatusColumn();
\r
130 class CTxDetailsDialog : public CTxDetailsDialogBase
\r
134 void OnButtonOK(wxCommandEvent& event);
\r
138 CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);
\r
146 class COptionsDialog : public COptionsDialogBase
\r
150 void OnListBox(wxCommandEvent& event);
\r
151 void OnKillFocusTransactionFee(wxFocusEvent& event);
\r
152 void OnCheckBoxLimitProcessors(wxCommandEvent& event);
\r
153 void OnCheckBoxUseProxy(wxCommandEvent& event);
\r
154 void OnKillFocusProxy(wxFocusEvent& event);
\r
156 void OnButtonOK(wxCommandEvent& event);
\r
157 void OnButtonCancel(wxCommandEvent& event);
\r
158 void OnButtonApply(wxCommandEvent& event);
\r
162 COptionsDialog(wxWindow* parent);
\r
165 bool fTmpStartOnSystemStartup;
\r
166 bool fTmpMinimizeOnClose;
\r
167 void SelectPage(int nPage);
\r
168 CAddress GetProxyAddr();
\r
173 class CAboutDialog : public CAboutDialogBase
\r
177 void OnButtonOK(wxCommandEvent& event);
\r
181 CAboutDialog(wxWindow* parent);
\r
186 class CSendDialog : public CSendDialogBase
\r
190 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
\r
191 void OnTextAddress(wxCommandEvent& event);
\r
192 void OnKillFocusAmount(wxFocusEvent& event);
\r
193 void OnButtonAddressBook(wxCommandEvent& event);
\r
194 void OnButtonPaste(wxCommandEvent& event);
\r
195 void OnButtonSend(wxCommandEvent& event);
\r
196 void OnButtonCancel(wxCommandEvent& event);
\r
200 CSendDialog(wxWindow* parent, const wxString& strAddress="");
\r
204 string strFromSave;
\r
205 string strMessageSave;
\r
210 class CSendingDialog : public CSendingDialogBase
\r
214 void OnClose(wxCloseEvent& event);
\r
215 void OnButtonOK(wxCommandEvent& event);
\r
216 void OnButtonCancel(wxCommandEvent& event);
\r
217 void OnPaint(wxPaintEvent& event);
\r
221 CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);
\r
229 char pszStatus[10000];
\r
239 bool Status(const string& str);
\r
240 bool Error(const string& str);
\r
241 void StartTransfer();
\r
242 void OnReply2(CDataStream& vRecv);
\r
243 void OnReply3(CDataStream& vRecv);
\r
246 void SendingDialogStartTransfer(void* parg);
\r
247 void SendingDialogOnReply2(void* parg, CDataStream& vRecv);
\r
248 void SendingDialogOnReply3(void* parg, CDataStream& vRecv);
\r
252 class CAddressBookDialog : public CAddressBookDialogBase
\r
256 void OnNotebookPageChanged(wxNotebookEvent& event);
\r
257 void OnListEndLabelEdit(wxListEvent& event);
\r
258 void OnListItemSelected(wxListEvent& event);
\r
259 void OnListItemActivated(wxListEvent& event);
\r
260 void OnButtonDelete(wxCommandEvent& event);
\r
261 void OnButtonCopy(wxCommandEvent& event);
\r
262 void OnButtonEdit(wxCommandEvent& event);
\r
263 void OnButtonNew(wxCommandEvent& event);
\r
264 void OnButtonOK(wxCommandEvent& event);
\r
265 void OnButtonCancel(wxCommandEvent& event);
\r
266 void OnClose(wxCloseEvent& event);
\r
270 CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);
\r
279 wxListCtrl* m_listCtrl;
\r
281 wxString GetAddress();
\r
282 wxString GetSelectedAddress();
\r
283 wxString GetSelectedSendingAddress();
\r
284 wxString GetSelectedReceivingAddress();
\r
285 bool CheckIfMine(const string& strAddress, const string& strTitle);
\r
290 class CGetTextFromUserDialog : public CGetTextFromUserDialogBase
\r
294 void OnButtonOK(wxCommandEvent& event) { EndModal(true); }
\r
295 void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }
\r
296 void OnClose(wxCloseEvent& event) { EndModal(false); }
\r
298 void OnKeyDown(wxKeyEvent& event)
\r
300 if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)
\r
303 HandleCtrlA(event);
\r
308 CGetTextFromUserDialog(wxWindow* parent,
\r
309 const string& strCaption,
\r
310 const string& strMessage1,
\r
311 const string& strValue1="",
\r
312 const string& strMessage2="",
\r
313 const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)
\r
315 int x = GetSize().GetWidth();
\r
316 int y = GetSize().GetHeight();
\r
317 m_staticTextMessage1->SetLabel(strMessage1);
\r
318 m_textCtrl1->SetValue(strValue1);
\r
319 y += wxString(strMessage1).Freq('\n') * 14;
\r
320 if (!strMessage2.empty())
\r
322 m_staticTextMessage2->Show(true);
\r
323 m_staticTextMessage2->SetLabel(strMessage2);
\r
324 m_textCtrl2->Show(true);
\r
325 m_textCtrl2->SetValue(strValue2);
\r
326 y += 46 + wxString(strMessage2).Freq('\n') * 14;
\r
337 string GetValue() { return (string)m_textCtrl1->GetValue(); }
\r
338 string GetValue1() { return (string)m_textCtrl1->GetValue(); }
\r
339 string GetValue2() { return (string)m_textCtrl2->GetValue(); }
\r
344 class CMyTaskBarIcon : public wxTaskBarIcon
\r
348 void OnLeftButtonDClick(wxTaskBarIconEvent& event);
\r
349 void OnMenuRestore(wxCommandEvent& event);
\r
350 void OnMenuOptions(wxCommandEvent& event);
\r
351 void OnUpdateUIGenerate(wxUpdateUIEvent& event);
\r
352 void OnMenuGenerate(wxCommandEvent& event);
\r
353 void OnMenuExit(wxCommandEvent& event);
\r
356 CMyTaskBarIcon() : wxTaskBarIcon()
\r
361 void Show(bool fShow=true);
\r
364 void UpdateTooltip();
\r
365 virtual wxMenu* CreatePopupMenu();
\r
367 DECLARE_EVENT_TABLE()
\r
370 #endif // wxUSE_GUI
\r