Beispiel #1
0
void SCH_TEXT::Plot( PLOTTER* aPlotter )
{
    static std::vector <wxPoint> Poly;
    COLOR4D  color = GetLayerColor( GetLayer() );
    int      tmp = GetThickness();
    int      thickness = GetPenSize();

    // Two thicknesses are set here:
    // The first is for EDA_TEXT, which controls the interline spacing based on text thickness
    // The second is for the output that sets the actual stroke size
    SetThickness( thickness );
    aPlotter->SetCurrentLineWidth( thickness );

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

        GetPositionsOfLinesOfMultilineText(positions, (int) strings_list.Count() );

        for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
        {
            wxPoint textpos = positions[ii] + GetSchematicTextOffset();
            wxString& txt = strings_list.Item( ii );
            aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(),
                            GetHorizJustify(), GetVertJustify(),
                            thickness, IsItalic(), IsBold() );
        }
    }
    else
    {
        wxPoint textpos = GetTextPos() + GetSchematicTextOffset();

        aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
                        GetHorizJustify(), GetVertJustify(),
                        thickness, IsItalic(), IsBold() );
    }

    // Draw graphic symbol for global or hierarchical labels
    CreateGraphicShape( Poly, GetTextPos() );

    aPlotter->SetCurrentLineWidth( GetPenSize() );

    if( Poly.size() )
        aPlotter->PlotPoly( Poly, NO_FILL );

    SetThickness( tmp );
}
Beispiel #2
0
////////////////////////////////////////////////////////////////////
// Public functions
//
void CDrawField::Draw( int page, CDC* dc )
/* ============================================================
	Function :		CDrawField::Draw
	Description :	Draws this object.
	Access :		Public
					
	Return :		void
	Parameters :	int page	-	Current page
					CDC* dc		-	CDC to draw to

	Usage :			Called by the generator to draw the object.

   ============================================================*/
{

	CString title = GetTitle();
	CDoubleRect rect = GetPosition();
	CUnitConversion::InchesToPixels( rect );

	CRect r( static_cast< int >( rect.left ), static_cast< int >( rect.top ), static_cast< int >( rect.right ), static_cast< int >( rect.bottom ) );
	CUnitConversion::AdjustPixelsToPaper( dc, r );

	LOGFONT	lf;
	ZeroMemory( &lf, sizeof( lf ) );

	lstrcpy( lf.lfFaceName, GetFontName() );
	lf.lfHeight = CUnitConversion::PointsToPixels( static_cast< double >( GetFontSize() ) / 10.0 );
	lf.lfItalic = static_cast< BYTE >( GetFontItalic() );
	lf.lfUnderline = static_cast< BYTE >( GetFontUnderline() );
	lf.lfStrikeOut = static_cast< BYTE >( GetFontStrikeout() );
	lf.lfCharSet = static_cast< BYTE >( GetFontCharset() );

	if( GetFontBold() )
		lf.lfWeight = FW_BOLD;
	else
		lf.lfWeight = FW_NORMAL;

	if( IsBold( title ) )
		lf.lfWeight = FW_BOLD;

	if( IsItalic( title ) )
		lf.lfItalic = TRUE;

	CFont	font;
	font.CreateFontIndirect( &lf );

	dc->SelectObject( &font );
	int color = dc->SetTextColor( GetFontColor() );
	int mode = dc->SetBkMode( TRANSPARENT );
	int justification = GetJustification();

	ReplaceFields( page, title );

	dc->DrawText( title, r, DT_NOPREFIX | DT_WORDBREAK | justification );

	dc->SetBkMode( mode );
	dc->SetTextColor( color );
	dc->SelectStockObject( ANSI_VAR_FONT );

}
void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
                      const TRANSFORM& aTransform )
{
    if( IsVoid() )
        return;

    /* Calculate the text orientation, according to the component
     * orientation/mirror */
    int orient = (int) GetTextAngle();

    if( aTransform.y1 )  // Rotate component 90 deg.
    {
        if( orient == TEXT_ANGLE_HORIZ )
            orient = TEXT_ANGLE_VERT;
        else
            orient = TEXT_ANGLE_HORIZ;
    }

    EDA_RECT BoundaryBox = GetBoundingBox();
    BoundaryBox.RevertYAxis();

    EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
    EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
    wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() )
                      + aOffset;

    aPlotter->Text( textpos, GetDefaultColor(), GetShownText(),
                    orient, GetTextSize(),
                    hjustify, vjustify,
                    GetPenSize(), IsItalic(), IsBold() );
}
Beispiel #4
0
void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
                     const TRANSFORM& aTransform )
{
    wxASSERT( plotter != NULL );

    EDA_RECT bBox = GetBoundingBox();
    // convert coordinates from draw Y axis to libedit Y axis
    bBox.RevertYAxis();
    wxPoint txtpos = bBox.Centre();

    /* The text orientation may need to be flipped if the
     * transformation matrix causes xy axes to be flipped. */
    int t1  = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
    wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset;

    // Get color
    COLOR4D color;

    if( plotter->GetColorMode() )       // Used normal color or selected color
        color = IsSelected() ? GetItemSelectedColor() : GetDefaultColor();
    else
        color = COLOR4D::BLACK;

    plotter->Text( pos, color, GetShownText(),
                   t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT,
                   GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                   GetPenSize(), IsItalic(), IsBold() );
}
Beispiel #5
0
void RichTxt::FormatInfo::ApplyTo(RichPara::CharFormat& fmt) const
{
	if(charvalid & BOLD)
		fmt.Bold(IsBold());
	if(charvalid & ITALIC)
		fmt.Italic(IsItalic());
	if(charvalid & UNDERLINE)
		fmt.Underline(IsUnderline());
	if(charvalid & STRIKEOUT)
		fmt.Strikeout(IsStrikeout());
	if(charvalid & NOAA)
		fmt.NonAntiAliased(IsNonAntiAliased());
	if(charvalid & CAPITALS)
		fmt.capitals = capitals;
	if(charvalid & DASHED)
		fmt.dashed = dashed;
	if(charvalid & SSCRIPT)
		fmt.sscript = sscript;
	if(charvalid & FACE)
		fmt.Face(GetFace());
	if(charvalid & HEIGHT)
		fmt.Height(GetHeight());
	if(charvalid & LANGUAGE)
		fmt.language = language;
	if(charvalid & INK)
		fmt.ink = ink;
	if(charvalid & PAPER)
		fmt.paper = paper;
	if(charvalid & LANG)
		fmt.language = language;
	if(charvalid & LINK)
		fmt.link = link;
	if(charvalid & INDEXENTRY)
		fmt.indexentry = indexentry;
}
void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
    throw( IO_ERROR )
{
#ifndef GERBVIEW        // Gerbview does not use EDA_TEXT::Format
                        // and does not define FMT_IU, used here
                        // however this function should exist
    if( !IsDefaultFormatting() )
    {
        aFormatter->Print( aNestLevel+1, "(effects" );

        if( ( m_Size.x != Mils2iu( DEFAULT_SIZE_TEXT ) )
          || ( m_Size.y != Mils2iu( DEFAULT_SIZE_TEXT ) )
          || ( m_Thickness != 0 ) || m_Bold || m_Italic )
        {
            aFormatter->Print( 0, " (font" );

            // Add font support here at some point in the future.

            if( ( m_Size.x != Mils2iu( DEFAULT_SIZE_TEXT ) )
              || ( m_Size.y != Mils2iu( DEFAULT_SIZE_TEXT ) ) )
                aFormatter->Print( 0, " (size %s %s)", FMT_IU( m_Size.GetHeight() ).c_str(),
                                   FMT_IU( m_Size.GetWidth() ).c_str() );

            if( m_Thickness != 0 )
                aFormatter->Print( 0, " (thickness %s)", FMT_IU( GetThickness() ).c_str() );

            if( m_Bold )
                aFormatter->Print( 0, " bold" );

            if( IsItalic() )
                aFormatter->Print( 0, " italic" );

            aFormatter->Print( 0, ")");
        }

        if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
          || ( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) )
        {
            aFormatter->Print( 0, " (justify");

            if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
                aFormatter->Print( 0, (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );

            if( m_VJustify != GR_TEXT_VJUSTIFY_CENTER )
                aFormatter->Print( 0, (m_VJustify == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );

            if( m_Mirror )
                aFormatter->Print( 0, " mirror" );

            aFormatter->Print( 0, ")" );
        }

        // As of now the only place this is used is in Eeschema to hide or show the text.
        if( m_Attributs )
            aFormatter->Print( 0, " hide" );

        aFormatter->Print( 0, ")\n" );
    }
#endif
}
Beispiel #7
0
void RichTxt::FormatInfo::Combine(const RichPara::CharFormat& fmt)
{
	if(IsBold() != fmt.IsBold()) {
		charvalid &= ~BOLD;
		NoBold();
	}
	if(IsItalic() != fmt.IsItalic()) {
		charvalid &= ~ITALIC;
		NoItalic();
	}
	if(IsUnderline() != fmt.IsUnderline()) {
		charvalid &= ~UNDERLINE;
		NoUnderline();
	}
	if(IsStrikeout() != fmt.IsStrikeout()) {
		charvalid &= ~STRIKEOUT;
		NoStrikeout();
	}
	if(IsNonAntiAliased() != fmt.IsNonAntiAliased()) {
		charvalid &= ~NOAA;
		NoNonAntiAliased();
	}
	if(capitals != fmt.capitals) {
		charvalid &= ~CAPITALS;
		capitals = false;
	}
	if(dashed != fmt.dashed) {
		charvalid &= ~DASHED;
		dashed = false;
	}
	if(sscript != fmt.sscript) {
		charvalid &= ~SSCRIPT;
		sscript = 0;
	}
	if(GetFace() != fmt.GetFace())
		charvalid &= ~FACE;
	if(GetHeight() != fmt.GetHeight())
		charvalid &= ~HEIGHT;
	if(ink != fmt.ink) {
		charvalid &= ~INK;
		ink = Null;
	}
	if(paper != fmt.paper) {
		charvalid &= ~PAPER;
		paper = Null;
	}
	if(language != fmt.language) {
		charvalid &= ~LANG;
		language = 0;
	}
	if(link != fmt.link) {
		charvalid &= ~LINK;
		link = Null;
	}
	if(indexentry != fmt.indexentry) {
		charvalid &= ~INDEXENTRY;
		indexentry = Null;
	}
}
void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
                            SHAPE_POLY_SET& aCornerBuffer,
                            int                    aClearanceValue,
                            int                    aCircleToSegmentsCount,
                            double                 aCorrectionFactor ) const
{
    wxSize size = GetSize();

    if( IsMirrored() )
        size.x = -size.x;

    s_cornerBuffer = &aCornerBuffer;
    s_textWidth  = GetThickness() + ( 2 * aClearanceValue );
    s_textCircle2SegmentCount = aCircleToSegmentsCount;
    EDA_COLOR_T color = BLACK;  // not actually used, but needed by DrawGraphicText

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

        for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
        {
            wxString txt = strings_list.Item( ii );
            DrawGraphicText( NULL, NULL, positions[ii], color,
                             txt, GetOrientation(), size,
                             GetHorizJustify(), GetVertJustify(),
                             GetThickness(), IsItalic(),
                             true, addTextSegmToPoly );
        }
    }
    else
    {
        DrawGraphicText( NULL, NULL, GetTextPosition(), color,
                         GetShownText(), GetOrientation(), size,
                         GetHorizJustify(), GetVertJustify(),
                         GetThickness(), IsItalic(),
                         true, addTextSegmToPoly );
    }
}
void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuffer ) const
{
    wxSize size = GetSize();

    if( IsMirrored() )
        NEGATE( size.x );

    s_cornerBuffer = &aCornerBuffer;
    EDA_COLOR_T color = BLACK;  // not actually used, but needed by DrawGraphicText

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

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

        delete list;
    }
    else
    {
        DrawGraphicText( NULL, NULL, GetTextPosition(), color,
                         GetText(), GetOrientation(), size,
                         GetHorizJustify(), GetVertJustify(),
                         GetThickness(), IsItalic(),
                         true, addTextSegmToBuffer );
    }
}
void SCH_FIELD::Plot( PLOTTER* aPlotter )
{
    SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();

    wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
                 wxT( "Cannot plot field with invalid parent." ) );

    COLOR4D color = GetLayerColor( GetLayer() );

    if( !IsVisible() )
        return;

    if( IsVoid() )
        return;

    /* Calculate the text orientation, according to the component
     * orientation/mirror */
    int orient = GetTextAngle();

    if( parent->GetTransform().y1 )  // Rotate component 90 deg.
    {
        if( orient == TEXT_ANGLE_HORIZ )
            orient = TEXT_ANGLE_VERT;
        else
            orient = TEXT_ANGLE_HORIZ;
    }

    /* Calculate the text justification, according to the component
     * orientation/mirror
     * this is a bit complicated due to cumulative calculations:
     * - numerous cases (mirrored or not, rotation)
     * - the DrawGraphicText function recalculate also H and H justifications
     *      according to the text orientation.
     * - When a component is mirrored, the text is not mirrored and
     *   justifications are complicated to calculate
     * so the more easily way is to use no justifications ( Centered text )
     * and use GetBoundaryBox to know the text coordinate considered as centered
     */
    EDA_RECT BoundaryBox = GetBoundingBox();
    EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
    EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
    wxPoint  textpos = BoundaryBox.Centre();

    int      thickness = GetPenSize();

    aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
            hjustify, vjustify,
            thickness, IsItalic(), IsBold() );
}
/// Initializes a wxFont object using the FontSetting data
/// @param font wxFont object to initialize
void FontSetting::GetFont(wxFont& font) const
{
    //------Last Checked------//
    // - Dec 6, 2004
    font.SetPointSize(GetPointSize());
    font.SetFamily(wxDEFAULT);
    font.SetStyle(((IsItalic()) ? wxITALIC : wxNORMAL));
    
    if (m_weight <= weightLight)
        font.SetWeight(wxLIGHT);
    else if (m_weight < weightBold)
        font.SetWeight(wxNORMAL);
    else
        font.SetWeight(wxBOLD);
    font.SetUnderlined(IsUnderline());
    font.SetFaceName(GetFaceName());
}
Beispiel #12
0
void ListBox::UpdateValues()
{
	Size newSize = Size(m_width, (m_charHeight + m_gapBetLines) * m_lineNbr + m_lineOffset.y * 2 - m_gapBetLines);
	if (!IsSize(newSize))
		SetSize(newSize);
	for (uint8 i = 0; i < m_lineNbr; i++)
	{
		m_lines[i]->SetPosition(Point(m_lineOffset.x, (GetCharHeight() + m_gapBetLines) * i + m_lineOffset.y));
		m_lines[i]->SetColor(GetColor());
		m_lines[i]->SetCharHeight(GetCharHeight());
		m_lines[i]->SetCharWidth(GetCharWidh());
		m_lines[i]->SetCharInterval(GetCharInterval());
		if (IsItalic())
			m_lines[i]->SetItalic();
		else m_lines[i]->RemoveItalic();
	}
}
bool SCH_FIELD::Save( FILE* aFile ) const
{
    char hjustify = 'C';

    if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
        hjustify = 'L';
    else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
        hjustify = 'R';

    char vjustify = 'C';

    if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
        vjustify = 'B';
    else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
        vjustify = 'T';

    if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
                 m_id,
                 EscapedUTF8( m_Text ).c_str(),     // wraps in quotes too
                 GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V',
                 GetTextPos().x, GetTextPos().y,
                 GetTextWidth(),
                 !IsVisible(),
                 hjustify, vjustify,
                 IsItalic() ? 'I' : 'N',
                 IsBold() ? 'B' : 'N' ) == EOF )
    {
        return false;
    }

    // Save field name, if the name is user definable
    if( m_id >= FIELD1 )
    {
        if( fprintf( aFile, " %s", EscapedUTF8( m_name ).c_str() ) == EOF )
        {
            return false;
        }
    }

    if( fprintf( aFile, "\n" ) == EOF )
    {
        return false;
    }

    return true;
}
Beispiel #14
0
void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
                             void* aData, const TRANSFORM& aTransform )
{
    wxPoint  text_pos;
    COLOR4D  color = IsVisible() ? GetDefaultColor() : GetInvisibleItemColor();
    int      linewidth = GetPenSize();

    text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;

    wxString text;

    if( aData )
        text = *(wxString*)aData;
    else
        text = m_Text;

    EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;

    DrawGraphicText( clipbox, aDC, text_pos, color, text, GetTextAngle(), GetTextSize(),
                     GetHorizJustify(), GetVertJustify(), linewidth, IsItalic(), IsBold() );
}
Beispiel #15
0
void CFontDialog::GetCharFormat(CHARFORMAT& cf) const
{
	USES_CONVERSION;
	cf.dwEffects = 0;
	cf.dwMask = 0;
	if ((m_cf.Flags & CF_NOSTYLESEL) == 0)
	{
		cf.dwMask |= CFM_BOLD | CFM_ITALIC;
		cf.dwEffects |= (IsBold()) ? CFE_BOLD : 0;
		cf.dwEffects |= (IsItalic()) ? CFE_ITALIC : 0;
	}
	if ((m_cf.Flags & CF_NOSIZESEL) == 0)
	{
		cf.dwMask |= CFM_SIZE;
		//GetSize() returns in tenths of points so mulitply by 2 to get twips
		cf.yHeight = GetSize()*2;
	}

	if ((m_cf.Flags & CF_NOFACESEL) == 0)
	{
		cf.dwMask |= CFM_FACE;
		cf.bPitchAndFamily = m_cf.lpLogFont->lfPitchAndFamily;
		lstrcpyA(cf.szFaceName, T2A((LPTSTR)(LPCTSTR)GetFaceName()));
	}

	if (m_cf.Flags & CF_EFFECTS)
	{
		cf.dwMask |= CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR;
		cf.dwEffects |= (IsUnderline()) ? CFE_UNDERLINE : 0;
		cf.dwEffects |= (IsStrikeOut()) ? CFE_STRIKEOUT : 0;
		cf.crTextColor = GetColor();
	}
	if ((m_cf.Flags & CF_NOSCRIPTSEL) == 0)
	{
		cf.bCharSet = m_cf.lpLogFont->lfCharSet;
		cf.dwMask |= CFM_CHARSET;
	}
	cf.yOffset = 0;
}
void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
{
    m_ConstrainedTextSize = m_TextSize;

    if( m_ConstrainedTextSize.x == 0  )
        m_ConstrainedTextSize.x = m_DefaultTextSize.x;

    if( m_ConstrainedTextSize.y == 0 )
        m_ConstrainedTextSize.y = m_DefaultTextSize.y;

    if( m_BoundingBoxSize.x || m_BoundingBoxSize.y )
    {
        int linewidth = 0;
        // to know the X and Y size of the line, we should use
        // EDA_TEXT::GetTextBox()
        // but this function uses integers
        // So, to avoid truncations with our unit in mm, use microns.
        wxSize size_micron;
        size_micron.x = KiROUND( m_ConstrainedTextSize.x * 1000.0 );
        size_micron.y = KiROUND( m_ConstrainedTextSize.y * 1000.0 );
        WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, this->m_FullText,
                                               wxPoint(0,0),
                                               size_micron,
                                               linewidth, BLACK,
                                               IsItalic(), IsBold() ) );
        dummy.SetMultilineAllowed( true );
        TransfertSetupToGraphicText( &dummy );
        EDA_RECT rect = dummy.GetTextBox();
        DSIZE size;
        size.x = rect.GetWidth() / 1000.0;
        size.y = rect.GetHeight() / 1000.0;

        if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x )
            m_ConstrainedTextSize.x *= m_BoundingBoxSize.x / size.x;

        if( m_BoundingBoxSize.y &&  size.y > m_BoundingBoxSize.y )
            m_ConstrainedTextSize.y *= m_BoundingBoxSize.y / size.y;
    }
}
Beispiel #17
0
void ListBox::InitListBox(uint8 lineNbr, int8 gap, Point offset, bool scrollable, Texture* uptext, Texture* downtext)
{
	m_lineNbr = lineNbr;
	m_gapBetLines = gap;
	m_scrollable = scrollable;
	m_lineOffset = offset;
	m_width = GetSize().w;
	m_showButtons = uptext != 0 || downtext != 0;

	m_lines = new Label*[lineNbr];
	std::ostringstream ss;
	for (uint8 i = 0; i < m_lineNbr; i++)
	{
		m_lines[i] = new Label();
		ss << GetName() << "_line" << (m_lineNbr - i - 1);
		m_lines[i]->InitControl(ss.str());
		m_lines[i]->InitLocalizable(Point(offset.x, (GetCharHeight() + m_gapBetLines) * i + offset.y) + GetPosition(), 0, this);
		m_lines[i]->InitTextual(GetColor(), IsItalic(), GetCharHeight(), GetCharWidh(), GetCharInterval());
		ss.str("");
	}
	SetSize(Size(m_width, (GetCharHeight() + gap) * lineNbr + offset.y * 2 - gap));
	if (m_showButtons)
	{
		// Init boutons
		m_upArrow = new Button();
		ss << m_name << "_uparrow";
		m_upArrow->InitControl(ss.str());
		m_upArrow->InitLocalizable(Point(GetSize().w - 30, 30) + GetPosition(), Size(30, 20), uptext, GetParent());
		ss.str("");
		m_downArrow = new Button();
		ss << m_name << "_downarrow";
		m_downArrow->InitControl(ss.str());
		m_downArrow->InitLocalizable(Point(GetSize().w - 30, 0) + GetPosition(), Size(30, 20), downtext, GetParent());
		ss.str("");
		// Events
		m_upArrow->OnClick.Attach(this, &ListBox::ScrollUp);
		m_downArrow->OnClick.Attach(this, &ListBox::ScrollDown);
	}
}
Beispiel #18
0
void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
                            COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                            const TRANSFORM& aTransform )
{
    COLOR4D color = GetDefaultColor();

    if( aColor == COLOR4D::UNSPECIFIED )       // Used normal color or selected color
    {
        if( IsSelected() )
            color = GetItemSelectedColor();
    }
    else
    {
        color = aColor;
    }

    GRSetDrawMode( aDC, aDrawMode );

    /* Calculate the text orientation, according to the component
     * orientation/mirror (needed when draw text in schematic)
     */
    int orient = GetTextAngle();

    if( aTransform.y1 )  // Rotate component 90 degrees.
    {
        if( orient == TEXT_ANGLE_HORIZ )
            orient = TEXT_ANGLE_VERT;
        else
            orient = TEXT_ANGLE_HORIZ;
    }

    /* Calculate the text justification, according to the component
     * orientation/mirror this is a bit complicated due to cumulative
     * calculations:
     * - numerous cases (mirrored or not, rotation)
     * - the DrawGraphicText function recalculate also H and H justifications
     *      according to the text orientation.
     * - When a component is mirrored, the text is not mirrored and
     *   justifications are complicated to calculate
     * so the more easily way is to use no justifications ( Centered text )
     * and use GetBoundaryBox to know the text coordinate considered as centered
    */
    EDA_RECT bBox = GetBoundingBox();

    // convert coordinates from draw Y axis to libedit Y axis:
    bBox.RevertYAxis();
    wxPoint txtpos = bBox.Centre();

    // Calculate pos according to mirror/rotation.
    txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;

    EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
    DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, GetTextSize(),
                     GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(),
                     IsItalic(), IsBold() );


    /* Enable this to draw the bounding box around the text field to validate
     * the bounding box calculations.
     */
