From 84c3fb07b0b8199c7f85c5de280e7100bad0786f Mon Sep 17 00:00:00 2001 From: Jaromil Date: Sat, 23 Apr 2011 11:49:47 +0200 Subject: directory re-organization (keeps the old build system) there is no internal modification of any file in this commit files are moved into directories according to established standards in sourcecode distribution; these directories contain: src - Files that are used in constructing the executable binaries, but are not installed. doc - Files in HTML and text format that document usage, quirks of the implementation, and contributor checklists. locale - Files that contain human language translation of strings used in the program contrib - Files contributed from distributions or other third party implementing scripts and auxiliary programs --- src/ui.h | 344 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 344 insertions(+) create mode 100644 src/ui.h (limited to 'src/ui.h') diff --git a/src/ui.h b/src/ui.h new file mode 100644 index 000000000..af97d5abb --- /dev/null +++ b/src/ui.h @@ -0,0 +1,344 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// 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 wxLocale g_locale; + + + +void HandleCtrlA(wxKeyEvent& event); +void UIThreadCall(boost::function0); +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); +void CalledSetStatusBar(const string& strText, int nField); +void MainFrameRepaint(); +void CreateMainWindow(); +void SetStartOnSystemStartup(bool fAutoStart); + + + + +inline int MyMessageBox(const wxString& message, const wxString& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1) +{ +#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; +} +#define wxMessageBox MyMessageBox + + + + + + +class CMainFrame : public CMainFrameBase +{ +protected: + // Event handlers + void OnNotebookPageChanged(wxNotebookEvent& event); + void OnClose(wxCloseEvent& event); + void OnIconize(wxIconizeEvent& event); + 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); + 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); + void OnListColBeginDrag(wxListEvent& event); + void OnListItemActivated(wxListEvent& event); + 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; + bool fRefreshListCtrl; + bool fRefreshListCtrlRunning; + bool fOnSetFocusAddress; + unsigned int nListViewUpdated; + bool fRefresh; + + void OnUIThreadCall(wxCommandEvent& event); + int GetSortIndex(const string& strSort); + 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); + bool DeleteLine(uint256 hashKey); + bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1); + void RefreshListCtrl(); + void RefreshStatusColumn(); +}; + + + + +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); + + void OnButtonOK(wxCommandEvent& event); + void OnButtonCancel(wxCommandEvent& event); + void OnButtonApply(wxCommandEvent& event); + +public: + /** Constructor */ + COptionsDialog(wxWindow* parent); + + // Custom + bool fTmpStartOnSystemStartup; + bool fTmpMinimizeOnClose; + void SelectPage(int nPage); + CAddress GetProxyAddr(); +}; + + + +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 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; +}; + + + +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]; + 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); + 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); + void OnButtonOK(wxCommandEvent& event); + void OnButtonCancel(wxCommandEvent& event); + void OnClose(wxCloseEvent& event); + +public: + /** Constructor */ + CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn); + + // Custom + enum + { + SENDING = 0, + RECEIVING = 1, + }; + int nPage; + wxListCtrl* m_listCtrl; + bool fDuringSend; + wxString GetAddress(); + wxString GetSelectedAddress(); + wxString GetSelectedSendingAddress(); + wxString GetSelectedReceivingAddress(); + 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(); + m_staticTextMessage1->SetLabel(strMessage1); + m_textCtrl1->SetValue(strValue1); + y += wxString(strMessage1).Freq('\n') * 14; + 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; + } +#ifndef __WXMSW__ + x = x * 114 / 100; + y = y * 114 / 100; +#endif + SetSize(x, y); + } + + // 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); + +public: + CMyTaskBarIcon() : wxTaskBarIcon() + { + Show(true); + } + + void Show(bool fShow=true); + void Hide(); + void Restore(); + void UpdateTooltip(); + virtual wxMenu* CreatePopupMenu(); + +DECLARE_EVENT_TABLE() +}; -- cgit v1.2.3 From 223b6f1ba4819e9a146e7aa451d546726d0bc714 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sun, 15 May 2011 09:11:04 +0200 Subject: make bitcoin include files more modular --- src/ui.h | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'src/ui.h') diff --git a/src/ui.h b/src/ui.h index aff1f1e0e..16643db42 100644 --- a/src/ui.h +++ b/src/ui.h @@ -1,6 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_UI_H +#define BITCOIN_UI_H DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1) @@ -12,9 +14,9 @@ extern wxLocale g_locale; void HandleCtrlA(wxKeyEvent& event); void UIThreadCall(boost::function0); -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); -void CalledSetStatusBar(const string& strText, int nField); +int ThreadSafeMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1); +bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent); +void CalledSetStatusBar(const std::string& strText, int nField); void MainFrameRepaint(); void CreateMainWindow(); void SetStartOnSystemStartup(bool fAutoStart); @@ -28,8 +30,8 @@ inline int MyMessageBox(const wxString& message, const wxString& caption="Messag 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()); + printf("wxMessageBox %s: %s\n", std::string(caption).c_str(), std::string(message).c_str()); + fprintf(stderr, "%s: %s\n", std::string(caption).c_str(), std::string(message).c_str()); return wxOK; } #define wxMessageBox MyMessageBox @@ -93,8 +95,8 @@ public: bool fRefresh; void OnUIThreadCall(wxCommandEvent& event); - int GetSortIndex(const string& strSort); - 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); + int GetSortIndex(const std::string& strSort); + void InsertLine(bool fNew, int nIndex, uint256 hashKey, std::string strSort, const wxColour& colour, 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); void RefreshListCtrl(); @@ -176,8 +178,8 @@ public: // Custom bool fEnabledPrev; - string strFromSave; - string strMessageSave; + std::string strFromSave; + std::string strMessageSave; }; @@ -211,8 +213,8 @@ public: void Close(); void Repaint(); bool Status(); - bool Status(const string& str); - bool Error(const string& str); + bool Status(const std::string& str); + bool Error(const std::string& str); void StartTransfer(); void OnReply2(CDataStream& vRecv); void OnReply3(CDataStream& vRecv); @@ -257,7 +259,7 @@ public: wxString GetSelectedAddress(); wxString GetSelectedSendingAddress(); wxString GetSelectedReceivingAddress(); - bool CheckIfMine(const string& strAddress, const string& strTitle); + bool CheckIfMine(const std::string& strAddress, const std::string& strTitle); }; @@ -281,11 +283,11 @@ protected: 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) + const std::string& strCaption, + const std::string& strMessage1, + const std::string& strValue1="", + const std::string& strMessage2="", + const std::string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption) { int x = GetSize().GetWidth(); int y = GetSize().GetHeight(); @@ -308,9 +310,9 @@ public: } // Custom - string GetValue() { return (string)m_textCtrl1->GetValue(); } - string GetValue1() { return (string)m_textCtrl1->GetValue(); } - string GetValue2() { return (string)m_textCtrl2->GetValue(); } + std::string GetValue() { return (std::string)m_textCtrl1->GetValue(); } + std::string GetValue1() { return (std::string)m_textCtrl1->GetValue(); } + std::string GetValue2() { return (std::string)m_textCtrl2->GetValue(); } }; @@ -341,3 +343,5 @@ public: DECLARE_EVENT_TABLE() }; + +#endif -- cgit v1.2.3 From e89b9f6a2abaa120ff0fc3cea9ae364e8cbd25e4 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 1 Jun 2011 18:27:05 +0200 Subject: move wallet code to separate file This introduces two new source files, keystore.cpp and wallet.cpp with corresponding headers. Code is moved from main and db, in a preparation for a follow-up commit which introduces the classes CWallet and CKeyStore. --- src/ui.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/ui.h') diff --git a/src/ui.h b/src/ui.h index 16643db42..3f06ad90c 100644 --- a/src/ui.h +++ b/src/ui.h @@ -4,6 +4,9 @@ #ifndef BITCOIN_UI_H #define BITCOIN_UI_H +#include +#include "wallet.h" + DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1) -- cgit v1.2.3