def __camera_box_expose(self, widget, event):
        cr = widget.window.cairo_create()
        x, y, w, h = widget.allocation
        # draw frame
        with cairo_disable_antialias(cr):
            cr.rectangle(x, y, w, h)
            cr.set_line_width(1)
            cr.set_source_rgb(*color_hex_to_cairo("#a2a2a2"))
            cr.stroke()
        # draw background
        cr.rectangle(x + 5, y + 5, w - 10, h - 10)
        cr.set_source_rgb(*color_hex_to_cairo("#333333"))
        cr.fill()

        # draw camera icon
        if hasattr(self, "scanning") and self.scanning:
            draw_pixbuf(cr, self.snapshot_pixbuf,
                        x = x + (CAMERA_BOX_SIZE - self.snapshot_pixbuf.get_width()) / 2,
                        y = y + (CAMERA_BOX_SIZE - self.snapshot_pixbuf.get_height()) / 2)
        else:
            draw_pixbuf(cr, self.camera_pixbuf,
                        x = x + (CAMERA_BOX_SIZE - self.camera_pixbuf.get_width()) / 2,
                        y = y + (CAMERA_BOX_SIZE - self.camera_pixbuf.get_height()) / 2)
            if not Webcam.has_device():
                draw_pixbuf(cr, self.error_pixbuf,
                            x = x + (CAMERA_BOX_SIZE - self.camera_pixbuf.get_width()) / 2 + 12,
                            y = y + (CAMERA_BOX_SIZE - self.camera_pixbuf.get_height()) / 2 + 12)
Example #2
0
    def __draw_frame(self, cr, allocation):
        with cairo_disable_antialias(cr):
            cr.set_line_width(1)
            cr.save()
            cr.set_dash((9, 3))
            cr.set_source_rgb(*color_hex_to_cairo(self.border_color))
            x = self.edit_coord_x
            y = self.edit_coord_y
            w = self.edit_coord_w
            h = self.edit_coord_h
            if x == 0:
                x = 1
            if y == 0:
                y = 1
            if x + w > self.AREA_WIDTH:
                w = self.AREA_WIDTH - x
            if y + h > self.AREA_HEIGHT:
                h = self.AREA_HEIGHT - y
            cr.rectangle(x, y, w, h)
            cr.stroke()

            cr.set_dash((3, 9))
            cr.set_source_rgb(1, 1, 1)
            cr.rectangle(x, y, w, h)
            cr.stroke()
            cr.restore()

            cr.set_source_rgb(*color_hex_to_cairo(self.border_color))
            cr.rectangle(self.drag_point_x, self.drag_point_y, self.DRAG_WIDTH,
                         self.DRAG_WIDTH)
            cr.stroke()
