X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6ef022bdffb620a8887eb5d162de4e2d816d72e0..cb7acf9cc78c309026bed1038631f2663cd90bda:/samples/menu/menu.cpp diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp index 7aab9c528d..63a7454627 100644 --- a/samples/menu/menu.cpp +++ b/samples/menu/menu.cpp @@ -18,19 +18,19 @@ // ---------------------------------------------------------------------------- // For compilers that support precompilation, includes "wx/wx.h". -#include +#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP - #include - #include - #include - #include - #include - #include + #include "wx/app.h" + #include "wx/frame.h" + #include "wx/menu.h" + #include "wx/msgdlg.h" + #include "wx/log.h" + #include "wx/textctrl.h" #endif #if !wxUSE_MENUS @@ -40,13 +40,6 @@ #include "copy.xpm" -#ifdef __WXUNIVERSAL__ - #include "wx/univ/theme.h" - - WX_USE_THEME(win32); - WX_USE_THEME(gtk); -#endif // __WXUNIVERSAL__ - // ---------------------------------------------------------------------------- // classes // ---------------------------------------------------------------------------- @@ -260,6 +253,7 @@ MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, -1, "wxWindows menu sample", wxDefaultPosition, wxSize(300, 200)) { + m_textctrl = NULL; m_menu = NULL; m_countDummy = 0; m_logOld = NULL; @@ -375,7 +369,7 @@ wxMenu *MyFrame::CreateDummyMenu(wxString *title) if ( title ) { - title->Printf("Dummy menu &%d", ++m_countDummy); + title->Printf(wxT("Dummy menu &%d"), ++m_countDummy); } return menu; @@ -389,7 +383,7 @@ wxMenuItem *MyFrame::GetLastMenuItem() const wxMenuItemList::Node *node = menu->GetMenuItems().GetLast(); if ( !node ) { - wxLogWarning("No last item in the last menu!"); + wxLogWarning(wxT("No last item in the last menu!")); return NULL; } @@ -405,10 +399,10 @@ void MyFrame::LogMenuEvent(const wxCommandEvent& event) if ( !GetMenuBar()->FindItem(id) ) return; - wxString msg = wxString::Format("Menu command %d", id); + wxString msg = wxString::Format(wxT("Menu command %d"), id); if ( GetMenuBar()->FindItem(id)->IsCheckable() ) { - msg += wxString::Format(" (the item is currently %schecked)", + msg += wxString::Format(wxT(" (the item is currently %schecked)"), event.IsChecked() ? "" : "not "); } @@ -431,14 +425,9 @@ void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { -#ifdef __WXUNIVERSAL__ - // wxMessageBox not implemented yet - wxLogMessage("wxWindows menu sample\n© 1999-2001 Vadim Zeitlin"); -#else (void)wxMessageBox("wxWindows menu sample\n© 1999-2001 Vadim Zeitlin", "About wxWindows menu sample", wxICON_INFORMATION); -#endif } void MyFrame::OnDeleteMenu(wxCommandEvent& WXUNUSED(event)) @@ -449,7 +438,7 @@ void MyFrame::OnDeleteMenu(wxCommandEvent& WXUNUSED(event)) if ( count == 2 ) { // don't let delete the first 2 menus - wxLogError("Can't delete any more menus"); + wxLogError(wxT("Can't delete any more menus")); } else { @@ -500,7 +489,7 @@ void MyFrame::OnGetLabelMenu(wxCommandEvent& WXUNUSED(event)) wxMenuBar *mbar = GetMenuBar(); size_t count = mbar->GetMenuCount(); - wxLogMessage("The label of the last menu item is '%s'", + wxLogMessage(wxT("The label of the last menu item is '%s'"), mbar->GetLabelTop(count - 1).c_str()); } @@ -514,7 +503,7 @@ void MyFrame::OnSetLabelMenu(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnDummy(wxCommandEvent& event) { - wxLogMessage("Dummy item #%d", event.GetId() - Menu_Dummy_First + 1); + wxLogMessage(wxT("Dummy item #%d"), event.GetId() - Menu_Dummy_First + 1); } void MyFrame::OnAppendMenuItem(wxCommandEvent& WXUNUSED(event)) @@ -545,7 +534,7 @@ void MyFrame::OnDeleteMenuItem(wxCommandEvent& WXUNUSED(event)) size_t count = menu->GetMenuItemCount(); if ( !count ) { - wxLogWarning("No items to delete!"); + wxLogWarning(wxT("No items to delete!")); } else { @@ -595,7 +584,7 @@ void MyFrame::OnGetLabelMenuItem(wxCommandEvent& WXUNUSED(event)) if ( item ) { - wxLogMessage("The label of the last menu item is '%s'", + wxLogMessage(wxT("The label of the last menu item is '%s'"), item->GetLabel().c_str()); } } @@ -713,6 +702,9 @@ void MyFrame::OnRightUp(wxMouseEvent &event) void MyFrame::OnSize(wxSizeEvent& event) { + if ( !m_textctrl ) + return; + // leave a band below for popup menu testing wxSize size = GetClientSize(); m_textctrl->SetSize(0, 0, size.x, (3*size.y)/4);