From 9e56521b4b79a90cfae63c658ed2ecb67acebfca Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Thu, 28 Jan 2010 21:49:20 +0000 Subject: now compiles on 64-bit Ubuntu Karmic with wxWidgets-2.9.0, fixes for wxWidgets-2.9.0, added superfluous GetEventHandler()'s, there's still a bug on wx2.9.0 that the status number is mashed up for some reason otherwise seems to run fine --- build-unix.txt | 25 +++++++++------ makefile.unix | 89 ----------------------------------------------------- makefile.unix.wx2.8 | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ makefile.unix.wx2.9 | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ ui.cpp | 54 ++++++++++++++++++-------------- uibase.cpp | 6 +++- uibase.h | 6 +++- uiproject.fbp | 14 ++++----- 8 files changed, 242 insertions(+), 130 deletions(-) delete mode 100644 makefile.unix create mode 100644 makefile.unix.wx2.8 create mode 100644 makefile.unix.wx2.9 diff --git a/build-unix.txt b/build-unix.txt index 7c650589a4..5467bbea17 100644 --- a/build-unix.txt +++ b/build-unix.txt @@ -1,6 +1,6 @@ Bitcoin v0.2.0 BETA -Copyright (c) 2009 Satoshi Nakamoto +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. This product includes software developed by the OpenSSL Project for use in @@ -13,15 +13,22 @@ UNIX BUILD NOTES Dependencies ------------ -apt-get install build-essential -apt-get install libgtk2.0-dev -apt-get install libssl-dev -apt-get install libdb4.7-dev -apt-get install libdb4.7++-dev -apt-get install libboost-dev +sudo apt-get install build-essential +sudo apt-get install libgtk2.0-dev +sudo apt-get install libssl-dev +sudo apt-get install libdb4.7-dev +sudo apt-get install libdb4.7++-dev +sudo apt-get install libboost-dev + +There is currently no libwxgtk2.8-ansi-dev debian package for Karmic. +libwxgtk2.8-dev is the "unicode" build, but for wxWidgets 2.8 "unicode" +means wchar, not UTF-8. wchar wxString doesn't convert to std::string. + +In wxWidgets 2.9, unicode is UTF-8 and that's the only version. You need to download wxWidgets from http://www.wxwidgets.org/downloads/ -and build it yourself. +and build it yourself. See the build instructions and configure parameters +below. Licenses of statically linked libraries: wxWidgets LGPL 2.1 with very liberal exceptions @@ -48,7 +55,7 @@ symbols, which reduces the executable size by about 90%. wxWidgets --------- -cd /usr/local/wxWidgets-2.8.9 +cd /usr/local/wxWidgets-2.8.9 or 2.9.0 mkdir buildgtk cd buildgtk ../configure --with-gtk --enable-debug --disable-shared --enable-monolithic diff --git a/makefile.unix b/makefile.unix deleted file mode 100644 index b9826d6ccb..0000000000 --- a/makefile.unix +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright (c) 2009 Satoshi Nakamoto -# Distributed under the MIT/X11 software license, see the accompanying -# file license.txt or http://www.opensource.org/licenses/mit-license.php. - - -ifneq "$(BUILD)" "debug" -ifneq "$(BUILD)" "release" -BUILD=debug -endif -endif -ifeq "$(BUILD)" "debug" -D=d -DEBUGFLAGS=-g -D__WXDEBUG__ -endif - - - -INCLUDEPATHS= \ - -I"/usr/include" \ - -I"/usr/local/include/wx-2.8" \ - -I"/usr/local/lib/wx/include/gtk2-ansi-debug-static-2.8" - -LIBPATHS= \ - -L"/usr/lib" \ - -L"/usr/local/lib" - -LIBS= \ - -Wl,-Bstatic \ - -l boost_system -l boost_filesystem \ - -l db_cxx \ - -l wx_gtk2$(D)-2.8 \ - -Wl,-Bdynamic \ - -l crypto \ - -l gtk-x11-2.0 -l gthread-2.0 -l SM - -WXDEFS=-D__WXGTK__ -DNOPCH -CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS) -HEADERS=headers.h util.h main.h serialize.h uint256.h key.h bignum.h script.h db.h base58.h - - - -all: bitcoin - - -headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h - g++ -c $(CFLAGS) -o $@ $< - -obj/util.o: util.cpp $(HEADERS) - g++ -c $(CFLAGS) -o $@ $< - -obj/script.o: script.cpp $(HEADERS) - g++ -c $(CFLAGS) -o $@ $< - -obj/db.o: db.cpp $(HEADERS) market.h - g++ -c $(CFLAGS) -o $@ $< - -obj/net.o: net.cpp $(HEADERS) net.h - g++ -c $(CFLAGS) -o $@ $< - -obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h - g++ -c $(CFLAGS) -o $@ $< - -obj/market.o: market.cpp $(HEADERS) market.h - g++ -c $(CFLAGS) -o $@ $< - -obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h - g++ -c $(CFLAGS) -o $@ $< - -obj/uibase.o: uibase.cpp uibase.h - g++ -c $(CFLAGS) -o $@ $< - -obj/sha.o: sha.cpp sha.h - g++ -c $(CFLAGS) -O3 -o $@ $< - -obj/irc.o: irc.cpp $(HEADERS) - g++ -c $(CFLAGS) -o $@ $< - - - - -OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \ - obj/ui.o obj/uibase.o obj/sha.o obj/irc.o - -bitcoin: headers.h.gch $(OBJS) - g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS) - -clean: - -rm obj/* - -rm headers.h.gch diff --git a/makefile.unix.wx2.8 b/makefile.unix.wx2.8 new file mode 100644 index 0000000000..b9826d6ccb --- /dev/null +++ b/makefile.unix.wx2.8 @@ -0,0 +1,89 @@ +# Copyright (c) 2009 Satoshi Nakamoto +# Distributed under the MIT/X11 software license, see the accompanying +# file license.txt or http://www.opensource.org/licenses/mit-license.php. + + +ifneq "$(BUILD)" "debug" +ifneq "$(BUILD)" "release" +BUILD=debug +endif +endif +ifeq "$(BUILD)" "debug" +D=d +DEBUGFLAGS=-g -D__WXDEBUG__ +endif + + + +INCLUDEPATHS= \ + -I"/usr/include" \ + -I"/usr/local/include/wx-2.8" \ + -I"/usr/local/lib/wx/include/gtk2-ansi-debug-static-2.8" + +LIBPATHS= \ + -L"/usr/lib" \ + -L"/usr/local/lib" + +LIBS= \ + -Wl,-Bstatic \ + -l boost_system -l boost_filesystem \ + -l db_cxx \ + -l wx_gtk2$(D)-2.8 \ + -Wl,-Bdynamic \ + -l crypto \ + -l gtk-x11-2.0 -l gthread-2.0 -l SM + +WXDEFS=-D__WXGTK__ -DNOPCH +CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS) +HEADERS=headers.h util.h main.h serialize.h uint256.h key.h bignum.h script.h db.h base58.h + + + +all: bitcoin + + +headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h + g++ -c $(CFLAGS) -o $@ $< + +obj/util.o: util.cpp $(HEADERS) + g++ -c $(CFLAGS) -o $@ $< + +obj/script.o: script.cpp $(HEADERS) + g++ -c $(CFLAGS) -o $@ $< + +obj/db.o: db.cpp $(HEADERS) market.h + g++ -c $(CFLAGS) -o $@ $< + +obj/net.o: net.cpp $(HEADERS) net.h + g++ -c $(CFLAGS) -o $@ $< + +obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h + g++ -c $(CFLAGS) -o $@ $< + +obj/market.o: market.cpp $(HEADERS) market.h + g++ -c $(CFLAGS) -o $@ $< + +obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h + g++ -c $(CFLAGS) -o $@ $< + +obj/uibase.o: uibase.cpp uibase.h + g++ -c $(CFLAGS) -o $@ $< + +obj/sha.o: sha.cpp sha.h + g++ -c $(CFLAGS) -O3 -o $@ $< + +obj/irc.o: irc.cpp $(HEADERS) + g++ -c $(CFLAGS) -o $@ $< + + + + +OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \ + obj/ui.o obj/uibase.o obj/sha.o obj/irc.o + +bitcoin: headers.h.gch $(OBJS) + g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS) + +clean: + -rm obj/* + -rm headers.h.gch diff --git a/makefile.unix.wx2.9 b/makefile.unix.wx2.9 new file mode 100644 index 0000000000..81dcbd70e9 --- /dev/null +++ b/makefile.unix.wx2.9 @@ -0,0 +1,89 @@ +# Copyright (c) 2009 Satoshi Nakamoto +# Distributed under the MIT/X11 software license, see the accompanying +# file license.txt or http://www.opensource.org/licenses/mit-license.php. + + +ifneq "$(BUILD)" "debug" +ifneq "$(BUILD)" "release" +BUILD=debug +endif +endif +ifeq "$(BUILD)" "debug" +D=d +DEBUGFLAGS=-g -D__WXDEBUG__ +endif + + + +INCLUDEPATHS= \ + -I"/usr/include" \ + -I"/usr/local/include/wx-2.9" \ + -I"/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9" + +LIBPATHS= \ + -L"/usr/lib" \ + -L"/usr/local/lib" + +LIBS= \ + -Wl,-Bstatic \ + -l boost_system-mt -l boost_filesystem-mt \ + -l db_cxx \ + -l wx_gtk2u$(D)-2.9 \ + -Wl,-Bdynamic \ + -l crypto \ + -l gtk-x11-2.0 -l gthread-2.0 -l SM + +WXDEFS=-D__WXGTK__ -DNOPCH +CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS) +HEADERS=headers.h util.h main.h serialize.h uint256.h key.h bignum.h script.h db.h base58.h + + + +all: bitcoin + + +headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h + g++ -c $(CFLAGS) -o $@ $< + +obj/util.o: util.cpp $(HEADERS) + g++ -c $(CFLAGS) -o $@ $< + +obj/script.o: script.cpp $(HEADERS) + g++ -c $(CFLAGS) -o $@ $< + +obj/db.o: db.cpp $(HEADERS) market.h + g++ -c $(CFLAGS) -o $@ $< + +obj/net.o: net.cpp $(HEADERS) net.h + g++ -c $(CFLAGS) -o $@ $< + +obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h + g++ -c $(CFLAGS) -o $@ $< + +obj/market.o: market.cpp $(HEADERS) market.h + g++ -c $(CFLAGS) -o $@ $< + +obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h + g++ -c $(CFLAGS) -o $@ $< + +obj/uibase.o: uibase.cpp uibase.h + g++ -c $(CFLAGS) -o $@ $< + +obj/sha.o: sha.cpp sha.h + g++ -c $(CFLAGS) -O3 -o $@ $< + +obj/irc.o: irc.cpp $(HEADERS) + g++ -c $(CFLAGS) -o $@ $< + + + + +OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \ + obj/ui.o obj/uibase.o obj/sha.o obj/irc.o + +bitcoin: headers.h.gch $(OBJS) + g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS) + +clean: + -rm obj/* + -rm headers.h.gch diff --git a/ui.cpp b/ui.cpp index 994cc7e214..d1163aa5bf 100644 --- a/ui.cpp +++ b/ui.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Satoshi Nakamoto +// 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. @@ -252,18 +252,23 @@ bool IsCallbackAvailable(void* p) template void AddPendingCustomEvent(wxEvtHandler* pevthandler, int nEventID, const T pbeginIn, const T pendIn) { - if (!pevthandler) - return; - - const char* pbegin = (pendIn != pbeginIn) ? &pbeginIn[0] : NULL; - const char* pend = pbegin + (pendIn - pbeginIn) * sizeof(pbeginIn[0]); - wxCommandEvent event(nEventID); - wxString strData(wxChar(0), (pend - pbegin) / sizeof(wxChar) + 1); - memcpy(&strData[0], pbegin, pend - pbegin); - event.SetString(strData); - event.SetInt(pend - pbegin); - - pevthandler->AddPendingEvent(event); + // Need to rewrite with something like UIThreadCall + // I'm tired of maintaining this hack that's only called by unfinished unused code, + // but I'm not willing to delete it because it serves as documentation of what the + // unfinished code was trying to do. + assert(("Unimplemented", 0)); + //if (!pevthandler) + // return; + // + //const char* pbegin = (pendIn != pbeginIn) ? &pbeginIn[0] : NULL; + //const char* pend = pbegin + (pendIn - pbeginIn) * sizeof(pbeginIn[0]); + //wxCommandEvent event(nEventID); + //wxString strData(wxChar(0), (pend - pbegin) / sizeof(wxChar) + 1); + //memcpy(&strData[0], pbegin, pend - pbegin); + //event.SetString(strData); + //event.SetInt(pend - pbegin); + // + //pevthandler->AddPendingEvent(event); } template @@ -335,9 +340,8 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent) m_toolBar->AddTool(wxID_BUTTONRECEIVE, "Address Book", wxBitmap(addressbook20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString); m_toolBar->Realize(); // resize to fit ubuntu's huge default font - dResize = 1.19; - SetSize(dResize * GetSize().GetWidth(), 1.1 * GetSize().GetHeight()); dResize = 1.20; + SetSize(dResize * GetSize().GetWidth(), 1.1 * GetSize().GetHeight()); #endif m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " "); m_listCtrl->SetFocus(); @@ -458,6 +462,8 @@ void CMainFrame::OnIconize(wxIconizeEvent& event) { // Hide the task bar button when minimized. // Event is sent when the frame is minimized or restored. + // wxWidgets 2.8.9 doesn't have IsIconized() so there's no way + // to get rid of the deprecated warning. Just ignore it. if (!event.Iconized()) fClosedToTray = false; #ifndef __WXMSW__ @@ -985,7 +991,7 @@ void ThreadDelayedRepaint(void* parg) printf("DelayedRepaint\n"); wxPaintEvent event; pframeMain->fRefresh = true; - pframeMain->AddPendingEvent(event); + pframeMain->GetEventHandler()->AddPendingEvent(event); } } Sleep(nRepaintInterval); @@ -1010,7 +1016,7 @@ void MainFrameRepaint() printf("MainFrameRepaint\n"); wxPaintEvent event; pframeMain->fRefresh = true; - pframeMain->AddPendingEvent(event); + pframeMain->GetEventHandler()->AddPendingEvent(event); } } @@ -1695,12 +1701,14 @@ CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent) // Workaround until upgrade to wxWidgets supporting UTF-8 wxString str = m_staticTextMain->GetLabel(); +#if !wxUSE_UNICODE if (str.Find('Â') != wxNOT_FOUND) str.Remove(str.Find('Â'), 1); - m_staticTextMain->SetLabel(str); +#endif #ifndef __WXMSW__ SetSize(510, 380); #endif + m_staticTextMain->SetLabel(str); } void CAboutDialog::OnButtonOK(wxCommandEvent& event) @@ -1732,7 +1740,7 @@ CSendDialog::CSendDialog(wxWindow* parent, const wxString& strAddress) : CSendDi if (fontTmp.GetPointSize() > 9); fontTmp.SetPointSize(9); m_staticTextInstructions->SetFont(fontTmp); - SetSize(725, wxDefaultCoord); + SetSize(725, 380); #endif // Set Icon @@ -2000,7 +2008,7 @@ void CSendingDialog::Repaint() { Refresh(); wxPaintEvent event; - AddPendingEvent(event); + GetEventHandler()->AddPendingEvent(event); } bool CSendingDialog::Status() @@ -3379,14 +3387,14 @@ void CMyTaskBarIcon::OnMenuOptions(wxCommandEvent& event) { // Since it's modal, get the main window to do it wxCommandEvent event2(wxEVT_COMMAND_MENU_SELECTED, wxID_MENUOPTIONSOPTIONS); - pframeMain->AddPendingEvent(event2); + pframeMain->GetEventHandler()->AddPendingEvent(event2); } void CMyTaskBarIcon::Restore() { pframeMain->Show(); wxIconizeEvent event(0, false); - pframeMain->AddPendingEvent(event); + pframeMain->GetEventHandler()->AddPendingEvent(event); pframeMain->Iconize(false); pframeMain->Raise(); } @@ -3548,7 +3556,7 @@ bool CMyApp::OnInit2() if (!fDebug && !pszSetDataDir[0]) ShrinkDebugFile(); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - printf("Bitcoin version %d%s, OS version %s\n", VERSION, pszSubVer, wxGetOsDescription().mb_str()); + printf("Bitcoin version %d%s, OS version %s\n", VERSION, pszSubVer, ((string)wxGetOsDescription()).c_str()); if (mapArgs.count("-loadblockindextest")) { diff --git a/uibase.cpp b/uibase.cpp index f05f1095fb..fb4f1ed08c 100644 --- a/uibase.cpp +++ b/uibase.cpp @@ -1,3 +1,7 @@ +// 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. + /////////////////////////////////////////////////////////////////////////// // C++ code generated with wxFormBuilder (version Apr 16 2008) // http://www.wxformbuilder.org/ @@ -639,7 +643,7 @@ CSendDialogBase::CSendDialogBase( wxWindow* parent, wxWindowID id, const wxStrin bSizer21->Add( 0, 5, 0, wxEXPAND, 5 ); wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 3, 2, 0, 0 ); + fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 ); fgSizer1->AddGrowableCol( 1 ); fgSizer1->SetFlexibleDirection( wxBOTH ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); diff --git a/uibase.h b/uibase.h index 7620a24e53..97bb1bdc3c 100644 --- a/uibase.h +++ b/uibase.h @@ -1,3 +1,7 @@ +// 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. + /////////////////////////////////////////////////////////////////////////// // C++ code generated with wxFormBuilder (version Apr 16 2008) // http://www.wxformbuilder.org/ @@ -158,7 +162,7 @@ class CMainFrameBase : public wxFrame wxListCtrl* m_listCtrlOrdersSent; wxListCtrl* m_listCtrlProductsSent; wxListCtrl* m_listCtrlOrdersReceived; - CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = wxT("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 725,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); + CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = wxT("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 727,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); ~CMainFrameBase(); }; diff --git a/uiproject.fbp b/uiproject.fbp index 34fde78148..3c489ae633 100644 --- a/uiproject.fbp +++ b/uiproject.fbp @@ -32,7 +32,7 @@ CMainFrameBase - 725,484 + 727,484 wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER Bitcoin @@ -3509,7 +3509,7 @@ - + @@ -3580,7 +3580,7 @@ 5 wxEXPAND|wxLEFT 0 - + 2 wxBOTH 1 @@ -3590,7 +3590,7 @@ fgSizer1 wxFLEX_GROWMODE_SPECIFIED none - 3 + 0 0 5 @@ -4189,7 +4189,7 @@ 5 wxEXPAND 0 - + bSizer672 wxHORIZONTAL @@ -4317,7 +4317,7 @@ 5 wxEXPAND 1 - + bSizer67 wxHORIZONTAL @@ -4445,7 +4445,7 @@ 5 wxEXPAND 0 - + bSizer23 wxHORIZONTAL -- cgit v1.2.3