示例#1
0
 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)
示例#2
0
    def draw(self, context):
        bounds = self.bounds
        x, y = bounds.x, bounds.y
        width, height = bounds.width, bounds.height

        cr = context.cairo
        text_set_font(cr, self._style.font)
        text_multiline(cr, x, y, self.text)
        cr.stroke()
        if self.editable and (context.hovered or context.focused):
            cr.save()
            cr.set_source_rgb(0.6, 0.6, 0.6)
            cr.set_line_width(0.5)
            cr.rectangle(x - 5, y - 1, width + 10, height + 2)
            cr.stroke()
            cr.restore()
示例#3
0
    def draw(self, context):
        """Draw name and multiplicity of the line end.
        """
        if not self.subject:
            return

        cr = context.cairo
        text_multiline(cr, self._name_bounds[0], self._name_bounds[1], self._name)
        text_multiline(cr, self._mult_bounds[0], self._mult_bounds[1], self._mult)
        cr.stroke()

        if context.hovered or context.focused or context.draw_all:
            cr.set_line_width(0.5)
            b = self._name_bounds
            cr.rectangle(b.x, b.y, b.width, b.height)
            cr.stroke()
            b = self._mult_bounds
            cr.rectangle(b.x, b.y, b.width, b.height)
            cr.stroke()
示例#4
0
    def draw(self, context):
        if not self.subject:
            return
        c = context.cairo
        # Width and height, adjusted for line width...
        ox = float(self._handles[NW].pos.x)
        oy = float(self._handles[NW].pos.y)
        w = self.width + ox
        h = self.height + oy
        ear = CommentItem.EAR
        c.move_to(w - ear, oy)
        line_to = c.line_to
        line_to(w - ear, oy + ear)
        line_to(w, oy + ear)
        line_to(w - ear, oy)
        line_to(ox, oy)
        line_to(ox, h)
        line_to(w, h)
        line_to(w, oy + ear)
        c.stroke()
	if self.subject.body:
	    # Do not print empty string, since cairo-win32 can't handle it.
            text_multiline(c, self.EAR, self.EAR, self.subject.body, padding=2)