X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e90c1d2a19361551eb07778280f22be3e759cf64..9abe166a3073d9e9ceb0110429a45adc6517d76f:/src/msw/menu.cpp diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index f36cf6573d..4cca3f9e59 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -138,12 +138,12 @@ void wxMenu::Break() // function appends a new item or submenu to the menu void wxMenu::Append(wxMenuItem *pItem) { - wxCHECK_RET( pItem != NULL, T("can't append NULL item to the menu") ); + wxCHECK_RET( pItem != NULL, wxT("can't append NULL item to the menu") ); #if wxUSE_ACCEL // check for accelerators: they are given after '\t' wxString label = pItem->GetName(); - int posTab = label.Find(T('\t')); + int posTab = label.Find(wxT('\t')); if ( posTab != wxNOT_FOUND ) { // parse the accelerator string int keyCode = 0; @@ -158,7 +158,7 @@ void wxMenu::Append(wxMenuItem *pItem) else if ( current == _("shift") ) accelFlags |= wxACCEL_SHIFT; else { - wxLogDebug(T("Unknown accel modifier: '%s'"), + wxLogDebug(wxT("Unknown accel modifier: '%s'"), current.c_str()); } @@ -170,7 +170,7 @@ void wxMenu::Append(wxMenuItem *pItem) } if ( current.IsEmpty() ) { - wxLogDebug(T("No accel key found, accel string ignored.")); + wxLogDebug(wxT("No accel key found, accel string ignored.")); } else { if ( current.Len() == 1 ) { @@ -178,18 +178,31 @@ void wxMenu::Append(wxMenuItem *pItem) keyCode = wxToupper(current[0U]); } else { - // it should be a function key + // is it a function key? if ( current[0U] == 'f' && isdigit(current[1U]) && (current.Len() == 2 || (current.Len() == 3 && isdigit(current[2U]))) ) { int n; - wxSscanf(current.c_str() + 1, T("%d"), &n); + wxSscanf(current.c_str() + 1, wxT("%d"), &n); keyCode = VK_F1 + n - 1; } else { - wxLogDebug(T("Unrecognized accel key '%s', accel " - "string ignored."), current.c_str()); + // several special cases + current.MakeUpper(); + if ( current == wxT("DEL") ) { + keyCode = VK_DELETE; + } + else if ( current == wxT("PGUP") ) { + keyCode = VK_PRIOR; + } + else if ( current == wxT("PGDN") ) { + keyCode = VK_NEXT; + } + else { + wxLogDebug(wxT("Unrecognized accel key '%s', accel " + "string ignored."), current.c_str()); + } } } } @@ -258,7 +271,7 @@ void wxMenu::Append(wxMenuItem *pItem) else { #ifdef __WIN32__ - if ( id == idMenuTitle ) + if ( (int)id == idMenuTitle ) { // visually select the menu title MENUITEMINFO mii; @@ -268,7 +281,7 @@ void wxMenu::Append(wxMenuItem *pItem) if ( !SetMenuItemInfo(GetHmenu(), (unsigned)id, FALSE, &mii) ) { - wxLogLastError(T("SetMenuItemInfo")); + wxLogLastError(wxT("SetMenuItemInfo")); } } #endif // __WIN32__ @@ -315,7 +328,7 @@ void wxMenu::Delete(int id) break; } - wxCHECK_RET( node, T("wxMenu::Delete(): item doesn't exist") ); + wxCHECK_RET( node, wxT("wxMenu::Delete(): item doesn't exist") ); HMENU menu = GetHmenu(); @@ -368,7 +381,7 @@ size_t wxMenu::CopyAccels(wxAcceleratorEntry *accels) const void wxMenu::Enable(int id, bool Flag) { wxMenuItem *item = FindItemForId(id); - wxCHECK_RET( item != NULL, T("can't enable non-existing menu item") ); + wxCHECK_RET( item != NULL, wxT("can't enable non-existing menu item") ); item->Enable(Flag); } @@ -376,7 +389,7 @@ void wxMenu::Enable(int id, bool Flag) bool wxMenu::IsEnabled(int id) const { wxMenuItem *item = FindItemForId(id); - wxCHECK_MSG( item != NULL, FALSE, T("invalid item id") ); + wxCHECK_MSG( item != NULL, FALSE, wxT("invalid item id") ); return item->IsEnabled(); } @@ -384,7 +397,7 @@ bool wxMenu::IsEnabled(int id) const void wxMenu::Check(int id, bool Flag) { wxMenuItem *item = FindItemForId(id); - wxCHECK_RET( item != NULL, T("can't get status of non-existing menu item") ); + wxCHECK_RET( item != NULL, wxT("can't get status of non-existing menu item") ); item->Check(Flag); } @@ -392,7 +405,7 @@ void wxMenu::Check(int id, bool Flag) bool wxMenu::IsChecked(int id) const { wxMenuItem *item = FindItemForId(id); - wxCHECK_MSG( item != NULL, FALSE, T("invalid item id") ); + wxCHECK_MSG( item != NULL, FALSE, wxT("invalid item id") ); return item->IsChecked(); } @@ -400,7 +413,7 @@ bool wxMenu::IsChecked(int id) const void wxMenu::SetLabel(int id, const wxString& label) { wxMenuItem *item = FindItemForId(id) ; - wxCHECK_RET( item, T("wxMenu::SetLabel: no such item") ); + wxCHECK_RET( item, wxT("wxMenu::SetLabel: no such item") ); item->SetName(label); } @@ -412,7 +425,7 @@ wxString wxMenu::GetLabel(int id) const if (pItem) label = pItem->GetName() ; else - wxFAIL_MSG(T("wxMenu::GetLabel: item doesn't exist")); + wxFAIL_MSG(wxT("wxMenu::GetLabel: item doesn't exist")); return label; } @@ -423,7 +436,7 @@ void wxMenu::SetHelpString(int itemId, const wxString& helpString) if (item) item->SetHelp(helpString); else - wxFAIL_MSG(T("wxMenu::SetHelpString: item doesn't exist")); + wxFAIL_MSG(wxT("wxMenu::SetHelpString: item doesn't exist")); } wxString wxMenu::GetHelpString (int itemId) const @@ -433,7 +446,7 @@ wxString wxMenu::GetHelpString (int itemId) const if (item) help = item->GetHelp(); else - wxFAIL_MSG(T("wxMenu::GetHelpString: item doesn't exist")); + wxFAIL_MSG(wxT("wxMenu::GetHelpString: item doesn't exist")); return help; } @@ -457,7 +470,7 @@ void wxMenu::SetTitle(const wxString& label) (unsigned)idMenuTitle, m_title) || !InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) ) { - wxLogLastError(T("InsertMenu")); + wxLogLastError(wxT("InsertMenu")); } } } @@ -618,7 +631,7 @@ void wxMenu::Attach(wxMenuBar *menubar) { // menu can be in at most one menubar because otherwise they would both // delete the menu pointer - wxASSERT_MSG( !m_menuBar, T("menu belongs to 2 menubars, expect a crash") ); + wxASSERT_MSG( !m_menuBar, wxT("menu belongs to 2 menubars, expect a crash") ); m_menuBar = menubar; m_savehMenu = m_hMenu; @@ -627,7 +640,7 @@ void wxMenu::Attach(wxMenuBar *menubar) void wxMenu::Detach() { - wxASSERT_MSG( m_menuBar, T("can't detach menu if it's not attached") ); + wxASSERT_MSG( m_menuBar, wxT("can't detach menu if it's not attached") ); m_hMenu = m_savehMenu; m_savehMenu = 0; @@ -690,7 +703,7 @@ wxMenuBar::~wxMenuBar() void wxMenuBar::Refresh() { - wxCHECK_RET( m_menuBarFrame, T("can't refresh a menubar withotu a frame") ); + wxCHECK_RET( m_menuBarFrame, wxT("can't refresh a menubar withotu a frame") ); DrawMenuBar((HWND)m_menuBarFrame->GetHWND()) ; } @@ -700,7 +713,7 @@ WXHMENU wxMenuBar::Create() if (m_hMenu != 0 ) return m_hMenu; - wxCHECK_MSG( !m_hMenu, TRUE, T("menubar already created") ); + wxCHECK_MSG( !m_hMenu, TRUE, wxT("menubar already created") ); m_hMenu = (WXHMENU)::CreateMenu(); @@ -735,7 +748,7 @@ void wxMenuBar::Enable(int id, bool enable) wxMenu *itemMenu = NULL; wxMenuItem *item = FindItemForId(id, &itemMenu) ; - wxCHECK_RET( item, T("attempt to enable an item which doesn't exist") ); + wxCHECK_RET( item, wxT("attempt to enable an item which doesn't exist") ); item->Enable(enable); } @@ -754,8 +767,8 @@ void wxMenuBar::Check(int id, bool check) wxMenu *itemMenu = NULL; wxMenuItem *item = FindItemForId(id, &itemMenu) ; - wxCHECK_RET( item, T("attempt to check an item which doesn't exist") ); - wxCHECK_RET( item->IsCheckable(), T("attempt to check an uncheckable item") ); + wxCHECK_RET( item, wxT("attempt to check an item which doesn't exist") ); + wxCHECK_RET( item->IsCheckable(), wxT("attempt to check an uncheckable item") ); item->Check(check); } @@ -765,7 +778,7 @@ bool wxMenuBar::IsChecked(int id) const wxMenu *itemMenu = NULL; wxMenuItem *item = FindItemForId(id, &itemMenu) ; - wxCHECK_MSG( item, FALSE, T("wxMenuBar::IsChecked(): no such item") ); + wxCHECK_MSG( item, FALSE, wxT("wxMenuBar::IsChecked(): no such item") ); int flag = ::GetMenuState(GetHmenuOf(itemMenu), id, MF_BYCOMMAND); @@ -777,7 +790,7 @@ bool wxMenuBar::IsEnabled(int id) const wxMenu *itemMenu = NULL; wxMenuItem *item = FindItemForId(id, &itemMenu) ; - wxCHECK_MSG( item, FALSE, T("wxMenuBar::IsEnabled(): no such item") ); + wxCHECK_MSG( item, FALSE, wxT("wxMenuBar::IsEnabled(): no such item") ); int flag = ::GetMenuState(GetHmenuOf(itemMenu), id, MF_BYCOMMAND) ; @@ -790,7 +803,7 @@ void wxMenuBar::SetLabel(int id, const wxString& label) wxMenu *itemMenu = NULL; wxMenuItem *item = FindItemForId(id, &itemMenu) ; - wxCHECK_RET( item, T("wxMenuBar::SetLabel(): no such item") ); + wxCHECK_RET( item, wxT("wxMenuBar::SetLabel(): no such item") ); item->SetName(label); } @@ -800,7 +813,7 @@ wxString wxMenuBar::GetLabel(int id) const wxMenu *itemMenu = NULL; wxMenuItem *item = FindItemForId(id, &itemMenu) ; - wxCHECK_MSG( item, T(""), T("wxMenuBar::GetLabel(): no such item") ); + wxCHECK_MSG( item, wxT(""), wxT("wxMenuBar::GetLabel(): no such item") ); return item->GetName(); } @@ -810,7 +823,7 @@ void wxMenuBar::SetHelpString (int id, const wxString& helpString) wxMenu *itemMenu = NULL; wxMenuItem *item = FindItemForId(id, &itemMenu) ; - wxCHECK_RET( item, T("wxMenuBar::SetHelpString(): no such item") ); + wxCHECK_RET( item, wxT("wxMenuBar::SetHelpString(): no such item") ); item->SetHelp(helpString); } @@ -820,7 +833,7 @@ wxString wxMenuBar::GetHelpString (int id) const wxMenu *itemMenu = NULL; wxMenuItem *item = FindItemForId(id, &itemMenu) ; - wxCHECK_MSG( item, T(""), T("wxMenuBar::GetHelpString(): no such item") ); + wxCHECK_MSG( item, wxT(""), wxT("wxMenuBar::GetHelpString(): no such item") ); return item->GetHelp(); } @@ -838,7 +851,7 @@ void wxMenuBar::SetLabelTop(int pos, const wxString& label) UINT flagsOld = ::GetMenuState((HMENU)m_hMenu, pos, MF_BYPOSITION); if ( flagsOld == 0xFFFFFFFF ) { - wxLogLastError(T("GetMenuState")); + wxLogLastError(wxT("GetMenuState")); return; } @@ -855,7 +868,7 @@ void wxMenuBar::SetLabelTop(int pos, const wxString& label) } if ( ::ModifyMenu(GetHmenu(), pos, MF_BYPOSITION | MF_STRING | flagsOld, - id, label) == 0xFFFFFFFF ) + id, label) == (int)0xFFFFFFFF ) { wxLogLastError("ModifyMenu"); } @@ -885,7 +898,7 @@ bool wxMenuBar::OnDelete(wxMenu *a_menu, int pos) if ( ::RemoveMenu((HMENU)m_hMenu, (UINT)pos, MF_BYPOSITION) ) { // VZ: I'm not sure about what's going on here, so I leave an assert - wxASSERT_MSG( m_menus[pos] == a_menu, T("what is this parameter for??") ); + wxASSERT_MSG( m_menus[pos] == a_menu, wxT("what is this parameter for??") ); a_menu->Detach(); @@ -916,7 +929,7 @@ bool wxMenuBar::OnAppend(wxMenu *a_menu, const wxChar *title) if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING, (UINT)submenu, title) ) { - wxLogLastError(T("AppendMenu")); + wxLogLastError(wxT("AppendMenu")); } Refresh(); @@ -971,7 +984,7 @@ void wxMenuBar::Insert(int pos, wxMenu * menu, const wxString& title) new_menus[i] = m_menus[i]; m_menus[i] = NULL; new_titles[i] = m_titles[i]; - m_titles[i] = T(""); + m_titles[i] = wxT(""); } new_menus[pos] = (wxMenu *)menu; @@ -982,7 +995,7 @@ void wxMenuBar::Insert(int pos, wxMenu * menu, const wxString& title) new_menus[i] = m_menus[i-1]; m_menus[i-1] = NULL; new_titles[i] = m_titles[i-1]; - m_titles[i-1] = T(""); + m_titles[i-1] = wxT(""); } if (m_menus) { @@ -1012,7 +1025,7 @@ void wxMenuBar::Append (wxMenu * menu, const wxString& title) new_menus[i] = m_menus[i]; m_menus[i] = NULL; new_titles[i] = m_titles[i]; - m_titles[i] = T(""); + m_titles[i] = wxT(""); } if (m_menus) { @@ -1060,7 +1073,7 @@ void wxMenuBar::Delete(wxMenu * menu, int i) void wxMenuBar::Attach(wxFrame *frame) { - wxASSERT_MSG( !m_menuBarFrame, T("menubar already attached!") ); + wxASSERT_MSG( !m_menuBarFrame, wxT("menubar already attached!") ); m_menuBarFrame = frame; @@ -1094,7 +1107,7 @@ void wxMenuBar::Attach(wxFrame *frame) void wxMenuBar::Detach() { // ::DestroyMenu((HMENU)m_hMenu); - m_hMenu = NULL; + m_hMenu = (WXHMENU)NULL; m_menuBarFrame = NULL; } @@ -1154,7 +1167,7 @@ WXHMENU wxMenu::GetHMenu() const else if ( m_savehMenu != 0 ) return m_savehMenu; - wxFAIL_MSG(T("wxMenu without HMENU")); + wxFAIL_MSG(wxT("wxMenu without HMENU")); return 0; }