MCPcopy Create free account
hub / github.com/PageBot/PageBot / drawMissingElementRect

Method drawMissingElementRect

Lib/pagebot/elements/views/pageview.py:756–803  ·  view source on GitHub ↗

When designing templates and pages, this will draw a filled rectangle on the element bounding box (if self.css('missingElementFill' is defined) and a cross, indicating that this element has missing content, for example when an image is missing. Only draw if the list s

(self, e, origin)

Source from the content-addressed store, hash-verified

754 context.drawString(bs, (px, py + S*1.5))
755
756 def drawMissingElementRect(self, e, origin):
757 """When designing templates and pages, this will draw a filled
758 rectangle on the element bounding box (if self.css('missingElementFill'
759 is defined) and a cross, indicating that this element has missing
760 content, for example when an image is missing. Only draw if the list
761 self.showGrid contains proper types of grid names.
762
763 >>> from pagebot import getContext
764 >>> context = getContext()
765 >>> from pagebot.elements.element import Element
766 >>> from pagebot.style import getRootStyle
767 >>> # Get default values.
768 >>> style = getRootStyle()
769 >>> # Works on generic elements as well as pages.
770 >>> e = Element(style=style)
771 >>> view = PageView(context=context, style=style)
772 >>> view.showMissingElement = True
773 >>> view.drawMissingElementRect(e, (0, 0))
774 """
775 if (self.showMissingElement and e.isPage) or e.showMissingElement:
776 context = self.context
777
778 p = pointOffset(e.origin, origin)
779 p = self._applyScale(e, p)
780 px, py, _ = e._applyAlignment(p) # Ignore z-axis for now.
781
782 context.save()
783 context.setShadow(self.shadow)
784 sMissingElementFill = self.css('viewMissingElementFill', noColor)
785
786 if sMissingElementFill is not noColor:
787 context.fill(sMissingElementFill)
788 context.stroke(noColor)
789 context.rect(px, py, self.w, self.h)
790
791 # Draw crossed rectangle.
792 context.fill(noColor)
793 context.stroke(blackColor, pt(0.5))
794 context.rect(px, py, self.w, self.h)
795 context.newPath()
796 context.moveTo((px, py))
797 context.lineTo((px + self.w, py + self.h))
798 context.moveTo((px + self.w, py))
799 context.lineTo((px, py + self.h))
800 context.drawPath()
801
802 context.restore()
803 e._restoreScale(self)
804
805 # G R I D
806

Callers

nothing calls this directly

Calls 15

pointOffsetFunction · 0.90
ptFunction · 0.90
_applyScaleMethod · 0.80
_applyAlignmentMethod · 0.80
setShadowMethod · 0.80
_restoreScaleMethod · 0.80
saveMethod · 0.45
cssMethod · 0.45
fillMethod · 0.45
strokeMethod · 0.45
rectMethod · 0.45
newPathMethod · 0.45

Tested by

no test coverage detected