Example #3
0
 def on_expose_event(self, widget, event):
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     # Draw left arc.
     cr.save()
     cr.translate(self.padding_x, self.padding_y)
     cr.rectangle(rect.x, rect.y, rect.width - self.padding_x * 2, rect.height - self.padding_y * 2)
     cr.set_line_width(1)
     cr.set_source_rgb(*color_hex_to_cairo("#999999"))
     cr.stroke()
     cr.restore()    
     
     cr.save()    
     for  i in range(1, self.max_number + 1):
         if i % 2 == 0:
             first_upper_x = self.move_x + rect.x + self.padding_y + self.item_width * i
             cr.move_to(first_upper_x, rect.y + self.padding_y)
             cr.rel_line_to(-self.item_width, self.item_height)
             cr.rel_line_to(self.item_width, 0)
             cr.rel_line_to(self.item_width, -self.item_height)
             cr.set_source_rgb(*color_hex_to_cairo("#3E89CF"))
             cr.fill()
         else:
             second_upper_x = self.move_x + rect.x + self.padding_y + self.item_width * i
             cr.move_to(second_upper_x, rect.y + self.padding_y)
             cr.rel_line_to(-self.item_width, self.item_height)
             cr.rel_line_to(self.item_width, 0)
             cr.rel_line_to(self.item_width, -self.item_height)
             cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
             cr.fill()
     cr.restore()
     return True
    def select_button_expose_event(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        if widget.state == gtk.STATE_PRELIGHT:
            with cairo_disable_antialias(cr):
                cr.set_source_rgb(*color_hex_to_cairo(self.bg_color))
                cr.rectangle(rect.x,
                             rect.y,
                             rect.width,
                             rect.height)
                cr.fill()

                cr.set_source_rgb(*color_hex_to_cairo(self.line_color))
                cr.rectangle(rect.x,
                             rect.y,
                             rect.width,
                             rect.height)
                cr.stroke()

        # draw text.
        draw_text(cr, self.label,
                  rect.x, rect.y,
                  rect.width, rect.height,
                  text_size=FONT_SIZE,
                  text_color=self.text_color,
                  alignment=pango.ALIGN_RIGHT
                  )

        return True
    def __draw_frame(self, cr, allocation):
        with cairo_disable_antialias(cr):
            cr.set_line_width(1)
            cr.save()
            cr.set_dash((9, 3))
            cr.set_source_rgb(*color_hex_to_cairo(self.border_color))
            x = self.edit_coord_x
            y = self.edit_coord_y
            w = self.edit_coord_w
            h = self.edit_coord_h
            if x == 0:
                x = 1
            if y == 0:
                y = 1
            if x + w > self.AREA_WIDTH:
                w = self.AREA_WIDTH- x
            if y + h > self.AREA_HEIGHT:
                h = self.AREA_HEIGHT- y
            cr.rectangle(x, y, w, h)
            cr.stroke()

            cr.set_dash((3, 9))
            cr.set_source_rgb(1, 1, 1)
            cr.rectangle(x, y, w, h)
            cr.stroke()
            cr.restore()

            cr.set_source_rgb(*color_hex_to_cairo(self.border_color))
            cr.rectangle(self.drag_point_x, self.drag_point_y, self.DRAG_WIDTH, self.DRAG_WIDTH)
            cr.stroke()
Example #6
0
    def render_name(self, cr, rect):
        text_color = "#333333"
        if self.is_select:
            cr.set_source_rgba(*color_hex_to_cairo(
                app_theme.get_color("sidebar_select").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

            text_color = "#FFFFFF"
        elif self.is_hover:
            cr.set_source_rgba(*color_hex_to_cairo(
                app_theme.get_color("sidebar_hover").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

        draw_text(
            cr,
            get_category_name(self.second_category_name),
            rect.x + SECOND_CATEGORY_PADDING_X,
            rect.y,
            rect.width,
            rect.height,
            text_size=SECOND_CATEGORY_ITEM_NAME_SIZE,
            text_color=text_color,
        )
    def draw_mask(self, cr, x, y, w, h):
        cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
        cr.rectangle(x, y, w, h)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo("#AEAEAE"))
        cr.rectangle(x, y, w, h)
        cr.stroke()
    def draw_mask(self, cr, x, y, w, h):
        cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
        cr.rectangle(x, y, w, h)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo("#AEAEAE"))
        cr.rectangle(x, y, w, h)
        cr.stroke()
    def draw_background(self, widget, event):
        cr = widget.window.cairo_create()
        x, y, w, h = widget.allocation
        cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))
        cr.rectangle(x, y+1, w, h-1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
        draw_line(cr, x, y + 1, x + w, y + 1)
Example #10
0
 def draw_frame_border(self, widget, event, sw1, sw2):
     x, y, w, h = sw1.allocation
     cr = widget.window.cairo_create()
     cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
     cr.rectangle(x, y, w, h)
     cr.stroke()
     x, y, w, h = sw2.allocation
     cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
     cr.rectangle(x, y, w, h)
     cr.stroke()
    def __expose(self, widget, event):
        cr = widget.window.cairo_create()                                       
        rect = widget.allocation                                                
        
        cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))                     
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)                       
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
        draw_line(cr, rect.x, rect.y + 1, rect.x + rect.width, rect.y + 1)
 def draw_mask(self, cr, x, y, w, h):
     cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))
     cr.rectangle(x, y, w, h)
     cr.fill()
     with cairo_disable_antialias(cr):
         cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
         cr.set_line_width(1)
         cr.move_to(x+w-2, y)
         cr.line_to(x+w-2, y+h)
         cr.stroke()
    def __expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
        draw_line(cr, rect.x, rect.y + 1, rect.x + rect.width, rect.y + 1)
 def draw_frame_border(self, widget, event, sw1, sw2):
     x, y, w, h = sw1.allocation
     cr = widget.window.cairo_create()
     cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
     cr.rectangle(x, y, w, h)
     cr.stroke()
     x, y, w, h = sw2.allocation
     cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
     cr.rectangle(x, y, w, h)
     cr.stroke()
 def render_background(self,  cr, rect):
     if self.is_select:
         background_color = app_theme.get_color("globalItemSelect")
         cr.set_source_rgb(*color_hex_to_cairo(background_color.get_color()))
     else:
         if  self.is_hover:
             background_color = app_theme.get_color("globalItemHover")
             cr.set_source_rgb(*color_hex_to_cairo(background_color.get_color()))
         else:
             background_color = "#ffffff"
             cr.set_source_rgb(*color_hex_to_cairo(background_color))
     cr.rectangle(rect.x, rect.y, rect.width, rect.height)
     cr.fill()
