void SELECTION_TOOL::AddMenuItem( const TOOL_ACTION& aAction, const SELECTION_CONDITION& aCondition )
{
    assert( aAction.GetId() > 0 );    // Check if the action was registered before in ACTION_MANAGER

    m_menu.Add( aAction );
    m_menuConditions.push_back( aCondition );
}
void CONTEXT_MENU::Add( const TOOL_ACTION& aAction )
{
    /// ID numbers for tool actions need to have a value higher than m_actionId
    int id = m_actionId + aAction.GetId();
    wxString menuEntry;

    if( aAction.HasHotKey() )
        menuEntry = wxString( ( aAction.GetMenuItem() + '\t' +
                                getHotKeyDescription( aAction ) ).c_str(), wxConvUTF8 );
    else
        menuEntry = wxString( aAction.GetMenuItem().c_str(), wxConvUTF8 );

    m_menu.Append( new wxMenuItem( &m_menu, id, menuEntry,
                    wxString( aAction.GetDescription().c_str(), wxConvUTF8 ), wxITEM_NORMAL ) );

    m_toolActions[id] = &aAction;
}
void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam )
{
    TOOL_EVENT event = aAction.MakeEvent();

    // Allow to override the action parameter
    if( aParam )
        event.SetParameter( aParam );

    if( aNow )
        ProcessEvent( event );
    else
        PostEvent( event );
}
bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, void* aParam )
{
    TOOL_ACTION* action = m_actionMgr->FindAction( aActionName );

    if( action )
    {
        TOOL_EVENT event = action->MakeEvent();

        // Allow to override the action parameter
        if( aParam )
            event.SetParameter( aParam );

        if( aNow )
            ProcessEvent( event );
        else
            PostEvent( event );

        return true;
    }

    wxASSERT_MSG( action != NULL, wxString::Format( wxT( "Could not find action %s." ), aActionName ) );

    return false;
}
void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam )
{
    TOOL_EVENT event = aAction.MakeEvent();

    // Allow to override the action parameter
    if( aParam )
        event.SetParameter( aParam );

    if( aNow )
    {
        TOOL_STATE* current = m_activeState;
        processEvent( event );
        setActiveState( current );
    }
    else
    {
        PostEvent( event );
    }
}
std::string CONTEXT_MENU::getHotKeyDescription( const TOOL_ACTION& aAction ) const
{
    int hotkey = aAction.GetHotKey();

    std::string description = "";

    if( hotkey & MD_ALT )
        description += "ALT+";

    if( hotkey & MD_CTRL )
        description += "CTRL+";

    if( hotkey & MD_SHIFT )
        description += "SHIFT+";

    // TODO dispatch keys such as Fx, TAB, PG_UP/DN, HOME, END, etc.
    description += char( hotkey & ~MD_MODIFIER_MASK );

    return description;
}
void ROUTER_TOOL::setTransitions()
{
    Go( &ROUTER_TOOL::RouteSingleTrace, PCB_ACTIONS::routerActivateSingle.MakeEvent() );
    Go( &ROUTER_TOOL::RouteDiffPair, PCB_ACTIONS::routerActivateDiffPair.MakeEvent() );
    Go( &ROUTER_TOOL::DpDimensionsDialog, PCB_ACTIONS::routerActivateDpDimensionsDialog.MakeEvent() );
    Go( &ROUTER_TOOL::SettingsDialog, PCB_ACTIONS::routerActivateSettingsDialog.MakeEvent() );
    Go( &ROUTER_TOOL::InlineDrag, PCB_ACTIONS::routerInlineDrag.MakeEvent() );
    Go( &ROUTER_TOOL::InlineBreakTrack, PCB_ACTIONS::inlineBreakTrack.MakeEvent() );

    Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceThroughVia.MakeEvent() );
    Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceBlindVia.MakeEvent() );
    Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceMicroVia.MakeEvent() );
    Go( &ROUTER_TOOL::onViaCommand, ACT_SelLayerAndPlaceThroughVia.MakeEvent() );
    Go( &ROUTER_TOOL::onViaCommand, ACT_SelLayerAndPlaceBlindVia.MakeEvent() );

    Go( &ROUTER_TOOL::CustomTrackWidthDialog, ACT_CustomTrackWidth.MakeEvent() );
    Go( &ROUTER_TOOL::onTrackViaSizeChanged, PCB_ACTIONS::trackViaSizeChanged.MakeEvent() );
}
void SELECTION_TOOL::AddMenuItem( const TOOL_ACTION& aAction )
{
    assert( aAction.GetId() > 0 );    // Check if the action was registered before in ACTION_MANAGER

    m_menu.Add( aAction );
}
Exemple #9
0
void CONDITIONAL_MENU::AddItem( const TOOL_ACTION& aAction, const SELECTION_CONDITION& aCondition,
                                int aOrder )
{
    assert( aAction.GetId() > 0 ); // Check if action was previously registered in ACTION_MANAGER
    addEntry( ENTRY( &aAction, aCondition, aOrder ) );
}