+ // clean-up the help menu before adding new items
+ static MenuHandle mh = NULL ;
+
+ if ( mh != NULL )
+ {
+ MenuItemIndex firstUserHelpMenuItem ;
+ if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) == noErr )
+ {
+ for ( int i = CountMenuItems( mh ) ; i >= firstUserHelpMenuItem ; --i )
+ {
+ DeleteMenuItem( mh , i ) ;
+ }
+ }
+ else
+ {
+ mh = NULL ;
+ }
+ }
+#if TARGET_CARBON
+ if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId)
+ {
+ wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ;
+ if ( item == NULL || !(item->IsEnabled()) )
+ DisableMenuCommand( NULL , kHICommandPreferences ) ;
+ else
+ EnableMenuCommand( NULL , kHICommandPreferences ) ;
+ }
+ // Unlike preferences which may or may not exist, the Quit item should be always
+ // enabled unless it is added by the application and then disabled, otherwise
+ // a program would be required to add an item with wxID_EXIT in order to get the
+ // Quit menu item to be enabled, which seems a bit burdensome.
+ if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macExitMenuItemId)
+ {
+ wxMenuItem *item = FindItem( wxApp::s_macExitMenuItemId , NULL ) ;
+ if ( item != NULL && !(item->IsEnabled()) )
+ DisableMenuCommand( NULL , kHICommandQuit ) ;
+ else
+ EnableMenuCommand( NULL , kHICommandQuit ) ;
+ }
+#endif
+ wxMenuList::compatibility_iterator menuIter = m_menus.GetFirst();
+ //
+ for (size_t i = 0; i < m_menus.GetCount(); i++, menuIter = menuIter->GetNext())
+ {
+ wxMenuItemList::compatibility_iterator node;
+ wxMenuItem *item;
+ int pos ;
+ wxMenu* menu = menuIter->GetData() , *subMenu = NULL ;
+
+ if( m_titles[i] == wxT("?") || m_titles[i] == wxT("&?") || m_titles[i] == wxApp::s_macHelpMenuTitleName )
+ {
+ for (pos = 0 , node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
+ {
+ item = (wxMenuItem *)node->GetData();
+ subMenu = item->GetSubMenu() ;
+ if (subMenu)
+ {
+ // we don't support hierarchical menus in the help menu yet
+ }
+ else
+ {
+ if ( item->GetId() != wxApp::s_macAboutMenuItemId )
+ {
+ if ( mh == NULL )
+ {
+ MenuItemIndex firstUserHelpMenuItem ;
+ if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) == noErr )
+ {
+ }
+ else
+ {
+ mh = NULL ;
+ break ;
+ }
+ }
+ }
+ if ( item->IsSeparator() )
+ {
+ if ( mh )
+ MacAppendMenu(mh, "\p-" );
+ }
+ else
+ {
+ wxAcceleratorEntry* entry = wxGetAccelFromString( item->GetText() ) ;
+
+ if ( item->GetId() == wxApp::s_macAboutMenuItemId )
+ {
+ // this will be taken care of below
+ }
+ else
+ {
+ if ( mh )
+ {
+ UMAAppendMenuItem(mh, item->GetText() , wxFont::GetDefaultEncoding(), entry);
+ SetMenuItemCommandID( mh , CountMenuItems(mh) , item->GetId() ) ;
+ SetMenuItemRefCon( mh , CountMenuItems(mh) , (UInt32)item ) ;
+ }
+ }
+
+ delete entry ;
+ }
+ }
+ }
+ }
+ else
+ {
+ UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i], m_font.GetEncoding() ) ;
+ menu->MacBeforeDisplay(false) ;
+ ::InsertMenu(MAC_WXHMENU(_wxMenuAt(m_menus, i)->GetHMenu()), 0);
+ }
+ }
+ // take care of the about menu item wherever it is
+ {
+ wxMenu* aboutMenu ;
+ wxMenuItem *aboutMenuItem = FindItem(wxApp::s_macAboutMenuItemId , &aboutMenu) ;
+ if ( aboutMenuItem )
+ {
+ wxAcceleratorEntry* entry = wxGetAccelFromString( aboutMenuItem->GetText() ) ;
+ UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , aboutMenuItem->GetText() , wxFont::GetDefaultEncoding() );
+ UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true );
+ SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , aboutMenuItem->GetId() ) ;
+ SetMenuItemRefCon(GetMenuHandle( kwxMacAppleMenuId ) , 1 , (UInt32)aboutMenuItem ) ;
+ UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ;
+ }
+ }
+ if ( GetAutoWindowMenu() )
+ {
+ if ( MacGetWindowMenuHMenu() == NULL )
+ {
+ CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ;
+ }
+ InsertMenu( (MenuHandle) MacGetWindowMenuHMenu() , 0 ) ;
+ }
+ ::DrawMenuBar() ;
+ s_macInstalledMenuBar = this;