Example #16
0
    def expose_left_view(self, widget, event):
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation

        # Draw background.
        cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()

        # Draw split line.
        cr.set_source_rgb(*color_hex_to_cairo("#AAAAAA"))
        cr.rectangle(rect.x + rect.width - 1, rect.y, 1, rect.height)
        cr.fill()
Example #17
0
    def expose_left_view(self, widget, event):
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation

        # Draw background.
        cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()

        # Draw split line.
        cr.set_source_rgb(*color_hex_to_cairo("#AAAAAA"))
        cr.rectangle(rect.x + rect.width - 1, rect.y, 1, rect.height)
        cr.fill()
    def render(self, cr, rect):
        padding = 10

        # Draw select background.
        if self.is_button_press == True:
            with cairo_disable_antialias(cr):
                cr.set_source_rgb(
                    *color_hex_to_cairo(self.highlight_fill_color))
                cr.rectangle(rect.x + padding, rect.y + padding,
                             rect.width - padding, rect.height - padding)
                cr.fill_preserve()
                cr.set_line_width(1)
                cr.set_source_rgb(
                    *color_hex_to_cairo(self.highlight_stroke_color))
                cr.stroke()

        # Draw device icon.
        draw_pixbuf(
            cr,
            self.pixbuf,
            rect.x + self.icon_size / 2 + 4,
            rect.y + (rect.height - self.icon_size) / 2,
        )

        if self.is_paired:
            draw_pixbuf(
                cr, self.pair_pixbuf.get_pixbuf(), rect.x + self.icon_size +
                self.pair_pixbuf.get_pixbuf().get_width() / 2,
                rect.y + self.icon_size +
                self.pair_pixbuf.get_pixbuf().get_height() / 2)
        if self.is_connected:
            draw_pixbuf(
                cr, self.device_connected_pixbuf.get_pixbuf(), rect.x +
                self.icon_size + self.pair_pixbuf.get_pixbuf().get_width() / 2,
                rect.y + self.pair_pixbuf.get_pixbuf().get_height())

        # Draw device name.
        text_color = "#000000"
        if self.is_button_press == True:
            text_color = "#FFFFFF"
        draw_text(cr,
                  self.name,
                  rect.x + padding,
                  rect.y + self.icon_size + self.__const_padding_y * 2,
                  rect.width - padding,
                  CONTENT_FONT_SIZE,
                  CONTENT_FONT_SIZE,
                  text_color,
                  alignment=pango.ALIGN_CENTER)
    def expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo('#cccccc'))
        cr.rectangle(rect.x, rect.y, rect.width, 1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo('#ffffff'))
        cr.rectangle(rect.x, rect.y+1, rect.width, 1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo('#fff9c9'))
        cr.rectangle(rect.x, rect.y+2, rect.width, rect.height-2)
        cr.fill()
Example #20
0
    def expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo('#cccccc'))
        cr.rectangle(rect.x, rect.y, rect.width, 1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo('#ffffff'))
        cr.rectangle(rect.x, rect.y + 1, rect.width, 1)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo('#fff9c9'))
        cr.rectangle(rect.x, rect.y + 2, rect.width, rect.height - 2)
        cr.fill()
Example #21
0
 def __expose_cb(self, widget, event):
     ''' expose-event callback'''
     cr = widget.window.cairo_create()
     x, y, w, h = widget.allocation
     if widget.get_state() == gtk.STATE_PRELIGHT:
         cr.set_source_rgb(*color_hex_to_cairo("#ddf3ff"))
         cr.rectangle(0, 0, w, self.padding_y)
         cr.fill()
         cr.rectangle(0, h - self.padding_y, w, self.padding_y)
         cr.fill()
         cr.rectangle(0, self.padding_y, self.padding_x,
                      h - 2 * self.padding_y)
         cr.fill()
         cr.rectangle(w - self.padding_x, self.padding_y, self.padding_x,
                      h - 2 * self.padding_y)
         cr.fill()
     else:
         cr.set_source_rgb(1, 1, 1)
         cr.rectangle(0, 0, w, self.padding_y)
         cr.fill()
         cr.rectangle(0, h - self.padding_y, w, self.padding_y)
         cr.fill()
         cr.rectangle(0, self.padding_y, self.padding_x,
                      h - 2 * self.padding_y)
         cr.fill()
         cr.rectangle(w - self.padding_x, self.padding_y, self.padding_x,
                      h - 2 * self.padding_y)
         cr.fill()
     if self.has_frame:
         with cairo_disable_antialias(cr):
             border_color = "#CCCCCC"
             cr.set_source_rgb(*color_hex_to_cairo(border_color))
             cr.set_line_width(1)
             cr.rectangle(self.padding_x, self.padding_y,
                          w - 2 * self.padding_x + 1,
                          h - 2 * self.padding_y + 1)
             cr.stroke()
     if self.pixbuf:
         cr.set_source_pixbuf(self.pixbuf, self.padding_x, self.padding_y)
         cr.paint()
     if self.can_del and widget.get_state() == gtk.STATE_PRELIGHT:
         bg_pixbuf = self.del_bg_pixbuf.get_pixbuf()
         fg_pixbuf = self.del_fg_pixbuf.get_pixbuf()
         cr.set_source_pixbuf(bg_pixbuf, self.bg_offset_x, self.bg_offset_y)
         cr.paint()
         cr.set_source_pixbuf(fg_pixbuf, self.fg_offset_x, self.fg_offset_y)
         cr.paint()
     return True
    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)
