- wxASSERT_MSG( pItem != NULL, "can't append NULL item to the menu" );
-#if wxUSE_ACCEL
- UpdateAccel(pItem);
-#endif // wxUSE_ACCEL
-
- if ( pItem->IsSeparator() )
- {
- if ( pos == (size_t)-1 )
- {
- MacAppendMenu(MAC_WXHMENU(m_hMenu), "\p-");
- }
- else
- {
- MacInsertMenuItem(MAC_WXHMENU(m_hMenu), "\p-" , pos);
- }
- }
- else
- {
- wxMenu *pSubMenu = pItem->GetSubMenu() ;
- if ( pSubMenu != NULL )
- {
- Str255 label;
- wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added");
- pSubMenu->m_menuParent = this ;
- wxMenuItem::MacBuildMenuString( label , NULL , NULL , pItem->GetText() ,false);
-
- if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar)
- {
- ::InsertMenu( MAC_WXHMENU( pSubMenu->m_hMenu ) , -1 ) ;
- }
-
- if ( pos == (size_t)-1 )
- {
- UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), label, pSubMenu->m_macMenuId);
- }
- else
- {
- UMAInsertSubMenuItem(MAC_WXHMENU(m_hMenu), label , pos, pSubMenu->m_macMenuId);
- }
- }
- else
- {
- Str255 label ;
- UInt8 modifiers ;
- SInt16 key ;
- wxMenuItem::MacBuildMenuString( label, &key , &modifiers , pItem->GetText(), pItem->GetId() == wxApp::s_macAboutMenuItemId);
- if ( label[0] == 0 )
- {
- // we cannot add empty menus on mac
- label[0] = 1 ;
- label[1] = ' ' ;
- }
- if ( pos == (size_t)-1 )
- {
- UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), label,key,modifiers);
- if ( pItem->GetBitmap().Ok() )
- {
- ControlButtonContentInfo info ;
- wxMacCreateBitmapButton( &info , pItem->GetBitmap() , true ) ;
- if ( info.contentType != kControlNoContent )
- {
- if ( info.contentType == kControlContentCIconHandle )
- SetMenuItemIconHandle( MAC_WXHMENU(m_hMenu) , CountMenuItems(MAC_WXHMENU(m_hMenu) ) ,
- kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
- }
-
- }
- }
- else
- {
- UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), label , pos,key,modifiers);
- if ( pItem->GetBitmap().Ok() )
- {
- ControlButtonContentInfo info ;
- wxMacCreateBitmapButton( &info , pItem->GetBitmap() , true ) ;
- if ( info.contentType != kControlNoContent )
- {
- if ( info.contentType == kControlContentCIconHandle )
- SetMenuItemIconHandle( MAC_WXHMENU(m_hMenu) , pos ,
- kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
- }
-
- }
- }
- if ( pItem->GetId() == idMenuTitle )
- {
- if ( pos == (size_t)-1 )
- {
- UMADisableMenuItem(MAC_WXHMENU(m_hMenu) , CountMenuItems(MAC_WXHMENU(m_hMenu) ) ) ;
- }
- else
- {
- UMADisableMenuItem(MAC_WXHMENU(m_hMenu) , pos + 1 ) ;
- }
- }
- }
- }
- // if we're already attached to the menubar, we must update it
- if ( IsAttached() )
+ wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") );
+
+ bool check = FALSE;
+
+ if ( item->GetKind() == wxITEM_RADIO )
+ {
+ int count = GetMenuItemCount();
+
+ if ( m_startRadioGroup == -1 )
+ {
+ // start a new radio group
+ m_startRadioGroup = count;
+
+ // for now it has just one element
+ item->SetAsRadioGroupStart();
+ item->SetRadioGroupEnd(m_startRadioGroup);
+
+ // ensure that we have a checked item in the radio group
+ check = TRUE;
+ }
+ else // extend the current radio group
+ {
+ // we need to update its end item
+ item->SetRadioGroupStart(m_startRadioGroup);
+ wxMenuItemList::Node *node = GetMenuItems().Item(m_startRadioGroup);
+
+ if ( node )
+ {
+ node->GetData()->SetRadioGroupEnd(count);
+ }
+ else
+ {
+ wxFAIL_MSG( _T("where is the radio group start item?") );
+ }
+ }
+ }
+ else // not a radio item