Пример #1
0
    def frame_on_expose(self, evt):
        log.warn("expose! %s", self)

        context = self.context
        cr = context.cr

        if False:
            context.fill((255, 0, 255))
            context.text(0, 10, self.window.get_property("WM_NAME")[0], (255, 255, 255))
            # fred: why do I have to set y=10?
            # dunk: because its specifying the baseline of the text not the top
        else:
            g = self.frame.get_geometry()
            log.warn(str((g, dir(g))))

            cairo.cairo_set_antialias(cr, cairo.CAIRO_ANTIALIAS_NONE)
            cairo.cairo_set_line_width(cr, 1)
            cairo.cairo_set_source_rgb(cr, 0.8, 0.0, 0.0)
            cairo.cairo_rectangle(cr, 0, 0, g["width"] - 1, g["height"] - 1)
            cairo.cairo_fill_preserve(cr)
            cairo.cairo_set_source_rgb(cr, 1.0, 1.0, 1.0)
            cairo.cairo_stroke(cr)

            context.text(
                self.style["border"] + 1,
                self.style["border"] + 1 + context.default_font_size,
                self.window.get_property("WM_NAME")[0],
                (255, 255, 255),
            )

            # TODO should the client know its own connection?
            self.window.connection.flush()
Пример #2
0
 def fillrect(self, x, y, width, height, color):
     if False:
         pat = cairo.cairo_pattern_create_linear (0.0, 0.0, width, 0.0)
         cairo.cairo_pattern_add_color_stop_rgba (pat, 0.0, 1.0, 0.0, 0.0, 1.0)
         cairo.cairo_pattern_add_color_stop_rgba (pat, width/3, 0.1, 0.0, 0.0, 1.0)
         cairo.cairo_pattern_add_color_stop_rgba (pat, width, 0.0, 0.0, 0.0, 1.0)
         cairo.cairo_rectangle(self.cr, x, y, width, height)
         cairo.cairo_set_source(self.cr, pat)
         cairo.cairo_fill(self.cr)
         cairo.cairo_pattern_destroy(pat)
     else:
         cairo.cairo_set_source_rgb(self.cr, color[0], color[1], color[2])
         cairo.cairo_rectangle(self.cr, x, y, width, height)
         cairo.cairo_fill(self.cr)
     self.connection.flush()