def do_draw(self, cr):
a = self.get_allocation()
#state = self.get_state_flags()
context = self.get_style_context()
ds_h = self._dropshadow.get_height()
y = (a.height - ds_h) / 2
Gdk.cairo_set_source_pixbuf(cr, self._dropshadow, 0, y)
cr.paint()
# layout circle
x = self._margin
y = (a.height - ds_h) / 2 + self._margin
w = a.width - 2 * self._margin
h = a.width - 2 * self._margin
cr.new_path()
r = min(w, h) * 0.5
x += int((w - 2 * r) / 2)
y += int((h - 2 * r) / 2)
from math import pi
cr.arc(r + x, r + y, r, 0, 2 * pi)
cr.close_path()
if self.is_active:
color = context.get_background_color(Gtk.StateFlags.SELECTED)
else:
color = context.get_background_color(Gtk.StateFlags.INSENSITIVE)
Gdk.cairo_set_source_rgba(cr, color)
cr.fill()
for child in self:
self.propagate_draw(child, cr)
评论列表
文章目录