Commit 0b1a6fd7 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

More work on fp lib table wizard: add a button to import the full list of .pretty libs on github.

* if the current select plugin is the github plugin, one can select some of these libraries and add them to the table
* if the current select plugin is the kicad plugin, one can select some of these libraries and download them to make alocal copy.
  They can added to the table after they are downloaded.
parent b269128b
Loading
Loading
Loading
Loading
+12 −15
Original line number Original line Diff line number Diff line
@@ -212,29 +212,26 @@ void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit )
}
}




wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter )
void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSplitter )
{
{
    wxArrayString* list = new wxArrayString();
    wxString tmp;


    while( 1 )
    for( unsigned ii = 0; ii < aText.Length(); ii++ )
    {
    {
        int index = aString.Find( aSplitter );
        if( aText[ii] == aSplitter )

        {
        if( index == wxNOT_FOUND )
            aStrings.Add( tmp );
            break;
            tmp.Clear();
        }


        wxString tmp;
        else
        tmp = aString.Mid( 0, index );
            tmp << aText[ii];
        aString = aString.Mid( index + 1, aString.size() - index );
        list->Add( tmp );
    }
    }


    if( !aString.IsEmpty() )
    if( !tmp.IsEmpty() )
    {
    {
        list->Add( aString );
        aStrings.Add( tmp );
    }
    }

    return list;
}
}




