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 CalledSetStatusBar(const string& strText, int nField);
\r
34 void MainFrameRepaint();
\r
35 void CreateMainWindow();
\r
42 inline int ThreadSafeMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y)
\r
44 return MyMessageBox(message, caption, style, parent, x, y);
\r
47 inline bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent)
\r
52 inline void CalledSetStatusBar(const string& strText, int nField)
\r
56 inline void UIThreadCall(boost::function0<void> fn)
\r
60 inline void MainFrameRepaint()
\r
64 inline void CreateMainWindow()
\r
73 class CMainFrame : public CMainFrameBase
\r
77 void OnNotebookPageChanged(wxNotebookEvent& event);
\r
78 void OnClose(wxCloseEvent& event);
\r
79 void OnIconize(wxIconizeEvent& event);
\r
80 void OnMouseEvents(wxMouseEvent& event);
\r
81 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
\r
82 void OnIdle(wxIdleEvent& event);
\r
83 void OnPaint(wxPaintEvent& event);
\r
84 void OnPaintListCtrl(wxPaintEvent& event);
\r
85 void OnMenuFileExit(wxCommandEvent& event);
\r
86 void OnMenuOptionsGenerate(wxCommandEvent& event);
\r
87 void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);
\r
88 void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);
\r
89 void OnMenuOptionsOptions(wxCommandEvent& event);
\r
90 void OnMenuHelpAbout(wxCommandEvent& event);
\r
91 void OnButtonSend(wxCommandEvent& event);
\r
92 void OnButtonAddressBook(wxCommandEvent& event);
\r
93 void OnSetFocusAddress(wxFocusEvent& event);
\r
94 void OnMouseEventsAddress(wxMouseEvent& event);
\r
95 void OnButtonNew(wxCommandEvent& event);
\r
96 void OnButtonCopy(wxCommandEvent& event);
\r
97 void OnListColBeginDrag(wxListEvent& event);
\r
98 void OnListItemActivated(wxListEvent& event);
\r
99 void OnListItemActivatedProductsSent(wxListEvent& event);
\r
100 void OnListItemActivatedOrdersSent(wxListEvent& event);
\r
101 void OnListItemActivatedOrdersReceived(wxListEvent& event);
\r
105 CMainFrame(wxWindow* parent);
\r
117 wxListCtrl* m_listCtrl;
\r
118 bool fShowGenerated;
\r
120 bool fShowReceived;
\r
121 bool fRefreshListCtrl;
\r
122 bool fRefreshListCtrlRunning;
\r
123 bool fOnSetFocusAddress;
\r
124 unsigned int nListViewUpdated;
\r
127 void OnUIThreadCall(wxCommandEvent& event);
\r
128 int GetSortIndex(const string& strSort);
\r
129 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
130 bool DeleteLine(uint256 hashKey);
\r
131 bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);
\r
132 void RefreshListCtrl();
\r
133 void RefreshStatusColumn();
\r
139 class CTxDetailsDialog : public CTxDetailsDialogBase
\r
143 void OnButtonOK(wxCommandEvent& event);
\r
147 CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);
\r
155 class COptionsDialog : public COptionsDialogBase
\r
159 void OnListBox(wxCommandEvent& event);
\r
160 void OnKillFocusTransactionFee(wxFocusEvent& event);
\r
161 void OnCheckBoxLimitProcessors(wxCommandEvent& event);
\r
162 void OnCheckBoxUseProxy(wxCommandEvent& event);
\r
163 void OnKillFocusProxy(wxFocusEvent& event);
\r
165 void OnButtonOK(wxCommandEvent& event);
\r
166 void OnButtonCancel(wxCommandEvent& event);
\r
167 void OnButtonApply(wxCommandEvent& event);
\r
171 COptionsDialog(wxWindow* parent);
\r
174 bool fTmpStartOnSystemStartup;
\r
175 bool fTmpMinimizeOnClose;
\r
176 void SelectPage(int nPage);
\r
177 CAddress GetProxyAddr();
\r
182 class CAboutDialog : public CAboutDialogBase
\r
186 void OnButtonOK(wxCommandEvent& event);
\r
190 CAboutDialog(wxWindow* parent);
\r
195 class CSendDialog : public CSendDialogBase
\r
199 void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
\r
200 void OnTextAddress(wxCommandEvent& event);
\r
201 void OnKillFocusAmount(wxFocusEvent& event);
\r
202 void OnButtonAddressBook(wxCommandEvent& event);
\r
203 void OnButtonPaste(wxCommandEvent& event);
\r
204 void OnButtonSend(wxCommandEvent& event);
\r
205 void OnButtonCancel(wxCommandEvent& event);
\r
209 CSendDialog(wxWindow* parent, const wxString& strAddress="");
\r
213 string strFromSave;
\r
214 string strMessageSave;
\r
219 class CSendingDialog : public CSendingDialogBase
\r
223 void OnClose(wxCloseEvent& event);
\r
224 void OnButtonOK(wxCommandEvent& event);
\r
225 void OnButtonCancel(wxCommandEvent& event);
\r
226 void OnPaint(wxPaintEvent& event);
\r
230 CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);
\r
238 char pszStatus[10000];
\r
248 bool Status(const string& str);
\r
249 bool Error(const string& str);
\r
250 void StartTransfer();
\r
251 void OnReply2(CDataStream& vRecv);
\r
252 void OnReply3(CDataStream& vRecv);
\r
255 void SendingDialogStartTransfer(void* parg);
\r
256 void SendingDialogOnReply2(void* parg, CDataStream& vRecv);
\r
257 void SendingDialogOnReply3(void* parg, CDataStream& vRecv);
\r
261 class CAddressBookDialog : public CAddressBookDialogBase
\r
265 void OnNotebookPageChanged(wxNotebookEvent& event);
\r
266 void OnListEndLabelEdit(wxListEvent& event);
\r
267 void OnListItemSelected(wxListEvent& event);
\r
268 void OnListItemActivated(wxListEvent& event);
\r
269 void OnButtonDelete(wxCommandEvent& event);
\r
270 void OnButtonCopy(wxCommandEvent& event);
\r
271 void OnButtonEdit(wxCommandEvent& event);
\r
272 void OnButtonNew(wxCommandEvent& event);
\r
273 void OnButtonOK(wxCommandEvent& event);
\r
274 void OnButtonCancel(wxCommandEvent& event);
\r
275 void OnClose(wxCloseEvent& event);
\r
279 CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);
\r
288 wxListCtrl* m_listCtrl;
\r
290 wxString GetAddress();
\r
291 wxString GetSelectedAddress();
\r
292 wxString GetSelectedSendingAddress();
\r
293 wxString GetSelectedReceivingAddress();
\r
294 bool CheckIfMine(const string& strAddress, const string& strTitle);
\r
299 class CGetTextFromUserDialog : public CGetTextFromUserDialogBase
\r
303 void OnButtonOK(wxCommandEvent& event) { EndModal(true); }
\r
304 void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }
\r
305 void OnClose(wxCloseEvent& event) { EndModal(false); }
\r
307 void OnKeyDown(wxKeyEvent& event)
\r
309 if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)
\r
312 HandleCtrlA(event);
\r
317 CGetTextFromUserDialog(wxWindow* parent,
\r
318 const string& strCaption,
\r
319 const string& strMessage1,
\r
320 const string& strValue1="",
\r
321 const string& strMessage2="",
\r
322 const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)
\r
324 int x = GetSize().GetWidth();
\r
325 int y = GetSize().GetHeight();
\r
326 m_staticTextMessage1->SetLabel(strMessage1);
\r
327 m_textCtrl1->SetValue(strValue1);
\r
328 y += wxString(strMessage1).Freq('\n') * 14;
\r
329 if (!strMessage2.empty())
\r
331 m_staticTextMessage2->Show(true);
\r
332 m_staticTextMessage2->SetLabel(strMessage2);
\r
333 m_textCtrl2->Show(true);
\r
334 m_textCtrl2->SetValue(strValue2);
\r
335 y += 46 + wxString(strMessage2).Freq('\n') * 14;
\r
346 string GetValue() { return (string)m_textCtrl1->GetValue(); }
\r
347 string GetValue1() { return (string)m_textCtrl1->GetValue(); }
\r
348 string GetValue2() { return (string)m_textCtrl2->GetValue(); }
\r
353 class CMyTaskBarIcon : public wxTaskBarIcon
\r
357 void OnLeftButtonDClick(wxTaskBarIconEvent& event);
\r
358 void OnMenuRestore(wxCommandEvent& event);
\r
359 void OnMenuOptions(wxCommandEvent& event);
\r
360 void OnUpdateUIGenerate(wxUpdateUIEvent& event);
\r
361 void OnMenuGenerate(wxCommandEvent& event);
\r
362 void OnMenuExit(wxCommandEvent& event);
\r
365 CMyTaskBarIcon() : wxTaskBarIcon()
\r
370 void Show(bool fShow=true);
\r
373 void UpdateTooltip();
\r
374 virtual wxMenu* CreatePopupMenu();
\r
376 DECLARE_EVENT_TABLE()
\r
379 #endif // wxUSE_GUI
\r