def draw(self, widget, event): cr = self.context = widget.window.cairo_create() if self.dragging: color = "blue" else: color = "black" # draw handle at position rect = self.get_widget_rect(widget) if rect: size = widget.window.get_size() rect.y = (size[1] / 2) - rect.height / 2 style = widget.get_style() style.paint_box(widget.window, self.state_type, self.shadow_type, rect, widget, "", rect.x, rect.y, rect.width, rect.height)
def on_expose(self, widget, event): size = widget.window.get_size() rect = gtk.gdk.Rectangle(0, 0, size[0], size[1]) style = widget.get_style() if self.zone.sample != "": shadow_style = gtk.SHADOW_OUT else: shadow_style = gtk.SHADOW_IN style.paint_box(widget.window, gtk.STATE_NORMAL, shadow_style, rect, widget, "", 0, 0, rect.width, rect.height) # paint text cr = widget.window.cairo_create() cr.set_font_size(8.0) cr.set_source_rgb(0.0, 0.0, 0.0) fascent, fdescent, fheight, fadvance, fyadvance = cr.font_extents() cr.move_to(2, ((size[1] / 2) - fdescent + fheight / 2)) if self.zone.sample != "": cr.show_text(self.zone.sample) return False