From 5c7766de900be4f22fde1c27c2398278583cbf43 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 20 Feb 2002 16:41:35 +0000 Subject: [PATCH] added commands to rename the menus and menu items for testing various characters in the menu labels git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14327 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/menu/menu.cpp | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp index 63a7454627..b60d0c74c9 100644 --- a/samples/menu/menu.cpp +++ b/samples/menu/menu.cpp @@ -31,6 +31,7 @@ #include "wx/msgdlg.h" #include "wx/log.h" #include "wx/textctrl.h" + #include "wx/textdlg.h" #endif #if !wxUSE_MENUS @@ -251,7 +252,7 @@ bool MyApp::OnInit() // Define my frame constructor MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, -1, "wxWindows menu sample", - wxDefaultPosition, wxSize(300, 200)) + wxDefaultPosition, wxSize(400, 250)) { m_textctrl = NULL; m_menu = NULL; @@ -340,12 +341,14 @@ MyFrame::MyFrame() wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); m_textctrl->SetEditable(FALSE); + + wxLog::SetTimestamp(NULL); m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_textctrl)); - wxLogMessage(_T("Brief explanations: the commands or the \"Menu\" menu\n") + wxLogMessage(_T("Brief explanations: the commands or the \"Menu\" menu ") _T("append/insert/delete items to/from the last menu.\n") - _T("The commands from \"Menubar\" menu work with the\n") - _T("menubar itself.\n") + _T("The commands from \"Menubar\" menu work with the ") + _T("menubar itself.\n\n") _T("Right click the band below to test popup menus.\n")); } @@ -489,6 +492,8 @@ void MyFrame::OnGetLabelMenu(wxCommandEvent& WXUNUSED(event)) wxMenuBar *mbar = GetMenuBar(); size_t count = mbar->GetMenuCount(); + wxCHECK_RET( count, _T("no last menu?") ); + wxLogMessage(wxT("The label of the last menu item is '%s'"), mbar->GetLabelTop(count - 1).c_str()); } @@ -498,7 +503,20 @@ void MyFrame::OnSetLabelMenu(wxCommandEvent& WXUNUSED(event)) wxMenuBar *mbar = GetMenuBar(); size_t count = mbar->GetMenuCount(); - mbar->SetLabelTop(count - 1, "Dummy label &0"); + wxCHECK_RET( count, _T("no last menu?") ); + + wxString label = wxGetTextFromUser + ( + _T("Enter new label: "), + _T("Change last menu text"), + mbar->GetLabelTop(count - 1), + this + ); + + if ( !label.empty() ) + { + mbar->SetLabelTop(count - 1, label); + } } void MyFrame::OnDummy(wxCommandEvent& event) @@ -595,7 +613,18 @@ void MyFrame::OnSetLabelMenuItem(wxCommandEvent& WXUNUSED(event)) if ( item ) { - item->SetText("Dummy menu item text"); + wxString label = wxGetTextFromUser + ( + _T("Enter new label: "), + _T("Change last menu item text"), + item->GetLabel(), + this + ); + + if ( !label.empty() ) + { + item->SetText(label); + } } } -- 2.47.2