Esempio n. 1
0
    def __expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        x, y = rect.x, rect.y
        x -= self.padding_left
        y -= self.padding_top * 2

        with cairo_state(cr):
            cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
            cr.rectangle(x,
                         y,
                         rect.width,
                         rect.height + self.padding_top)
            cr.fill()

            if self.width < self.__const_width or self.height < self.__const_height:
                self.cache_bg_pixbuf.scale(self.bg_pixbuf.get_pixbuf(),
                                           self.width,
                                           self.height)
                self.cache_timezone_pixbuf.scale(self.timezone_pixbuf[self.__timezone].get_pixbuf(),
                                                 self.width,
                                                 self.height)

                draw_pixbuf(cr, self.cache_bg_pixbuf.get_cache(), x, y)
                draw_pixbuf(cr, self.cache_timezone_pixbuf.get_cache(), x, y)
            else:
                draw_pixbuf(cr, self.bg_pixbuf.get_pixbuf(), x, y)
                draw_pixbuf(cr,
                            self.timezone_pixbuf[self.__timezone].get_pixbuf(),
                            x,
                            y)

        return True
Esempio n. 2
0
    def expose_background_box(self, widget, event):
        '''
        Callback for `expose-event` signal.

        @param widget: BackgroundBox self.
        @param event: Expose event.
        @return: Always return False.
        '''
        cr = widget.window.cairo_create()
        with cairo_state(cr):
            rect = widget.allocation
            toplevel = widget.get_toplevel()
            (offset_x, offset_y) = widget.translate_coordinates(toplevel, 0, 0)
            (shadow_x, shadow_y) = get_window_shadow_size(toplevel)

            x = shadow_x - offset_x
            y = shadow_y - offset_y

            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.clip()
            cr.translate(x, y)
            skin_config.render_background(cr, widget, 0, 0)

        self.draw_mask(cr, rect.x, rect.y, rect.width, rect.height)

        return False
Esempio n. 3
0
    def expose_background_box(self, widget, event):
        '''
        Callback for `expose-event` signal.

        @param widget: BackgroundBox self.
        @param event: Expose event.
        @return: Always return False.
        '''
        cr = widget.window.cairo_create()
        with cairo_state(cr):
            rect = widget.allocation
            toplevel = widget.get_toplevel()
            (offset_x, offset_y) = widget.translate_coordinates(toplevel, 0, 0)
            (shadow_x, shadow_y) = get_window_shadow_size(toplevel)

            x = shadow_x - offset_x
            y = shadow_y - offset_y

            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.clip()
            cr.translate(x, y)
            skin_config.render_background(cr, widget, 0, 0)

        self.draw_mask(cr, rect.x, rect.y, rect.width, rect.height)

        return False
Esempio n. 4
0
    def __expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        x, y, w, h = rect.x, rect.y, rect.width, rect.height
        
        ox = x + self.clockface_width * 0.5

        self.hour_value = time.localtime().tm_hour
        self.minute_value = time.localtime().tm_min
        self.second_value = time.localtime().tm_sec

        with cairo_state(cr):
            draw_pixbuf(cr, self.clockface.get_pixbuf(), x, y)
        
        #hour
        with cairo_state(cr):
            oy = y + self.hourhand_height * 0.5
            cr.translate(ox, oy)
            cr.rotate(radians(360 * self.hour_value / 12))
            cr.translate(-self.hourhand_width * 0.5, -self.hourhand_height * 0.5)
            draw_pixbuf(cr, self.hourhand.get_pixbuf(), 0, 0)
        
        #minute
        with cairo_state(cr):
            oy = y + self.minhand_height * 0.5
            cr.translate(ox, oy)
            cr.rotate(radians(360 * self.minute_value / 60))
            cr.translate(-self.minhand_width * 0.5, -self.minhand_height * 0.5)
            draw_pixbuf(cr, self.minhand.get_pixbuf(), 0, 0)
        
        #second
        with cairo_state(cr):
            oy = y + self.sechand_height * 0.5
            cr.translate(ox, oy) 
            cr.rotate(radians(360 * self.second_value / 60))
            cr.translate(-self.sechand_width * 0.5, -self.sechand_height * 0.5)
            draw_pixbuf(cr, self.sechand.get_pixbuf(), 0, 0)
Esempio n. 5
0
    def __expose(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        x, y, w, h = rect.x, rect.y, rect.width, rect.height

        ox = x + self.clockface_width * 0.5

        self.hour_value = time.localtime().tm_hour
        self.minute_value = time.localtime().tm_min
        self.second_value = time.localtime().tm_sec

        with cairo_state(cr):
            draw_pixbuf(cr, self.clockface.get_pixbuf(), x, y)

        #hour
        with cairo_state(cr):
            oy = y + self.hourhand_height * 0.5
            cr.translate(ox, oy)
            cr.rotate(radians(360 * self.hour_value / 12))
            cr.translate(-self.hourhand_width * 0.5, -self.hourhand_height * 0.5)
            draw_pixbuf(cr, self.hourhand.get_pixbuf(), 0, 0)

        #minute
        with cairo_state(cr):
            oy = y + self.minhand_height * 0.5
            cr.translate(ox, oy)
            cr.rotate(radians(360 * self.minute_value / 60))
            cr.translate(-self.minhand_width * 0.5, -self.minhand_height * 0.5)
            draw_pixbuf(cr, self.minhand.get_pixbuf(), 0, 0)

        #second
        with cairo_state(cr):
            oy = y + self.sechand_height * 0.5
            cr.translate(ox, oy)
            cr.rotate(radians(360 * self.second_value / 60))
            cr.translate(-self.sechand_width * 0.5, -self.sechand_height * 0.5)
            draw_pixbuf(cr, self.sechand.get_pixbuf(), 0, 0)
Esempio n. 6
0
    def expose_background_box(self, widget, event):
        '''Expose background box.'''
        cr = widget.window.cairo_create()
        rect = widget.allocation
        toplevel = widget.get_toplevel()
        coordinate = widget.translate_coordinates(toplevel, rect.x, rect.y)
        (offset_x, offset_y) = coordinate
        
        with cairo_state(cr):
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.clip()
            
            (shadow_x, shadow_y) = get_window_shadow_size(toplevel)
            skin_config.render_background(cr, widget, shadow_x, shadow_y)
            
        self.draw_mask(cr, rect.x, rect.y, rect.width, rect.height)    

        return False