- if ( node->GetData() == item )
- break;
-
- node = node->GetNext();
- }
-
- // DoRemove() (unlike Remove) can only be called for existing item!
- wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") );
-
- ::DeleteMenuItem(MAC_WXHMENU(m_hMenu) , pos + 1);
-
- if ( IsAttached() && GetMenuBar()->IsAttached() )
- // otherwise, the change won't be visible
- GetMenuBar()->Refresh();
-
- // and from internal data structures
- return wxMenuBase::DoRemove(item);
-}
-
-void wxMenu::SetTitle(const wxString& label)
-{
- m_title = label ;
- UMASetMenuTitle(MAC_WXHMENU(m_hMenu) , label , wxFont::GetDefaultEncoding() ) ;
-}
-
-bool wxMenu::ProcessCommand(wxCommandEvent & event)
-{
- bool processed = false;
-
- // Try the menu's event handler
- if ( /* !processed && */ GetEventHandler())
- processed = GetEventHandler()->SafelyProcessEvent(event);
-
- // Try the window the menu was popped up from
- // (and up through the hierarchy)
- wxWindow *win = GetInvokingWindow();
- if ( !processed && win )
- processed = win->HandleWindowEvent(event);
-
- return processed;
-}
-
-// ---------------------------------------------------------------------------
-// other
-// ---------------------------------------------------------------------------
-
-wxWindow *wxMenu::GetWindow() const
-{
- if ( m_invokingWindow != NULL )
- return m_invokingWindow;
- else if ( GetMenuBar() != NULL)
- return (wxWindow *) GetMenuBar()->GetFrame();
-
- return NULL;
-}
-
-// helper functions returning the mac menu position for a certain item, note that this is
-// mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0
-
-int wxMenu::MacGetIndexFromId( int id )
-{
- size_t pos;
- wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
- for ( pos = 0; node; pos++ )
- {
- if ( node->GetData()->GetId() == id )
- break;
-
- node = node->GetNext();
- }
-
- if (!node)
- return 0;
-
- return pos + 1 ;
-}
-
-int wxMenu::MacGetIndexFromItem( wxMenuItem *pItem )
-{
- size_t pos;
- wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
- for ( pos = 0; node; pos++ )
- {
- if ( node->GetData() == pItem )
- break;
-
- node = node->GetNext();
- }
-
- if (!node)
- return 0;
-
- return pos + 1 ;
-}
-
-void wxMenu::MacEnableMenu( bool bDoEnable )
-{
- UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , 0 , bDoEnable ) ;
-
- ::DrawMenuBar() ;
-}
-
-// MacOS needs to know about submenus somewhere within this menu
-// before it can be displayed, also hide special menu items
-// like preferences that are handled by the OS
-void wxMenu::MacBeforeDisplay( bool isSubMenu )
-{
- wxMenuItem* previousItem = NULL ;
- size_t pos ;
- wxMenuItemList::compatibility_iterator node;
- wxMenuItem *item;
-
- for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
- {
- item = (wxMenuItem *)node->GetData();
- wxMenu* subMenu = item->GetSubMenu() ;
- if (subMenu)
- {
- subMenu->MacBeforeDisplay( true ) ;
- }
- else // normal item