void SetHtmlDesc()
    {
        wxString raw_desc;

        if( m_part->IsRoot() )
        {
            raw_desc = m_part->GetDescription();
        }
        else
        {
            LIB_PART* root = m_part->GetPart();

            for( size_t i = 0; i < root->GetAliasCount(); ++i )
            {
                LIB_ALIAS* alias = root->GetAlias( i );

                if( alias && !alias->GetDescription().empty() )
                {
                    raw_desc = alias->GetDescription();
                    break;
                }
            }
        }

        m_html.Replace( "__DESC__", wxString::Format( DescFormat, EscapedHTML( raw_desc ) ) );
    }
示例#2
0
void DIALOG_CHOOSE_COMPONENT::OnHandlePreviewRepaint( wxPaintEvent& aRepaintEvent )
{
    int unit = 0;
    LIB_ALIAS*  selection = m_search_container->GetSelectedAlias( &unit );
    LIB_PART*   part = selection ? selection->GetPart() : NULL;

    // Don't draw anything (not even the background) if we don't have
    // a part to show
    if( !part )
        return;

    if( selection->IsRoot() )
    {
        // just show the part directly
        renderPreview( part, unit );
    }
    else
    {
        // switch out the name temporarily for the alias name
        wxString tmp( part->GetName() );
        part->SetName( selection->GetName() );

        renderPreview( part, unit );

        part->SetName( tmp );
    }
}
示例#3
0
/**
 * Function RedrawActiveWindow
 * Display the current selected component.
 * If the component is an alias, the ROOT component is displayed
*/
void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
    LIB_COMPONENT* component;
    LIB_ALIAS*     entry;
    CMP_LIBRARY*   lib;
    wxString       msg;
    wxString       tmp;

    lib = CMP_LIBRARY::FindLibrary( m_libraryName );

    if( lib == NULL )
        return;

    entry = lib->FindEntry( m_entryName );

    if( entry == NULL )
        return;

    component = entry->GetComponent();

    m_canvas->DrawBackGround( DC );

    if( !entry->IsRoot() )
    {
        if( component == NULL )     // Should not occur
            return;

        // Temporarily change the name field text to reflect the alias name.
        msg = entry->GetName();
        tmp = component->GetName();
        component->SetName( msg );

        if( m_unit < 1 )
            m_unit = 1;

        if( m_convert < 1 )
            m_convert = 1;
    }
    else
    {
        msg = _( "None" );
    }

    component->Draw( m_canvas, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE );

    /* Redraw the cursor */
    m_canvas->DrawCrossHair( DC );

    if( !tmp.IsEmpty() )
        component->SetName( tmp );

    ClearMsgPanel();
    AppendMsgPanel( _( "Part" ), component->GetName(), BLUE, 6 );
    AppendMsgPanel( _( "Alias" ), msg, RED, 6 );
    AppendMsgPanel( _( "Description" ), entry->GetDescription(), CYAN, 6 );
    AppendMsgPanel( _( "Key words" ), entry->GetKeyWords(), DARKDARKGRAY );
}
 void SetHtmlAliasOf()
 {
     if( m_part->IsRoot() )
     {
         m_html.Replace( "__ALIASOF__", wxEmptyString );
     }
     else
     {
         LIB_PART* root = m_part->GetPart();
         const wxString root_name = ( root ? root->GetName() : _( "Unknown" ) );
         m_html.Replace(
             "__ALIASOF__", wxString::Format( AliasOfFormat, EscapedHTML( root_name ) ) );
     }
 }
示例#5
0
void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
    LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName );

    if( !entry )
        return;

    LIB_PART* part = entry->GetPart();

    if( !part )
        return;

    wxString    msg;
    wxString    tmp;

    m_canvas->DrawBackGround( DC );

    if( !entry->IsRoot() )
    {
        // Temporarily change the name field text to reflect the alias name.
        msg = entry->GetName();
        tmp = part->GetName();

        part->SetName( msg );

        if( m_unit < 1 )
            m_unit = 1;

        if( m_convert < 1 )
            m_convert = 1;
    }
    else
        msg = _( "None" );

    part->Draw( m_canvas, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE );

    // Redraw the cursor
    m_canvas->DrawCrossHair( DC );

    if( !tmp.IsEmpty() )
        part->SetName( tmp );

    ClearMsgPanel();
    AppendMsgPanel( _( "Part" ), part->GetName(), BLUE, 6 );
    AppendMsgPanel( _( "Alias" ), msg, RED, 6 );
    AppendMsgPanel( _( "Description" ), entry->GetDescription(), CYAN, 6 );
    AppendMsgPanel( _( "Key words" ), entry->GetKeyWords(), DARKDARKGRAY );
}
示例#6
0
bool DIALOG_CHOOSE_COMPONENT::updateSelection()
{
    int unit = 0;
    LIB_ALIAS* selection = m_search_container->GetSelectedAlias( &unit );

    m_componentView->Refresh();

    m_componentDetails->Clear();

    if( selection == NULL )
        return false;

    m_componentDetails->Freeze();
    wxFont font_normal = m_componentDetails->GetFont();
    wxFont font_bold = m_componentDetails->GetFont();
    font_bold.SetWeight( wxFONTWEIGHT_BOLD );

    wxTextAttr headline_attribute;
    headline_attribute.SetFont( font_bold );
    wxTextAttr text_attribute;
    text_attribute.SetFont( font_normal );

    const wxString name = selection->GetName();

    if ( !name.empty() )
    {
        m_componentDetails->SetDefaultStyle( headline_attribute );
        m_componentDetails->AppendText( name );
    }

    const wxString description = selection->GetDescription();

    if( !description.empty() )
    {
        if ( !m_componentDetails->IsEmpty() )
            m_componentDetails->AppendText( wxT( "\n\n" ) );

        m_componentDetails->SetDefaultStyle( headline_attribute );
        m_componentDetails->AppendText( _( "Description\n" ) );
        m_componentDetails->SetDefaultStyle( text_attribute );
        m_componentDetails->AppendText( description );
    }

    const wxString keywords = selection->GetKeyWords();

    if( !keywords.empty() )
    {
        if ( !m_componentDetails->IsEmpty() )
            m_componentDetails->AppendText( wxT( "\n\n" ) );

        m_componentDetails->SetDefaultStyle( headline_attribute );
        m_componentDetails->AppendText( _( "Keywords\n" ) );
        m_componentDetails->SetDefaultStyle( text_attribute );
        m_componentDetails->AppendText( keywords );
    }

    if ( !selection->IsRoot() )
    {
        LIB_PART* root_part = selection->GetPart();
        const wxString root_component_name( root_part ? root_part->GetName() : _( "Unknown" ) );

        if ( !m_componentDetails->IsEmpty() )
            m_componentDetails->AppendText( wxT( "\n\n" ) );

        m_componentDetails->SetDefaultStyle( headline_attribute );
        m_componentDetails->AppendText( _( "Alias of " ) );
        m_componentDetails->SetDefaultStyle( text_attribute );
        m_componentDetails->AppendText( root_component_name );
    }

    m_componentDetails->SetInsertionPoint( 0 );  // scroll up.
    m_componentDetails->Thaw();

    return true;
}