def draw(self, context): cr = context.cairo if self.font: text_set_font(cr, self.font) if hasattr(self.subject, 'isStatic') and self.subject.isStatic: text_underline(cr, 0, 0, self.render() or '') else: text_align(cr, 0, 0, self.render(), align_x=1, align_y=1)
def draw(self, context): cr = context.cairo if self.multiline: text_multiline(cr, 0, 0, self.text) elif self.plain: cr.show_text(self.text) else: text_align(cr, 0, 0, self.text, self.align_x, self.align_y)
def draw_compartment(self, context): self.draw_compartment_border(context) super(CompartmentItem, self).draw(context) cr = context.cairo # make room for name, stereotype, etc. y = self._header_size[1] cr.translate(0, y) if self._drawing_style == self.DRAW_COMPARTMENT_ICON: width = self.width - self.ICON_WIDTH else: width = self.width extra_space = self.height - self.min_height # extra space is used by header if self.style.extra_space == 'header': cr.translate(0, extra_space) # draw compartments and stereotype compartments extra_used = False for comp in self._compartments: if not comp.visible: continue cr.save() cr.move_to(0, 0) cr.line_to(self.width, 0) cr.stroke() if comp.title: padding = self.style.compartment_padding text_align(cr, self.width / 2.0, padding[0], comp.title, align_y=1) try: comp.draw(context) finally: cr.restore() d = comp.height if not extra_used and comp.use_extra_space \ and self.style.extra_space == 'compartment': d += extra_space extra_used = True cr.translate(0, d)