Example #23
0
 def draw_entry_text(self, cr, rect):
     ''' draw text.expose-event callback'''
     x, y, w, h = rect.x, rect.y, rect.width, rect.height
     with cairo_state(cr):
         # Clip text area first.
         draw_x = x + self.padding_x
         draw_y = y + self.padding_y
         draw_width = w - self.padding_x * 2
         draw_height = h - self.padding_y * 2
         cr.rectangle(draw_x, draw_y, draw_width, draw_height)
         cr.clip()
         # Create pangocairo context.
         context = pangocairo.CairoContext(cr)
         # Move text.
         cr.move_to(draw_x, draw_y)
         # Draw text.
         cr.set_source_rgb(
             *color_hex_to_cairo(self.entry_buffer.text_color))
         context.update_layout(self._layout)
         context.show_layout(self._layout)
     # draw selection
     if not self.buffer.get_has_selection():
         return
     bounds = self.buffer.get_selection_bounds()
     self.draw_selection_lines(bounds[0], bounds[1], cr, x, y)
Example #24
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 __draw_title_background(self, cr, widget):
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))
        cr.rectangle(rect.x, rect.y - FRAME_TOP_PADDING, rect.width,
                     rect.height - 1)
        cr.fill()
 def draw_frame_border(self, widget, event, la, ra):
     cr = widget.window.cairo_create()
     with cairo_disable_antialias(cr):
         cr.set_line_width(1)
         x, y, w, h = self.thumbnail_large.allocation
         cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
         cr.rectangle(x-1, y-1, w+2, h+2)
         cr.stroke()
         x, y, w, h = self.thumbnail_mid.allocation
         cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
         cr.rectangle(x-1, y-1, w+2, h+2)
         cr.stroke()
         x, y, w, h = self.thumbnail_small.allocation
         cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
         cr.rectangle(x-1, y-1, w+2, h+2)
         cr.stroke()
    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)    
Example #28
0
 def render_text(self, cr, rect):
     if self.is_select:
         text_color = "#FFFFFF"
         bg_color = "#3399FF"
     else:
         text_color = "#000000"
         bg_color = MODULE_BG_COLOR
     cr.set_source_rgb(*color_hex_to_cairo(bg_color))
     cr.rectangle(rect.x + 1, rect.y, rect.width - 2, rect.height - 1)
     cr.paint()
     if self.get_treeview().show_search_flag and not self.is_select:
         draw_text(cr,
                   self.name_in_search,
                   rect.x + self.padding_x,
                   rect.y,
                   rect.width,
                   rect.height,
                   text_color=text_color)
     else:
         draw_text(cr,
                   self.name,
                   rect.x + self.padding_x,
                   rect.y,
                   rect.width,
                   rect.height,
                   text_color=text_color)
    def render_check(self, cr, rect):
        self.render_background(cr,rect)

        if self.is_hover and self.network_state ==self.NETWORK_DISCONNECT:
            draw_pixbuf(cr, self.check_hover_pixbuf.get_pixbuf(), rect.x + self.H_PADDING, rect.y + (rect.height - IMG_WIDTH)/2)
        elif self.is_hover:
            if self.hover_column == 0 and self.can_disable:
                draw_pixbuf(cr, self.check_disable.get_pixbuf(), rect.x + self.H_PADDING, rect.y + (rect.height - IMG_WIDTH)/2)
            else:
                if self.network_state == self.NETWORK_LOADING:
                    self.draw_loading(cr, rect)
                elif self.network_state == self.NETWORK_CONNECTED:
                    draw_pixbuf(cr, self.check_pixbuf.get_pixbuf(), rect.x + self.H_PADDING, rect.y + (rect.height - IMG_WIDTH)/2)
        else:
            if self.network_state == self.NETWORK_LOADING:
                self.draw_loading(cr, rect)
            elif self.network_state == self.NETWORK_CONNECTED:
                draw_pixbuf(cr, self.check_pixbuf.get_pixbuf(), rect.x + self.H_PADDING, rect.y + (rect.height - IMG_WIDTH)/2)

        #draw outline
        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.y, 1, rect.height)
            cr.fill()
