示例#1
0
    def expose_simple_item(self, widget, event):

        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        font_color = app_theme.get_color("labelText").get_color()
        item_pixbuf = self.normal_dpixbuf.get_pixbuf()
        # Draw pixbuf.
        draw_pixbuf(cr, item_pixbuf, rect.x + self.padding_left,
                    rect.y + (rect.height - item_pixbuf.get_height()) / 2)

        # Draw content.
        draw_text(cr,
                  self.content,
                  rect.x + self.padding_left + self.font_offset,
                  rect.y,
                  rect.width - self.padding_left - self.font_offset -
                  self.padding_right,
                  rect.height,
                  self.font_size,
                  font_color,
                  alignment=self.x_align)

        propagate_expose(widget, event)

        return True
示例#2
0
    def screenshot_box_expose(self, widget, event):
        rect = widget.allocation
        cr = widget.window.cairo_create()

        #cr.set_source_rgba(1.0, 1.0, 1.0, 0.0)
        #cr.set_operator(cairo.OPERATOR_SOURCE)
        #cr.paint()

        if self.screenshot_pixbuf:
            draw_pixbuf(
                cr,
                self.screenshot_pixbuf,
                rect.x + (rect.width - self.screenshot_pixbuf.get_width()) / 2,
                rect.y +
                (rect.height - self.screenshot_pixbuf.get_height()) / 2,
            )

        cr.set_source_rgba(0, 0, 0, 0.7)
        cr.rectangle(*rect)
        cr.fill()

        # Propagate expose to children.
        propagate_expose(widget, event)

        return True
示例#3
0
    def render_pkg_picture(self, cr, rect):
        if self.pixbuf == None:
            self.pixbuf = gtk.gdk.pixbuf_new_from_file(
                DEFAULT_CACHE_IMAGE_PATH)

        draw_pixbuf(cr, self.pixbuf, rect.x + self.PICTURE_PADDING_X,
                    rect.y + self.PICTURE_PADDING_Y)
示例#4
0
 def text_view_bg_expose(self, widget, event):
     '''draw text view bg'''
     cr = widget.window.cairo_create()
     rect = widget.allocation
     text_pixbuf = app_theme_get_dynamic_pixbuf(
         'image/share/text_view.png').get_pixbuf()
     draw.draw_pixbuf(cr, text_pixbuf, rect.x, rect.y)
    def render(self, cr, rect):
        '''
        Render item.
        
        This is IconView interface, you should implement it.
        '''
        if self.pixbuf == None:
            self.create_cache_pixbuf()
        
        wallpaper_x = rect.x + (rect.width - self.wallpaper_width) / 2
        wallpaper_y = rect.y + (rect.height - self.wallpaper_height) / 2
        
        # Draw shadow.
        drop_shadow_padding = 7
        drop_shadow_radious = 7
        draw_shadow(
            cr,
            wallpaper_x,
            wallpaper_y,
            self.wallpaper_width + drop_shadow_padding,
            self.wallpaper_height + drop_shadow_padding,
            drop_shadow_radious,
            app_theme.get_shadow_color("window_shadow")
            )

        outside_shadow_padding = 4
        outside_shadow_radious = 5
        draw_shadow(
            cr,
            wallpaper_x - outside_shadow_padding,
            wallpaper_y - outside_shadow_padding,
            self.wallpaper_width + outside_shadow_padding * 2,
            self.wallpaper_height + outside_shadow_padding * 2,
            outside_shadow_radious,
            app_theme.get_shadow_color("window_shadow")
            )
        
        # Draw wallpaper.
        draw_pixbuf(cr, self.pixbuf, wallpaper_x, wallpaper_y)    
        
        # Draw wallpaper frame.
        with cairo_disable_antialias(cr):
            cr.set_line_width(2)
            cr.set_source_rgba(1, 1, 1, 1)
            cr.rectangle(wallpaper_x, wallpaper_y, self.wallpaper_width, self.wallpaper_height)
            cr.stroke()
            
        if self.is_hover:    
            cr.rectangle(wallpaper_x, wallpaper_y, self.wallpaper_width, self.wallpaper_height)
            cr.set_source_rgb(*color_hex_to_cairo(self.hover_stroke_dcolor.get_color()))
            cr.stroke()
        
        if self.is_tick:    
            tick_pixbuf = self.tick_normal_dpixbuf.get_pixbuf()
        else:    
            tick_pixbuf = self.tick_gray_dpixbuf.get_pixbuf()
            
        tick_x = wallpaper_x + self.wallpaper_width - tick_pixbuf.get_width() / 2 
        tick_y = wallpaper_y - tick_pixbuf.get_height() / 2
        draw_pixbuf(cr, tick_pixbuf, tick_x, tick_y)    
    def render_wallpaper(self, cr, pixbuf, wallpaper_draw_x, wallpaper_draw_y, reflection=False):    
        cr.set_source_rgba(1, 1, 1, 1)
        cr.rectangle(wallpaper_draw_x - self.wallpaper_frame_size,
                     wallpaper_draw_y - self.wallpaper_frame_size,
                     self.wallpaper_width + self.wallpaper_frame_size * 2,
                     self.wallpaper_height + self.wallpaper_frame_size * 2)
        cr.fill()
        
        with cairo_disable_antialias(cr):
            cr.set_line_width(1)
            cr.set_source_rgb(*color_hex_to_cairo("#A4A7A7"))
            
            cr.rectangle(wallpaper_draw_x - self.wallpaper_frame_size,
                         wallpaper_draw_y - self.wallpaper_frame_size,
                         self.wallpaper_width + self.wallpaper_frame_size * 2 + 1,
                         self.wallpaper_height + self.wallpaper_frame_size * 2 + 1)
            cr.stroke()

            cr.rectangle(wallpaper_draw_x,
                         wallpaper_draw_y,
                         self.wallpaper_width + 1,
                         self.wallpaper_height + 1)
            cr.stroke()
        
        if reflection:
            cr.translate(wallpaper_draw_x - self.wallpaper_frame_size - 1,
                         wallpaper_draw_y + self.wallpaper_height + self.wallpaper_frame_size + 1)
            cr.scale(1, -1)
        
        draw_pixbuf(cr, pixbuf, wallpaper_draw_x, wallpaper_draw_y)
 def render_icon(self, cr, rect, in_select, in_highlight):    
     icon_x = rect.x + self.status_icon_padding_x
     icon_y = rect.y + (rect.height - self.status_icon_h) / 2
     if in_select:
         draw_pixbuf(cr, self.status_icon_press, icon_x, icon_y)
     else:    
         draw_pixbuf(cr, self.status_icon, icon_x, icon_y)
