2010-02-03 23:58:40 +01:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2009-08-30 05:46:39 +02:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2009-11-06 19:53:26 +01:00
|
|
|
DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)
|
2009-10-21 03:08:05 +02:00
|
|
|
|
2010-02-20 22:59:59 +01:00
|
|
|
|
2009-10-21 03:08:05 +02:00
|
|
|
|
2010-07-26 19:15:18 +02:00
|
|
|
extern wxLocale g_locale;
|
2009-10-21 03:08:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-17 18:22:01 +01:00
|
|
|
void HandleCtrlA(wxKeyEvent& event);
|
|
|
|
string FormatTxStatus(const CWalletTx& wtx);
|
|
|
|
void UIThreadCall(boost::function0<void>);
|
|
|
|
int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
|
2010-02-20 22:59:59 +01:00
|
|
|
bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);
|
2010-05-26 02:05:26 +02:00
|
|
|
void CalledSetStatusBar(const string& strText, int nField);
|
2010-02-25 22:55:27 +01:00
|
|
|
void MainFrameRepaint();
|
|
|
|
void CreateMainWindow();
|
2010-07-26 19:15:18 +02:00
|
|
|
void SetStartOnSystemStartup(bool fAutoStart);
|
2010-02-25 22:55:27 +01:00
|
|
|
|
2009-08-30 05:46:39 +02:00
|
|
|
|
2009-10-21 03:08:05 +02:00
|
|
|
|
|
|
|
|
2010-07-26 19:15:18 +02:00
|
|
|
inline int MyMessageBox(const wxString& message, const wxString& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
|
2010-02-25 22:55:27 +01:00
|
|
|
{
|
2010-07-26 19:15:18 +02:00
|
|
|
#ifdef GUI
|
|
|
|
if (!fDaemon)
|
|
|
|
return wxMessageBox(message, caption, style, parent, x, y);
|
|
|
|
#endif
|
|
|
|
printf("wxMessageBox %s: %s\n", string(caption).c_str(), string(message).c_str());
|
|
|
|
fprintf(stderr, "%s: %s\n", string(caption).c_str(), string(message).c_str());
|
|
|
|
return wxOK;
|
2010-02-25 22:55:27 +01:00
|
|
|
}
|
2010-07-26 19:15:18 +02:00
|
|
|
#define wxMessageBox MyMessageBox
|
2010-02-25 22:55:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-08-30 05:46:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
class CMainFrame : public CMainFrameBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
// Event handlers
|
2010-02-21 22:42:01 +01:00
|
|
|
void OnNotebookPageChanged(wxNotebookEvent& event);
|
2009-08-30 05:46:39 +02:00
|
|
|
void OnClose(wxCloseEvent& event);
|
2009-10-21 03:08:05 +02:00
|
|
|
void OnIconize(wxIconizeEvent& event);
|
2009-08-30 05:46:39 +02:00
|
|
|
void OnMouseEvents(wxMouseEvent& event);
|
|
|
|
void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
|
|
|
|
void OnIdle(wxIdleEvent& event);
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
void OnPaintListCtrl(wxPaintEvent& event);
|
|
|
|
void OnMenuFileExit(wxCommandEvent& event);
|
|
|
|
void OnMenuOptionsGenerate(wxCommandEvent& event);
|
2009-10-21 03:08:05 +02:00
|
|
|
void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);
|
2009-08-30 05:46:39 +02:00
|
|
|
void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);
|
|
|
|
void OnMenuOptionsOptions(wxCommandEvent& event);
|
|
|
|
void OnMenuHelpAbout(wxCommandEvent& event);
|
|
|
|
void OnButtonSend(wxCommandEvent& event);
|
|
|
|
void OnButtonAddressBook(wxCommandEvent& event);
|
|
|
|
void OnSetFocusAddress(wxFocusEvent& event);
|
|
|
|
void OnMouseEventsAddress(wxMouseEvent& event);
|
2010-02-20 22:59:59 +01:00
|
|
|
void OnButtonNew(wxCommandEvent& event);
|
2010-02-15 05:03:07 +01:00
|
|
|
void OnButtonCopy(wxCommandEvent& event);
|
2009-08-30 05:46:39 +02:00
|
|
|
void OnListColBeginDrag(wxListEvent& event);
|
2010-02-03 23:58:40 +01:00
|
|
|
void OnListItemActivated(wxListEvent& event);
|
2009-08-30 05:46:39 +02:00
|
|
|
void OnListItemActivatedProductsSent(wxListEvent& event);
|
|
|
|
void OnListItemActivatedOrdersSent(wxListEvent& event);
|
|
|
|
void OnListItemActivatedOrdersReceived(wxListEvent& event);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructor */
|
|
|
|
CMainFrame(wxWindow* parent);
|
|
|
|
~CMainFrame();
|
|
|
|
|
|
|
|
// Custom
|
2010-02-21 22:42:01 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ALL = 0,
|
|
|
|
SENTRECEIVED = 1,
|
|
|
|
SENT = 2,
|
|
|
|
RECEIVED = 3,
|
|
|
|
};
|
|
|
|
int nPage;
|
|
|
|
wxListCtrl* m_listCtrl;
|
|
|
|
bool fShowGenerated;
|
|
|
|
bool fShowSent;
|
|
|
|
bool fShowReceived;
|
2009-08-30 05:46:39 +02:00
|
|
|
bool fRefreshListCtrl;
|
|
|
|
bool fRefreshListCtrlRunning;
|
|
|
|
bool fOnSetFocusAddress;
|
2009-11-01 02:16:51 +01:00
|
|
|
unsigned int nListViewUpdated;
|
2009-11-06 06:50:05 +01:00
|
|
|
bool fRefresh;
|
2009-08-30 05:46:39 +02:00
|
|
|
|
2009-11-06 19:53:26 +01:00
|
|
|
void OnUIThreadCall(wxCommandEvent& event);
|
2009-11-06 06:50:05 +01:00
|
|
|
int GetSortIndex(const string& strSort);
|
2009-08-30 05:46:39 +02:00
|
|
|
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);
|
2009-10-25 05:35:01 +01:00
|
|
|
bool DeleteLine(uint256 hashKey);
|
2009-10-29 03:52:48 +01:00
|
|
|
bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);
|
2009-08-30 05:46:39 +02:00
|
|
|
void RefreshListCtrl();
|
2009-11-01 02:16:51 +01:00
|
|
|
void RefreshStatusColumn();
|
2009-08-30 05:46:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CTxDetailsDialog : public CTxDetailsDialogBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
// Event handlers
|
|
|
|
void OnButtonOK(wxCommandEvent& event);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructor */
|
|
|
|
CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);
|
|
|
|
|
|
|
|
// State
|
|
|
|
CWalletTx wtx;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class COptionsDialog : public COptionsDialogBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
// Event handlers
|
2009-10-21 03:08:05 +02:00
|
|
|
void OnListBox(wxCommandEvent& event);
|
|
|
|
void OnKillFocusTransactionFee(wxFocusEvent& event);
|
|
|
|
void OnCheckBoxLimitProcessors(wxCommandEvent& event);
|
2009-10-29 03:52:48 +01:00
|
|
|
void OnCheckBoxUseProxy(wxCommandEvent& event);
|
|
|
|
void OnKillFocusProxy(wxFocusEvent& event);
|
|
|
|
|
2009-08-30 05:46:39 +02:00
|
|
|
void OnButtonOK(wxCommandEvent& event);
|
|
|
|
void OnButtonCancel(wxCommandEvent& event);
|
2009-10-21 03:08:05 +02:00
|
|
|
void OnButtonApply(wxCommandEvent& event);
|
2009-08-30 05:46:39 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructor */
|
|
|
|
COptionsDialog(wxWindow* parent);
|
2009-10-21 03:08:05 +02:00
|
|
|
|
|
|
|
// Custom
|
|
|
|
bool fTmpStartOnSystemStartup;
|
|
|
|
bool fTmpMinimizeOnClose;
|
|
|
|
void SelectPage(int nPage);
|
2009-10-29 03:52:48 +01:00
|
|
|
CAddress GetProxyAddr();
|
2009-08-30 05:46:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CAboutDialog : public CAboutDialogBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
// Event handlers
|
|
|
|
void OnButtonOK(wxCommandEvent& event);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructor */
|
|
|
|
CAboutDialog(wxWindow* parent);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CSendDialog : public CSendDialogBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
// Event handlers
|
|
|
|
void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
|
|
|
|
void OnTextAddress(wxCommandEvent& event);
|
|
|
|
void OnKillFocusAmount(wxFocusEvent& event);
|
|
|
|
void OnButtonAddressBook(wxCommandEvent& event);
|
|
|
|
void OnButtonPaste(wxCommandEvent& event);
|
|
|
|
void OnButtonSend(wxCommandEvent& event);
|
|
|
|
void OnButtonCancel(wxCommandEvent& event);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructor */
|
|
|
|
CSendDialog(wxWindow* parent, const wxString& strAddress="");
|
2009-10-21 03:08:05 +02:00
|
|
|
|
|
|
|
// Custom
|
|
|
|
bool fEnabledPrev;
|
|
|
|
string strFromSave;
|
|
|
|
string strMessageSave;
|
2009-08-30 05:46:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CSendingDialog : public CSendingDialogBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Event handlers
|
|
|
|
void OnClose(wxCloseEvent& event);
|
|
|
|
void OnButtonOK(wxCommandEvent& event);
|
|
|
|
void OnButtonCancel(wxCommandEvent& event);
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructor */
|
|
|
|
CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);
|
|
|
|
~CSendingDialog();
|
|
|
|
|
|
|
|
// State
|
|
|
|
CAddress addr;
|
|
|
|
int64 nPrice;
|
|
|
|
CWalletTx wtx;
|
|
|
|
wxDateTime start;
|
2009-10-29 03:52:48 +01:00
|
|
|
char pszStatus[10000];
|
2009-08-30 05:46:39 +02:00
|
|
|
bool fCanCancel;
|
|
|
|
bool fAbort;
|
|
|
|
bool fSuccess;
|
|
|
|
bool fUIDone;
|
|
|
|
bool fWorkDone;
|
|
|
|
|
|
|
|
void Close();
|
|
|
|
void Repaint();
|
|
|
|
bool Status();
|
|
|
|
bool Status(const string& str);
|
|
|
|
bool Error(const string& str);
|
|
|
|
void StartTransfer();
|
|
|
|
void OnReply2(CDataStream& vRecv);
|
|
|
|
void OnReply3(CDataStream& vRecv);
|
|
|
|
};
|
|
|
|
|
|
|
|
void SendingDialogStartTransfer(void* parg);
|
|
|
|
void SendingDialogOnReply2(void* parg, CDataStream& vRecv);
|
|
|
|
void SendingDialogOnReply3(void* parg, CDataStream& vRecv);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CAddressBookDialog : public CAddressBookDialogBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
// Event handlers
|
2010-02-20 22:59:59 +01:00
|
|
|
void OnNotebookPageChanged(wxNotebookEvent& event);
|
2009-08-30 05:46:39 +02:00
|
|
|
void OnListEndLabelEdit(wxListEvent& event);
|
|
|
|
void OnListItemSelected(wxListEvent& event);
|
|
|
|
void OnListItemActivated(wxListEvent& event);
|
|
|
|
void OnButtonDelete(wxCommandEvent& event);
|
|
|
|
void OnButtonCopy(wxCommandEvent& event);
|
2010-02-20 22:59:59 +01:00
|
|
|
void OnButtonEdit(wxCommandEvent& event);
|
|
|
|
void OnButtonNew(wxCommandEvent& event);
|
2009-08-30 05:46:39 +02:00
|
|
|
void OnButtonOK(wxCommandEvent& event);
|
|
|
|
void OnButtonCancel(wxCommandEvent& event);
|
|
|
|
void OnClose(wxCloseEvent& event);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructor */
|
2010-02-20 22:59:59 +01:00
|
|
|
CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);
|
2009-08-30 05:46:39 +02:00
|
|
|
|
|
|
|
// Custom
|
2010-02-20 22:59:59 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SENDING = 0,
|
|
|
|
RECEIVING = 1,
|
|
|
|
};
|
|
|
|
int nPage;
|
|
|
|
wxListCtrl* m_listCtrl;
|
|
|
|
bool fDuringSend;
|
2009-08-30 05:46:39 +02:00
|
|
|
wxString GetAddress();
|
2010-02-20 22:59:59 +01:00
|
|
|
wxString GetSelectedAddress();
|
|
|
|
wxString GetSelectedSendingAddress();
|
|
|
|
wxString GetSelectedReceivingAddress();
|
2009-08-30 05:46:39 +02:00
|
|
|
bool CheckIfMine(const string& strAddress, const string& strTitle);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CGetTextFromUserDialog : public CGetTextFromUserDialogBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
// Event handlers
|
|
|
|
void OnButtonOK(wxCommandEvent& event) { EndModal(true); }
|
|
|
|
void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }
|
|
|
|
void OnClose(wxCloseEvent& event) { EndModal(false); }
|
|
|
|
|
|
|
|
void OnKeyDown(wxKeyEvent& event)
|
|
|
|
{
|
|
|
|
if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)
|
|
|
|
EndModal(true);
|
|
|
|
else
|
|
|
|
HandleCtrlA(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructor */
|
|
|
|
CGetTextFromUserDialog(wxWindow* parent,
|
|
|
|
const string& strCaption,
|
|
|
|
const string& strMessage1,
|
|
|
|
const string& strValue1="",
|
|
|
|
const string& strMessage2="",
|
|
|
|
const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)
|
|
|
|
{
|
2010-02-20 22:59:59 +01:00
|
|
|
int x = GetSize().GetWidth();
|
|
|
|
int y = GetSize().GetHeight();
|
2009-08-30 05:46:39 +02:00
|
|
|
m_staticTextMessage1->SetLabel(strMessage1);
|
|
|
|
m_textCtrl1->SetValue(strValue1);
|
2010-02-20 22:59:59 +01:00
|
|
|
y += wxString(strMessage1).Freq('\n') * 14;
|
2009-08-30 05:46:39 +02:00
|
|
|
if (!strMessage2.empty())
|
|
|
|
{
|
|
|
|
m_staticTextMessage2->Show(true);
|
|
|
|
m_staticTextMessage2->SetLabel(strMessage2);
|
|
|
|
m_textCtrl2->Show(true);
|
|
|
|
m_textCtrl2->SetValue(strValue2);
|
2010-02-20 22:59:59 +01:00
|
|
|
y += 46 + wxString(strMessage2).Freq('\n') * 14;
|
2009-08-30 05:46:39 +02:00
|
|
|
}
|
2010-07-26 19:15:18 +02:00
|
|
|
#ifndef __WXMSW__
|
|
|
|
x *= 1.14;
|
|
|
|
y *= 1.14;
|
|
|
|
#endif
|
2010-02-20 22:59:59 +01:00
|
|
|
SetSize(x, y);
|
2009-08-30 05:46:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Custom
|
|
|
|
string GetValue() { return (string)m_textCtrl1->GetValue(); }
|
|
|
|
string GetValue1() { return (string)m_textCtrl1->GetValue(); }
|
|
|
|
string GetValue2() { return (string)m_textCtrl2->GetValue(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-21 03:08:05 +02:00
|
|
|
class CMyTaskBarIcon : public wxTaskBarIcon
|
2009-09-24 06:09:56 +02:00
|
|
|
{
|
|
|
|
protected:
|
2009-10-21 03:08:05 +02:00
|
|
|
// Event handlers
|
|
|
|
void OnLeftButtonDClick(wxTaskBarIconEvent& event);
|
|
|
|
void OnMenuRestore(wxCommandEvent& event);
|
2009-11-13 02:23:08 +01:00
|
|
|
void OnMenuOptions(wxCommandEvent& event);
|
2009-10-21 03:08:05 +02:00
|
|
|
void OnUpdateUIGenerate(wxUpdateUIEvent& event);
|
|
|
|
void OnMenuGenerate(wxCommandEvent& event);
|
|
|
|
void OnMenuExit(wxCommandEvent& event);
|
2009-08-30 05:46:39 +02:00
|
|
|
|
2009-09-24 06:09:56 +02:00
|
|
|
public:
|
2009-10-21 03:08:05 +02:00
|
|
|
CMyTaskBarIcon() : wxTaskBarIcon()
|
|
|
|
{
|
|
|
|
Show(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Show(bool fShow=true);
|
|
|
|
void Hide();
|
|
|
|
void Restore();
|
|
|
|
void UpdateTooltip();
|
|
|
|
virtual wxMenu* CreatePopupMenu();
|
2009-08-30 05:46:39 +02:00
|
|
|
|
2009-09-24 06:09:56 +02:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|