X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b8d3a4f1a1a74b90394576d5828b8fdd8aeef277..a62489828e83c6196b7f6d4e95d74621d9a7e151:/src/msw/menu.cpp diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 570d92e727..2278e11d3f 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -9,21 +9,8 @@ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// wxWindows headers -// ----------------- - #ifdef __GNUG__ - #pragma implementation "menu.h" - #pragma implementation "menuitem.h" +#pragma implementation "menu.h" #endif // For compilers that support precompilation, includes "wx.h". @@ -86,6 +73,8 @@ wxMenu::wxMenu(const wxString& Title, const wxFunction func) m_hMenu = (WXHMENU) CreatePopupMenu(); m_savehMenu = 0 ; m_topLevelMenu = this; + m_clientData = (void*) NULL; + if (m_title != "") { Append(idMenuTitle, m_title) ; @@ -242,10 +231,10 @@ void wxMenu::Append(int Id, const wxString& label, void wxMenu::Delete(int id) { wxNode *node; - wxMenuItem *item; int pos; HMENU menu; + wxMenuItem *item = NULL; for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) { item = (wxMenuItem *)node->Data(); if (item->GetId() == id) @@ -321,9 +310,9 @@ void wxMenu::SetTitle(const wxString& label) { if ( !label.IsEmpty() ) { - if ( !InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, - idMenuTitle, m_title) || - !InsertMenu(hMenu, 1, MF_BYPOSITION, -1, NULL) ) + if ( !InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, + (unsigned)idMenuTitle, m_title) || + !InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) ) { wxLogLastError("InsertMenu"); } @@ -343,9 +332,9 @@ void wxMenu::SetTitle(const wxString& label) else { // modify the title - if ( !ModifyMenu(hMenu, 0, + if ( !ModifyMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, - idMenuTitle, m_title) ) + (unsigned)idMenuTitle, m_title) ) { wxLogLastError("ModifyMenu"); } @@ -400,8 +389,9 @@ void wxMenu::SetLabel(int Id, const wxString& label) item->SetName(label); } -wxString wxMenu::GetLabel(int Id) const +wxString wxMenu::GetLabel(int id) const { +/* static char tmp[128] ; int len; if (m_hMenu) @@ -412,11 +402,18 @@ wxString wxMenu::GetLabel(int Id) const len = 0 ; tmp[len] = '\0' ; return wxString(tmp) ; + +*/ + wxMenuItem *pItem = FindItemForId(id) ; + if (pItem) + return pItem->GetName() ; + else + return wxEmptyString; } bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id) { - wxCommandEvent event(wxEVENT_TYPE_MENU_COMMAND); + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED); event.SetEventObject( this ); event.SetId( id ); event.SetInt( id ); @@ -489,8 +486,10 @@ void wxMenu::SetHelpString(int itemId, const wxString& helpString) wxString wxMenu::GetHelpString (int itemId) const { wxMenuItem *item = FindItemForId (itemId); - wxString str(""); - return (item == NULL) ? str : item->GetHelp(); + if (item) + return item->GetHelp(); + else + return wxEmptyString; } void wxMenu::ProcessCommand(wxCommandEvent & event) @@ -513,7 +512,7 @@ void wxMenu::ProcessCommand(wxCommandEvent & event) // Try the window the menu was popped up from (and up // through the hierarchy) if ( !processed && GetInvokingWindow()) - processed = GetInvokingWindow()->ProcessEvent(event); + processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event); } extern wxMenu *wxCurrentPopupMenu; @@ -670,7 +669,7 @@ bool wxMenuBar::Checked(int Id) const if (!item) return FALSE; - int Flag ; + int Flag = 0; if (itemMenu->m_hMenu) Flag=GetMenuState((HMENU)itemMenu->m_hMenu, Id, MF_BYCOMMAND) ; @@ -895,8 +894,11 @@ wxMenuItem *wxMenuBar::FindItemForId (int Id, wxMenu ** itemMenu) const wxMenuItem *item = NULL; int i; for (i = 0; i < m_menuCount; i++) - if ((item = m_menus[i]->FindItemForId (Id, itemMenu))) + { + item = m_menus[i]->FindItemForId (Id, itemMenu); + if (item) return item; + } return NULL; }