Commit f7452ce1 authored by stambaughw's avatar stambaughw
Browse files

Component library object and other minor improvements.

* Create static component library methods to manage library list.
* Rename component library, component, and alias objects to more readable name.
* Use pointer to component instead of root name to prevent redundant library searches.
* Add append message helper to message panel that calculates string length.
* Initial ground work for merging library and library document files.
* Improved component library file load error checking.
* Minor component library editor improvements.
parent 7776dd61
Loading
Loading
Loading
Loading
+0 −22
Original line number Original line Diff line number Diff line
@@ -690,28 +690,6 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame, int pos_X,
}
}




/*
 *  Routine d'affichage de la documentation associee a un composant
 */
/****************************************************************************/
void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc,
                 const wxString& KeyW )
/****************************************************************************/
{
    wxString Line1( wxT( "Doc:  " ) ), Line2( wxT( "KeyW: " ) );

    int      color = BLUE;

    if( frame && frame->MsgPanel )
    {
        frame->MsgPanel->EraseMsgBox();
        Line1 += Doc;
        Line2 += KeyW;
        frame->MsgPanel->Affiche_1_Parametre( 10, Line1, Line2, color );
    }
}


/***********************/
/***********************/
int GetTimeStamp()
int GetTimeStamp()
/***********************/
/***********************/
+9 −1
Original line number Original line Diff line number Diff line
@@ -1379,7 +1379,8 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
}
}




void WinEDA_DrawPanel::UnManageCursor( void )
void WinEDA_DrawPanel::UnManageCursor( int id, int cursor,
                                       const wxString& title )
{
{
    wxClientDC dc( this );
    wxClientDC dc( this );


@@ -1387,5 +1388,12 @@ void WinEDA_DrawPanel::UnManageCursor( void )
    {
    {
        ForceCloseManageCurseur( this, &dc );
        ForceCloseManageCurseur( this, &dc );
        m_AutoPAN_Request = false;
        m_AutoPAN_Request = false;

        if( id != -1 && cursor != -1 )
        {
            wxASSERT( cursor > wxCURSOR_NONE && cursor < wxCURSOR_MAX );

            m_Parent->SetToolID( id, cursor, title );
        }
    }
    }
}
}
+44 −0
Original line number Original line Diff line number Diff line
@@ -61,6 +61,20 @@ int WinEDA_MsgPanel::GetRequiredHeight()
}
}




wxSize WinEDA_MsgPanel::computeTextSize( const wxString& text )
{
    // Get size of the wxSYS_DEFAULT_GUI_FONT
    wxSize      textSizeInPixels;

    wxScreenDC dc;

    dc.SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) );
    dc.GetTextExtent( text, &textSizeInPixels.x, &textSizeInPixels.y );

    return textSizeInPixels;
}


/*************************************************/
/*************************************************/
void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event )
void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event )
/*************************************************/
/*************************************************/
@@ -80,6 +94,36 @@ void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event )
    event.Skip();
    event.Skip();
}
}


void WinEDA_MsgPanel::AppendMessage( const wxString& textUpper,
                                     const wxString& textLower,
                                     int color, int pad )
{
    wxString    text;
    wxSize      drawSize = GetClientSize();

    text = ( textUpper.Len() > textLower.Len() ) ? textUpper : textLower;
    text.Append( ' ', pad );

    MsgItem item;

    /* Don't put the first message a window client position 0.  Offset by
     * one 'W' character width. */
    if( m_last_x == 0 )
        m_last_x = m_fontSize.x;

    item.m_X = m_last_x;

    item.m_UpperY = ( drawSize.y / 2 ) - m_fontSize.y;
    item.m_LowerY = drawSize.y - m_fontSize.y;

    item.m_UpperText = textUpper;
    item.m_LowerText = textLower;
    item.m_Color = color;
    m_Items.push_back( item );
    m_last_x += computeTextSize( text ).x;

    Refresh();
}


/*****************************************************************************/
/*****************************************************************************/
void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H,
void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H,
+9 −8
Original line number Original line Diff line number Diff line
@@ -73,8 +73,8 @@ void ReAnnotatePowerSymbolsOnly( void )
            if( DrawList->Type() != TYPE_SCH_COMPONENT )
            if( DrawList->Type() != TYPE_SCH_COMPONENT )
                continue;
                continue;
            SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList;
            SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList;
            EDA_LibComponentStruct* Entry =
            LIB_COMPONENT* Entry =
                ( EDA_LibComponentStruct* )FindLibPart( DrawLibItem->m_ChipName );
                CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );


            if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) )
            if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) )
                continue;
                continue;
@@ -347,14 +347,15 @@ int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
    int             NbrCmp   = 0;
    int             NbrCmp   = 0;
    EDA_BaseStruct* DrawList = aSheet->LastDrawList();
    EDA_BaseStruct* DrawList = aSheet->LastDrawList();
    SCH_COMPONENT*  DrawLibItem;
    SCH_COMPONENT*  DrawLibItem;
    EDA_LibComponentStruct* Entry;
    LIB_COMPONENT*  Entry;


    for( ; DrawList != NULL;   DrawList = DrawList->Next() )
    for( ; DrawList != NULL;   DrawList = DrawList->Next() )
    {
    {
        if( DrawList->Type() == TYPE_SCH_COMPONENT )
        if( DrawList->Type() == TYPE_SCH_COMPONENT )
        {
        {
            DrawLibItem = (SCH_COMPONENT*) DrawList;
            DrawLibItem = (SCH_COMPONENT*) DrawList;
            Entry = ( EDA_LibComponentStruct* )FindLibPart( DrawLibItem->m_ChipName );
            Entry =
                CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
            if( Entry == NULL )
            if( Entry == NULL )
                continue;
                continue;


+2 −3
Original line number Original line Diff line number Diff line
@@ -855,7 +855,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
 * @return a pointer to the pin
 * @return a pointer to the pin
 */
 */
{
{
    EDA_LibComponentStruct* Entry;
    LIB_COMPONENT* Entry;
    static LibEDA_BaseStruct* NextItem;
    static LibEDA_BaseStruct* NextItem;
    static int Multi, convert, TransMat[2][2];
    static int Multi, convert, TransMat[2][2];
    LibEDA_BaseStruct* DEntry;
    LibEDA_BaseStruct* DEntry;
@@ -866,8 +866,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
    if( aDrawLibItem )
    if( aDrawLibItem )
    {
    {
        NextItem = NULL;
        NextItem = NULL;
        Entry =
        Entry = CMP_LIBRARY::FindLibraryComponent( aDrawLibItem->m_ChipName );
            ( EDA_LibComponentStruct* )FindLibPart( aDrawLibItem->m_ChipName );


        if( Entry == NULL )
        if( Entry == NULL )
            return NULL;
            return NULL;
Loading