- int pos ;
- wxMenu* menu = m_menus[i] , *subMenu = NULL ;
-
- if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName )
- {
- if ( mh == NULL )
- {
- continue ;
- }
-
- 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->IsSeparator() )
- {
- if ( mh )
- MacAppendMenu(mh, "\p-" );
- }
- else
- {
- wxAcceleratorEntry* entry = wxGetAccelFromString( item->GetText() ) ;
-
- if ( item->GetId() == wxApp::s_macAboutMenuItemId )
- {
- UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetText() );
- UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true );
- SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetId() ) ;
- UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ;
- }
- else
- {
- if ( mh )
- {
- UMAAppendMenuItem(mh, item->GetText() , entry );
- SetMenuItemCommandID( mh , CountMenuItems(mh) , item->GetId() ) ;
- }
- }
-
- delete entry ;
- }
- }
- }
- }
- else
- {
- UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i] ) ;
- wxArrayPtrVoid submenus ;
- wxMenuItem* previousItem = NULL ;
- for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
- {
- item = (wxMenuItem *)node->GetData();
- subMenu = item->GetSubMenu() ;
- if (subMenu)
- {
- submenus.Add(subMenu) ;
- }
- else
- {
-#if TARGET_CARBON
- if ( UMAGetSystemVersion() >= 0x1000 )
- {
- if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId)
- {
- ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 );
- if ( menu->GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() )
- {
- ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos , kMenuItemAttrHidden, 0 );
- }
- }
- }
-#endif
- }
- previousItem = item ;
- }
- ::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0);
- for ( size_t i = 0 ; i < submenus.GetCount() ; ++i )
- {
- wxMenu* submenu = (wxMenu*) submenus[i] ;
- wxMenuItemList::Node *subnode;
- wxMenuItem *subitem;
- int subpos ;
- for ( subpos = 0 , subnode = submenu->GetMenuItems().GetFirst(); subnode; subnode = subnode->GetNext(), subpos++)
- {
- subitem = (wxMenuItem *)subnode->GetData();
- wxMenu* itsSubMenu = subitem->GetSubMenu() ;
- if (itsSubMenu)
- {
- submenus.Add(itsSubMenu) ;
- }
- }
- ::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ;
- }
- }
- }
- ::DrawMenuBar() ;
- s_macInstalledMenuBar = this;
+ wxMenu* menu = menuIter->GetData() , *subMenu = NULL ;
+ wxString strippedMenuTitle = wxStripMenuCodes(m_titles[i]);
+
+ if ( strippedMenuTitle == wxT("?") || strippedMenuTitle == strippedHelpMenuTitle || strippedMenuTitle == strippedTranslatedHelpMenuTitle )
+ {
+ for (node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext())
+ {
+ 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 )
+ {
+ // we have found a user help menu and an item other than the about item,
+ // so we can create the mac help menu now, if we haven't created it yet
+ if ( helpMenuHandle == NULL )
+ {
+ if ( UMAGetHelpMenu( &helpMenuHandle , &firstUserHelpMenuItem) != noErr )
+ {
+ helpMenuHandle = NULL ;
+ break ;
+ }
+ }
+ }
+
+ if ( item->IsSeparator() )
+ {
+ if ( helpMenuHandle )
+ AppendMenuItemTextWithCFString( helpMenuHandle,
+ CFSTR(""), kMenuItemAttrSeparator, 0,NULL);
+ }
+ else
+ {
+ wxAcceleratorEntry*
+ entry = wxAcceleratorEntry::Create( item->GetItemLabel() ) ;
+
+ if ( item->GetId() == wxApp::s_macAboutMenuItemId )
+ {
+ // this will be taken care of below
+ }
+ else
+ {
+ if ( helpMenuHandle )
+ {
+ UMAAppendMenuItem(helpMenuHandle, wxStripMenuCodes(item->GetItemLabel()) , wxFont::GetDefaultEncoding(), entry);
+ SetMenuItemCommandID( helpMenuHandle , CountMenuItems(helpMenuHandle) , wxIdToMacCommand ( item->GetId() ) ) ;
+ SetMenuItemRefCon( helpMenuHandle , CountMenuItems(helpMenuHandle) , (URefCon) item ) ;
+ }
+ }
+
+ delete entry ;
+ }
+ }
+ }
+ }
+
+ else if ( ( m_titles[i] == wxT("Window") || m_titles[i] == wxT("&Window") )
+ && GetAutoWindowMenu() )
+ {
+ if ( MacGetWindowMenuHMenu() == NULL )
+ {
+ CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ;
+ }
+
+ MenuRef wm = (MenuRef)MacGetWindowMenuHMenu();
+ if ( wm == NULL )
+ break;
+
+ // get the insertion point in the standard menu
+ MenuItemIndex winListStart;
+ GetIndMenuItemWithCommandID(wm,
+ kHICommandWindowListSeparator, 1, NULL, &winListStart);
+
+ // add a separator so that the standard items and the custom items
+ // aren't mixed together, but only if this is the first run
+ OSStatus err = GetIndMenuItemWithCommandID(wm,
+ 'WXWM', 1, NULL, NULL);
+
+ if ( err == menuItemNotFoundErr )
+ {
+ InsertMenuItemTextWithCFString( wm,
+ CFSTR(""), winListStart-1, kMenuItemAttrSeparator, 'WXWM');
+ }
+
+ wxInsertMenuItemsInMenu(menu, wm, winListStart);
+ }
+ 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 = wxAcceleratorEntry::Create( aboutMenuItem->GetItemLabel() ) ;
+ UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , wxStripMenuCodes ( aboutMenuItem->GetItemLabel() ) , wxFont::GetDefaultEncoding() );
+ UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true );
+ SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , kHICommandAbout ) ;
+ SetMenuItemRefCon(GetMenuHandle( kwxMacAppleMenuId ) , 1 , (URefCon)aboutMenuItem ) ;
+ UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ;
+ }
+ }
+
+ if ( GetAutoWindowMenu() )
+ {
+ if ( MacGetWindowMenuHMenu() == NULL )
+ CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ;
+
+ InsertMenu( (MenuHandle) MacGetWindowMenuHMenu() , 0 ) ;
+ }
+
+ ::DrawMenuBar() ;
+ s_macInstalledMenuBar = this;