示例#1
0
文件: app.cpp 项目: hgwells/tive
static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
    OSStatus result = eventNotHandledErr ;

    HICommand command ;

    wxMacCarbonEvent cEvent( event ) ;
    cEvent.GetParameter<HICommand>(kEventParamDirectObject,typeHICommand,&command) ;

    wxMenuItem* item = NULL ;
    wxMenu* itemMenu = wxFindMenuFromMacCommand( command , item ) ;
    int id = wxMacCommandToId( command.commandID ) ;

    if ( item )
    {
        wxASSERT( itemMenu != NULL ) ;

        switch ( cEvent.GetKind() )
        {
        case kEventProcessCommand :
            result = itemMenu->MacHandleCommandProcess( item, id );
            break ;

        case kEventCommandUpdateStatus:
            result = itemMenu->MacHandleCommandUpdateStatus( item, id );
            break ;

        default :
            break ;
        }
    }
    return result ;
}
示例#2
0
文件: app.cpp 项目: zhchbin/wxWidgets
static pascal OSStatus
wxMacAppMenuEventHandler( EventHandlerCallRef WXUNUSED(handler),
                          EventRef event,
                          void *WXUNUSED(data) )
{
    wxMacCarbonEvent cEvent( event ) ;
    MenuRef menuRef = cEvent.GetParameter<MenuRef>(kEventParamDirectObject) ;
#ifndef __WXUNIVERSAL__
    wxMenu* menu = wxFindMenuFromMacMenu( menuRef ) ;

    if ( menu )
    {
        switch (GetEventKind(event))
        {
            case kEventMenuOpening:
                menu->HandleMenuOpened();
                break;

            case kEventMenuClosed:
                menu->HandleMenuClosed();
                break;

            case kEventMenuTargetItem:
                {
                    HICommand command ;

                    command.menu.menuRef = menuRef;
                    command.menu.menuItemIndex = cEvent.GetParameter<MenuItemIndex>(kEventParamMenuItemIndex,typeMenuItemIndex) ;
                    command.commandID = cEvent.GetParameter<MenuCommand>(kEventParamMenuCommand,typeMenuCommand) ;
                    if (command.commandID != 0)
                    {
                        wxMenuItem* item = NULL ;
                        wxMenu* itemMenu = wxFindMenuFromMacCommand( command , item ) ;
                        if ( itemMenu && item )
                            itemMenu->HandleMenuItemHighlighted( item );
                    }
                }
                break;

            default:
                wxFAIL_MSG(wxT("Unexpected menu event kind"));
                break;
        }

    }
#endif
    return eventNotHandledErr;
}