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
def render_pkg_info(cr, rect, alias_name, pkg_name, icon_pixbuf, first_info, second_info, offset_x=0): text_width = rect.width - ICON_SIZE - ITEM_PADDING_X * 2 - ITEM_PADDING_MIDDLE # Draw icon. render_pkg_icon(cr, rect, icon_pixbuf, offset_x) # Draw name. render_pkg_name(cr, rect, alias_name, text_width, offset_x) # Draw first pkg information. draw_text(cr, first_info, rect.x + ITEM_PADDING_X + ICON_SIZE + ITEM_PADDING_MIDDLE + offset_x, rect.y + ITEM_PADDING_Y + DEFAULT_FONT_SIZE * 2, text_width, DEFAULT_FONT_SIZE, text_size=DEFAULT_FONT_SIZE, text_color="#333333") # Draw second pkg information. if second_info: draw_text(cr, second_info, rect.x + ITEM_PADDING_X + ICON_SIZE + ITEM_PADDING_MIDDLE + offset_x, rect.y + ITEM_PADDING_Y + DEFAULT_FONT_SIZE * 4, text_width, DEFAULT_FONT_SIZE, text_size=DEFAULT_FONT_SIZE, text_color="#333333")
def render_pkg_summary(self, cr, rect): # Draw album title. text_width = self.SUMMARY_WIDTH draw_text( cr, "%s: %s" % (self.alias_name, self.pkg_title), rect.x, rect.y + self.PICTURE_PADDING_Y, text_width, self.TITLE_SIZE, text_size=self.TITLE_SIZE, text_color="#000000", vertical_alignment=TEXT_ALIGN_TOP, ) # Draw album summary. text_height = rect.height draw_text( cr, self.pkg_summary, rect.x, rect.y + self.PICTURE_PADDING_Y + self.SUMMARY_PADDING_Y, text_width, text_height, text_size=self.SUMMARY_SIZE, text_color="#4c4c4c", wrap_width=text_width, vertical_alignment=TEXT_ALIGN_TOP, clip_line_count=3, )
def render_time(self, cr, rect): if self.row_index % 2: cr.rectangle(*rect) cr.set_source_rgba(0, 0, 1, 0.05) cr.fill() if self.owner == "detail": if self.is_select: draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height, "globalItemSelect") 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 = "#000000" else: if self.is_hover: draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height, "#ebf4fd") draw_half_rectangle(cr, rect, "#7da2ce", False) text_color = "#000000" if self.owner == "detail": text = self.time.replace('-', ' ') else: text = self.time.split("-")[1][:-3] draw_text(cr, text, rect.x + 20, rect.y + 10, rect.width, rect.height / 2, text_color = text_color, wrap_width = 50, alignment=pango.ALIGN_CENTER)
def render_title(self, cr, rect): text_color = "#000000" draw_text(cr, "<b>%s</b>" % 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)
def render_essid(self, cr, rect): self.render_background(cr, rect) ssid = self.ssid.replace("&", "&").replace("<", "<").replace(">", ">") (text_width, text_height) = get_content_size(ssid) if self.active: text_color = "#3da1f7" else: text_color = "#000000" draw_text(cr, ssid, rect.x + ALIGN_SPACING, rect.y, rect.width, rect.height, alignment=pango.ALIGN_LEFT, text_color=text_color) if self.is_hover: with cairo_disable_antialias(cr): cr.set_source_rgb(*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 + 1, rect.y + 1, rect.width, rect.height - 1) cr.stroke()
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
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)
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 render_description(self, cr, rect): self.description = str_mark_down(self.item.comment) self.render_background(cr, rect) rect.x += self.padding_x rect.width -= self.padding_x * 2 if self.description: text_to_draw = self.description else: text_to_draw = _("No description") (text_width, text_height) = get_content_size(text_to_draw) if self.item.type == self.item.TYPE_SYS: draw_text(cr, text_to_draw, rect.x, rect.y, rect.width, rect.height, text_color=self.TYPE_SYS_COLOR, alignment=pango.ALIGN_LEFT) else: draw_text(cr, text_to_draw, rect.x, rect.y, rect.width, rect.height, alignment=pango.ALIGN_LEFT)
def render_text(self, cr, rect): if self.is_hover or self.is_select: # Draw background. draw_vlinear( cr, rect.x, rect.y, rect.width, rect.height, ui_theme.get_shadow_color("menu_item_select").get_color_info()) # Set font color. font_color = ui_theme.get_color("menu_select_font").get_color() # Don't highlight when select. text = self.text else: # Set font color. font_color = ui_theme.get_color("menu_font").get_color() # Highilght match string. r = self.text.partition(self.search_string.lower()) text = "%s<span foreground=\"#00AAFF\">%s</span>%s" % (r[0], r[1], r[2]) draw_text(cr, text, rect.x + self.padding_x, rect.y, rect.width - self.padding_x * 2, rect.height, text_color=font_color)
def render_exec(self, cr, rect): exec_ = self.item.exec_ self.render_background(cr, rect) rect.x += self.padding_x rect.width -= self.padding_x * 2 if exec_: text_to_draw = exec_ else: text_to_draw = _("No exec") (text_width, text_height) = get_content_size(text_to_draw) if self.item.type == self.item.TYPE_SYS: draw_text(cr, text_to_draw, rect.x, rect.y, rect.width, rect.height, text_color=self.TYPE_SYS_COLOR, alignment=pango.ALIGN_LEFT) else: draw_text(cr, text_to_draw, rect.x, rect.y, rect.width, rect.height, alignment=pango.ALIGN_LEFT)
def render_app(self, cr, rect): app_name = str_mark_down(self.item.name) self.render_background(cr, rect) # Draw Text (text_width, text_height) = get_content_size(app_name) rect.x += self.padding_x rect.width -= self.padding_x * 2 if self.item.type == self.item.TYPE_SYS: draw_text(cr, app_name, rect.x, rect.y, rect.width, rect.height, text_color=self.TYPE_SYS_COLOR, alignment=pango.ALIGN_LEFT) else: draw_text(cr, app_name, rect.x, rect.y, rect.width, rect.height, alignment=pango.ALIGN_LEFT)
def render_item(self, cr, rect): if self.is_head: rect.y += self.head_height rect.height -= self.head_height if self.is_hover: text_color = "#000000" bg_color = app_theme.get_color("globalItemHover").get_color() if self.is_select: #text_color = "#FFFFFF" text_color = app_theme.get_color("globalTitleForeground").get_color() bg_color = app_theme.get_color("globalItemSelect").get_color() if not self.is_hover and not self.is_select: text_color = "#000000" bg_color = MODULE_BG_COLOR #cr.set_source_rgb(*color_hex_to_cairo(bg_color)) #cr.rectangle(rect.x, rect.y+self.title_height, rect.width-4, rect.height-2*self.title_height-1) #cr.fill() # draw account type text if self.is_myowner: text_color2 = app_theme.get_color("globalTitleForeground").get_color() x1 = rect.x y1 = rect.y draw_text(cr, _("My Account"), x1, y1, self.title_width, self.title_height, text_size=TITLE_FONT_SIZE, text_color=text_color2) x2 = rect.x y2 = rect.y + self.height + self.title_height + BETWEEN_SPACING - self.padding_y draw_text(cr, _("Other Accounts"), x2, y2, self.title_width, self.title_height, text_size=TITLE_FONT_SIZE, text_color=text_color2) self.render_icon(cr, gtk.gdk.Rectangle(rect.x+1, rect.y, 58, rect.height)) self.render_content(cr, gtk.gdk.Rectangle(rect.x+58, rect.y, rect.width-58, rect.height), text_color)
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() column_offset = self.column_offset * self.column_index draw_text(cr, self.title, rect.x + self.title_padding_x + column_offset, rect.y, rect.width - self.title_padding_x - column_offset, rect.height, text_size=10, text_color=text_color, alignment=pango.ALIGN_LEFT)
def on_expose_event(self, widget, event): ''' docs ''' cr = widget.window.cairo_create() rect = widget.allocation cr.set_operator(cairo.OPERATOR_SOURCE) cr.set_source_rgba(1, 1, 1, 0) cr.rectangle(*rect) cr.paint() cr.set_operator(cairo.OPERATOR_OVER) if not self.surface or self.reset_surface_flag: self.compute_shadow(rect) cr.set_source_surface(self.surface, 0, 0) cr.paint() draw_text(cr, self.content, rect.x + 6, rect.y + 6, rect.width - 6 * 2, rect.height - 6 *2 - self.arrow_height, 9, "#707070", alignment=pango.ALIGN_CENTER) return True
def render_text(self, cr, rect): if self.is_hover: # Draw background. draw_single_mask(cr, rect.x + 1, rect.y, rect.width - 2, rect.height, "globalItemSelect") # Set font color. font_color = "#FFFFFF" # Don't highlight when select. # text = self.text else: # Set font color. font_color = app_theme.get_color("labelText").get_color() # Highilght match string. # (text_pre, text_post) = self.text.split(self.search_string) # text = "%s<span foreground=\"#00AAFF\">%s</span>%s" % (text_pre, self.search_string, text_post) draw_text(cr, self.text, rect.x + self.padding_x, rect.y, rect.width - self.padding_x * 2, rect.height, text_color=font_color)
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
def render_item_text2(cr, content, rect, in_select, in_highlight, align=pango.ALIGN_LEFT, font_size=9, error=False): if in_select: color = app_theme.get_color("simpleSelectItem").get_color() else: # color = app_theme.get_color("labelText").get_color() color = "#707070" if error: color = "#ff0000" content = utils.xmlescape(content) draw_text(cr, content, rect.x, rect.y, rect.width, rect.height, font_size, color, alignment=align)
def on_expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation draw_text(cr, self.text, rect.x, rect.y, rect.width, rect.height, text_color=app_theme.get_color("labelText").get_color(), alignment=pango.ALIGN_CENTER)
def render_text(self, cr, rect): if self.is_hover or self.is_select: # Draw background. draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, ui_theme.get_shadow_color("menu_item_select").get_color_info()) # Set font color. font_color = ui_theme.get_color("menu_select_font").get_color() # Don't highlight when select. text = self.text else: # Set font color. font_color = ui_theme.get_color("menu_font").get_color() # Highilght match string. r = self.text.partition(self.search_string.lower()) text = "%s<span foreground=\"#00AAFF\">%s</span>%s" % (r[0], r[1], r[2]) draw_text(cr, text, rect.x + self.padding_x, rect.y, rect.width - self.padding_x * 2, rect.height, text_color=font_color)
def expose_rank_tab(self, widget, event): # Init. cr = widget.window.cairo_create() rect = widget.allocation if self.active_flag: text_color = "#2C8BBA" else: if widget.state == gtk.STATE_NORMAL: text_color = "#333333" elif widget.state == gtk.STATE_PRELIGHT: text_color = "#2C8BBA" elif widget.state == gtk.STATE_ACTIVE: text_color = "#2C8BBA" draw_text(cr, self.tab_name, rect.x, rect.y, rect.width, self.tab_height - 3, text_size=self.tab_name_size, text_color=text_color, underline=not self.active_flag) return True
def on_panel_expose_event(self, widget, event): if not self.items: return cr = widget.window.cairo_create() rect = widget.allocation draw_line(cr, (rect.x, rect.y + 1), (rect.x + rect.width, rect.y + 1), "#c7c7c7") draw_line(cr, (rect.x + rect.width, rect.y), (rect.x + rect.width, rect.y + rect.height), "#c7c7c7") draw_line(cr, (rect.x, rect.y + rect.height), (rect.x + rect.width, rect.y + rect.height), "#c7c7c7") draw_line(cr, (rect.x + 1, rect.y + 32), (rect.x + 1, rect.y + rect.height), "#c7c7c7") rect.y += self.block_height start_x, start_y = self.padding_x, self.padding_y for index, item in enumerate(self.items): item_width, item_height = item.get_size() if rect.width - start_x < item_width + self.separate_width: start_y += item_height + self.item_interval_height start_x = self.padding_x item.render(cr, gtk.gdk.Rectangle(rect.x + start_x, rect.y + start_y, item_width, item_height)) self.coords[index] = self.range(rect.x + start_x, rect.x + start_x + item_width, rect.y + start_y, rect.y + start_y + item_height) start_x += item_width draw_text(cr, self.separate_text, rect.x + start_x, rect.y + start_y, self.separate_width, self.separate_height, text_color=app_theme.get_color("labelText").get_color()) start_x += self.separate_width return True
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 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 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
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
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 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 on_expose_event(self, widget, event): ''' docs ''' cr = widget.window.cairo_create() rect = widget.allocation cr.set_operator(cairo.OPERATOR_SOURCE) cr.set_source_rgba(1, 1, 1, 0) cr.rectangle(*rect) cr.paint() cr.set_operator(cairo.OPERATOR_OVER) if not self.surface or self.reset_surface_flag: self.compute_shadow(rect) cr.set_source_surface(self.surface, 0, 0) cr.paint() draw_text(cr, self.content, rect.x + 6, rect.y + 6, rect.width - 6 * 2, rect.height - 6 * 2 - self.arrow_height, 9, "#707070", alignment=pango.ALIGN_CENTER) return True
def render(self, cr, rect): if self.hover_flag or self.is_select: color = app_theme.get_color("simpleItemHighlight").get_color() else: color = "#333333" draw_text(cr, self.title, rect.x, rect.y, rect.width, rect.height, text_color=color, underline=self.underline_flag)
def render_pkg_summary(self, cr, rect): # Draw album title. text_width = self.SUMMARY_WIDTH draw_text(cr, "%s: %s" % (self.alias_name, self.pkg_title), rect.x, rect.y + self.PICTURE_PADDING_Y, text_width, self.TITLE_SIZE, text_size=self.TITLE_SIZE, text_color="#000000", vertical_alignment=TEXT_ALIGN_TOP, ) # Draw album summary. text_height = rect.height draw_text(cr, self.pkg_summary, rect.x, rect.y + self.PICTURE_PADDING_Y + self.SUMMARY_PADDING_Y, text_width, text_height, text_size=self.SUMMARY_SIZE, text_color="#4c4c4c", wrap_width=text_width, vertical_alignment=TEXT_ALIGN_TOP, clip_line_count=3, )
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_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 draw_complie_show_text(self, cr, rect): text_index = 0 for text in self.message_text_list: offset_y = (text_index * self.draw_height) height = get_content_size(text)[1] + self.draw_height / 2 draw_text(cr, text, rect.x, rect.y + offset_y, rect.width, height) text_index += 1
def render_pkg_name(cr, rect, alias_name, text_width, offset_x=0): draw_text(cr, alias_name, rect.x + ITEM_PADDING_X + ICON_SIZE + ITEM_PADDING_MIDDLE + offset_x, rect.y + ITEM_PADDING_Y, text_width, NAME_SIZE, text_size=NAME_SIZE)
def render_content(self, cr, rect, text_color): draw_text(cr, self.content, rect.x + self.padding_x, rect.y, rect.width - self.padding_x, rect.height - 1, text_color=text_color)
def render(self, cr, text, rect): draw_text(cr, text, rect.x, rect.y, rect.width, rect.height, text_size=NAME_SIZE)
def draw_content(self, cr, rect): draw_text(cr, self.artist_label, rect.x + self.padding_x, rect.y, rect.width - self.padding_x * 2, rect.height, text_size=9.5, gaussian_radious=self.gaussian_radious, gaussian_color="#000000", border_radious=self.border_radious, border_color="#000000", text_color = self.text_color, )
def render_content(self, cr, rect): render_background(self, cr, rect) if self.is_select: text_color = "#ffffff" else: text_color = "#000000" content = gettext.gettext(self.content) draw_text(cr, content, rect.x , rect.y, rect.width, rect.height, alignment = pango.ALIGN_LEFT, text_color=text_color)
def render_active(self, cr, rect): with cairo_disable_antialias(cr): cr.set_source_rgb(0, 0, 0) cr.set_line_width(1) cr.rectangle(rect.x, rect.y + 4, rect.width, 22) cr.stroke() draw_text(cr, _("active"), rect.x, rect.y, rect.width, rect.height, alignment = pango.ALIGN_LEFT)
def render(self, cr, text, rect): draw_text( cr, text, rect.x, rect.y, rect.width, rect.height, text_size=NAME_SIZE)
def render_item_text(cr, content, rect, in_select, in_highlight, align=pango.ALIGN_LEFT, font_size=8, error=False): if in_select or in_highlight: color = app_theme.get_color("simpleSelectItem").get_color() else: color = app_theme.get_color("labelText").get_color() if error: color = "#ff0000" draw_text(cr, content, rect.x, rect.y, rect.width, rect.height, font_size, color, alignment=align)
def render(self, cr, rect): if not self.hover_flag: color = "#333333" self.underline = False else: if self.has_underline: self.underline = True color = app_theme.get_color("simpleItemHighlight").get_color() draw_text(cr, self.title, rect.x, rect.y, rect.width, rect.height, text_color=color, underline=self.underline)
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
def render_text(cr, content, rect, color, font_size, align=pango.ALIGN_CENTER): draw_text(cr, content, rect.x, rect.y, rect.width, rect.height, font_size, color, alignment=align)
def _render_action(self, cr, rect, text): with cairo_disable_antialias(cr): cr.rectangle(*rect) cr.set_source_rgb(1, 1, 1) cr.set_line_width(2) cr.stroke_preserve() cr.set_source_rgb(*color_hex_to_cairo(ACTION_BUTTON_COLOR_BG)) cr.fill() draw_text(cr, text, rect.x, rect.y, rect.width, rect.height, text_color="#ffffff", alignment=pango.ALIGN_CENTER)
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)
def render_pwd(self, cr, rect): render_background(cr, rect) draw_text(cr, _("Password:"), rect.x, rect.y, rect.width, rect.height, alignment=pango.ALIGN_LEFT)
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
def render_text(self, cr, rect): self.render_background(cr, rect) text = _("card %d") % (self.index) (text_width, text_height) = get_content_size(text) draw_text(cr, text, rect.x, rect.y, rect.width, rect.height, alignment=pango.ALIGN_CENTER)
def render_description(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, rect.y, rect.width, rect.height-1) cr.paint() draw_text(cr, self.description, rect.x+self.padding_x, rect.y, rect.width, rect.height, text_color=text_color)
def draw_complie_show_text(self, cr, rect): text_index = 0 for text in self.message_text_list: offset_y = (text_index * self.draw_height) height = get_content_size(text)[1] + self.draw_height /2 draw_text(cr, text, rect.x, rect.y + offset_y, rect.width, height ) text_index += 1