#if 0
    // bBox already uses libedit Y axis.
    bBox = aTransform.TransformCoordinate( bBox );
    bBox.Move( aOffset );
    GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA );
#endif
}
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                         const wxPoint& aOffset )
{
    if( aPanel == NULL )
        return;

    /* parent must *not* be NULL (a footprint text without a footprint
       parent has no sense) */
    wxASSERT( m_Parent );

    BOARD* brd = GetBoard( );

    auto frame = static_cast<PCB_BASE_FRAME*> ( aPanel->GetParent() );
    auto color = frame->Settings().Colors().GetLayerColor( GetLayer() );

    PCB_LAYER_ID text_layer = GetLayer();

    if( !brd->IsLayerVisible( m_Layer )
      || ( IsFrontLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_FR ) )
      || ( IsBackLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_BK ) ) )
        return;

    if( !brd->IsElementVisible( LAYER_MOD_REFERENCES ) && GetText() == wxT( "%R" ) )
        return;

    if( !brd->IsElementVisible( LAYER_MOD_VALUES ) && GetText() == wxT( "%V" ) )
        return;

    // Invisible texts are still drawn (not plotted) in LAYER_MOD_TEXT_INVISIBLE
    // Just because we must have to edit them (at least to make them visible)
    if( !IsVisible() )
    {
        if( !brd->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) )
            return;

        color = frame->Settings().Colors().GetItemColor( LAYER_MOD_TEXT_INVISIBLE );
    }

    auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aPanel->GetDisplayOptions() );

    // shade text if high contrast mode is active
    if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay )
    {
        PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer;

        if( !IsOnLayer( curr_layer ) )
            color = COLOR4D( DARKDARKGRAY );
    }

    // Draw mode compensation for the width
    int width = GetThickness();

    if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH )
        width = -width;

    GRSetDrawMode( aDC, aDrawMode );
    wxPoint pos = GetTextPos() - aOffset;

    // Draw the text anchor point
    if( brd->IsElementVisible( LAYER_ANCHOR ) )
    {
        COLOR4D anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR );
        GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color );
    }

    // Draw the text proper, with the right attributes
    wxSize size   = GetTextSize();
    double orient = GetDrawRotation();

    // If the text is mirrored : negate size.x (mirror / Y axis)
    if( IsMirrored() )
        size.x = -size.x;

    DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient,
                     size, GetHorizJustify(), GetVertJustify(),
                     width, IsItalic(), IsBold() );

    // Enable these line to draw the bounding box (debug test purpose only)