示例#8
0
    def on_expose_event(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        failed_pixbuf = self.failed_dpixbuf
        #draw_alpha_mask(cr, rect.x, rect.y, rect.width, rect.height, "layoutLeft")
        pixbuf_offset_x = (rect.width - failed_pixbuf.get_width()) / 2
        pixbuf_offset_y = (rect.height - failed_pixbuf.get_height()) / 2 - 20
        icon_x = rect.x + pixbuf_offset_x
        icon_y = rect.y + pixbuf_offset_y
        draw_pixbuf(cr, failed_pixbuf, icon_x, icon_y)

        text_y = icon_y + failed_pixbuf.get_height() + self.text_padding_y
        text_x = icon_x + self.text_padding_x

        _width, _height = dutils.get_content_size(self.prompt_text)

        self.text_rect = gtk.gdk.Rectangle(
            text_x - rect.x, text_y - rect.y,
            rect.x + rect.width - text_x - pixbuf_offset_x, _height)

        if self.is_hover:
            text_color = self.hover_text_dcolor.get_color()
        else:
            text_color = self.normal_text_dcolor.get_color()

        draw_text(cr,
                  self.prompt_text,
                  text_x,
                  text_y,
                  self.text_rect.width,
                  _height,
                  text_color=text_color,
                  underline=True,
                  alignment=pango.ALIGN_CENTER)
        return True
示例#9
0
 def on_expose_event(self, widget, event):    
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     # Draw Background.
     draw_pixbuf(cr, self.bg_pixbuf, rect.x, rect.y)
     # cr.rectangle(rect.x, rect.y, rect.width, rect.height)
     # cr.set_source_rgb(*color_hex_to_cairo("#D7D7D7"))
     # cr.fill()
     
     pixbuf  = None
     if widget.state == gtk.STATE_NORMAL:
         pixbuf = self.normal_dpixbuf.get_pixbuf()
     elif widget.state == gtk.STATE_PRELIGHT:    
         pixbuf = self.hover_dpixbuf.get_pixbuf()
     elif widget.state == gtk.STATE_ACTIVE:    
         pixbuf = self.press_dpixbuf.get_pixbuf()
         
     if pixbuf is None:    
         pixbuf = self.normal_dpixbuf.get_pixbuf()
         
     icon_x = rect.x + (rect.width - pixbuf.get_width()) / 2
     icon_y = rect.y + (rect.height - pixbuf.get_height()) / 2 + 2
     
     draw_pixbuf(cr, pixbuf, icon_x, icon_y)    
     return True
 def render_title(self, cr, rect):        
     # Draw select background.
         
     if self.is_select:    
         draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height, "globalItemHighlight")
     elif self.is_hover:
         draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height, "globalItemHover")
     
     if self.is_select:
         text_color = "#FFFFFF"
     else:    
         text_color = app_theme.get_color("labelText").get_color()
         
     # draw arrow    
     if self.is_expand:    
         if self.is_select:
             arrow_pixbuf = self.down_press_dpixbuf.get_pixbuf()
         else:
             arrow_pixbuf = self.down_normal_dpixbuf.get_pixbuf()
     else:        
         if self.is_select:
             arrow_pixbuf = self.right_press_dpixbuf.get_pixbuf()
         else:
             arrow_pixbuf = self.right_normal_dpixbuf.get_pixbuf()
             
     arrow_x = rect.x + self.arrow_padding_x
     arrow_y = rect.y + (rect.height - arrow_pixbuf.get_height()) / 2
     draw_pixbuf(cr, arrow_pixbuf, arrow_x, arrow_y)
     draw_text(cr, self.title, rect.x + self.title_padding_x, rect.y, 
               rect.width - self.title_padding_x, rect.height, text_size=10, 
               text_color = text_color,
               alignment=pango.ALIGN_LEFT)    