Example #30
0
 def draw_frame_border(self, widget, event, la, ra):
     cr = widget.window.cairo_create()
     with cairo_disable_antialias(cr):
         cr.set_line_width(1)
         x, y, w, h = self.thumbnail_large.allocation
         cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
         cr.rectangle(x - 1, y - 1, w + 2, h + 2)
         cr.stroke()
         x, y, w, h = self.thumbnail_mid.allocation
         cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
         cr.rectangle(x - 1, y - 1, w + 2, h + 2)
         cr.stroke()
         x, y, w, h = self.thumbnail_small.allocation
         cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
         cr.rectangle(x - 1, y - 1, w + 2, h + 2)
         cr.stroke()
    def draw_progress_bar(self, cr, rect):

        # Draw progressbar background.
        bg_height = self.bg_dpixbuf.get_pixbuf().get_height()
        self.bg_cache_pixbuf.scale(self.bg_dpixbuf.get_pixbuf(),
                                   self.progress_width, bg_height)

        bg_y = rect.y + (rect.height - bg_height) / 2
        draw_pixbuf(cr, self.bg_cache_pixbuf.get_cache(),
                    rect.x + self.bg_offset, bg_y)

        # Draw progressbar foreground.
        if self.current_progress_width > 0:
            fg_height = self.fg_dpixbuf.get_pixbuf().get_height()
            # self.fg_cache_pixbuf.scale(self.fg_dpixbuf.get_pixbuf(),
            #                            int(self.current_progress_width),
            #                            fg_height)

            fg_y = rect.y + (rect.height - fg_height) / 2
            # draw_pixbuf(cr, self.fg_cache_pixbuf.get_cache(),  rect.x + self.fg_offset, fg_y)

            lg_width = int(self.current_progress_width)
            pat = cairo.LinearGradient(rect.x + self.fg_offset, fg_y,
                                       rect.x + self.fg_offset + lg_width,
                                       fg_y)
            pat.add_color_stop_rgb(
                0.6, *color_hex_to_cairo(self.fg_left_dcolor.get_color()))
            pat.add_color_stop_rgb(
                1.0, *color_hex_to_cairo(self.fg_right_dcolor.get_color()))
            cr.set_operator(cairo.OPERATOR_OVER)
            cr.set_source(pat)
            cr.rectangle(rect.x + self.fg_offset, fg_y, lg_width, fg_height)
            cr.fill()

            with cairo_disable_antialias(cr):
                cr.set_line_width(1)
                cr.set_source_rgba(1, 1, 1, 0.3)
                cr.rectangle(rect.x + self.fg_offset, fg_y, lg_width,
                             fg_height)
                cr.stroke()

        # Draw point.
        point_y = rect.y + (rect.height -
                            self.point_dpixbuf.get_pixbuf().get_height()) / 2
        draw_pixbuf(cr, self.point_dpixbuf.get_pixbuf(),
                    rect.x + self.point_offset + self.current_progress_width,
                    point_y)
