Exemple #1
0
    def draw(self, cr):
        w_size = utils.text_size(cr, "W")[1] + 6

        if self.tokens_count == 0:
            return

        px, py = self.get_position()

        text_width = 0
        all =  self.removed_tokens + self.tokens + self.new_tokens
        if all:
            text_width = max(utils.text_size(cr, t)[0] for t in all) + 5

        size_y = len(all) * w_size
        self.size = (text_width, size_y)
        self.visual_position = (px + 10, py - size_y / 2)
        top = py - size_y / 2 + 2
        y = top
        if self.removed_tokens:
            cr.set_source_rgba(0.2, 0.2, 0.2, 0.7)
            cr.rectangle(px + 10, y + 4, text_width + 6, w_size * len(self.removed_tokens))
            cr.fill()
            y += w_size * len(self.removed_tokens)

        if self.tokens:
            cr.set_source_rgba(0.2, 0.45, 0, 0.7)
            cr.rectangle(px + 10, y + 4, text_width + 6, w_size * len(self.tokens))
            cr.fill()
            y += w_size * len(self.tokens)

        if self.new_tokens:
            cr.set_source_rgba(0.2,0.7,0,0.7)
            cr.rectangle(px + 10, y + 4, text_width + 6, w_size * len(self.new_tokens))
            cr.fill()
            y += w_size * len(self.new_tokens)

        y = top
        cr.set_source_rgb(1.0,1.0,1.0)
        for t in all:
            y += w_size
            cr.move_to(px + 15, y)
            cr.show_text(t)

        if self.new_tokens:
            cr.set_source_rgb(0.2,0.6,0)
        else:
            cr.set_source_rgb(0.2,0.45,0)


        cr.new_sub_path()
        cr.arc(px, py, 8, 0, 2 * math.pi)
        cr.fill()

        cr.set_line_width(0.5)
        cr.new_sub_path()
        cr.arc(px, py, 8, 0, 2 * math.pi)
        cr.set_source_rgb(0,0,0)
        cr.stroke()

        drawing.draw_centered_text(cr, px, py, str(self.tokens_count))
    def draw(self, cr):
        px, py = self.get_position()
        sx, sy = self.size
        drawing.draw_round_rectangle(cr, px, py, sx, sy, self.radius)

        if self.inactive:
            color = (0.5, 0.5, 0.5)
        else:
            color = (0, 0, 0)

        cr.set_source_rgb(1, 1, 1)
        cr.fill()

        if self.highlight:
            drawing.draw_round_rectangle(cr, px, py, sx, sy, self.radius)
            cr.set_line_width(6.5)
            cr.set_source_rgba(*self.highlight)
            cr.stroke()

        drawing.draw_round_rectangle(cr, px, py, sx, sy, self.radius)
        cr.set_line_width(1.2)
        cr.set_source_rgb(*color)
        cr.stroke()

        if self.thicklines:
            cr.rectangle(px, py, 8, sy)
            cr.rectangle(px + sx - 8, py, 8, sy)
            cr.fill()
        elif self.doubleborder:
            if self.radius > 3:
                drawing.draw_round_rectangle(cr, px, py, sx, sy,
                                             self.radius - 3.5)
            else:
                drawing.draw_round_rectangle(cr, px + 3, py + 3, sx - 6,
                                             sy - 6, self.radius)
            cr.stroke()
        drawing.draw_centered_text(cr, px + sx / 2, py + sy / 2, self.name)
        if self.corner_text:
            if self.thicklines:
                shift_x = 10
                shift_y = 3
            elif self.doubleborder:
                shift_x = 6
                shift_y = 6
            else:
                shift_x = 3
                shift_y = 3
            cr.save()
            cr.set_font_size(8)
            drawing.draw_text(cr, px + sx - shift_x, py + shift_y,
                              self.corner_text, 1, 1)
            cr.restore()
 def draw(self, cr):
     x, y = self.get_position()
     sx, sy = self.size
     cr.move_to(x - 2, y + sy / 2)
     cr.rel_line_to(sx, 0)
     cr.rel_line_to(-4, -sy / 2)
     cr.rel_line_to(4, -sy / 2)
     cr.rel_line_to(-sx, 0)
     cr.rel_line_to(-4, sy / 2)
     cr.rel_line_to(4, sy / 2)
     cr.set_source_rgba(*self.color)
     cr.fill()
     cr.set_source_rgb(0, 0, 0)
     drawing.draw_centered_text(cr, x + sx / 2 - 4, y, self.text)
