From bb8b3773c9bd0e6d316e8e8e80d3cb3303338e1c Mon Sep 17 00:00:00 2001 From: Cheng Date: Sat, 7 May 2022 14:40:17 +1000 Subject: [PATCH] working, unfinished edit --- display_wallet.cpp | 21 ++++++++++++++++++--- display_wallet.h | 3 ++- frame.cpp | 4 ++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/display_wallet.cpp b/display_wallet.cpp index 1c624ba..531cc22 100644 --- a/display_wallet.cpp +++ b/display_wallet.cpp @@ -3,7 +3,8 @@ using ro::base58; display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) : wxPanel(parent, myID_WALLET_UI, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("Wallet")), m_db(nullptr), - m_menuitem_close(this, &display_wallet::close_menu_event_handler) + m_menuitem_close(this, &display_wallet::close_menu_event_handler), + m_menuitem_add_name(this, &display_wallet::add_name_event_handler) { wxLogMessage(_T("Loading %s"), walletfile.GetFullPath()); if (!walletfile.IsOk() || !walletfile.HasName() || !walletfile.HasExt()) throw MyException("unexpected file name"); @@ -61,17 +62,31 @@ display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) : singletonFrame->m_LastUsedSqlite.Assign(walletfile); wxMenu* menuFile{ singletonFrame->GetMenuBar()->GetMenu(0) }; - m_menuitem_close.Insert(menuFile, 1, "close", "test"); + m_menuitem_close.Insert(menuFile, 1, "close", "close wallet"); + singletonFrame->GetMenuBar()->EnableTop(1, true); //enable edit menu. + wxMenu* menuEdit{ singletonFrame->GetMenuBar()->GetMenu(1) }; + m_menuitem_add_name.Insert(menuEdit, 0, "add name", "create new Zooko identity"); + + } display_wallet::~display_wallet() { assert(true); + singletonFrame->GetMenuBar()->EnableTop(1, false); //disable edit menu. + } void display_wallet::close_menu_event_handler(wxCommandEvent& event) { - wxMessageDialog dlg(this, event.GetString(), wsz_error, wxICON_ERROR); Close(true); } +void display_wallet::add_name_event_handler(wxCommandEvent& event) { + wxMessageDialog dlg(this, "not yet implemented", wsz_error, wxICON_ERROR); + dlg.SetId(myID_ERRORMESSAGE); + dlg.ShowModal(); + +} + + void display_wallet::OnClose(wxCloseEvent& event) { // This event gives you the opportunity to clean up anything that needs explicit cleanup, albeit if you have done your work right nothing should need explicit cleanup, // and to object to the closing in a "file not saved" type situation. diff --git a/display_wallet.h b/display_wallet.h index dbc8e6e..a90a51f 100644 --- a/display_wallet.h +++ b/display_wallet.h @@ -11,7 +11,8 @@ private: wxBoxSizer* m_lSizer; wxBoxSizer* m_rSizer; void close_menu_event_handler(wxCommandEvent&); - // MenuLink m_close(display_wallet::close); + void add_name_event_handler(wxCommandEvent&); MenuLink m_menuitem_close; + MenuLink m_menuitem_add_name; void OnClose(wxCloseEvent& event); }; diff --git a/frame.cpp b/frame.cpp index 507312b..e93403e 100644 --- a/frame.cpp +++ b/frame.cpp @@ -144,11 +144,11 @@ try { menuHelp->Bind(wxEVT_MENU, &Frame::OnAbout, this, wxID_ABOUT); wxMenuBar* menuBar = new wxMenuBar; menuBar->Append(menuFile, menu_strings[0].head); - menuBar->Append(new wxMenu, menu_strings[1].head); + menuBar->Append(new wxMenu, menu_strings[1].head); //Edit menu, initially empty and disabled menuBar->Append(menuHelp, menu_strings[2].head); SetMenuBar(menuBar); CreateStatusBar(); - menuBar->EnableTop(1, false); + menuBar->EnableTop(1, false); //disable edit menu. // child controls m_LastUsedSqlite.Assign(singletonApp->pConfig->Read(_T("/Wallet/LastUsed"), _T(""))); if (!m_LastUsedSqlite.IsOk() || !m_LastUsedSqlite.HasName() || !m_LastUsedSqlite.HasExt()) {