-}
-
-#endif // wxUSE_ACCEL
-
-
-void wxMenuBar::MacInstallMenuBar()
-{
- if ( s_macInstalledMenuBar == this )
- return ;
-
- Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ;
- wxString message ;
- wxCHECK_RET( menubar != NULL, "can't read MBAR resource" );
- ::SetMenuBar( menubar ) ;
- ::DisposeHandle( menubar ) ;
-
- MenuHandle menu = ::GetMenuHandle( kwxMacAppleMenuId ) ;
- ::AppendResMenu(menu, 'DRVR');
-
- for (int i = 0; i < m_menus.GetCount(); i++)
- {
- Str255 label;
- wxNode *node;
- wxMenuItem *item;
- int pos ;
- wxMenu* menu = m_menus[i] , *subMenu = NULL ;
-
-#if !TARGET_CARBON
- /* the help menu does not exist in CARBON anymore */
- if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName )
- {
- MenuHandle mh = NULL ;
- if ( HMGetHelpMenuHandle( &mh ) != noErr )
- {
- continue ;
- }
- if ( formerHelpMenuItems == 0 )
- {
- if( mh )
- formerHelpMenuItems = CountMenuItems( mh ) ;
- }
-
- for (pos = 0 , node = menu->GetMenuItems().First(); node; node = node->Next(), pos++)
- {
- item = (wxMenuItem *)node->Data();
- subMenu = item->GetSubMenu() ;
- if (subMenu)
- {
- // we don't support hierarchical menus in the help menu yet
- }
- else
- {
- if ( item->IsSeparator() )
- {
- if ( mh )
- UMAAppendMenuItem(mh, "\p-" );
- }
- else
- {
- Str255 label ;
- UInt8 modifiers ;
- SInt16 key ;
- wxMenuItem::MacBuildMenuString( label, &key , &modifiers , item->GetText(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu
- if ( label[0] == 0 )
- {
- // we cannot add empty menus on mac
- label[0] = 1 ;
- label[1] = ' ' ;
- }
- if ( item->GetId() == wxApp::s_macAboutMenuItemId )
- {
- UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label );
- UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
- }
- else
- {
- if ( mh )
- UMAAppendMenuItem(mh, label , key , modifiers );
- }
- }
- }
- }
- }
-#else
- if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName )
- {
- wxMenuItem::MacBuildMenuString( label, NULL , NULL , m_titles[i] , false );
- UMASetMenuTitle( menu->GetHMenu() , label ) ;
-
- for (pos = 0 , node = menu->GetMenuItems().First(); node; node = node->Next(), pos++)
- {
- item = (wxMenuItem *)node->Data();
- subMenu = item->GetSubMenu() ;
- if (subMenu)
- {
- UMAInsertMenu( subMenu->GetHMenu() , -1 ) ;
- }
- else
- {
- if ( item->GetId() == wxApp::s_macAboutMenuItemId )
- {
- Str255 label ;
- UInt8 modifiers ;
- SInt16 key ;
- wxMenuItem::MacBuildMenuString( label, &key , &modifiers , item->GetText(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu
- UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label );
- UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
- }
- }
- }
- UMAInsertMenu(m_menus[i]->GetHMenu(), 0);
- }