]>
Commit | Line | Data |
---|---|---|
0a61b0df | 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. | |
4 | ||
5 | DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1) | |
6 | ||
7 | ||
8 | ||
9 | extern wxLocale g_locale; | |
10 | ||
11 | ||
12 | ||
13 | void HandleCtrlA(wxKeyEvent& event); | |
0a61b0df | 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); | |
21 | ||
22 | ||
23 | ||
24 | ||
25 | inline int MyMessageBox(const wxString& message, const wxString& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1) | |
26 | { | |
27 | #ifdef GUI | |
28 | if (!fDaemon) | |
29 | return wxMessageBox(message, caption, style, parent, x, y); | |
30 | #endif | |
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()); | |
33 | return wxOK; | |
34 | } | |
35 | #define wxMessageBox MyMessageBox | |
36 | ||
37 | ||
38 | ||
39 | ||
40 | ||
41 | ||
42 | class CMainFrame : public CMainFrameBase | |
43 | { | |
44 | protected: | |
45 | // Event handlers | |
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); | |
0a61b0df | 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); | |
70 | ||
71 | public: | |
72 | /** Constructor */ | |
73 | CMainFrame(wxWindow* parent); | |
74 | ~CMainFrame(); | |
75 | ||
76 | // Custom | |
77 | enum | |
78 | { | |
79 | ALL = 0, | |
80 | SENTRECEIVED = 1, | |
81 | SENT = 2, | |
82 | RECEIVED = 3, | |
83 | }; | |
84 | int nPage; | |
85 | wxListCtrl* m_listCtrl; | |
86 | bool fShowGenerated; | |
87 | bool fShowSent; | |
88 | bool fShowReceived; | |
89 | bool fRefreshListCtrl; | |
90 | bool fRefreshListCtrlRunning; | |
91 | bool fOnSetFocusAddress; | |
92 | unsigned int nListViewUpdated; | |
93 | bool fRefresh; | |
94 | ||
95 | void OnUIThreadCall(wxCommandEvent& event); | |
96 | int GetSortIndex(const string& strSort); | |
a790fa46 | 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); |
0a61b0df | 98 | bool DeleteLine(uint256 hashKey); |
99 | bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1); | |
100 | void RefreshListCtrl(); | |
101 | void RefreshStatusColumn(); | |
102 | }; | |
103 | ||
104 | ||
105 | ||
106 | ||
107 | class CTxDetailsDialog : public CTxDetailsDialogBase | |
108 | { | |
109 | protected: | |
110 | // Event handlers | |
111 | void OnButtonOK(wxCommandEvent& event); | |
112 | ||
113 | public: | |
114 | /** Constructor */ | |
115 | CTxDetailsDialog(wxWindow* parent, CWalletTx wtx); | |
116 | ||
117 | // State | |
118 | CWalletTx wtx; | |
119 | }; | |
120 | ||
121 | ||
122 | ||
123 | class COptionsDialog : public COptionsDialogBase | |
124 | { | |
125 | protected: | |
126 | // Event handlers | |
127 | void OnListBox(wxCommandEvent& event); | |
128 | void OnKillFocusTransactionFee(wxFocusEvent& event); | |
0a61b0df | 129 | void OnCheckBoxUseProxy(wxCommandEvent& event); |
130 | void OnKillFocusProxy(wxFocusEvent& event); | |
131 | ||
132 | void OnButtonOK(wxCommandEvent& event); | |
133 | void OnButtonCancel(wxCommandEvent& event); | |
134 | void OnButtonApply(wxCommandEvent& event); | |
135 | ||
136 | public: | |
137 | /** Constructor */ | |
138 | COptionsDialog(wxWindow* parent); | |
139 | ||
140 | // Custom | |
141 | bool fTmpStartOnSystemStartup; | |
142 | bool fTmpMinimizeOnClose; | |
143 | void SelectPage(int nPage); | |
144 | CAddress GetProxyAddr(); | |
145 | }; | |
146 | ||
147 | ||
148 | ||
149 | class CAboutDialog : public CAboutDialogBase | |
150 | { | |
151 | protected: | |
152 | // Event handlers | |
153 | void OnButtonOK(wxCommandEvent& event); | |
154 | ||
155 | public: | |
156 | /** Constructor */ | |
157 | CAboutDialog(wxWindow* parent); | |
158 | }; | |
159 | ||
160 | ||
161 | ||
162 | class CSendDialog : public CSendDialogBase | |
163 | { | |
164 | protected: | |
165 | // Event handlers | |
166 | void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); } | |
0a61b0df | 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); | |
172 | ||
173 | public: | |
174 | /** Constructor */ | |
175 | CSendDialog(wxWindow* parent, const wxString& strAddress=""); | |
176 | ||
177 | // Custom | |
178 | bool fEnabledPrev; | |
179 | string strFromSave; | |
180 | string strMessageSave; | |
181 | }; | |
182 | ||
183 | ||
184 | ||
185 | class CSendingDialog : public CSendingDialogBase | |
186 | { | |
187 | public: | |
188 | // Event handlers | |
189 | void OnClose(wxCloseEvent& event); | |
190 | void OnButtonOK(wxCommandEvent& event); | |
191 | void OnButtonCancel(wxCommandEvent& event); | |
192 | void OnPaint(wxPaintEvent& event); | |
193 | ||
194 | public: | |
195 | /** Constructor */ | |
196 | CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn); | |
197 | ~CSendingDialog(); | |
198 | ||
199 | // State | |
200 | CAddress addr; | |
201 | int64 nPrice; | |
202 | CWalletTx wtx; | |
203 | wxDateTime start; | |
204 | char pszStatus[10000]; | |
205 | bool fCanCancel; | |
206 | bool fAbort; | |
207 | bool fSuccess; | |
208 | bool fUIDone; | |
209 | bool fWorkDone; | |
210 | ||
211 | void Close(); | |
212 | void Repaint(); | |
213 | bool Status(); | |
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); | |
219 | }; | |
220 | ||
221 | void SendingDialogStartTransfer(void* parg); | |
222 | void SendingDialogOnReply2(void* parg, CDataStream& vRecv); | |
223 | void SendingDialogOnReply3(void* parg, CDataStream& vRecv); | |
224 | ||
225 | ||
226 | ||
227 | class CAddressBookDialog : public CAddressBookDialogBase | |
228 | { | |
229 | protected: | |
230 | // Event handlers | |
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); | |
242 | ||
243 | public: | |
244 | /** Constructor */ | |
245 | CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn); | |
246 | ||
247 | // Custom | |
248 | enum | |
249 | { | |
250 | SENDING = 0, | |
251 | RECEIVING = 1, | |
252 | }; | |
253 | int nPage; | |
254 | wxListCtrl* m_listCtrl; | |
255 | bool fDuringSend; | |
256 | wxString GetAddress(); | |
257 | wxString GetSelectedAddress(); | |
258 | wxString GetSelectedSendingAddress(); | |
259 | wxString GetSelectedReceivingAddress(); | |
260 | bool CheckIfMine(const string& strAddress, const string& strTitle); | |
261 | }; | |
262 | ||
263 | ||
264 | ||
265 | class CGetTextFromUserDialog : public CGetTextFromUserDialogBase | |
266 | { | |
267 | protected: | |
268 | // Event handlers | |
269 | void OnButtonOK(wxCommandEvent& event) { EndModal(true); } | |
270 | void OnButtonCancel(wxCommandEvent& event) { EndModal(false); } | |
271 | void OnClose(wxCloseEvent& event) { EndModal(false); } | |
272 | ||
273 | void OnKeyDown(wxKeyEvent& event) | |
274 | { | |
275 | if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER) | |
276 | EndModal(true); | |
277 | else | |
278 | HandleCtrlA(event); | |
279 | } | |
280 | ||
281 | public: | |
282 | /** Constructor */ | |
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) | |
289 | { | |
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()) | |
296 | { | |
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; | |
302 | } | |
303 | #ifndef __WXMSW__ | |
f1e1fb4b | 304 | x = x * 114 / 100; |
305 | y = y * 114 / 100; | |
0a61b0df | 306 | #endif |
307 | SetSize(x, y); | |
308 | } | |
309 | ||
310 | // Custom | |
311 | string GetValue() { return (string)m_textCtrl1->GetValue(); } | |
312 | string GetValue1() { return (string)m_textCtrl1->GetValue(); } | |
313 | string GetValue2() { return (string)m_textCtrl2->GetValue(); } | |
314 | }; | |
315 | ||
316 | ||
317 | ||
318 | class CMyTaskBarIcon : public wxTaskBarIcon | |
319 | { | |
320 | protected: | |
321 | // Event handlers | |
322 | void OnLeftButtonDClick(wxTaskBarIconEvent& event); | |
323 | void OnMenuRestore(wxCommandEvent& event); | |
3b7925eb | 324 | void OnMenuSend(wxCommandEvent& event); |
0a61b0df | 325 | void OnMenuOptions(wxCommandEvent& event); |
326 | void OnUpdateUIGenerate(wxUpdateUIEvent& event); | |
327 | void OnMenuGenerate(wxCommandEvent& event); | |
328 | void OnMenuExit(wxCommandEvent& event); | |
329 | ||
330 | public: | |
331 | CMyTaskBarIcon() : wxTaskBarIcon() | |
332 | { | |
333 | Show(true); | |
334 | } | |
335 | ||
336 | void Show(bool fShow=true); | |
337 | void Hide(); | |
338 | void Restore(); | |
339 | void UpdateTooltip(); | |
340 | virtual wxMenu* CreatePopupMenu(); | |
341 | ||
342 | DECLARE_EVENT_TABLE() | |
343 | }; |