+7 −6
Original line number Original line Diff line number Diff line
@@ -636,6 +636,7 @@ void PLOTTER::Text( const wxPoint& aPos,
    {
    {
        // EDA_TEXT needs for calculations of the position of every
        // EDA_TEXT needs for calculations of the position of every
        // line according to orientation and justifications
        // line according to orientation and justifications
        wxArrayString strings;
        EDA_TEXT* multilineText = new EDA_TEXT( aText );
        EDA_TEXT* multilineText = new EDA_TEXT( aText );
        multilineText->SetSize( aSize );
        multilineText->SetSize( aSize );
        multilineText->SetTextPosition( aPos );
        multilineText->SetTextPosition( aPos );
@@ -646,15 +647,15 @@ void PLOTTER::Text( const wxPoint& aPos,
        multilineText->SetMultilineAllowed( aMultilineAllowed );
        multilineText->SetMultilineAllowed( aMultilineAllowed );


        std::vector<wxPoint> positions;
        std::vector<wxPoint> positions;
        wxArrayString* list = wxStringSplit( aText, '\n' );
        wxStringSplit( aText, strings, '\n' );
        positions.reserve( list->Count() );
        positions.reserve( strings.Count() );


        multilineText->GetPositionsOfLinesOfMultilineText(
        multilineText->GetPositionsOfLinesOfMultilineText(
                positions, list->Count() );
                positions, strings.Count() );


        for( unsigned ii = 0; ii < list->Count(); ii++ )
        for( unsigned ii = 0; ii < strings.Count(); ii++ )
        {
        {
            wxString& txt = list->Item( ii );
            wxString& txt = strings.Item( ii );
            DrawGraphicText( NULL, NULL, positions[ii], aColor, txt,
            DrawGraphicText( NULL, NULL, positions[ii], aColor, txt,
                             aOrient, aSize,
                             aOrient, aSize,
                             aH_justify, aV_justify,
                             aH_justify, aV_justify,
@@ -663,8 +664,8 @@ void PLOTTER::Text( const wxPoint& aPos,
                             NULL,
                             NULL,
                             this );
                             this );
        }
        }

        delete multilineText;
        delete multilineText;
        delete list;
    }
    }
    else
    else
    {
    {
+22 −26
Original line number Original line Diff line number Diff line
@@ -120,23 +120,23 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
{
{
    EDA_RECT       rect;
    EDA_RECT       rect;
    wxPoint        pos;
    wxPoint        pos;
    wxArrayString* list = NULL;
    wxArrayString  strings;
    wxString       text = GetShownText();
    wxString       text = GetShownText();
    int            thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
    int            thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
    int            linecount = 1;
    int            linecount = 1;


    if( m_MultilineAllowed )
    if( m_MultilineAllowed )
    {
    {
        list = wxStringSplit( text, '\n' );
        wxStringSplit( text, strings, '\n' );


        if ( list->GetCount() )     // GetCount() == 0 for void strings
        if ( strings.GetCount() )     // GetCount() == 0 for void strings
        {
        {
            if( aLine >= 0 && (aLine < (int)list->GetCount()) )
            if( aLine >= 0 && (aLine < (int)strings.GetCount()) )
                text = list->Item( aLine );
                text = strings.Item( aLine );
            else
            else
                text = list->Item( 0 );
                text = strings.Item( 0 );


            linecount = list->GetCount();
            linecount = strings.GetCount();
        }
        }
    }
    }


@@ -157,19 +157,17 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
    rect.Move( wxPoint( 0, -extra_dy / 2 ) ); // move origin by the half extra interval
    rect.Move( wxPoint( 0, -extra_dy / 2 ) ); // move origin by the half extra interval


    // for multiline texts and aLine < 0, merge all rectangles
    // for multiline texts and aLine < 0, merge all rectangles
    if( m_MultilineAllowed && list && aLine < 0 )
    if( m_MultilineAllowed && aLine < 0 )
    {
    {
        for( unsigned ii = 1; ii < list->GetCount(); ii++ )
        for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
        {
        {
            text = list->Item( ii );
            text = strings.Item( ii );
            dx   = LenSize( text );
            dx   = LenSize( text );
            textsize.x  = std::max( textsize.x, dx );
            textsize.x  = std::max( textsize.x, dx );
            textsize.y += dy;
            textsize.y += dy;
        }
        }
    }
    }


    delete list;

    rect.SetSize( textsize );
    rect.SetSize( textsize );


    /* Now, calculate the rect origin, according to text justification
    /* Now, calculate the rect origin, according to text justification
@@ -272,19 +270,18 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
    if( m_MultilineAllowed )
    if( m_MultilineAllowed )
    {
    {
        std::vector<wxPoint> positions;
        std::vector<wxPoint> positions;
        wxArrayString* list = wxStringSplit( GetShownText(), '\n' );
        wxArrayString  strings;
        positions.reserve( list->Count() );
        wxStringSplit( GetShownText(), strings, '\n' );
        positions.reserve( strings.Count() );


        GetPositionsOfLinesOfMultilineText(positions, list->Count() );
        GetPositionsOfLinesOfMultilineText(positions, strings.Count() );


        for( unsigned ii = 0; ii < list->Count(); ii++ )
        for( unsigned ii = 0; ii < strings.Count(); ii++ )
        {
        {
            wxString& txt = list->Item( ii );
            wxString& txt = strings.Item( ii );
            drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
            drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
                               aDrawMode, aFillMode, txt, positions[ii] );
                               aDrawMode, aFillMode, txt, positions[ii] );
        }
        }

        delete (list);
    }
    }
    else
    else
        drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
        drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
@@ -489,22 +486,21 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf


    if( IsMultilineAllowed() )
    if( IsMultilineAllowed() )
    {
    {
        wxArrayString* list = wxStringSplit( GetShownText(), '\n' );
        wxArrayString strings_list;
        wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
        std::vector<wxPoint> positions;
        std::vector<wxPoint> positions;
        positions.reserve( list->Count() );
        positions.reserve( strings_list.Count() );
        GetPositionsOfLinesOfMultilineText( positions, list->Count() );
        GetPositionsOfLinesOfMultilineText( positions,strings_list.Count() );


        for( unsigned ii = 0; ii < list->Count(); ii++ )
        for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
        {
        {
            wxString txt = list->Item( ii );
            wxString txt = strings_list.Item( ii );
            DrawGraphicText( NULL, NULL, positions[ii], color,
            DrawGraphicText( NULL, NULL, positions[ii], color,
                             txt, GetOrientation(), size,
                             txt, GetOrientation(), size,
                             GetHorizJustify(), GetVertJustify(),
                             GetHorizJustify(), GetVertJustify(),
                             GetThickness(), IsItalic(),
                             GetThickness(), IsItalic(),
                             true, addTextSegmToBuffer );
                             true, addTextSegmToBuffer );
        }
        }

        delete list;
    }
    }
    else
    else
    {
    {
+4 −7
Original line number Original line Diff line number Diff line
@@ -51,23 +51,20 @@ void HTML_MESSAGE_BOX::ListClear()


void HTML_MESSAGE_BOX::ListSet( const wxString& aList )
void HTML_MESSAGE_BOX::ListSet( const wxString& aList )
{
{
    // wxArrayString* wxStringSplit( wxString txt, wxChar splitter );
    wxArrayString strings_list;

    wxStringSplit( aList, strings_list, wxChar( '\n' ) );
    wxArrayString* strings_list = wxStringSplit( aList, wxChar( '\n' ) );


    wxString msg = wxT( "<ul>" );
    wxString msg = wxT( "<ul>" );


    for ( unsigned ii = 0; ii < strings_list->GetCount(); ii++ )
    for ( unsigned ii = 0; ii < strings_list.GetCount(); ii++ )
    {
    {
        msg += wxT( "<li>" );
        msg += wxT( "<li>" );
        msg += strings_list->Item( ii ) + wxT( "</li>" );
        msg += strings_list.Item( ii ) + wxT( "</li>" );
    }
    }


    msg += wxT( "</ul>" );
    msg += wxT( "</ul>" );


    m_htmlWindow->AppendToPage( msg );
    m_htmlWindow->AppendToPage( msg );

    delete strings_list;
}
}




+29 −5
Original line number Original line Diff line number Diff line
@@ -90,6 +90,31 @@ void DIALOG_CONFIG_EQUFILES::Init()


}
}


void DIALOG_CONFIG_EQUFILES::OnEditEquFile( wxCommandEvent& event )
{
    wxString    editorname = Pgm().GetEditorName();

    if( editorname.IsEmpty() )
    {
        wxMessageBox( _( "No editor defined in Kicad. Please chose it" ) );
        return;
    }

    wxArrayInt selections;
    m_ListEquiv->GetSelections( selections );

    wxString fullFileNames, tmp;

    for( unsigned ii = 0; ii < selections.GetCount(); ii++ )
    {
        tmp = m_ListEquiv->GetString( selections[ii] );
        fullFileNames << wxT( " \"" ) << wxExpandEnvVars( tmp ) << wxT( "\"" );
        m_ListChanged = true;
    }

    ExecuteFile( this, editorname, fullFileNames );
}



void DIALOG_CONFIG_EQUFILES::OnCancelClick( wxCommandEvent& event )
void DIALOG_CONFIG_EQUFILES::OnCancelClick( wxCommandEvent& event )
{
{
@@ -126,10 +151,9 @@ void DIALOG_CONFIG_EQUFILES::OnCloseWindow( wxCloseEvent& event )
void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
/********************************************************************/
/********************************************************************/
{
{
    wxListBox * list = m_ListEquiv;
    wxArrayInt selections;
    wxArrayInt selections;


    list->GetSelections( selections );
    m_ListEquiv->GetSelections( selections );


    if ( selections.GetCount() <= 0 )   // No selection.
    if ( selections.GetCount() <= 0 )   // No selection.
        return;
        return;
@@ -137,7 +161,7 @@ void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
    if( selections[0] == 0 )            // The first lib is selected. cannot move up it
    if( selections[0] == 0 )            // The first lib is selected. cannot move up it
        return;
        return;


    wxArrayString libnames = list->GetStrings();
    wxArrayString libnames = m_ListEquiv->GetStrings();


    for( size_t ii = 0; ii < selections.GetCount(); ii++ )
    for( size_t ii = 0; ii < selections.GetCount(); ii++ )
    {
    {
@@ -145,13 +169,13 @@ void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
        EXCHG( libnames[jj],  libnames[jj-1] );
        EXCHG( libnames[jj],  libnames[jj-1] );
    }
    }


    list->Set( libnames );
    m_ListEquiv->Set( libnames );


    // Reselect previously selected names
    // Reselect previously selected names
    for( size_t ii = 0; ii < selections.GetCount(); ii++ )
    for( size_t ii = 0; ii < selections.GetCount(); ii++ )
    {
    {
        int jj = selections[ii];
        int jj = selections[ii];
        list->SetSelection( jj-1 );
        m_ListEquiv->SetSelection( jj-1 );
    }
    }


    m_ListChanged = true;
    m_ListChanged = true;
Loading