#if 0
    {
        EDA_RECT BoundaryBox = GetBoundingBox();
        GRRect( aPanel->GetClipBox(), aDC, BoundaryBox, 0, BROWN );
    }
#endif
}
Beispiel #20
0
void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
{
    wxString msg;

    switch( Type() )
    {
    case SCH_TEXT_T:               msg = _( "Graphic Text" );           break;
    case SCH_LABEL_T:              msg = _( "Label" );                  break;
    case SCH_GLOBAL_LABEL_T:       msg = _( "Global Label" );           break;
    case SCH_HIERARCHICAL_LABEL_T: msg = _( "Hierarchical Label" );     break;
    case SCH_SHEET_PIN_T:          msg = _( "Hierarchical Sheet Pin" ); break;
    default: return;
    }

    aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) );

    switch( GetLabelSpinStyle() )
    {
    case 0:  msg = _( "Horizontal" );        break;
    case 1:  msg = _( "Vertical up" );       break;
    case 2:  msg = _( "Horizontal invert" ); break;
    case 3:  msg = _( "Vertical down" );     break;
    default: msg = wxT( "???" );             break;
    }

    aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) );

    wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
    int style = 0;

    if( IsItalic() )
        style = 1;

    if( IsBold() )
        style += 2;

    aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) );


    // Display electricat type if it is relevant
    if( (Type() == SCH_GLOBAL_LABEL_T) ||
        (Type() == SCH_HIERARCHICAL_LABEL_T ) ||
        (Type() == SCH_SHEET_PIN_T ) )
    {
        switch( GetShape() )
        {
        case NET_INPUT:        msg = _( "Input" );           break;
        case NET_OUTPUT:       msg = _( "Output" );          break;
        case NET_BIDI:         msg = _( "Bidirectional" );   break;
        case NET_TRISTATE:     msg = _( "Tri-State" );       break;
        case NET_UNSPECIFIED:  msg = _( "Passive" );         break;
        default:               msg = wxT( "???" );           break;
        }

        aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) );
    }

    // Display text size (X or Y value, with are the same value in Eeschema)
    msg = MessageTextFromValue( aUnits, GetTextWidth(), true );
    aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) );