示例#11
0
    def expose_button_cb(self, widget, event):
        # Init.
        rect = widget.allocation

        bg_normal_dpixbuf, bg_hover_dpixbuf, bg_press_dpixbuf = self.bg_image_group
        fg_normal_dpixbuf, fg_hover_dpixbuf, fg_press_dpixbuf = self.icon_group

        if widget.state == gtk.STATE_NORMAL:
            bg_image = bg_normal_dpixbuf.get_pixbuf()
            fg_image = fg_normal_dpixbuf.get_pixbuf()
        elif widget.state == gtk.STATE_PRELIGHT:
            bg_image = bg_hover_dpixbuf.get_pixbuf()
            fg_image = fg_hover_dpixbuf.get_pixbuf()
        elif widget.state == gtk.STATE_ACTIVE:
            bg_image = bg_press_dpixbuf.get_pixbuf()
            fg_image = fg_press_dpixbuf.get_pixbuf()

        image_width = bg_image.get_width()
        image_height = bg_image.get_height()

        fg_rect_x = rect.x + (image_width - fg_image.get_width()) / 2
        fg_rect_y = rect.y + (image_height - fg_image.get_height()) / 2

        cr = widget.window.cairo_create()
        draw_pixbuf(cr, bg_image, rect.x, rect.y)
        draw_pixbuf(cr, fg_image, fg_rect_x, fg_rect_y)

        propagate_expose(widget, event)

        return True
    def render_content(self, cr, rect):
        (text_width,
         text_height) = get_content_size(self.html_escape(self.content))
        render_background(self, cr, rect)

        if self.show_arrow:
            if self.is_expand:
                draw_pixbuf(cr, self.arrow_down.get_pixbuf(), rect.x + 5,
                            rect.y + (rect.height - self.arrow_height) / 2)
            else:
                draw_pixbuf(cr, self.arrow_right.get_pixbuf(), rect.x + 5,
                            rect.y + (rect.height - self.arrow_height) / 2)

        if self.is_select:
            text_color = "#ffffff"
        else:
            text_color = "#000000"

        content = gettext.gettext(self.content)
        draw_text(cr,
                  self.html_escape(content),
                  rect.x + IMG_WIDTH + 10,
                  rect.y,
                  rect.width,
                  rect.height,
                  alignment=pango.ALIGN_LEFT,
                  text_color=text_color)
    def render_flag(self, cr, rect):
        render_background(self, cr, rect)

        flag_icon = self.find_match_flag(self.content)
        if flag_icon:
            draw_pixbuf(cr, flag_icon.get_pixbuf(),
                        rect.x + BETWEEN_SPACING / 2, rect.y)
 def render_stop(self, cr, rect):    
     if self.is_hover:
         draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height, "globalItemHover")
     
     icon_x = rect.x + (rect.width - self.stop_pixbuf.get_width()) / 2
     icon_y = rect.y + (rect.height - self.stop_pixbuf.get_height()) / 2
     draw_pixbuf(cr, self.stop_pixbuf, icon_x, icon_y)
示例#15
0
    def render_signal(self, cr, rect):
        self.render_background(cr, rect)

        if self.security:
            lock_icon = self.lock_pixbuf
            draw_pixbuf(cr, lock_icon.get_pixbuf(), rect.x,
                        rect.y + (rect.height - IMG_WIDTH) / 2)

        if self.strength > 80:
            signal_icon = self.strength_3
        elif self.strength > 60:
            signal_icon = self.strength_2
        elif self.strength > 30:
            signal_icon = self.strength_1
        else:
            signal_icon = self.strength_0

        draw_pixbuf(cr, signal_icon.get_pixbuf(), rect.x + IMG_WIDTH + 5,
                    rect.y + (rect.height - IMG_WIDTH) / 2)
        with cairo_disable_antialias(cr):
            cr.set_source_rgb(*color_hex_to_cairo(self.border_color))
            cr.set_line_width(1)
            if self.is_last:
                cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
            cr.rectangle(rect.x, rect.y, rect.width, 1)
            cr.fill()
    def render_check(self, cr, rect):
        render_background(cr, rect)

        gap = (rect.height - IMG_WIDTH)/2
        
        if self.is_active:
            draw_pixbuf(cr, self.check_pixbuf.get_pixbuf(), rect.x + 10, rect.y + gap)   
示例#17
0
 def expose_button(self, widget, event):    
     
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     if widget.state == gtk.STATE_NORMAL:
         bg_pixbuf = self.normal_bg.get_pixbuf()
     elif widget.state == gtk.STATE_PRELIGHT:    
         bg_pixbuf = self.hover_bg.get_pixbuf()
     elif widget.state == gtk.STATE_ACTIVE:    
         bg_pixbuf = self.press_bg.get_pixbuf()
         
     icon_pixbuf = self.button_icon.get_pixbuf()    
         
     icon_y = rect.y + (rect.height - icon_pixbuf.get_height()) / 2    
     
     # Draw bg.
     draw_pixbuf(cr, bg_pixbuf, rect.x, rect.y)
     
     # Draw icon.
     draw_pixbuf(cr, icon_pixbuf, rect.x + self.left_padding, icon_y)
     
     # Draw label.
     draw_text(cr, utils.xmlescape(self.content), rect.x + self.left_padding + self.label_padding + icon_pixbuf.get_width(),
               rect.y, rect.width - self.left_padding - self.label_padding - icon_pixbuf.get_width(), rect.height,
               self.font_size, text_color="#FFFFFF")
     
     return True
示例#18
0
 def render_animation(self, cr, rect):
     self.animation_cache_pixbuf.scale(self.normal_pixbuf, self.active_size,
                                       self.active_size)
     animation_pixbuf = self.animation_cache_pixbuf.get_cache()
     icon_x = rect.x + (rect.width - self.active_size) / 2
     icon_y = rect.y + (rect.height - self.active_size) / 2
     draw_pixbuf(cr, animation_pixbuf, icon_x, icon_y)
