MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _paint_text_fallback

Method _paint_text_fallback

SLiCAP/schematic/model_item.py:137–160  ·  view source on GitHub ↗
(self, painter: QPainter, r: QRectF)

Source from the content-addressed store, hash-verified

135 return lines
136
137 def _paint_text_fallback(self, painter: QPainter, r: QRectF) -> None:
138 lines = self._text_display_lines()
139
140 hdr_font = QFont(COMP_REFDES_FONT_FAMILY)
141 hdr_font.setBold(True)
142 hdr_font.setPointSizeF(COMP_LABEL_FONT_SIZE)
143 body_font = QFont(COMP_REFDES_FONT_FAMILY)
144 body_font.setPointSizeF(COMP_LABEL_FONT_SIZE)
145
146 fm_h = QFontMetricsF(hdr_font)
147 fm_b = QFontMetricsF(body_font)
148 pad = fm_b.height() * 0.3
149 line_h = fm_b.height() * _LINE_SPACING
150 y = r.top() + pad + fm_h.ascent()
151
152 painter.setPen(_BORDER_COLOR)
153 painter.setFont(hdr_font)
154 painter.drawText(QPointF(r.left() + pad, y), lines[0])
155 y += line_h
156
157 painter.setFont(body_font)
158 for line in lines[1:]:
159 painter.drawText(QPointF(r.left() + pad, y), line)
160 y += line_h
161
162 def itemChange(self, change, value):
163 if change == QGraphicsItem.ItemPositionChange:

Callers 1

paintMethod · 0.95

Calls 1

_text_display_linesMethod · 0.95

Tested by

no test coverage detected