Draws the page frame if the the flag is on and if there ie padding enough to show other meta info. Otherwise the padding is truncated to 0: no use to draw the frame. Note that drawing a frame around a page or element here is for viewing purposes only. Actual frame (s
(self, e, origin)
| 278 | self.drawFlowConnections(page, origin) |
| 279 | |
| 280 | def drawFrame(self, e, origin): |
| 281 | """Draws the page frame if the the flag is on and if there ie padding |
| 282 | enough to show other meta info. Otherwise the padding is truncated to |
| 283 | 0: no use to draw the frame. |
| 284 | |
| 285 | Note that drawing a frame around a page or element here is for viewing |
| 286 | purposes only. Actual frame (stroke) drawing of an element is done |
| 287 | by the element itself. |
| 288 | |
| 289 | >>> from pagebot import getContext |
| 290 | >>> context = getContext() |
| 291 | >>> from pagebot.elements.element import Element |
| 292 | >>> from pagebot.style import getRootStyle |
| 293 | >>> style = getRootStyle() # Get default values |
| 294 | >>> e = Element(style=style) # Works on generic elements as well as pages. |
| 295 | >>> view = PageView(context=context, style=style) |
| 296 | >>> view.showFrame = True |
| 297 | >>> view.drawFrame(e, (0, 0)) |
| 298 | """ |
| 299 | if ((self.showFrame and e.isPage) or e.showFrame) and \ |
| 300 | self.pl >= self.viewMinInfoPadding and \ |
| 301 | self.pr >= self.viewMinInfoPadding and \ |
| 302 | self.pt >= self.viewMinInfoPadding and \ |
| 303 | self.pb >= self.viewMinInfoPadding: |
| 304 | |
| 305 | # TODO: May need to be scaled, as self.drawPadding does. |
| 306 | ox, oy = point2D(origin) |
| 307 | context = self.context |
| 308 | context.fill(noColor) |
| 309 | |
| 310 | viewFrameStroke = e.viewFrameStroke or \ |
| 311 | self.viewFrameStroke or \ |
| 312 | self.DEFAULT_STROKE_COLOR |
| 313 | |
| 314 | viewFrameStrokeWidth = e.viewFrameStrokeWidth or \ |
| 315 | self.viewFrameStrokeWidth or \ |
| 316 | self.DEFAULT_STROKE_WIDTH |
| 317 | |
| 318 | context.stroke(viewFrameStroke, viewFrameStrokeWidth) |
| 319 | context.rect(ox, oy, e.w, e.h) |
| 320 | |
| 321 | # If there are folds, draw them too in the same color. |
| 322 | folds = e.folds or self.folds |
| 323 | if folds: |
| 324 | for (x, y) in folds: |
| 325 | if x is not None: |
| 326 | context.line((ox+x, oy), (ox+x, oy+e.h)) |
| 327 | if y is not None: |
| 328 | context.line((ox, ox+y), (ox+e.w, ox+y)) |
| 329 | |
| 330 | |
| 331 | def drawPadding(self, e, origin): |