示例#19
0
 def on_expose_event(self, widget, event):    
     cr = widget.window.cairo_create()
     rect = widget.allocation
     failed_pixbuf = self.failed_dpixbuf.get_pixbuf()
     draw_alpha_mask(cr, rect.x, rect.y, rect.width, rect.height, "layoutLeft")
     pixbuf_offset_x = (rect.width - failed_pixbuf.get_width()) / 2 
     pixbuf_offset_y = (rect.height - failed_pixbuf.get_height()) / 2 - 50
     icon_x = rect.x + pixbuf_offset_x
     icon_y = rect.y + pixbuf_offset_y
     draw_pixbuf(cr, failed_pixbuf, icon_x, icon_y)
     
     text_y = icon_y + failed_pixbuf.get_height() + self.text_padding_y
     text_x = icon_x + self.text_padding_x
     
     _width, _height = get_content_size(self.prompt_text)
     
     self.text_rect = gtk.gdk.Rectangle(text_x - rect.x, text_y - rect.y,
                                        rect.x + rect.width -  text_x - pixbuf_offset_x,
                                        _height)
     
     if self.is_hover:        
         text_color = self.hover_text_dcolor.get_color()
     else:    
         text_color = self.normal_text_dcolor.get_color()
         
     draw_text(cr, self.prompt_text, text_x, text_y, self.text_rect.width, _height,
               text_color=text_color, 
               underline=True, 
               alignment=pango.ALIGN_CENTER)
     return True
示例#20
0
 def render_icon(self, cr, rect, in_select, in_highlight):
     icon_x = rect.x + self.status_icon_padding_x
     icon_y = rect.y + (rect.height - self.status_icon_h) / 2
     if in_select:
         draw_pixbuf(cr, self.status_icon_press, icon_x, icon_y)
     else:
         draw_pixbuf(cr, self.status_icon, icon_x, icon_y)
示例#21
0
 def expose_button_cb(self, widget, event):    
     # Init.
     rect = widget.allocation
     
     bg_normal_dpixbuf, bg_hover_dpixbuf, bg_press_dpixbuf = self.bg_image_group
     fg_normal_dpixbuf, fg_hover_dpixbuf, fg_press_dpixbuf = self.icon_group
     
     if widget.state == gtk.STATE_NORMAL:
         bg_image = bg_normal_dpixbuf.get_pixbuf()
         fg_image = fg_normal_dpixbuf.get_pixbuf()
     elif widget.state == gtk.STATE_PRELIGHT:
         bg_image = bg_hover_dpixbuf.get_pixbuf()
         fg_image = fg_hover_dpixbuf.get_pixbuf()
     elif widget.state == gtk.STATE_ACTIVE:
         bg_image = bg_press_dpixbuf.get_pixbuf()
         fg_image = fg_press_dpixbuf.get_pixbuf()
         
     image_width = bg_image.get_width()    
     image_height = bg_image.get_height()
     
     fg_rect_x  = rect.x + (image_width - fg_image.get_width()) / 2
     fg_rect_y  = rect.y + (image_height - fg_image.get_height()) / 2
     
     cr = widget.window.cairo_create()
     draw_pixbuf(cr, bg_image, rect.x, rect.y)
     draw_pixbuf(cr, fg_image, fg_rect_x, fg_rect_y)
     
     propagate_expose(widget, event)
     
     return True
示例#22
0
 def expose_button(self, widget, event):    
     
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     if widget.state == gtk.STATE_NORMAL:
         bg_pixbuf = self.normal_bg.get_pixbuf()
     elif widget.state == gtk.STATE_PRELIGHT:    
         bg_pixbuf = self.hover_bg.get_pixbuf()
     elif widget.state == gtk.STATE_ACTIVE:    
         bg_pixbuf = self.press_bg.get_pixbuf()
         
     icon_pixbuf = self.button_icon.get_pixbuf()    
         
     icon_y = rect.y + (rect.height - icon_pixbuf.get_height()) / 2    
     
     # Draw bg.
     draw_pixbuf(cr, bg_pixbuf, rect.x, rect.y)
     
     # Draw icon.
     draw_pixbuf(cr, icon_pixbuf, rect.x + self.left_padding, icon_y)
     
     # Draw label.
     draw_text(cr, self.content, rect.x + self.left_padding + self.label_padding + icon_pixbuf.get_width(),
               rect.y, rect.width - self.left_padding - self.label_padding - icon_pixbuf.get_width(), rect.height,
               self.font_size, text_color="#FFFFFF")
     
     return True
    def on_expose_event(self, widget, event):
        '''
        docs
        '''
        cr = widget.window.cairo_create()
        rect = widget.allocation

        if widget.state == gtk.STATE_NORMAL:
            cr.set_source_rgba(0, 0, 0, 0)
        elif widget.state == gtk.STATE_PRELIGHT:
            cr.set_source_rgba(0.5, 0.5, 0.5, 0.5)
        elif widget.state == gtk.STATE_ACTIVE:
            cr.set_source_rgb(0.5, 0.5, 0.5)

        cr.rectangle(*rect)
        cr.fill()

        draw_pixbuf(cr, self.pixbuf, rect.x, rect.y + 5)

        draw_text(cr, self.content,
                  rect.x + self.pixbuf_width + 2,
                  rect.y + 8,
                  rect.width - self.pixbuf_width,
                  rect.height - self.pixbuf_height,
                  text_color=ui_theme.get_color("title_text").get_color(),
                  )

        return True