Exemple #4
0
 def draw(self, cr):
     x, y = self.get_position()
     sx, sy = self.size
     cr.move_to(x - 2, y + sy/2)
     cr.rel_line_to(sx, 0)
     cr.rel_line_to(-4, -sy/2)
     cr.rel_line_to(4, -sy/2)
     cr.rel_line_to(-sx, 0)
     cr.rel_line_to(-4, sy/2)
     cr.rel_line_to(4, sy/2)
     cr.set_source_rgba(*self.color)
     cr.fill()
     cr.set_source_rgb(0, 0, 0)
     drawing.draw_centered_text(cr, x + sx/2-4, y, self.text)
Exemple #5
0
    def draw(self, cr):
        px, py = self.get_position()
        sx, sy = self.size
        drawing.draw_round_rectangle(cr, px, py, sx, sy, self.radius)

        if self.inactive:
            color = (0.5, 0.5, 0.5)
        else:
            color = (0, 0, 0)

        cr.set_source_rgb(1, 1, 1)
        cr.fill()

        if self.highlight:
            drawing.draw_round_rectangle(cr, px, py, sx, sy, self.radius)
            cr.set_line_width(6.5)
            cr.set_source_rgba(*self.highlight)
            cr.stroke()

        drawing.draw_round_rectangle(cr, px, py, sx, sy, self.radius)
        cr.set_line_width(1.2)
        cr.set_source_rgb(*color)
        cr.stroke()

        if self.thicklines:
            cr.rectangle(px, py, 8, sy)
            cr.rectangle(px + sx - 8, py, 8, sy)
            cr.fill()
        elif self.doubleborder:
            if self.radius > 3:
                drawing.draw_round_rectangle(cr, px, py, sx, sy, self.radius - 3.5)
            else:
                drawing.draw_round_rectangle(cr, px + 3, py + 3, sx - 6, sy - 6, self.radius)
            cr.stroke()
        drawing.draw_centered_text(cr, px + sx / 2, py + sy / 2, self.name)
        if self.corner_text:
            if self.thicklines:
                shift_x = 10
                shift_y = 3
            elif self.doubleborder:
                shift_x = 6
                shift_y = 6
            else:
                shift_x = 3
                shift_y = 3
            cr.save()
            cr.set_font_size(8)
            drawing.draw_text(cr, px + sx - shift_x, py + shift_y, self.corner_text, 1, 1)
            cr.restore()
    def draw(self, cr):
        w_size = utils.text_size(cr, "W")[1] + 6

        if self.tokens_count == 0:
            return

        px, py = self.get_position()

        text_width = 0
        all = self.removed_tokens + self.tokens + self.new_tokens
        if all:
            text_width = max(utils.text_size(cr, t)[0] for t in all) + 5

        size_y = len(all) * w_size
        self.size = (text_width, size_y)
        self.visual_position = (px + 10, py - size_y / 2)
        top = py - size_y / 2 + 2
        y = top
        if self.removed_tokens:
            cr.set_source_rgba(0.2, 0.2, 0.2, 0.7)
            cr.rectangle(px + 10, y + 4, text_width + 6,
                         w_size * len(self.removed_tokens))
            cr.fill()
            y += w_size * len(self.removed_tokens)

        if self.tokens:
            cr.set_source_rgba(0.2, 0.45, 0, 0.7)
            cr.rectangle(px + 10, y + 4, text_width + 6,
                         w_size * len(self.tokens))
            cr.fill()
            y += w_size * len(self.tokens)

        if self.new_tokens:
            cr.set_source_rgba(0.2, 0.7, 0, 0.7)
            cr.rectangle(px + 10, y + 4, text_width + 6,
                         w_size * len(self.new_tokens))
            cr.fill()
            y += w_size * len(self.new_tokens)

        y = top
        cr.set_source_rgb(1.0, 1.0, 1.0)
        for t in all:
            y += w_size
            cr.move_to(px + 15, y)
            cr.show_text(t)

        if self.new_tokens:
            cr.set_source_rgb(0.2, 0.6, 0)
        else:
            cr.set_source_rgb(0.2, 0.45, 0)

        cr.new_sub_path()
        cr.arc(px, py, 8, 0, 2 * math.pi)
        cr.fill()

        cr.set_line_width(0.5)
        cr.new_sub_path()
        cr.arc(px, py, 8, 0, 2 * math.pi)
        cr.set_source_rgb(0, 0, 0)
        cr.stroke()

        drawing.draw_centered_text(cr, px, py, str(self.tokens_count))