Пример #1
0
 def on_expose_event(self, widget, event):    
     cr = widget.window.cairo_create()
     rect = widget.allocation
     draw_alpha_mask(cr, rect.x, rect.y, rect.width - 1, rect.height ,"layoutRight")
     
     draw_line(cr, (rect.x + 1, rect.y), 
               (rect.x + 1, rect.y + rect.height), "#b0b0b0")
     return False
    def on_bottombox_expose_event(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        cr.set_source_rgba(1, 1, 1, 0.95)
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()

        draw_line(cr, (rect.x, rect.y + 1), (rect.x + rect.width, rect.y + 1), "#b0b0b0")
        return False
    def on_bottombox_expose_event(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        cr.set_source_rgba(1, 1, 1, 0.95)
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()

        draw_line(cr, (rect.x, rect.y + 1), (rect.x + rect.width, rect.y + 1),
                  "#b0b0b0")
        return False
 def on_panel_expose_event(self, widget, event):    
     if not self.items:
         return 
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     draw_line(cr, (rect.x, rect.y + 1), (rect.x + rect.width, rect.y + 1), "#c7c7c7")
     draw_line(cr, (rect.x + rect.width, rect.y), (rect.x + rect.width, rect.y + rect.height), "#c7c7c7")
     draw_line(cr, (rect.x, rect.y + rect.height), (rect.x + rect.width, rect.y + rect.height), "#c7c7c7")
     draw_line(cr, (rect.x + 1, rect.y + 32), (rect.x + 1, rect.y + rect.height), "#c7c7c7")
     rect.y += self.block_height        
     
     start_x, start_y = self.padding_x, self.padding_y
     
     for index, item in enumerate(self.items):
         item_width, item_height = item.get_size()
         if rect.width - start_x < item_width + self.separate_width:
             start_y += item_height + self.item_interval_height
             start_x = self.padding_x
             
         item.render(cr, gtk.gdk.Rectangle(rect.x + start_x, rect.y + start_y,
                                           item_width, item_height))    
         
         self.coords[index] = self.range(rect.x + start_x, rect.x + start_x + item_width,
                                         rect.y + start_y, rect.y + start_y + item_height)
         start_x += item_width            
         
         
         draw_text(cr, self.separate_text, rect.x + start_x, rect.y + start_y, self.separate_width, 
                   self.separate_height, text_color=app_theme.get_color("labelText").get_color())
         start_x += self.separate_width
         
     return True    
Пример #5
0
    def on_panel_expose_event(self, widget, event):    
        cr = widget.window.cairo_create()
        rect = widget.allocation
        
        draw_line(cr, (rect.x, rect.y + 1), (rect.x + rect.width, rect.y + 1), "#c7c7c7")
        draw_line(cr, (rect.x + rect.width, rect.y), (rect.x + rect.width, rect.y + rect.height), "#c7c7c7")
        draw_line(cr, (rect.x, rect.y + rect.height), (rect.x + rect.width, rect.y + rect.height), "#c7c7c7")
        draw_line(cr, (rect.x + 1, rect.y), (rect.x + 1, rect.y + rect.height), "#c7c7c7")
        
        tx = rect.x + self.padding_x        
        ty = rect.y + self.padding_y
        tw = rect.width - self.padding_x * 2
        intro = self.channel_info.get("intro", "").strip()
        intro = utils.xmlescape(intro)
        if intro:
            intro_text = "<b>%s:</b> %s" % ("简介", intro)
            intro_tw, intro_th = get_content_size(intro_text, wrap_width=tw,text_size=9)
            if intro_th > self.line_height * 2:
                intro_th = self.line_height * 2
            cr.save()
            cr.rectangle(tx, ty, intro_tw, intro_th)
            cr.clip()
            draw_text(cr, intro_text, tx, ty, intro_tw, intro_th, text_size=9,
                      text_color="#878787", wrap_width=tw)
            cr.restore()

            with cairo_disable_antialias(cr):
                cr.save()
                cr.move_to(tx, ty + intro_th + self.line_height)
                cr.rel_line_to(tw, 0)
                cr.set_dash([2.0, 2.0])
                cr.stroke()
                cr.restore()
            
        hotsongs =  " / ".join(self.channel_info.get("hot_songs", [])).strip()
        hotsongs = utils.xmlescape(hotsongs)
        hotsongs_text = "<b>%s:</b> %s" % ("热门歌曲", hotsongs)
        if intro:
            new_ty = ty + intro_th + self.line_height * 2
        else:    
            new_ty = ty
            
        hotsongs_tw, hotsongs_th = get_content_size(hotsongs_text, wrap_width=tw,text_size=9)
        if hotsongs_th > self.line_height * 2:
            hotsongs_th = self.line_height * 2
        cr.save()
        cr.rectangle(tx, new_ty, hotsongs_tw, hotsongs_th)
        cr.clip()
        draw_text(cr, hotsongs_text, tx, new_ty, hotsongs_tw, hotsongs_th, text_size=9,
                  text_color="#878787", wrap_width=tw)
        return True
Пример #6
0
    def on_panel_expose_event(self, widget, event):
        if not self.items:
            return
        cr = widget.window.cairo_create()
        rect = widget.allocation

        draw_line(cr, (rect.x, rect.y + 1), (rect.x + rect.width, rect.y + 1),
                  "#c7c7c7")
        draw_line(cr, (rect.x + rect.width, rect.y),
                  (rect.x + rect.width, rect.y + rect.height), "#c7c7c7")
        draw_line(cr, (rect.x, rect.y + rect.height),
                  (rect.x + rect.width, rect.y + rect.height), "#c7c7c7")
        draw_line(cr, (rect.x + 1, rect.y + 32),
                  (rect.x + 1, rect.y + rect.height), "#c7c7c7")
        rect.y += self.block_height

        start_x, start_y = self.padding_x, self.padding_y

        for index, item in enumerate(self.items):
            item_width, item_height = item.get_size()
            if rect.width - start_x < item_width + self.separate_width:
                start_y += item_height + self.item_interval_height
                start_x = self.padding_x

            item.render(
                cr,
                gtk.gdk.Rectangle(rect.x + start_x, rect.y + start_y,
                                  item_width, item_height))

            self.coords[index] = self.range(rect.x + start_x,
                                            rect.x + start_x + item_width,
                                            rect.y + start_y,
                                            rect.y + start_y + item_height)
            start_x += item_width

            draw_text(cr,
                      self.separate_text,
                      rect.x + start_x,
                      rect.y + start_y,
                      self.separate_width,
                      self.separate_height,
                      text_color=app_theme.get_color("labelText").get_color())
            start_x += self.separate_width

        return True