X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e58dab20ce995856303154a367bcca904066525c..24f932d22a085ce899b94c98578f475782c75bf6:/src/os2/menu.cpp diff --git a/src/os2/menu.cpp b/src/os2/menu.cpp index 6b82bb84fd..ccf5fce86f 100644 --- a/src/os2/menu.cpp +++ b/src/os2/menu.cpp @@ -188,6 +188,14 @@ void wxMenu::Break() #if wxUSE_ACCEL +void wxMenu::EndRadioGroup() +{ + // + // We're not inside a radio group any longer + // + m_nStartRadioGroup = -1; +} // end of wxMenu::EndRadioGroup + int wxMenu::FindAccel( int nId ) const @@ -398,8 +406,64 @@ bool wxMenu::DoAppend( wxMenuItem* pItem ) { - return wxMenuBase::DoAppend(pItem) && DoInsertOrAppend(pItem); -} + wxCHECK_MSG( pItem, FALSE, _T("NULL item in wxMenu::DoAppend") ); + + bool bCheck = FALSE; + + if (pItem->GetKind() == wxITEM_RADIO) + { + int nCount = GetMenuItemCount(); + + if (m_nStartRadioGroup == -1) + { + // + // Start a new radio group + // + m_nStartRadioGroup = nCount; + + // + // For now it has just one element + // + pItem->SetAsRadioGroupStart(); + pItem->SetRadioGroupEnd(m_nStartRadioGroup); + + // + // Ensure that we have a checked item in the radio group + // + bCheck = TRUE; + } + else // extend the current radio group + { + // + // We need to update its end item + // + pItem->SetRadioGroupStart(m_nStartRadioGroup); + wxMenuItemList::Node* pNode = GetMenuItems().Item(m_nStartRadioGroup); + + if (pNode) + { + pNode->GetData()->SetRadioGroupEnd(nCount); + } + else + { + wxFAIL_MSG( _T("where is the radio group start item?") ); + } + } + } + else // not a radio item + { + EndRadioGroup(); + } + if (!wxMenuBase::DoAppend(pItem) || !DoInsertOrAppend(pItem)) + { + return FALSE; + } + if (bCheck) + { + pItem->Check(TRUE); + } + return TRUE; +} // end of wxMenu::DoInsert bool wxMenu::DoInsert( size_t nPos @@ -1022,7 +1086,6 @@ void wxMenuBar::Attach( ) { wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") ); - m_menuBarFrame = pFrame; #if wxUSE_ACCEL RebuildAccelTable();