示例#24
0
    def expose_button(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        x,y,w,h = rect.x, rect.y, rect.width, rect.height
                    
        if widget.state == gtk.STATE_NORMAL:
            if self.start_bool:                
                image = self.start_button_normal.get_pixbuf()
            else:
                image = self.pause_button_normal.get_pixbuf()                
        elif widget.state == gtk.STATE_PRELIGHT:
            if self.start_bool:
                image = self.start_button_hover.get_pixbuf()
            else:    
                image = self.pause_button_hover.get_pixbuf()
        elif widget.state == gtk.STATE_ACTIVE:
            if self.start_bool:
                image = self.start_button_press.get_pixbuf()
            else:    
                image = self.pause_button_press.get_pixbuf()

        widget.set_size_request(image.get_width(), image.get_height())
        self.cache_pixbuf.scale(image, image.get_width(), image.get_height())        
        draw_pixbuf(cr, self.cache_pixbuf.get_cache(), widget.allocation.x, widget.allocation.y - self.image_y_padding)
        
        # Set widget size.
        propagate_expose(widget, event)
        return True
    def expose_top_left_icon(self, widget, event):
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation

        # Draw pkg icon.
        draw_pixbuf(cr, self.guide_pixbuf, rect.x, rect.y)
 def render(self, cr, rect):
     '''
     Render item.
     
     This is IconView interface, you should implement it.
     '''
     if self.icon_pixbuf == None:
         self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(get_icon_pixbuf_path(self.desktop_icon_name))
         
     draw_pixbuf(
         cr,
         self.icon_pixbuf,
         rect.x + (rect.width - self.icon_pixbuf.get_width()) / 2,
         rect.y + self.DESKTOP_ICON_PADDING_Y)    
     
     text_width = rect.width - self.DESKTOP_TEXT_PADDING_X * 2
     draw_text(
         cr,
         self.desktop_display_name,
         rect.x + self.DESKTOP_TEXT_PADDING_X,
         rect.y + self.DESKTOP_TEXT_PADDING_Y,
         text_width,
         DEFAULT_FONT_SIZE,
         alignment=pango.ALIGN_CENTER,
         wrap_width=text_width)
 def render_webcast_icon(self, cr, rect):        
     # Draw select background.
     if self.is_select:
         draw_single_mask(cr, rect.x, rect.y, rect.w, rect.h, "simpleItemHighlight")
         
     draw_pixbuf(cr, self.webcast_icon, rect.x + self.side_padding, 
                 rect.y + (rect.height - self.webcast_icon.get_height()) / 2)
示例#28
0
    def __paint_bottom_toolbar_background(self, e):
        # 将皮肤的图片画在bottom toolbar上,作为背景.
        cr = e.window.cairo_create()
        bottom_size = e.window.get_size()
        # draw background.
        cr.set_source_rgba(*alpha_color_hex_to_cairo(("#ebebeb", 0.1)))
        cr.rectangle(0, 0, bottom_size[0], bottom_size[1])
        cr.fill()
        # draw background pixbuf.
        pixbuf = skin_config.background_pixbuf
        app_h = self.application.window.allocation.height
        app_w = self.application.window.allocation.width
        bottom_h = bottom_size[1]
        # 当图片的高度小雨窗口高度的时候,只拿出图片的最尾巴.
        if pixbuf.get_height() > app_h + bottom_h:
            h = app_h
        else:
            h = pixbuf.get_height() - bottom_h
        # 当图片小于窗口宽度的时候,拉伸图片.
        if pixbuf.get_width() < app_w:
            pixbuf = pixbuf.scale_simple(app_w,
                                pixbuf.get_width(),
                                gtk.gdk.INTERP_BILINEAR)

        draw_pixbuf(cr, 
                    pixbuf, 
                    0, 
                    -(h))
def render_pkg_icon(cr, rect, icon_pixbuf, offset_x=0):
    # Draw icon.
    draw_pixbuf(cr, 
                icon_pixbuf, 
                rect.x + ITEM_PADDING_X + offset_x + (ICON_SIZE - icon_pixbuf.get_width()) / 2,
                rect.y + ITEM_PADDING_Y,
                )    
 def render_title(self, cr, rect):        
     # Draw select background.
         
     if self.is_select:    
         draw_single_mask(cr, rect.x + 1, rect.y, rect.width - 2, rect.height, "globalItemHighlight")
     elif self.is_hover:
         draw_single_mask(cr, rect.x + 1, rect.y, rect.width - 2, rect.height, "globalItemHover")
     
     if self.is_select:
         text_color = "#FFFFFF"
     else:    
         text_color = app_theme.get_color("labelText").get_color()
         
     if self.is_select:    
         icon_pixbuf = self.press_dpixbuf.get_pixbuf()
     else:    
         icon_pixbuf = self.normal_dpixbuf.get_pixbuf()
         
     rect.x += self.padding_x    
     rect.width -= self.padding_x * 2
     icon_y = rect.y + (rect.height - icon_pixbuf.get_height()) / 2
     draw_pixbuf(cr,icon_pixbuf, rect.x, icon_y)    
     rect.x += self.icon_width + self.padding_x
     rect.width -= self.icon_width
         
     draw_text(cr, self.title, rect.x,
               rect.y, rect.width,
               rect.height, text_size=10, 
               text_color = text_color,
               alignment=pango.ALIGN_LEFT)    
    def expose_state(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        if self.net_state == 1:
            self.draw_loading(cr, rect)
        elif self.net_state == 2:
            draw_pixbuf(cr, self.check_pixbuf.get_pixbuf(), rect.x + 10, rect.y + 7)
示例#32
0
 def render_collect_icon(self, cr, rect, in_select, in_highlight):
     icon_y = rect.y + (rect.height - self.collect_icon_h) / 2
     rect.x += self.collect_icon_padding_x
     if self.is_collected:
         pixbuf = self.collect_press_pixbuf
     else:
         pixbuf = self.collect_normal_pixbuf
     draw_pixbuf(cr, pixbuf, rect.x, icon_y)
 def render_collect_icon(self, cr, rect, in_select, in_highlight):    
     icon_y = rect.y + (rect.height - self.collect_icon_h) / 2
     rect.x += self.collect_icon_padding_x
     if self.is_collected:
         pixbuf = self.collect_press_pixbuf
     else:    
         pixbuf = self.collect_normal_pixbuf
     draw_pixbuf(cr, pixbuf, rect.x , icon_y)
示例#34
0
    def render_check(self, cr, rect):
        render_background(cr, rect)

        gap = (rect.height - IMG_WIDTH) / 2

        if self.is_active:
            draw_pixbuf(cr, self.check_pixbuf.get_pixbuf(), rect.x + 10,
                        rect.y + gap)
 def render_webcast_icon(self, cr, rect, in_select, in_highlight):    
     icon_x = rect.x + self.webcast_icon_padding_x 
     icon_y = rect.y + (rect.height - self.webcast_icon_h) / 2
     if in_select:
         pixbuf = self.webcast_press_pixbuf
     else:    
         pixbuf = self.webcast_normal_pixbuf
     draw_pixbuf(cr, pixbuf, icon_x, icon_y)
示例#36
0
 def expose_topmenu(self, widget, event):
     cr = widget.window.cairo_create()
     rect = widget.allocation
     # get pixbuf.
     pixbuf = self.state_return_pixbuf(widget.state)
     # draw pixbuf.
     draw_pixbuf(cr, pixbuf, rect.x, rect.y)
     return True
示例#37
0
 def render_webcast_icon(self, cr, rect, in_select, in_highlight):
     icon_x = rect.x + self.webcast_icon_padding_x
     icon_y = rect.y + (rect.height - self.webcast_icon_h) / 2
     if in_highlight:
         pixbuf = self.webcast_press_pixbuf
     else:
         pixbuf = self.webcast_normal_pixbuf
     draw_pixbuf(cr, pixbuf, icon_x, icon_y)
示例#38
0
    def render_pkg_picture(self, cr, rect):
        if self.pixbuf == None:
            self.pixbuf = gtk.gdk.pixbuf_new_from_file(DEFAULT_CACHE_IMAGE_PATH)

        draw_pixbuf(cr,
                    self.pixbuf,
                    rect.x + self.PICTURE_PADDING_X,
                    rect.y + self.PICTURE_PADDING_Y)
    def render_stop(self, cr, rect):
        if self.is_hover:
            draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height,
                             "globalItemHover")

        icon_x = rect.x + (rect.width - self.stop_pixbuf.get_width()) / 2
        icon_y = rect.y + (rect.height - self.stop_pixbuf.get_height()) / 2
        draw_pixbuf(cr, self.stop_pixbuf, icon_x, icon_y)
示例#40
0
def render_pkg_icon(cr, rect, icon_pixbuf, offset_x=0):
    # Draw icon.
    draw_pixbuf(
        cr,
        icon_pixbuf,
        rect.x + ITEM_PADDING_X + offset_x +
        (ICON_SIZE - icon_pixbuf.get_width()) / 2,
        rect.y + ITEM_PADDING_Y,
    )
 def on_expose_event(self, widget, event):
     cr = widget.window.cairo_create()
     rect = widget.get_allocation()
     draw_pixbuf(cr,
                 self.pixbuf,
                 rect.x,
                 rect.y,
                 )    
     return True
示例#42
0
    def render_webcast_icon(self, cr, rect):
        # Draw select background.
        if self.is_select:
            draw_single_mask(cr, rect.x, rect.y, rect.w, rect.h,
                             "simpleItemHighlight")

        draw_pixbuf(
            cr, self.webcast_icon, rect.x + self.side_padding,
            rect.y + (rect.height - self.webcast_icon.get_height()) / 2)
 def render_title(self, cr, rect, in_selection, in_highlight):
     '''Render title.'''
     rect.x += self.status_icon_padding_x # title_padding_x
     icon_x = rect.x + self.status_icon_padding_x # self.status_icon_padding_x
     icon_y = rect.y + (rect.height - self.status_icon_h) / 2
     if in_selection:
         draw_pixbuf(cr, self.status_icon_press, icon_x, icon_y)
     else:    
         draw_pixbuf(cr, self.status_icon, icon_x, icon_y)
示例#44
0
 def expose_button_cb(self, widget, event):    
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     # Draw cover side.
     draw_pixbuf(cr, self.cover_side_pixbuf, rect.x, rect.y)
     
     draw_pixbuf(cr, self.current_cover_pixbuf, rect.x + 4, rect.y + 4)
     return True
示例#45
0
    def expose_waiting(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.translate(rect.x, rect.y)
        draw_pixbuf(cr, self.waiting_bg_pixbuf)
        cr.translate(rect.width/2, rect.height/2)
        cr.rotate(self.counter * self.factor)
        draw_pixbuf(cr, self.waiting_fg_pixbuf, -rect.width/2, -rect.height/2)
示例#46
0
    def render(self, cr, rect):
        '''
        Render item.
        
        This is IconView interface, you should implement it.
        '''
        if self.pixbuf == None:
            self.create_cache_pixbuf()

        wallpaper_x = rect.x + (rect.width - self.wallpaper_width) / 2
        wallpaper_y = rect.y + (rect.height - self.wallpaper_height) / 2

        # Draw shadow.
        drop_shadow_padding = 7
        drop_shadow_radious = 7
        draw_shadow(cr, wallpaper_x, wallpaper_y,
                    self.wallpaper_width + drop_shadow_padding,
                    self.wallpaper_height + drop_shadow_padding,
                    drop_shadow_radious,
                    app_theme.get_shadow_color("window_shadow"))

        outside_shadow_padding = 4
        outside_shadow_radious = 5
        draw_shadow(cr, wallpaper_x - outside_shadow_padding,
                    wallpaper_y - outside_shadow_padding,
                    self.wallpaper_width + outside_shadow_padding * 2,
                    self.wallpaper_height + outside_shadow_padding * 2,
                    outside_shadow_radious,
                    app_theme.get_shadow_color("window_shadow"))

        # Draw wallpaper.
        draw_pixbuf(cr, self.pixbuf, wallpaper_x, wallpaper_y)

        # Draw wallpaper frame.
        with cairo_disable_antialias(cr):
            cr.set_line_width(2)
            cr.set_source_rgba(1, 1, 1, 1)
            cr.rectangle(wallpaper_x, wallpaper_y, self.wallpaper_width,
                         self.wallpaper_height)
            cr.stroke()

        if self.is_hover:
            cr.rectangle(wallpaper_x, wallpaper_y, self.wallpaper_width,
                         self.wallpaper_height)
            cr.set_source_rgb(
                *color_hex_to_cairo(self.hover_stroke_dcolor.get_color()))
            cr.stroke()

        if self.is_tick:
            tick_pixbuf = self.tick_normal_dpixbuf.get_pixbuf()
        else:
            tick_pixbuf = self.tick_gray_dpixbuf.get_pixbuf()

        tick_x = wallpaper_x + self.wallpaper_width - tick_pixbuf.get_width(
        ) / 2
        tick_y = wallpaper_y - tick_pixbuf.get_height() / 2
        draw_pixbuf(cr, tick_pixbuf, tick_x, tick_y)
示例#47
0
    def expose_h_scalebar(self, widget, event):    
        cr = widget.window.cairo_create()
        rect = widget.allocation
        
        # Init pixbuf.
        fg_pixbuf = self.fg_dpixbuf.get_pixbuf()
        bg_pixbuf = self.bg_dpixbuf.get_pixbuf()
        point_normal_pixbuf = self.point_normal_dpixbuf.get_pixbuf()
        # point_hover_pixbuf = self.point_hover_dpixbuf.get_pixbuf()
        # point_press_pixbuf = self.point_press_dpixbuf.get_pixbuf()
        
        # Init value.
        upper = self.get_adjustment().get_upper()
        lower = self.get_adjustment().get_lower()
        total_length = max(upper - lower, 1)
        
        point_width = point_normal_pixbuf.get_width()
        point_height = point_normal_pixbuf.get_height()
        x, y, w, h = rect.x + point_width / 2, rect.y, rect.width - point_width, rect.height
        
        line_height = bg_pixbuf.get_height()

        line_y = y + (point_height - line_height) / 2
        value = int((self.get_value() - lower) / total_length * w)
        
        
        # Draw background.
        self.fg_cache_pixbuf.scale(
            bg_pixbuf, w + point_width, line_height)
        draw_pixbuf(
            cr,
            self.fg_cache_pixbuf.get_cache(),
            rect.x, line_y)
        
        self.bg_cache_pixbuf.scale(
            fg_pixbuf, point_width / 2, line_height)
        draw_pixbuf(
            cr,
            self.bg_cache_pixbuf.get_cache(),
            rect.x, line_y)

        
        if value > 0:
            self.side_cache_pixbuf.scale(
                fg_pixbuf, value + point_width, line_height)
            draw_pixbuf(
                cr, 
                self.side_cache_pixbuf.get_cache(),
                rect.x, line_y)
            
        if value > 0:    
            draw_pixbuf(cr, point_normal_pixbuf, x + value - point_width / 2 + 2, y)    
        else:    
            draw_pixbuf(cr, point_normal_pixbuf, x + value - point_width / 2 - 1, y)
        
        return True
示例#48
0
    def expose_simple_item(self, widget, event):

        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        rect.x += 1
        rect.width -= 2
        font_color = app_theme.get_color("labelText").get_color()
        item_pixbuf = self.normal_dpixbuf.get_pixbuf()
        select_index = self.get_index()

        if widget.state == gtk.STATE_NORMAL:
            if select_index == self.index:
                select_status = BUTTON_PRESS
            else:
                select_status = BUTTON_NORMAL

        elif widget.state == gtk.STATE_PRELIGHT:
            if select_index == self.index:
                select_status = BUTTON_PRESS
            else:
                select_status = BUTTON_HOVER

        elif widget.state == gtk.STATE_ACTIVE:
            select_status = BUTTON_PRESS

        if select_status == BUTTON_PRESS:
            draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height,
                             "globalItemHighlight")
            # font_color = app_theme.get_color("simpleSelectItem").get_color()
            font_color = "#FFFFFF"
            item_pixbuf = self.press_dpixbuf.get_pixbuf()

        elif select_status == BUTTON_HOVER:
            draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height,
                             "globalItemHover")

        # Draw pixbuf.
        draw_pixbuf(cr, item_pixbuf, rect.x + self.padding_left,
                    rect.y + (rect.height - item_pixbuf.get_height()) / 2)

        # Draw content.
        draw_text(cr,
                  self.content,
                  rect.x + self.padding_left + self.font_offset,
                  rect.y,
                  rect.width - self.padding_left - self.font_offset -
                  self.padding_right,
                  rect.height,
                  self.font_size,
                  font_color,
                  alignment=self.x_align)

        propagate_expose(widget, event)

        return True
