void LIB_VIEW_FRAME::ClickOnCmpList( wxCommandEvent& event )
{
    int ii = m_cmpList->GetSelection();

    if( ii < 0 )
        return;

    SetSelectedComponent( m_cmpList->GetString( ii ) );
}
Пример #2
0
bool LIB_VIEW_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
{
    if( aSymbol && !aSymbol->IsEmpty() )
    {
        wxString msg;
        LIB_TABLE* libTable = Prj().SchSymbolLibTable();
        LIB_ID libid;

        libid.Parse( *aSymbol, LIB_ID::ID_SCH, true );

        if( libid.IsValid() )
        {
            wxString nickname = libid.GetLibNickname();

            if( !libTable->HasLibrary( libid.GetLibNickname(), false ) )
            {
                msg.sprintf( _( "The current configuration does not include a library with the\n"
                                "nickname \"%s\".  Use Manage Symbol Libraries\n"
                                "to edit the configuration." ), nickname );
                DisplayErrorMessage( aParent, _( "Symbol library not found." ), msg );
            }
            else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
            {
                msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
                                "in the current configuration.  Use Manage Symbol Libraries to\n"
                                "edit the configuration." ), nickname );
                DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
            }
            else
            {
                SetSelectedLibrary( libid.GetLibNickname() );
                SetSelectedComponent( libid.GetLibItemName() );
            }
        }
    }

    return KIWAY_PLAYER::ShowModal( aSymbol, aParent );
}
Пример #3
0
void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
{
    wxString   dialogTitle;
    PART_LIBS* libs = Prj().SchLibs();

    // Container doing search-as-you-type.
    COMPONENT_TREE_SEARCH_CONTAINER search_container( libs );

    for( PART_LIB& lib : *libs )
    {
        search_container.AddLibrary( lib );
    }

    dialogTitle.Printf( _( "Choose Component (%d items loaded)" ),
                        search_container.GetComponentsCount() );
    DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, &search_container, m_convert );

    if( dlg.ShowModal() == wxID_CANCEL )
        return;

    /// @todo: The unit selection gets reset to 1 by SetSelectedComponent() so the unit
    ///        selection feature of the choose symbol dialog doesn't work.
    LIB_ALIAS* const alias = dlg.GetSelectedAlias( &m_unit );

    if( !alias || !alias->GetLib() )
        return;

    if( m_libraryName == alias->GetLib()->GetName() )
    {
        if( m_entryName != alias->GetName() )
            SetSelectedComponent( alias->GetName() );
    }
    else
    {
        m_entryName = alias->GetName();
        SetSelectedLibrary( alias->GetLib()->GetName() );
    }
}