X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/45bedfdd737b5d707dce277cc664018e9f566994..304862976530be1315f3861157168f6edea2195e:/src/os2/menu.cpp diff --git a/src/os2/menu.cpp b/src/os2/menu.cpp index 07327e565b..6b82bb84fd 100644 --- a/src/os2/menu.cpp +++ b/src/os2/menu.cpp @@ -73,7 +73,7 @@ static wxString TextToLabel(const wxString& rTitle) { wxString Title; const wxChar *pc; - for (pc = rTitle; *pc != wxT('\0'); pc++ ) + for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ ) { if (*pc == wxT('&') ) { @@ -85,10 +85,6 @@ static wxString TextToLabel(const wxString& rTitle) else Title << wxT('~'); } -// else if (*pc == wxT('/')) -// { -// Title << wxT('\\'); -// } else { if ( *pc == wxT('~') ) @@ -244,7 +240,7 @@ void wxMenu::UpdateAccel( if (pAccel) m_vAccels[n] = pAccel; else - m_vAccels.Remove(n); + m_vAccels.RemoveAt(n); } if (IsAttached()) @@ -330,7 +326,7 @@ bool wxMenu::DoInsertOrAppend( // Will eventually need to set the image handle somewhere into vItem.hItem // rItem.afStyle |= MIS_OWNERDRAW; - pData = (BYTE*)pItem; + pData = (BYTE*)NULL; rItem.hItem = (HBITMAP)pItem->GetBitmap().GetHBITMAP(); pItem->m_vMenuData.afStyle = rItem.afStyle; pItem->m_vMenuData.hItem = rItem.hItem; @@ -389,7 +385,7 @@ bool wxMenu::DoInsertOrAppend( // // If we're already attached to the menubar, we must update it // - if (IsAttached()) + if (IsAttached() && m_menuBar->IsAttached()) { m_menuBar->Refresh(); } @@ -448,7 +444,7 @@ wxMenuItem* wxMenu::DoRemove( if (n != wxNOT_FOUND) { delete m_vAccels[n]; - m_vAccels.Remove(n); + m_vAccels.RemoveAt(n); } #endif // wxUSE_ACCEL @@ -460,7 +456,7 @@ wxMenuItem* wxMenu::DoRemove( ,MPFROM2SHORT(pItem->GetId(), TRUE) ,(MPARAM)0 ); - if (IsAttached()) + if (IsAttached() && m_menuBar->IsAttached()) { // // Otherwise, the chane won't be visible @@ -559,73 +555,21 @@ bool wxMenu::OS2Command( if (vId != (WXWORD)idMenuTitle) { - wxCommandEvent vEvent(wxEVT_COMMAND_MENU_SELECTED); - - vEvent.SetEventObject(this); - vEvent.SetId(vId); - vEvent.SetInt(vId); - ProcessCommand(vEvent); + SendEvent( vId + ,(int)::WinSendMsg( GetHmenu() + ,MM_QUERYITEMATTR + ,(MPARAM)vId + ,(MPARAM)MIA_CHECKED + ) + ); } return TRUE; } // end of wxMenu::OS2Command -bool wxMenu::ProcessCommand( - wxCommandEvent& rEvent -) -{ - bool bProcessed = FALSE; - -#if wxUSE_MENU_CALLBACK - // - // Try a callback - // - if (m_callback) - { - (void)(*(m_callback))(*this, rEvent); - bProcessed = TRUE; - } -#endif // wxUSE_MENU_CALLBACK - - // - // Try the menu's event handler - // - if (!bProcessed && GetEventHandler()) - { - bProcessed = GetEventHandler()->ProcessEvent(rEvent); - } - - // - // Try the window the menu was popped up from (and up through the - // hierarchy) - wxWindow* pWin = GetInvokingWindow(); - - if (!bProcessed && pWin) - bProcessed = pWin->GetEventHandler()->ProcessEvent(rEvent); - return bProcessed; -} // end of wxMenu::ProcessCommand - // --------------------------------------------------------------------------- // other // --------------------------------------------------------------------------- -void wxMenu::Attach( - wxMenuBar* pMenubar -) -{ - // - // Menu can be in at most one menubar because otherwise they would both - // delete the menu pointer - // - wxASSERT_MSG(!m_menuBar, wxT("menu belongs to 2 menubars, expect a crash")); - m_menuBar = pMenubar; -} // end of - -void wxMenu::Detach() -{ - wxASSERT_MSG( m_menuBar, wxT("can't detach menu if it's not attached") ); - m_menuBar = NULL; -} // end of wxMenu::Detach - wxWindow* wxMenu::GetWindow() const { if (m_invokingWindow != NULL) @@ -661,7 +605,12 @@ wxMenuItem* wxMenu::FindItem( } else if ( pItem->IsSubMenu() ) { - pItem = pItem->GetSubMenu()->FindItem(nItemId, hItem, ppItemMenu); + pItem = pItem->GetSubMenu()->FindItem( nItemId + ,hItem + ,ppItemMenu + ); + if (pItem) + break; } else { @@ -679,7 +628,7 @@ wxMenuItem* wxMenu::FindItem( void wxMenuBar::Init() { m_eventHandler = this; - m_pMenuBarFrame = NULL; + m_menuBarFrame = NULL; m_hMenu = 0; } // end of wxMenuBar::Init @@ -724,7 +673,7 @@ void wxMenuBar::Refresh() { wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") ); - WinSendMsg(GetWinHwnd(m_pMenuBarFrame), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0); + WinSendMsg(GetWinHwnd(m_menuBarFrame), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0); } // end of wxMenuBar::Refresh WXHMENU wxMenuBar::Create() @@ -740,8 +689,8 @@ WXHMENU wxMenuBar::Create() // // Menubars should be associated with a frame otherwise they are popups // - if (m_pMenuBarFrame != NULL) - hFrame = GetWinHwnd(m_pMenuBarFrame); + if (m_menuBarFrame != NULL) + hFrame = GetWinHwnd(m_menuBarFrame); else hFrame = HWND_DESKTOP; // @@ -951,8 +900,6 @@ bool wxMenuBar::Insert( ,nPos ); - pMenu->Attach(this); - if (IsAttached()) { ::WinSendMsg((HWND)m_hMenu, MM_INSERTITEM, (MPARAM)&pMenu->m_vMenuData, (MPARAM)Title.c_str()); @@ -981,7 +928,6 @@ bool wxMenuBar::Append( if (!wxMenuBarBase::Append(pMenu, Title)) return FALSE; - pMenu->Attach(this); m_titles.Add(Title); if ( IsAttached() ) @@ -1021,7 +967,6 @@ wxMenu* wxMenuBar::Remove( if (IsAttached()) { ::WinSendMsg((HWND)GetHmenu(), MM_REMOVEITEM, MPFROM2SHORT(nId, TRUE), (MPARAM)0); - pMenu->Detach(); #if wxUSE_ACCEL if (pMenu->HasAccels()) @@ -1077,7 +1022,7 @@ void wxMenuBar::Attach( ) { wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") ); - m_pMenuBarFrame = pFrame; + m_menuBarFrame = pFrame; #if wxUSE_ACCEL RebuildAccelTable(); @@ -1096,7 +1041,7 @@ void wxMenuBar::Detach() { ::WinDestroyWindow((HWND)m_hMenu); m_hMenu = (WXHMENU)NULL; - m_pMenuBarFrame = NULL; + m_menuBarFrame = NULL; } // end of wxMenuBar::Detach // ---------------------------------------------------------------------------