示例#49
0
    def expose_waiting(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.translate(rect.x, rect.y)
        draw_pixbuf(cr, self.waiting_bg_pixbuf)
        cr.translate(rect.width / 2, rect.height / 2)
        cr.rotate(self.counter * self.factor)
        draw_pixbuf(cr, self.waiting_fg_pixbuf, -rect.width / 2,
                    -rect.height / 2)
示例#50
0
 def on_expose_event(self, widget, event):
     cr = widget.window.cairo_create()
     rect = widget.get_allocation()
     draw_pixbuf(
         cr,
         self.pixbuf,
         rect.x,
         rect.y,
     )
     return True
 def expose_top_left_icon(self, widget, event):
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     # Draw pkg icon.
     draw_pixbuf(cr,
                 self.guide_pixbuf,
                 rect.x,
                 rect.y)
示例#52
0
    def render(self, cr, rect):
        if self.pkg_picture_pixbuf == None:
            self.pkg_picture_pixbuf = get_common_image_pixbuf('recommend/default_cache.png')

        padding_x = (rect.width - self.pkg_picture_pixbuf.get_width()) / 2
        padding_y = (rect.height - self.pkg_picture_pixbuf.get_height()) / 2
        draw_pixbuf(cr,
                    self.pkg_picture_pixbuf,
                    rect.x + padding_x,
                    rect.y + padding_y)
示例#53
0
    def expose_category_item(self, widget, event):

        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        font_color = app_theme.get_color("labelText").get_color()
        arrow_pixbuf = self.arrow_dpixbuf.get_pixbuf()
        select_index = self.get_index()

        if widget.state == gtk.STATE_NORMAL:
            if select_index == self.index:
                select_status = BUTTON_PRESS
            else:
                select_status = BUTTON_NORMAL

        elif widget.state == gtk.STATE_PRELIGHT:
            if select_index == self.index:
                select_status = BUTTON_PRESS
            else:
                select_status = BUTTON_HOVER

        elif widget.state == gtk.STATE_ACTIVE:
            select_status = BUTTON_PRESS

        if select_status == BUTTON_PRESS:
            draw_vlinear(
                cr, rect.x, rect.y, rect.width, rect.height,
                app_theme.get_shadow_color("simpleItemPress").get_color_info())
            font_color = app_theme.get_color("simpleSelectItem").get_color()

        elif select_status == BUTTON_HOVER:
            draw_vlinear(
                cr, rect.x, rect.y, rect.width, rect.height,
                app_theme.get_shadow_color("simpleItemHover").get_color_info())

        # Draw content.
        draw_text(cr,
                  self.content,
                  rect.x + self.padding_left,
                  rect.y,
                  rect.width - self.padding_left - self.arrow_width -
                  self.padding_right,
                  rect.height,
                  self.font_size,
                  font_color,
                  alignment=self.x_align)

        # Draw pixbuf.
        draw_pixbuf(
            cr, arrow_pixbuf,
            rect.x + rect.width - self.arrow_width - self.padding_right,
            rect.y + (rect.height - arrow_pixbuf.get_height()) / 2)
        propagate_expose(widget, event)

        return True
示例#54
0
    def draw_loop_pixbuf(self, cr, loop_pixbuf, loop_x, loop_y):
        width = loop_pixbuf.get_width()
        height = loop_pixbuf.get_height()
        ox = loop_x + width * 0.5
        oy = loop_y + height * 0.5

        with cairo_state(cr):
            cr.translate(ox, oy)
            cr.rotate(radians(self.degree))
            cr.translate(-width * 0.5, -height * 0.5)
            draw_pixbuf(cr, loop_pixbuf, 0, 0)
 def render_jumpto(self, cr, rect):
     self.render_background(cr, rect)
     draw_pixbuf(cr, self.jumpto_pixbuf.get_pixbuf(), rect.x , rect.y + (rect.height - IMG_WIDTH)/2)
     with cairo_disable_antialias(cr):
         cr.set_source_rgb(*color_hex_to_cairo(self.border_color))
         cr.set_line_width(1)
         if self.is_last:
             cr.rectangle(rect.x, rect.y + rect.height -1, rect.width, 1)
         cr.rectangle(rect.x, rect.y, rect.width, 1)
         cr.rectangle(rect.x + rect.width -1, rect.y, 1, rect.height)
         cr.fill()
 def expose_info_image_box(self, widget, event):
     cr = widget.window.cairo_create()
     rect = widget.allocation
     msg_pixbuf = get_common_image_pixbuf("msg/msg1.png")
     pix_width = msg_pixbuf.get_width()
     pix_height = msg_pixbuf.get_height()
     draw_pixbuf(cr,
                 msg_pixbuf,
                 rect.x + (rect.width-pix_width)/2,
                 rect.y + (rect.height-pix_height)/2,
                 )