#if defined(DEBUG)

    if( auto conn = Connection( *g_CurrentSheet ) )
    {
        conn->AppendDebugInfoToMsgPanel( aList );
    }

    msg.Printf( "%p", this );
    aList.push_back( MSG_PANEL_ITEM( "Object Address", msg, RED ) );

#endif
}
Beispiel #21
0
////////////////////////////////////////////////////////////////////
// Public functions
//
void CDrawGrid::Draw( int page, CDC* dc )
/* ============================================================
	Function :		CDrawGrid::Draw
	Description :	Draws this object.
	Access :		Public
					
	Return :		void
	Parameters :	int page	-	Current page
					CDC* dc		-	CDC to draw to

	Usage :			Called by the generator to draw the object.

   ============================================================*/
{

	/////////////////////////////////
	// Get and convert grid position
	//

	int drawpage = page - GetPageOffset();
	CDoubleRect rect = GetPosition();
	CUnitConversion::InchesToPixels( rect );

	CRect r( static_cast< int >( rect.left ), static_cast< int >( rect.top ), static_cast< int >( rect.right ), static_cast< int >( rect.bottom ) );
	CUnitConversion::AdjustPixelsToPaper( dc, r );

	/////////////////////////////////
	// Create column widths and 
	// fonts 
	//

	int restWidth = 0;
	int sumWidth = 0;
	TContainer< CFont* > fonts;

	double lpi = static_cast< double >( GetLPI() );
	double inch = static_cast< double >( dc->GetDeviceCaps( LOGPIXELSY ) );
	int lineHeight = static_cast< int >( inch / lpi + .5 );

	int max = m_columns.GetSize();
	for( int t = 0 ; t < max ; t++ )
	{

		CColumn* column = m_columns.GetAt( t );
		if( column )
		{
			sumWidth += CUnitConversion::InchesToPixels( column->GetWidth() );
			fonts.Add( column->GetColumnFont() );
		}

	}

	// restWidth will be used for 
	// any 0-length field
	restWidth = r.Width() - sumWidth;

	/////////////////////////////////
	// Find start and end of data
	// 

	int start = m_pages.GetAt( drawpage )->m_startLine;
	int end = m_pages.GetAt( drawpage )->m_endLine;

	int mode = dc->SetBkMode( TRANSPARENT );
	COLORREF color = dc->GetTextColor();

	/////////////////////////////////
	// Border
	//

	const CBorderLine* borderline = GetBorder();
	CPen pen;
	CPen boldPen;

	if( borderline->GetVisible() )
	{
		// Draw a border around the grid
		int thickness = CUnitConversion::InchesToPixels( borderline->GetThickness() );
		pen.CreatePen( borderline->GetStyle(),
					   thickness,
					   borderline->GetColor() );

		dc->SelectObject( &pen );
		dc->SelectStockObject( NULL_BRUSH );
		dc->Rectangle( r );
		dc->SelectStockObject( NULL_PEN );
	}


	/////////////////////////////////
	// Line pens
	//

	const CBorderLine* columnline = GetColumnLine();
	const CBorderLine* rowline = GetRowLine();
	CPen* columnpen = NULL;
	CPen* rowpen = NULL;
	if( columnline->GetVisible() )
	{
		columnpen = new CPen;
		int thickness = CUnitConversion::InchesToPixels( columnline->GetThickness() );
		columnpen->CreatePen( columnline->GetStyle(),
					   thickness,
					   columnline->GetColor() );
	}

	if( rowline->GetVisible() )
	{
		rowpen = new CPen;
		int thickness = CUnitConversion::InchesToPixels( rowline->GetThickness() );
		rowpen->CreatePen( rowline->GetStyle(),
					   thickness,
					   rowline->GetColor() );
	}


	/////////////////////////////////
	// Column lines
	//

	if( columnpen )
	{

		dc->SelectObject( columnpen );
		int left = r.left;

		// Loop columns
		for( int i = 0 ; i < max - 1; i++ )
		{

			CColumn* column = m_columns.GetAt( i );
			if( column )
			{

				int pixelWidth = CUnitConversion::InchesToPixels( column->GetWidth() );
				if( pixelWidth == 0 )
					pixelWidth = restWidth;

				left += pixelWidth;

				dc->MoveTo( left, r.top );
				dc->LineTo( left, r.bottom );

			}

		}

		dc->SelectStockObject( NULL_PEN );

	}

	/////////////////////////////////
	// Loop and print column strings
	//

	int top = r.top;
	for(int t = start ; t < end ; t++ )
	{
		// Tokenize a line of data
		CString line( m_data[ t ] );
		int quarterHeight = lineHeight / 4;

		// Check if this is a separator 
		if( IsSeparator( line ) )
		{
			// Draw a line across the grid
			dc->SelectStockObject( BLACK_PEN );
			dc->MoveTo( r.left, top + quarterHeight );
			dc->LineTo( r.right, top + quarterHeight );
		}
		else if( IsDoubleSeparator( line ) )
		{
			// Draw a double line across the grid
			dc->SelectStockObject( BLACK_PEN );
			dc->MoveTo( r.left, top + quarterHeight );
			dc->LineTo( r.right, top + quarterHeight );
			dc->MoveTo( r.left, top + quarterHeight * 2 );
			dc->LineTo( r.right, top + quarterHeight * 2 );
		}
		else if( IsBoldSeparator( line ) )
		{
			// Draw a bold line across the grid
			boldPen.CreatePen( PS_SOLID, quarterHeight / 2, RGB( 0, 0, 0 ) );
			dc->SelectObject( boldPen );
			dc->MoveTo( r.left, top + quarterHeight );
			dc->LineTo( r.right, top + quarterHeight );
			dc->SelectStockObject( BLACK_PEN );
		}
		else
		{
			CTokenizer tok( line, _T( "|" ) );

			int left = r.left;
			// Loop columns
			for( int i = 0 ; i < max ; i++ )
			{
				CColumn* column = m_columns.GetAt( i );
				CRect drawRect( left, top, r.right, top + lineHeight );
				if( column )
				{
					// Get the data for this column
					CString data;
					tok.GetAt( i, data );

					// Get the width of the column
					int pixelWidth = CUnitConversion::InchesToPixels( column->GetWidth() );
					if( pixelWidth == 0 )
						pixelWidth = restWidth;

					// Set font
					CFont* font = fonts.GetAt( i );
					CFont* specialFont = NULL;

					if( font )
					{
						if( IsBold( data ) )
						{

							// Select a bold font 
							// here instead

							specialFont = new CFont;
							LOGFONT lf;

							font->GetLogFont( &lf );

							lf.lfWeight = FW_BOLD;
							specialFont->CreateFontIndirect( &lf );

						}

						if( IsItalic( data ))
						{

							// Select an italic font 
							// here instead

							specialFont = new CFont;
							LOGFONT lf;

							font->GetLogFont( &lf );

							lf.lfItalic = TRUE;
							specialFont->CreateFontIndirect( &lf );

						}
					}

					if( specialFont )
						dc->SelectObject( specialFont );
					else if( font )
						dc->SelectObject( font );

					// Create draw rect
					drawRect.SetRect( left, top, left + pixelWidth, top + lineHeight );

					// Add offsets for columns
					int offset = CUnitConversion::PointsToPixels( column->GetFontSize() / 40.0 );
					if( borderline->GetVisible() && i == 0 )
						offset += max( 1, CUnitConversion::InchesToPixels( borderline->GetThickness() ) );
					if( columnline->GetVisible() && i > 0 )
						offset += max( 1, CUnitConversion::InchesToPixels( columnline->GetThickness() ) );

					drawRect.left += offset;
					drawRect.right -= offset;

					// Draw data
					int justification = column->GetJustification();
					dc->DrawText( data, drawRect, DT_VCENTER | DT_NOPREFIX | DT_WORDBREAK | justification );

					if( specialFont )
						delete specialFont;

					// Increase x-coord
					left += pixelWidth;
				}


				/////////////////////////////////
				// Row dividers
				//

				if( rowpen && t < end )
				{

					dc->SelectObject( rowpen );
					dc->MoveTo( r.left, drawRect.bottom );
					dc->LineTo( r.right, drawRect.bottom );

				}

			}
		}

		// Increase y-coord
		top += lineHeight;

	}

	/////////////////////////////////
	// Restore everything
	//

	dc->SetBkMode( mode );
	dc->SetTextColor( color );
	dc->SelectStockObject( ANSI_VAR_FONT );
	dc->SelectStockObject( NULL_PEN );

	if( columnpen )
		delete columnpen;

	if( rowpen )
		delete rowpen;
	
}
void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
                      GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
    int            orient;
    COLOR4D        color;
    wxPoint        textpos;
    SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
    int            lineWidth = GetThickness();

    if( lineWidth == 0 )   // Use default values for pen size
    {
        if( IsBold() )
            lineWidth = GetPenSizeForBold( GetTextWidth() );
        else
            lineWidth = GetDefaultLineThickness();
    }

    // Clip pen size for small texts:
    lineWidth = Clamp_Text_PenSize( lineWidth, GetTextSize(), IsBold() );

    if( ( !IsVisible() && !m_forceVisible) || IsVoid() )
        return;

    GRSetDrawMode( aDC, aDrawMode );

    // Calculate the text orientation according to the component orientation.
    orient = GetTextAngle();

    if( parentComponent->GetTransform().y1 )  // Rotate component 90 degrees.
    {
        if( orient == TEXT_ANGLE_HORIZ )
            orient = TEXT_ANGLE_VERT;
        else
            orient = TEXT_ANGLE_HORIZ;
    }

    /* Calculate the text justification, according to the component
     * orientation/mirror this is a bit complicated due to cumulative
     * calculations:
     * - numerous cases (mirrored or not, rotation)
     * - the DrawGraphicText function recalculate also H and H justifications
     *      according to the text orientation.
     * - When a component is mirrored, the text is not mirrored and
     *   justifications are complicated to calculate
     * so the more easily way is to use no justifications ( Centered text )
     * and use GetBoundaryBox to know the text coordinate considered as centered
     */
    EDA_RECT boundaryBox = GetBoundingBox();
    textpos = boundaryBox.Centre() + aOffset;

    if( m_forceVisible )
    {
        color = COLOR4D( DARKGRAY );
    }
    else
    {
        if( m_id == REFERENCE )
            color = GetLayerColor( LAYER_REFERENCEPART );
        else if( m_id == VALUE )
            color = GetLayerColor( LAYER_VALUEPART );
        else
            color = GetLayerColor( LAYER_FIELDS );
    }

    EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
    DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
                     GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                     lineWidth, IsItalic(), IsBold() );

    // While moving: don't loose visual contact to which component this label belongs.
    if ( IsWireImage() )
    {
        const wxPoint origin = parentComponent->GetPosition();
        textpos  = GetTextPos() - origin;
        textpos  = parentComponent->GetScreenCoord( textpos );
        textpos += parentComponent->GetPosition();
        GRLine( clipbox, aDC, origin, textpos, 2, DARKGRAY );
    }

    /* Enable this to draw the bounding box around the text field to validate
     * the bounding box calculations.
     */
#if 0

    // Draw boundary box:
    GRRect( aPanel->GetClipBox(), aDC, boundaryBox, 0, BROWN );

    // Draw the text anchor point

    /* Calculate the text position, according to the component
     * orientation/mirror */
    textpos  = m_Pos - parentComponent->GetPosition();
    textpos  = parentComponent->GetScreenCoord( textpos );
    textpos += parentComponent->GetPosition();
    const int len = 10;
    GRLine( clipbox, aDC,
            textpos.x - len, textpos.y, textpos.x + len, textpos.y, 0, BLUE );
    GRLine( clipbox, aDC,
            textpos.x, textpos.y - len, textpos.x, textpos.y + len, 0, BLUE );
#endif
}