def __render_day_cell(self, cell, col): # Set up a drawing buffer for the day cell buffer = adesklets.create_image(self._cellsize, self._cellsize) adesklets.context_set_image(buffer) adesklets.context_set_blend(False) adesklets.context_set_color(0,0,0,0) adesklets.image_fill_rectangle(0,0,self._cellsize,self._cellsize) adesklets.context_set_blend(True) # Draws the day cell background adesklets.context_set_color(*self._day_bg_color) adesklets.image_fill_rectangle(self._cell_padding, self._cell_padding, (self._cellsize - self._cell_padding), (self._cellsize - self._cell_padding)) # Draws the day cell border adesklets.context_set_color(*self._day_border_color) adesklets.image_draw_rectangle(self._cell_padding, self._cell_padding, (self._cellsize - self._cell_padding), (self._cellsize - self._cell_padding)) # Draws the day cell text adesklets.context_set_font(self._day_font) x, y = adesklets.get_text_size(cell) adesklets.context_set_color(*self._day_font_color) adesklets.text_draw(((self._cellsize / 2) - (x / 2)),((self._cellsize / 2) - (y / 2)),cell) # Blend day cell image into main buffer adesklets.context_set_image(self._buffer) adesklets.blend_image_onto_image(buffer,1,0,0,self._cellsize,self._cellsize, (col * self._cellsize),self._cellsize,self._cellsize,self._cellsize) adesklets.free_image(buffer)
def background_grab(self, delayed): """ Set up the bar background. We choosed to work directly on image #1 because the operation is always setting the same pixels, so there is no real flickering, just a delay. """ if self.config['bar_height']>0: # Compute rectangle dimensions # coords=[0,(self.config['icon_max_height']- self.config['bar_height'])/2, self._window_width,self.config['bar_height']] if self.config['caption_above']: coords[1]+=self._caption_height # Draw it # adesklets.context_set_blend(True) adesklets.context_set_image(1) if self.config['bar_background_1']: adesklets.context_set_color( *(self.config.color(self.config['bar_background_1'])+ [self.config['bar_opacity_1']])) if self.config['bar_background_2']: adesklets.context_set_color_range( adesklets.create_color_range()) adesklets.add_color_to_color_range(0) adesklets.context_set_color( *(self.config.color(self.config['bar_background_2'])+ [self.config['bar_opacity_2']])) adesklets.add_color_to_color_range(self._window_width) adesklets.image_fill_color_range_rectangle( *(coords+[self.config['bar_gradient_angle']])) adesklets.free_color_range(0) else: adesklets.image_fill_rectangle(*coords) if self.config['bar_foreground']: adesklets.context_set_color( *(self.config.color(self.config['bar_foreground']+'FF'))) adesklets.image_draw_rectangle(*coords) adesklets.context_set_blend(False)
def __render_date_cell(self, cell, col, row): # Set up a drawing buffer for the date buffer = adesklets.create_image(self._cellsize, self._cellsize) adesklets.context_set_image(buffer) adesklets.context_set_blend(False) adesklets.context_set_color(0,0,0,0) adesklets.image_fill_rectangle(0,0,self._cellsize,self._cellsize) adesklets.context_set_blend(True) # Draws the date cell background if (int(cell) == int(datetime.date.today().day)): adesklets.context_set_color(*self._date_today_bg_color) elif (int(cell) < int(datetime.date.today().day)): adesklets.context_set_color(*self._date_past_bg_color) else: adesklets.context_set_color(*self._date_bg_color) if self._month_offset<0 or self._year_offset<0: adesklets.context_set_color(*self._date_past_bg_color) elif self._month_offset>0 or self._year_offset>0: adesklets.context_set_color(*self._date_bg_color) adesklets.image_fill_rectangle(self._cell_padding, self._cell_padding, (self._cellsize - self._cell_padding), (self._cellsize - self._cell_padding)) # Draws the date cell border if (int(cell) == int(datetime.date.today().day)): adesklets.context_set_color(*self._date_today_border_color) elif (int(cell) < int(datetime.date.today().day)): adesklets.context_set_color(*self._date_past_border_color) else: adesklets.context_set_color(*self._date_border_color) if self._month_offset<0 or self._year_offset<0: adesklets.context_set_color(*self._date_past_border_color) elif self._month_offset>0 or self._year_offset>0: adesklets.context_set_color(*self._date_border_color) adesklets.image_draw_rectangle(self._cell_padding, self._cell_padding, (self._cellsize - self._cell_padding), (self._cellsize - self._cell_padding)) # Draws the date cell text if (int(cell) == int(datetime.date.today().day)): adesklets.context_set_font(self._date_today_font) adesklets.context_set_color(*self._date_today_font_color) elif (int(cell) < int(datetime.date.today().day)): adesklets.context_set_font(self._date_past_font) adesklets.context_set_color(*self._date_past_font_color) else: adesklets.context_set_font(self._date_font) adesklets.context_set_color(*self._date_font_color) if self._month_offset<0 or self._year_offset<0: adesklets.context_set_font(self._date_past_font) adesklets.context_set_color(*self._date_past_font_color) elif self._month_offset>0 or self._year_offset>0: adesklets.context_set_font(self._date_font) adesklets.context_set_color(*self._date_font_color) x, y = adesklets.get_text_size(cell) adesklets.text_draw(((self._cellsize / 2) - (x / 2)),((self._cellsize / 2) - (y / 2)),cell) # Blend date cell image into main buffer adesklets.context_set_image(self._buffer) adesklets.blend_image_onto_image(buffer,1,0,0,self._cellsize,self._cellsize, (col * self._cellsize),(row * self._cellsize),self._cellsize,self._cellsize) adesklets.free_image(buffer)