Commit 260ca0e7 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio
Browse files

Added support for decoupling stored text from shown text in EDA_TEXT

Factored out text ellipsing support to max 15 character (for generating menu items)
parent 3132690c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
            {
                WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
                plotter->Text( text->GetTextPosition(), text->GetColor(),
                               text->GetText(), text->GetOrientation(),
                               text->GetShownText(), text->GetOrientation(),
                               text->GetSize(),
                               text->GetHorizJustify(), text->GetVertJustify(),
                               text->GetPenWidth(),
+22 −7
Original line number Diff line number Diff line
@@ -90,6 +90,21 @@ int EDA_TEXT::LenSize( const wxString& aLine ) const
    return GraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold );
}


wxString EDA_TEXT::ShortenedShownText() const
{
    wxString tmp = GetShownText();
    tmp.Replace( wxT( "\n" ), wxT( " " ) );
    tmp.Replace( wxT( "\r" ), wxT( " " ) );
    tmp.Replace( wxT( "\t" ), wxT( " " ) );

    if( tmp.Length() > 15 )
        tmp = tmp.Left( 12 ) + wxT( "..." );

    return tmp;
}


/**
 * Function GetInterline
 * return the distance between 2 text lines
@@ -106,13 +121,13 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
    EDA_RECT       rect;
    wxPoint        pos;
    wxArrayString* list = NULL;
    wxString       text = m_Text;
    wxString       text = GetShownText();
    int            thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
    int            linecount = 1;

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

        if ( list->GetCount() )     // GetCount() == 0 for void strings
        {
@@ -129,7 +144,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
    int    dx = LenSize( text );
    int    dy = GetInterline( aThickness );

    /* Creates bounding box (rectangle) for an horizontal text */
    // Creates bounding box (rectangle) for an horizontal text
    wxSize textsize = wxSize( dx, dy );

    if( aInvertY )
@@ -257,7 +272,7 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
    if( m_MultilineAllowed )
    {
        std::vector<wxPoint> positions;
        wxArrayString* list = wxStringSplit( m_Text, '\n' );
        wxArrayString* list = wxStringSplit( GetShownText(), '\n' );
        positions.reserve( list->Count() );

        GetPositionsOfLinesOfMultilineText(positions, list->Count() );
@@ -273,7 +288,7 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
    }
    else
        drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
                           aDrawMode, aFillMode, m_Text, m_Pos );
                           aDrawMode, aFillMode, GetShownText(), m_Pos );

    // Draw text anchor, if requested
    if( aAnchor_color != UNSPECIFIED_COLOR )
@@ -330,7 +345,7 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
                                  const wxPoint& aOffset, EDA_COLOR_T aColor,
                                  GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode,
                                  wxString& aText, wxPoint aPos )
                                  const wxString& aText, const wxPoint &aPos )
{
    int width = m_Thickness;

@@ -474,7 +489,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf

    if( IsMultilineAllowed() )
    {
        wxArrayString* list = wxStringSplit( GetText(), '\n' );
        wxArrayString* list = wxStringSplit( GetShownText(), '\n' );
        std::vector<wxPoint> positions;
        positions.reserve( list->Count() );
        GetPositionsOfLinesOfMultilineText( positions, list->Count() );
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const
    aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
    aGal->SetLineWidth( aItem->GetThickness() );
    aGal->SetTextAttributes( aItem );
    aGal->StrokeText( aItem->GetText(), VECTOR2D( 0, 0 ), 0.0 );
    aGal->StrokeText( aItem->GetShownText(), VECTOR2D( 0, 0 ), 0.0 );
    aGal->Restore();
}

+1 −1
Original line number Diff line number Diff line
@@ -452,7 +452,7 @@ void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
        // The reference is a special case: we shoud change the basic text
        // to add '?' and the part id
        LIB_FIELD& field = (LIB_FIELD&) item;
        wxString tmp = field.GetText();
        wxString tmp = field.GetShownText();
        if( field.GetId() == REFERENCE )
        {
            wxString text = field.GetFullText( aUnit );
+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC

        if( LibItem )
            items.push_back( MSG_PANEL_ITEM( LibItem->GetRef( m_CurrentSheet ),
                                             LibItem->GetField( VALUE )->GetText(), DARKCYAN ) );
                                             LibItem->GetField( VALUE )->GetShownText(), DARKCYAN ) );

        SetMsgPanel( items );

Loading