def wrap(self, availWidth, availHeight):
# try to get the caption aligned
if self.caption:
self._getCaptionPara()
w, h = self.captionPara.wrap(self.width, availHeight - self.figureHeight)
self.captionHeight = h + self.captionGap
self.height = self.captionHeight + self.figureHeight
if w>self.width: self.width = w
else:
self.height = self.figureHeight
return (self.width, self.height)
def draw(self):
if self.caption and self.captionPosition=='bottom':
self.canv.translate(0, self.captionHeight)
if self.background:
self.drawBackground()
if self.border:
self.drawBorder()
self.canv.saveState()
self.drawFigure()
self.canv.restoreState()
if self.caption:
if self.captionPosition=='bottom':
self.canv.translate(0, -self.captionHeight)
else:
self.canv.translate(0, self.figureHeight+self.captionGap)
self._getCaptionPara()
self.drawCaption()