34 const wxColour& aForeground,
const wxColour& aBackground,
35 wxWindow* aWindow,
bool aShapeOnRight )
37 double scaleFactor = aWindow->GetDPIScaleFactor();
39 wxSize physSize( aWindow->ToPhys( aSize.GetWidth() ),
40 aWindow->ToPhys( aSize.GetHeight() ) );
42 wxBitmap bitmap( physSize );
43 wxMemoryDC dc( bitmap );
45 dc.SetBackground( wxBrush( aBackground ) );
48 int w = physSize.GetWidth();
49 int h = physSize.GetHeight();
51 int marginL =
static_cast<int>( 4 * scaleFactor );
52 int marginR =
static_cast<int>( 4 * scaleFactor );
54 int lineStartX = marginL;
55 int lineEndX = w - marginR;
56 int lineDrawStartX = lineStartX;
57 int lineDrawEndX = lineEndX;
61 int shapeHeight = h -
static_cast<int>( 4 * scaleFactor );
87 std::vector<VECTOR2I> polygon;
88 ending.
GetShapes( tip, tangent, fakeLineWidth, polygon );
90 if( !polygon.empty() )
92 std::vector<wxPoint> wxPts;
93 wxPts.reserve( polygon.size() );
96 wxPts.emplace_back( pt.x, pt.y );
101 lineDrawEndX = lineEndX - shortenDepth;
103 lineDrawStartX = lineStartX + shortenDepth;
105 dc.SetPen( wxPen( aForeground,
static_cast<int>( scaleFactor ) ) );
109 dc.SetBrush( *wxTRANSPARENT_BRUSH );
110 dc.SetPen( wxPen( aForeground, std::max( 1,
static_cast<int>( 1.5 * scaleFactor ) ) ) );
111 dc.DrawLines(
static_cast<int>( wxPts.size() ), wxPts.data() );
115 dc.SetBrush( wxBrush( aForeground ) );
116 dc.DrawPolygon(
static_cast<int>( wxPts.size() ), wxPts.data() );
121 dc.SetPen( wxPen( aForeground,
static_cast<int>( scaleFactor ) ) );
122 dc.DrawLine( lineDrawStartX, midY, lineDrawEndX, midY );
124 dc.SelectObject( wxNullBitmap );
125 bitmap.SetScaleFactor( scaleFactor );
void GetShapes(const VECTOR2I &aPoint, const EDA_ANGLE &aTangent, int aLineWidth, std::vector< VECTOR2I > &aPolygon) const
Generate ending geometry as polygon vertices at the given point and direction.
wxBitmap MakeLineEndingBitmap(LINE_ENDING_STYLE aStyle, const wxSize &aSize, const wxColour &aForeground, const wxColour &aBackground, wxWindow *aWindow, bool aShapeOnRight)
Generate a DPI-aware bitmap icon showing a line ending style.