+ 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() )
+ {
+ m_menuBar->Refresh();
+ }
+ return TRUE ;