Example #32
0
    def render_name(self, cr, rect):
        text_color = "#333333"
        font_image_color = app_theme.get_color("sidebar_select").get_color()
        if self.is_select:
            cr.set_source_rgba(*color_hex_to_cairo(
                app_theme.get_color("sidebar_select").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

            text_color = "#FFFFFF"
            font_image_color = "#FFFFFF"
        elif self.is_hover:
            cr.set_source_rgba(*color_hex_to_cairo(
                app_theme.get_color("sidebar_hover").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

        pixbuf = app_theme.get_pixbuf("category/%s.png" %
                                      (self.index)).get_pixbuf()

        category_img_path = os.path.join(get_parent_dir(__file__, 2), "image",
                                         "category",
                                         "%s.png" % (self.index + 1, ))
        surface = cairo.ImageSurface.create_from_png(category_img_path)
        cr.set_source_rgb(*color_hex_to_cairo(font_image_color))
        cr.mask_surface(surface, rect.x + 14, rect.y + (rect.height - 24) / 2)

        draw_text(
            cr,
            get_category_name(self.first_category_name),
            rect.x + pixbuf.get_width() + 22,
            rect.y,
            rect.width,
            rect.height,
            text_size=CATEGORY_ITEM_NAME_SIZE,
            text_color=text_color,
        )

        if self.is_hover:
            if self.is_expand:
                pixbuf = app_theme.get_pixbuf("sidebar/close.png").get_pixbuf()
            else:
                pixbuf = app_theme.get_pixbuf("sidebar/open.png").get_pixbuf()

            draw_pixbuf(cr, pixbuf,
                        rect.x + rect.width - CATEGORY_ITEM_EXPAND_PADDING_X,
                        rect.y + (rect.height - pixbuf.get_height()) / 2)
Example #33
0
    def on_expose_event(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        rect.x += self.padding_x
        rect.width -= self.padding_x * 2

        keyword_span = self.red_span % self.keyword
        from_keyword_span = self.black_span % self.from_keyword
        from_keyword_dict = {
            "keyword": keyword_span,
            "from": from_keyword_span
        }
        self.prompt_text = self.prompt_format_text.format(**from_keyword_dict)
        _width, _height = get_content_size(self.prompt_text)

        draw_text(cr,
                  self.prompt_text,
                  rect.x,
                  rect.y,
                  rect.width,
                  _height,
                  text_color=app_theme.get_color("labelText").get_color())

        # draw dash
        rect.y += _height + self.padding_y
        dash_line_width = 1
        with cairo_disable_antialias(cr):
            cr.set_source_rgb(*color_hex_to_cairo("#D6D6D6"))
            cr.set_line_width(dash_line_width)
            cr.set_dash([4.0, 4.0])
            cr.move_to(rect.x, rect.y)
            cr.rel_line_to(rect.width, 0)
            cr.stroke()

        rect.y += self.padding_y + dash_line_width

        _width, _height = get_content_size(self.suggest_title)
        draw_text(cr, self.suggest_title, rect.x, rect.y, rect.width, _height)

        rect.y += _height + self.padding_y
        _width, _height = get_content_size(self.suggest_first_line)
        draw_text(cr,
                  self.suggest_first_line,
                  rect.x,
                  rect.y,
                  rect.width,
                  _height,
                  text_color=app_theme.get_color("labelText").get_color())

        rect.y += _height + self.padding_y
        _width, _height = get_content_size(self.suggest_second_line)
        draw_text(cr,
                  self.suggest_second_line,
                  rect.x,
                  rect.y,
                  rect.width,
                  _height,
                  text_color=app_theme.get_color("labelText").get_color())
        return True
Example #34
0
    def render(self, cr, rect):
        '''
        Render item.
        
        This is IconView interface, you should implement it.
        '''
        # Init size.
        icon_width = self.module_info.icon_pixbuf.get_width()
        icon_height = self.module_info.icon_pixbuf.get_height()

        # Draw background.
        if self.hover_flag:
            with cairo_disable_antialias(cr):
                cr.set_source_rgb(
                    *color_hex_to_cairo(self.hover_fill_dcolor.get_color()))
                cr.rectangle(rect.x + self.hover_offset,
                             rect.y + self.hover_offset,
                             rect.width - self.hover_offset * 2,
                             rect.height - self.hover_offset * 2)
                cr.fill_preserve()
                cr.set_line_width(1)
                cr.set_source_rgb(
                    *color_hex_to_cairo(self.hover_stroke_dcolor.get_color()))
                cr.stroke()

        # Draw icon.
        draw_pixbuf(cr, self.module_info.icon_pixbuf,
                    rect.x + (rect.width - icon_width) / 2,
                    rect.y + self.icon_padding_y)

        # Draw icon name.
        # TODO: lihongwu req to support i18n
        name = self.module_info.default_name
        if MAIN_LANG != "en_US":
            name = self.module_info.name
        padding_x = 10
        draw_text(
            cr,
            name,
            rect.x + padding_x,
            rect.y + self.icon_padding_y + icon_height + self.name_padding_y,
            rect.width - padding_x * 2,
            DEFAULT_FONT_SIZE,
            alignment=pango.ALIGN_CENTER,
            wrap_width=rect.width - padding_x * 2,
        )
    def render_delete(self, cr, rect):
         
        self.render_background(cr, rect)

        BORDER_COLOR = color_hex_to_cairo("#d2d2d2")
        with cairo_disable_antialias(cr):
            cr.set_source_rgb(*BORDER_COLOR)
            cr.set_line_width(1)
 def treeview_container_expose_cb(self, widget, event, treeview):
     rect = treeview.allocation
     cr = widget.window.cairo_create()
     with cairo_disable_antialias(cr):
         cr.set_source_rgb(*color_hex_to_cairo(TREEVIEW_BORDER_COLOR))
         cr.set_line_width(1)
         cr.rectangle(rect.x, rect.y, rect.width+1, rect.height+1)
         cr.stroke()
 def expose_event(self, widget, event):
     cr = widget.window.cairo_create()
     rect = widget.child.allocation
     width, height = get_content_size(self.label_name)
     cr.set_source_rgb(
         *color_hex_to_cairo(ui_theme.get_color("link_text").get_color()))
     draw_line(cr, rect.x, rect.y + rect.height, rect.x + width,
               rect.y + rect.height)
    def render(self, cr, rect):
        padding = 10

        # Draw select background.
        if self.is_button_press == True:
            with cairo_disable_antialias(cr):
                cr.set_source_rgb(*color_hex_to_cairo(self.highlight_fill_color))
                cr.rectangle(rect.x + padding,
                             rect.y + padding,
                             rect.width - padding,
                             rect.height - padding)
                cr.fill_preserve()
                cr.set_line_width(1)
                cr.set_source_rgb(*color_hex_to_cairo(self.highlight_stroke_color))
                cr.stroke()

        # Draw device icon.
        draw_pixbuf(cr, self.pixbuf,
                    rect.x + self.icon_size / 2 + 4,
                    rect.y + (rect.height - self.icon_size) / 2,
                    )

        if self.is_paired:
            draw_pixbuf(cr,
                        self.pair_pixbuf.get_pixbuf(),
                        rect.x + self.icon_size + self.pair_pixbuf.get_pixbuf().get_width() / 2,
                        rect.y + self.icon_size + self.pair_pixbuf.get_pixbuf().get_height() / 2)
        if self.is_connected:
            draw_pixbuf(cr,
                        self.device_connected_pixbuf.get_pixbuf(),
                        rect.x + self.icon_size + self.pair_pixbuf.get_pixbuf().get_width() / 2,
                        rect.y + self.pair_pixbuf.get_pixbuf().get_height())

        # Draw device name.
        text_color="#000000"
        if self.is_button_press == True:
            text_color="#FFFFFF"
        draw_text(cr,
                  self.name,
                  rect.x + padding,
                  rect.y + self.icon_size + self.__const_padding_y * 2,
                  rect.width - padding,
                  CONTENT_FONT_SIZE,
                  CONTENT_FONT_SIZE,
                  text_color,
                  alignment=pango.ALIGN_CENTER)
 def render(self, cr, rect):
     '''
     Render item.
     
     This is IconView interface, you should implement it.
     '''
     # Init size.
     icon_width = self.module_info.icon_pixbuf.get_width()
     icon_height = self.module_info.icon_pixbuf.get_height()
     
     # Draw background.
     if self.hover_flag:
         with cairo_disable_antialias(cr):
             cr.set_source_rgb(*color_hex_to_cairo(self.hover_fill_dcolor.get_color()))
             cr.rectangle(rect.x + self.hover_offset, 
                          rect.y + self.hover_offset, 
                          rect.width - self.hover_offset * 2, 
                          rect.height - self.hover_offset * 2)
             cr.fill_preserve()
             cr.set_line_width(1)
             cr.set_source_rgb(*color_hex_to_cairo(self.hover_stroke_dcolor.get_color()))
             cr.stroke()
     
     # Draw icon.
     draw_pixbuf(
         cr, 
         self.module_info.icon_pixbuf,
         rect.x + (rect.width - icon_width) / 2,
         rect.y + self.icon_padding_y
         )
     
     # Draw icon name.
     # TODO: lihongwu req to support i18n
     name = self.module_info.default_name
     if MAIN_LANG != "en_US":
         name = self.module_info.name
     padding_x = 10
     draw_text(cr, name, 
               rect.x + padding_x,
               rect.y + self.icon_padding_y + icon_height + self.name_padding_y,
               rect.width - padding_x * 2,
               DEFAULT_FONT_SIZE, 
               alignment=pango.ALIGN_CENTER,
               wrap_width=rect.width - padding_x * 2,
               )
 def __draw_title_background(self, cr, widget):                                           
     rect = widget.allocation                                    
     
     cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))                 
     cr.rectangle(rect.x, 
                  rect.y - FRAME_TOP_PADDING, 
                  rect.width, 
                  rect.height - 1)                        
     cr.fill()
    def render_right(self, cr, rect):
        render_background(cr, rect)

        BORDER_COLOR = color_hex_to_cairo("#d2d2d2")
        with cairo_disable_antialias(cr):
            cr.set_source_rgb(*BORDER_COLOR)
            cr.set_line_width(1)
            cr.rectangle(rect.x , rect.y , rect.width , rect.height + 1)
            cr.stroke()
def draw_single_mask(cr, x, y, width, height, color_name):
    if color_name.startswith("#"):
        color = color_name
    else:    
        color = app_theme.get_color(color_name).get_color()
    cairo_color = color_hex_to_cairo(color)
    cr.set_source_rgb(*cairo_color)
    cr.rectangle(x, y, width, height)
    cr.fill()
Example #43
0
    def expose_right_top_box(self, widget, event):
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation

        # Draw background.
        cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()
Example #44
0
    def expose_right_top_box(self, widget, event):
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation

        # Draw background.
        cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()
Example #45
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)
Example #46
0
 def render_blank(self, cr, rect):
     self.render_background(cr, rect)
     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_blank(self, cr, rect):
     render_background(cr, rect)
     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 draw_single_mask(cr, x, y, width, height, color_name):
    if color_name.startswith("#"):
        color = color_name
    else:
        color = app_theme.get_color(color_name).get_color()
    cairo_color = color_hex_to_cairo(color)
    cr.set_source_rgb(*cairo_color)
    cr.rectangle(x, y, width, height)
    cr.fill()
    def expose_split_line(self, widget, event):
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.set_source_rgb(*color_hex_to_cairo("#e5e5e5"))
        cr.rectangle(rect.x, rect.y, 1, rect.height)
        cr.fill()
        
        return True
Example #50
0
    def expose_resizable_label_background(self, widget, event):
        if self.pkg_name != None:
            # Init.
            cr = widget.window.cairo_create()
            rect = widget.allocation

            # Draw background.
            cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()
 def __expose(self, widget, event):
     try:
         cr = widget.window.cairo_create()                                        
         rect = widget.allocation                                                 
     
         cr.set_source_rgb(*color_hex_to_cairo(MODULE_BG_COLOR))                  
         cr.rectangle(rect.x, rect.y, rect.width, rect.height)                    
         cr.fill()
     except e:
         print "DEBUG", e
    def render_name(self, cr, rect):
        text_color = "#333333"
        font_image_color = app_theme.get_color("sidebar_select").get_color()
        if self.is_select:
            cr.set_source_rgba(*color_hex_to_cairo(app_theme.get_color("sidebar_select").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()
            
            text_color = "#FFFFFF"
            font_image_color = "#FFFFFF"
        elif self.is_hover:
            cr.set_source_rgba(*color_hex_to_cairo(app_theme.get_color("sidebar_hover").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()
        
        pixbuf = app_theme.get_pixbuf("category/%s.png" % (self.index)).get_pixbuf()

        category_img_path = os.path.join(get_parent_dir(__file__, 2), "image", "category", "%s.png" % (self.index+1, ))
        surface = cairo.ImageSurface.create_from_png(category_img_path)
        cr.set_source_rgb(*color_hex_to_cairo(font_image_color))
        cr.mask_surface(surface, rect.x+14, rect.y+(rect.height-24)/2)

        draw_text(cr, 
                  get_category_name(self.first_category_name),
                  rect.x + pixbuf.get_width() + 22, 
                  rect.y,
                  rect.width,
                  rect.height,
                  text_size=CATEGORY_ITEM_NAME_SIZE,
                  text_color=text_color,
                  )
        
        if self.is_hover:
            if self.is_expand:
                pixbuf = app_theme.get_pixbuf("sidebar/close.png").get_pixbuf()
            else:
                pixbuf = app_theme.get_pixbuf("sidebar/open.png").get_pixbuf()
                
            draw_pixbuf(
                cr,
                pixbuf,
                rect.x + rect.width - CATEGORY_ITEM_EXPAND_PADDING_X,
                rect.y + (rect.height - pixbuf.get_height()) / 2)
Example #53
0
 def render_keyname(self, cr, rect):
     if self.is_select:
         text_color = "#FFFFFF"
         bg_color = "#3399FF"
         cr.set_source_rgb(*color_hex_to_cairo(bg_color))
         cr.rectangle(rect.x, rect.y, rect.width, rect.height)
         cr.paint()
     else:
         text_color = "#000000"
     draw_text(cr, self.keyname, rect.x+self.padding_x, rect.y, rect.width, rect.height, text_color=text_color)