Kevacoin source tree
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

334 lines
9.5 KiB

// Copyright (c) 2009-2010 Satoshi Nakamoto
15 years ago
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)
extern map<string, string> mapArgs;
// Settings
extern int fMinimizeToTray;
extern int fMinimizeOnClose;
void HandleCtrlA(wxKeyEvent& event);
string FormatTxStatus(const CWalletTx& wtx);
void UIThreadCall(boost::function0<void>);
void MainFrameRepaint();
void Shutdown(void* parg);
int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);
15 years ago
15 years ago
class CMainFrame : public CMainFrameBase
{
protected:
// Event handlers
void OnNotebookPageChanged(wxNotebookEvent& event);
15 years ago
void OnClose(wxCloseEvent& event);
void OnIconize(wxIconizeEvent& event);
15 years ago
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);
void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);
15 years ago
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);
void OnButtonNew(wxCommandEvent& event);
void OnButtonCopy(wxCommandEvent& event);
15 years ago
void OnListColBeginDrag(wxListEvent& event);
void OnListItemActivated(wxListEvent& event);
15 years ago
void OnListItemActivatedProductsSent(wxListEvent& event);
void OnListItemActivatedOrdersSent(wxListEvent& event);
void OnListItemActivatedOrdersReceived(wxListEvent& event);
public:
/** Constructor */
CMainFrame(wxWindow* parent);
~CMainFrame();
// Custom
enum
{
ALL = 0,
SENTRECEIVED = 1,
SENT = 2,
RECEIVED = 3,
};
int nPage;
wxListCtrl* m_listCtrl;
bool fShowGenerated;
bool fShowSent;
bool fShowReceived;
15 years ago
bool fRefreshListCtrl;
bool fRefreshListCtrlRunning;
bool fOnSetFocusAddress;
unsigned int nListViewUpdated;
bool fRefresh;
15 years ago
void OnUIThreadCall(wxCommandEvent& event);
int GetSortIndex(const string& strSort);
15 years ago
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);
bool DeleteLine(uint256 hashKey);
bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);
15 years ago
void RefreshListCtrl();
void RefreshStatusColumn();
15 years ago
};
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
void OnListBox(wxCommandEvent& event);
void OnKillFocusTransactionFee(wxFocusEvent& event);
void OnCheckBoxLimitProcessors(wxCommandEvent& event);
void OnCheckBoxUseProxy(wxCommandEvent& event);
void OnKillFocusProxy(wxFocusEvent& event);
15 years ago
void OnButtonOK(wxCommandEvent& event);
void OnButtonCancel(wxCommandEvent& event);
void OnButtonApply(wxCommandEvent& event);
15 years ago
public:
/** Constructor */
COptionsDialog(wxWindow* parent);
// Custom
bool fTmpStartOnSystemStartup;
bool fTmpMinimizeOnClose;
void SelectPage(int nPage);
CAddress GetProxyAddr();
15 years ago
};
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="");
// Custom
bool fEnabledPrev;
string strFromSave;
string strMessageSave;
15 years ago
};
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;
char pszStatus[10000];
15 years ago
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
void OnNotebookPageChanged(wxNotebookEvent& event);
15 years ago
void OnListEndLabelEdit(wxListEvent& event);
void OnListItemSelected(wxListEvent& event);
void OnListItemActivated(wxListEvent& event);
void OnButtonDelete(wxCommandEvent& event);
void OnButtonCopy(wxCommandEvent& event);
void OnButtonEdit(wxCommandEvent& event);
void OnButtonNew(wxCommandEvent& event);
15 years ago
void OnButtonOK(wxCommandEvent& event);
void OnButtonCancel(wxCommandEvent& event);
void OnClose(wxCloseEvent& event);
public:
/** Constructor */
CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);
15 years ago
// Custom
enum
{
SENDING = 0,
RECEIVING = 1,
};
int nPage;
wxListCtrl* m_listCtrl;
bool fDuringSend;
15 years ago
wxString GetAddress();
wxString GetSelectedAddress();
wxString GetSelectedSendingAddress();
wxString GetSelectedReceivingAddress();
15 years ago
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)
{
int x = GetSize().GetWidth();
int y = GetSize().GetHeight();
15 years ago
m_staticTextMessage1->SetLabel(strMessage1);
m_textCtrl1->SetValue(strValue1);
y += wxString(strMessage1).Freq('\n') * 14;
15 years ago
if (!strMessage2.empty())
{
m_staticTextMessage2->Show(true);
m_staticTextMessage2->SetLabel(strMessage2);
m_textCtrl2->Show(true);
m_textCtrl2->SetValue(strValue2);
y += 46 + wxString(strMessage2).Freq('\n') * 14;
15 years ago
}
if (!fWindows)
{
x *= 1.14;
y *= 1.14;
}
SetSize(x, y);
15 years ago
}
// Custom
string GetValue() { return (string)m_textCtrl1->GetValue(); }
string GetValue1() { return (string)m_textCtrl1->GetValue(); }
string GetValue2() { return (string)m_textCtrl2->GetValue(); }
};
class CMyTaskBarIcon : public wxTaskBarIcon
{
protected:
// Event handlers
void OnLeftButtonDClick(wxTaskBarIconEvent& event);
void OnMenuRestore(wxCommandEvent& event);
void OnMenuOptions(wxCommandEvent& event);
void OnUpdateUIGenerate(wxUpdateUIEvent& event);
void OnMenuGenerate(wxCommandEvent& event);
void OnMenuExit(wxCommandEvent& event);
15 years ago
public:
CMyTaskBarIcon() : wxTaskBarIcon()
{
Show(true);
}
void Show(bool fShow=true);
void Hide();
void Restore();
void UpdateTooltip();
virtual wxMenu* CreatePopupMenu();
15 years ago
DECLARE_EVENT_TABLE()
};