def expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation cr.set_source_rgb(*color_hex_to_cairo(THEME['bg'])) cr.rectangle(0, 0, rect.width, rect.height) cr.fill() pixbuf = gtk.gdk.pixbuf_new_from_file(self.image) image_size = [pixbuf.get_width(), pixbuf.get_height()] self.real_size = self.get_real_size( [rect.width, rect.height], image_size ) pixbuf = pixbuf.scale_simple(self.real_size[0], self.real_size[1], gtk.gdk.INTERP_HYPER) pixbuf = pixbuf.rotate_simple(self.rotate_type[self.rotate]) offset_x = (rect.width - self.real_size[0]) / 2 offset_y = (rect.height - self.real_size[1]) / 2 draw_pixbuf(cr, pixbuf, offset_x, offset_y) propagate_expose(widget, event) return True
def expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation cr.set_source_rgb(*color_hex_to_cairo(THEME['bg'])) cr.rectangle(*rect) cr.fill() if self.changable: if widget.state == gtk.STATE_PRELIGHT: x_offset = rect.width elif widget.state == gtk.STATE_ACTIVE: x_offset = rect.width * 2 elif self.show_state == "active": x_offset = rect.width * 2 else: x_offset = 0 pixbuf = self.image.scale_simple(rect.width * 3, rect.height, gtk.gdk.INTERP_BILINEAR) pixbuf = pixbuf.subpixbuf(x_offset, 0, rect.width, rect.height) else: pixbuf = self.image.scale_simple(rect.width, rect.height, gtk.gdk.INTERP_BILINEAR) draw_pixbuf(cr, pixbuf, rect.x, rect.y) propagate_expose(widget, event) return True
def expose_droplist_item(self, widget, event, item_content): '''Expose droplist item.''' # Init. cr = widget.window.cairo_create() rect = widget.allocation font_color = ui_theme.get_color("menu_font").get_color() # Draw select effect. if self.subdroplist_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]: # 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() # Draw item content. draw_text(cr, item_content, rect.x + self.item_padding_left, rect.y, rect.width, rect.height, self.font_size, font_color, ) # Propagate expose to children. propagate_expose(widget, event) return True
def expose_spin_bg(self, widget, event): ''' Internal callback for `expose-event` signal. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation x, y, w, h = rect.x, rect.y, rect.width, rect.height # Draw frame. with cairo_disable_antialias(cr): cr.set_line_width(1) if widget.state == gtk.STATE_INSENSITIVE: cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("disable_frame").get_color())) else: cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("combo_entry_frame").get_color())) cr.rectangle(rect.x, rect.y, rect.width, rect.height) cr.stroke() if widget.state == gtk.STATE_INSENSITIVE: cr.set_source_rgba(*alpha_color_hex_to_cairo((ui_theme.get_color("disable_background").get_color(), 0.9))) else: cr.set_source_rgba(*alpha_color_hex_to_cairo((ui_theme.get_color("combo_entry_background").get_color(), 0.9))) cr.rectangle(rect.x, rect.y, rect.width - 1, rect.height - 1) cr.fill() propagate_expose(widget, event) return False
def expose_button_item(self, widget, event): # Init. cr = widget.window.cairo_create() rect = widget.allocation select_index = self.get_index() # Draw background 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: pixbuf = self.press_dpixbuf.get_pixbuf() elif select_status == BUTTON_NORMAL: pixbuf = self.normal_dpixbuf.get_pixbuf() elif select_status == BUTTON_HOVER: pixbuf = self.hover_dpixbuf.get_pixbuf() draw_pixbuf(cr, pixbuf, rect.x, rect.y) propagate_expose(widget, event) return True
def scrollbar_expose_event(self, widget, event, direction="v"): cr = widget.window.cairo_create() rect = widget.allocation if direction == "v": widget.set_size_request(self.bar_width, rect.height) else: widget.set_size_request(rect.width, self.bar_width) cr.set_source_rgb(*color_hex_to_cairo(THEME['bg'])) cr.rectangle(*rect) cr.fill() if direction == "v": real_height = self._eventBox.allocation.height bar_height = rect.height ** 2 / real_height + 2 _adjustment = widget.get_adjustment() offsetY = _adjustment.get_value() * rect.height / real_height real_rect = (rect.x - 1, rect.y + offsetY, self.bar_width + 1, bar_height) else: real_width = self._eventBox.allocation.width if self._vscrollbar: bar_width = rect.width ** 2 / real_width + rect.height + 2 else: bar_width = rect.width ** 2 / real_width _adjustment = widget.get_adjustment() offsetX = _adjustment.get_value() * rect.width / real_width real_rect = (rect.x + offsetX, rect.y - 1, bar_width, self.bar_width + 1) cr.set_source_rgb(*color_hex_to_cairo(THEME['hover'])) cr.rectangle(*real_rect) cr.fill() propagate_expose(widget, event) return True
def expose_spin_bg(self, widget, event): ''' Internal callback for `expose-event` signal. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation x, y, w, h = rect.x, rect.y, rect.width, rect.height # Draw frame. with cairo_disable_antialias(cr): cr.set_line_width(1) if widget.state == gtk.STATE_INSENSITIVE: cr.set_source_rgb(*color_hex_to_cairo( ui_theme.get_color("disable_frame").get_color())) else: cr.set_source_rgb(*color_hex_to_cairo( ui_theme.get_color("combo_entry_frame").get_color())) cr.rectangle(rect.x, rect.y, rect.width, rect.height) cr.stroke() if widget.state == gtk.STATE_INSENSITIVE: cr.set_source_rgba(*alpha_color_hex_to_cairo(( ui_theme.get_color("disable_background").get_color(), 0.9))) else: cr.set_source_rgba(*alpha_color_hex_to_cairo(( ui_theme.get_color("combo_entry_background").get_color(), 0.9))) cr.rectangle(rect.x, rect.y, rect.width - 1, rect.height - 1) cr.fill() propagate_expose(widget, event) return False
def on_expose_combo_frame(self, widget, event): # Init. cr = widget.window.cairo_create() rect = widget.allocation # Draw frame. with cairo_disable_antialias(cr): cr.set_line_width(1) if self.get_sensitive(): cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("combo_entry_frame").get_color())) else: cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("disable_frame").get_color())) cr.rectangle(rect.x, rect.y, rect.width, rect.height) cr.stroke() if self.focus_flag: color = (ui_theme.get_color("combo_entry_select_background").get_color(), 0.9) cr.set_source_rgba(*alpha_color_hex_to_cairo(color)) cr.rectangle(rect.x, rect.y, rect.width - 1 - self.drop_button_width, rect.height - 1) cr.fill() cr.set_source_rgba(*alpha_color_hex_to_cairo((ui_theme.get_color("combo_entry_background").get_color(), 0.9))) cr.rectangle(rect.x + rect.width - 1 - self.drop_button_width, rect.y, self.drop_button_width, rect.height - 1) cr.fill() else: cr.set_source_rgba(*alpha_color_hex_to_cairo((ui_theme.get_color("combo_entry_background").get_color(), 0.9))) cr.rectangle(rect.x, rect.y, rect.width - 1, rect.height - 1) cr.fill() # Propagate expose to children. propagate_expose(widget, event) return True
def on_expose_event(win, e): cr = win.swindow.cairo_create() cr.set_source_rgba(1, 1, 1, 0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() winfo = TooltipInfo.winfo if winfo.has_shadow: (x, y, width, height) = (0, 0, win.allocation.width, win.allocation.height) (o_x, o_y) = (5, 5) #right-bottom corner radial = cairo.RadialGradient(width - o_x, height-o_y, 1, width -o_x, height-o_y, o_x) radial.add_color_stop_rgba(0.0, 0,0,0, 0.3) radial.add_color_stop_rgba(0.6, 0,0,0, 0.1) radial.add_color_stop_rgba(1, 0,0,0, 0) cr.set_source(radial) cr.rectangle(width-o_x, height-o_y, o_x, o_y) cr.fill() #left-bottom corner radial = cairo.RadialGradient(o_x, height-o_y, 1, o_x, height-o_y, o_x) radial.add_color_stop_rgba(0.0, 0,0,0, 0.3) radial.add_color_stop_rgba(0.6, 0,0,0, 0.1) radial.add_color_stop_rgba(1, 0,0,0, 0) cr.set_source(radial) cr.rectangle(0, height-o_y, o_x, o_y) cr.fill() #left-top corner radial = cairo.RadialGradient(width-o_x, o_y, 1, width-o_x, o_y, o_x) radial.add_color_stop_rgba(0.0, 0,0,0, 0.3) radial.add_color_stop_rgba(0.6, 0,0,0, 0.1) radial.add_color_stop_rgba(1, 0,0,0, 0) cr.set_source(radial) cr.rectangle(width-o_x, 0, o_x, o_y) cr.fill() vradial = cairo.LinearGradient(0, height-o_y, 0, height) vradial.add_color_stop_rgba(0.0, 0,0,0, .5) vradial.add_color_stop_rgba(0.4, 0,0,0, 0.25) vradial.add_color_stop_rgba(1, 0,0,0, 0.0) cr.set_source(vradial) cr.rectangle(o_x, height-o_x, width-2*o_x, height) cr.fill() hradial = cairo.LinearGradient(width-o_x, 0, width, 0) hradial.add_color_stop_rgba(0.0, 0,0,0, .5) hradial.add_color_stop_rgba(0.4, 0,0,0, 0.25) hradial.add_color_stop_rgba(1, 0,0,0, 0.0) cr.set_source(hradial) cr.rectangle(width-o_x, o_y, width, height-2*o_y) cr.fill() gtk.Alignment.do_expose_event(TooltipInfo.alignment, e) propagate_expose(win, e) return True
def expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation with cairo_disable_antialias(cr): cr.set_source_rgb(*color_hex_to_cairo(THEME['bg'])) cr.rectangle(*rect) cr.fill() propagate_expose(widget, event) return True
def expose_menu_item(self, widget, event): '''Expose menu item.''' # Init. cr = widget.window.cairo_create() rect = widget.allocation font_color = ui_theme.get_color("menu_font").get_color() (item_icons, item_content, item_node) = self.item[0:3] # Draw select effect. if self.submenu_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]: # Draw background. draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, ui_theme.get_shadow_color("menu_item_select").get_color_info(), MENU_ITEM_RADIUS) # Set font color. font_color = ui_theme.get_color("menu_select_font").get_color() # Draw item icon. pixbuf = None pixbuf_width = 0 if item_icons: (item_normal_dpixbuf, item_hover_dpixbuf) = item_icons if self.submenu_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]: if item_hover_dpixbuf == None: pixbuf = item_normal_dpixbuf.get_pixbuf() else: pixbuf = item_hover_dpixbuf.get_pixbuf() else: pixbuf = item_normal_dpixbuf.get_pixbuf() pixbuf_width += pixbuf.get_width() draw_pixbuf(cr, pixbuf, rect.x + self.item_padding_x, rect.y + (rect.height - pixbuf.get_height()) / 2) # Draw item content. draw_text(cr, item_content, rect.x + self.item_padding_x * 2 + self.icon_width, rect.y, rect.width, rect.height, self.font_size, font_color, ) # Draw submenu arrow. if isinstance(item_node, Menu): if self.submenu_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]: submenu_pixbuf = ui_theme.get_pixbuf("menu/arrow_hover.png").get_pixbuf() else: submenu_pixbuf = ui_theme.get_pixbuf("menu/arrow_normal.png").get_pixbuf() draw_pixbuf(cr, submenu_pixbuf, rect.x + rect.width - self.item_padding_x - submenu_pixbuf.get_width() - self.arrow_padding_x, rect.y + (rect.height - submenu_pixbuf.get_height()) / 2) # Propagate expose to children. propagate_expose(widget, event) return True
def expose_category_item(self, widget, event): '''Expose navigate item.''' # Init. cr = widget.window.cairo_create() rect = widget.allocation select_index = self.get_index() font_color = ui_theme.get_color("category_item").get_color() # Draw background. 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, ui_theme.get_shadow_color("category_item_press").get_color_info()) font_color = ui_theme.get_color("category_select_item").get_color() elif select_status == BUTTON_HOVER: draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, ui_theme.get_shadow_color("category_item_hover").get_color_info()) font_color = ui_theme.get_color("category_select_item").get_color() # Draw navigate item. category_item_pixbuf = self.icon_dpixbuf.get_pixbuf() draw_pixbuf( cr, category_item_pixbuf, rect.x + self.padding_left, rect.y + (rect.height - category_item_pixbuf.get_height()) / 2 ) # Draw font. 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, ) # Propagate expose to children. propagate_expose(widget, event) return True
def expose_star_view(self, widget, event): # Init. cr = widget.window.cairo_create() rect = widget.allocation self.star_buffer.render(cr, rect) # Propagate expose. propagate_expose(widget, event) return True
def expose_window(self, widget, event): ''' Internal function to expose the window. @param widget: A window of type Gtk.Widget. @param event: The expose event of type gtk.gdk.Event. @return: Always return True. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation x, y, w, h = rect.x, rect.y, rect.width, rect.height # Draw background. self.draw_background(cr, rect.x, rect.y, rect.width, rect.height) # Draw skin and mask. with cairo_state(cr): if self.window.get_state( ) & gtk.gdk.WINDOW_STATE_MAXIMIZED != gtk.gdk.WINDOW_STATE_MAXIMIZED: cr.rectangle(x + 2, y, w - 4, 1) cr.rectangle(x + 1, y + 1, w - 2, 1) cr.rectangle(x, y + 2, w, h - 4) cr.rectangle(x + 2, y + h - 1, w - 4, 1) cr.rectangle(x + 1, y + h - 2, w - 2, 1) cr.clip() self.draw_skin(cr, x, y, w, h) # Draw mask. self.draw_mask(cr, x, y, w, h) # Draw window frame. if self.window.get_state( ) & gtk.gdk.WINDOW_STATE_MAXIMIZED != gtk.gdk.WINDOW_STATE_MAXIMIZED: draw_window_frame( cr, x, y, w, h, ui_theme.get_alpha_color("window_frame_outside_1"), ui_theme.get_alpha_color("window_frame_outside_2"), ui_theme.get_alpha_color("window_frame_outside_3"), ui_theme.get_alpha_color("window_frame_inside_1"), ui_theme.get_alpha_color("window_frame_inside_2"), ) # Propagate expose. propagate_expose(widget, event) return True
def expose_label(self, widget, event): '''Expose label.''' cr = widget.window.cairo_create() rect = widget.allocation self.draw_label_background(cr, rect) self.draw_label_text(cr, rect) propagate_expose(widget, event) return True
def _expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation rect.y, rect.x = 0, 0 cr.set_source_rgba(*alpha_color_hex_to_cairo( (self.bg, self.opacity))) cr.rectangle(*rect) cr.fill() propagate_expose(widget, event) return True
def loading_flag(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation cr.set_source_rgb(*color_hex_to_cairo(THEME['bg'])) cr.rectangle(0, 0, rect.width, rect.height) cr.fill() draw_text(cr, rect.x, rect.y, text_size=20, text_color=THEME['font_color']) propagate_expose(widget, event)
def expose_linear_background(widget, event, color_infos): '''Expose linear background.''' # Init. cr = widget.window.cairo_create() rect = widget.allocation # Draw linear background. draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, color_infos) # Propagate expose. propagate_expose(widget, event) return True
def expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation size = min(rect. width, rect.height) pixbuf = self.image.scale_simple(size, size, gtk.gdk.INTERP_BILINEAR) draw_pixbuf(cr, pixbuf, rect.x + (rect.width - size) / 2, rect.y + (rect.height - size) / 2) propagate_expose(widget, event) return True
def image_button_expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation if widget.state == gtk.STATE_NORMAL: image = self.normal_image_pixbuf elif widget.state == gtk.STATE_PRELIGHT: image = self.hover_image_pixbuf elif widget.state == gtk.STATE_ACTIVE: image = self.press_image_pixbuf draw_pixbuf(cr, image, rect.x, rect.y) propagate_expose(widget, event) return True
def expose_progressbar(self, widget, event): ''' Internal callback for `expose` signal. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation self.progress_buffer.render(cr, rect) # Propagate expose. propagate_expose(widget, event) return True
def expose_nav_item(self, widget, event): '''Expose navigate item.''' # Init. cr = widget.window.cairo_create() rect = widget.allocation select_index = self.get_index() hover_pixbuf = ui_theme.get_pixbuf("navigatebar/nav_item_hover.png").get_pixbuf() press_pixbuf = ui_theme.get_pixbuf("navigatebar/nav_item_press.png").get_pixbuf() # Draw background. if widget.state == gtk.STATE_NORMAL: if select_index == self.index: select_pixbuf = press_pixbuf else: select_pixbuf = None elif widget.state == gtk.STATE_PRELIGHT: if select_index == self.index: select_pixbuf = press_pixbuf else: select_pixbuf = hover_pixbuf elif widget.state == gtk.STATE_ACTIVE: select_pixbuf = press_pixbuf if select_pixbuf: draw_pixbuf(cr, select_pixbuf, rect.x, rect.y) # Draw navigate item. nav_item_pixbuf = self.icon_dpixbuf.get_pixbuf() draw_pixbuf( cr, nav_item_pixbuf, rect.x + (rect.width - nav_item_pixbuf.get_width()) / 2, rect.y) # Draw font. draw_text(cr, self.content, rect.x, rect.y + nav_item_pixbuf.get_height() - 3, rect.width, rect.height - nav_item_pixbuf.get_height(), text_color="#FFFFFF", alignment=pango.ALIGN_CENTER, gaussian_radious=2, gaussian_color="#000000", border_radious=1, border_color="#000000", ) # Propagate expose to children. propagate_expose(widget, event) return True
def expose_display_button(self, widget, event): '''Expose display button.''' # Init. cr = widget.window.cairo_create() rect = widget.allocation cr.set_source_rgb(*color_hex_to_cairo(self.color_string)) cr.rectangle(rect.x, rect.y, rect.width, rect.height) cr.fill() # Propagate expose. propagate_expose(widget, event) return True
def expose_window(self, widget, event): """ Internal function to expose the window. @param widget: A window of type Gtk.Widget. @param event: The expose event of type gtk.gdk.Event. @return: Always return True. """ # Init. cr = widget.window.cairo_create() rect = widget.allocation x, y, w, h = rect.x, rect.y, rect.width, rect.height # Clear color to transparent window. cr.set_source_rgba(*self.background_color) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() # Draw background. with cairo_state(cr): if self.window.get_state() != gtk.gdk.WINDOW_STATE_MAXIMIZED: cr.rectangle(x + 2, y, w - 4, 1) cr.rectangle(x + 1, y + 1, w - 2, 1) cr.rectangle(x, y + 2, w, h - 4) cr.rectangle(x + 2, y + h - 1, w - 4, 1) cr.rectangle(x + 1, y + h - 2, w - 2, 1) cr.clip() skin_config.render_background(cr, self, x, y) # Draw mask. self.draw_mask(cr, x, y, w, h) # Draw window frame. if self.window.get_state() != gtk.gdk.WINDOW_STATE_MAXIMIZED: draw_window_frame(cr, x, y, w, h, ui_theme.get_alpha_color("window_frame_outside_1"), ui_theme.get_alpha_color("window_frame_outside_2"), ui_theme.get_alpha_color("window_frame_outside_3"), ui_theme.get_alpha_color("window_frame_inside_1"), ui_theme.get_alpha_color("window_frame_inside_2"), ) # Propagate expose. propagate_expose(widget, event) return True
def expose_button(widget, event, cache_pixbuf, scale_x, scaleY, normal_dpixbuf, hover_dpixbuf, press_dpixbuf, button_label, font_size, label_dcolor): '''Expose function to replace event box's image.''' # Init. rect = widget.allocation # Get pixbuf along with button's sate. if widget.state == gtk.STATE_NORMAL: image = normal_dpixbuf.get_pixbuf() elif widget.state == gtk.STATE_PRELIGHT: image = hover_dpixbuf.get_pixbuf() elif widget.state == gtk.STATE_ACTIVE: image = press_dpixbuf.get_pixbuf() # Init size. if scale_x: image_width = widget.allocation.width else: image_width = image.get_width() if scaleY: image_height = widget.allocation.height else: image_height = image.get_height() # Draw button. pixbuf = image if pixbuf.get_width() != image_width or pixbuf.get_height() != image_height: cache_pixbuf.scale(image, image_width, image_height) pixbuf = cache_pixbuf.get_cache() cr = widget.window.cairo_create() draw_pixbuf(cr, pixbuf, widget.allocation.x, widget.allocation.y) # Draw font. if button_label: draw_text(cr, button_label, rect.x, rect.y, rect.width, rect.height, font_size, label_dcolor.get_color(), alignment=pango.ALIGN_CENTER ) # Propagate expose to children. propagate_expose(widget, event) return True
def draw_expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation # cr.rectangle(*rect) cr.set_source_rgba(1, 1, 1, 0.0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() cr = widget.window.cairo_create() x, y, w, h = rect self.expose_event_draw(cr) # propagate_expose(widget, event) return True
def expose_window(self, widget, event): ''' Internal function to expose the window. @param widget: A window of type Gtk.Widget. @param event: The expose event of type gtk.gdk.Event. @return: Always return True. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation x, y, w, h = rect.x, rect.y, rect.width, rect.height # Draw background. self.draw_background(cr, rect.x, rect.y, rect.width, rect.height) # Draw skin and mask. with cairo_state(cr): if self.window.get_state() & gtk.gdk.WINDOW_STATE_MAXIMIZED != gtk.gdk.WINDOW_STATE_MAXIMIZED: cr.rectangle(x + 2, y, w - 4, 1) cr.rectangle(x + 1, y + 1, w - 2, 1) cr.rectangle(x, y + 2, w, h - 4) cr.rectangle(x + 2, y + h - 1, w - 4, 1) cr.rectangle(x + 1, y + h - 2, w - 2, 1) cr.clip() self.draw_skin(cr, x, y, w, h) # Draw mask. self.draw_mask(cr, x, y, w, h) # Draw window frame. if self.window.get_state() & gtk.gdk.WINDOW_STATE_MAXIMIZED != gtk.gdk.WINDOW_STATE_MAXIMIZED: draw_window_frame(cr, x, y, w, h, ui_theme.get_alpha_color("window_frame_outside_1"), ui_theme.get_alpha_color("window_frame_outside_2"), ui_theme.get_alpha_color("window_frame_outside_3"), ui_theme.get_alpha_color("window_frame_inside_1"), ui_theme.get_alpha_color("window_frame_inside_2"), ) # Propagate expose. propagate_expose(widget, event) return True
def expose_label(self, widget, event): ''' Internal callback for `expose-event` signal. @param widget: Label widget. @param event: Expose event. ''' cr = widget.window.cairo_create() rect = widget.allocation self.draw_label_background(cr, rect) self.draw_label_text(cr, rect) propagate_expose(widget, event) return True
def expose_linear_background(widget, event, color_infos): ''' Expose linear background. @param widget: Gtk.Widget instance. @param event: Expose event. @param color_infos: A list of ColorInfo, ColorInfo format: (color_stop_position, (color_hex_value, color_alpha)) ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation # Draw linear background. draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, color_infos) # Propagate expose. propagate_expose(widget, event) return True
def statusicon_draw_expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation x, y, w, h = rect # cr.rectangle(*rect) if self.debug: cr.set_source_rgba(0, 0, 1, 1.0) else: cr.set_source_rgba(1, 1, 1, 0.0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() # cr = widget.window.cairo_create() # self.draw_function_id(cr, x, y, w, h) # propagate_expose(widget, event) return True
def expose_action_button(self, widget, event): '''Expose action button.''' # Init. cr = widget.window.cairo_create() rect = widget.allocation if widget.state == gtk.STATE_NORMAL: pixbuf = self.actions[self.index][0][0].get_pixbuf() elif widget.state == gtk.STATE_PRELIGHT: pixbuf = self.actions[self.index][0][1].get_pixbuf() elif widget.state == gtk.STATE_ACTIVE: pixbuf = self.actions[self.index][0][2].get_pixbuf() draw_pixbuf(cr, pixbuf, rect.x, rect.y) # Propagate expose to children. propagate_expose(widget, event) return True
def color_test_widget_expose(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation # Draw pixbuf. draw_pixbuf(cr, self.pixbuf, 0, 0) # Draw mask. draw_vlinear(cr, rect.x, rect.y + self.pixbuf.get_height() - SHADOW_SIZE, rect.width, SHADOW_SIZE, [(0, (self.background_color, 0)), (1, (self.background_color, 1))]) draw_hlinear(cr, rect.x + self.pixbuf.get_width() - SHADOW_SIZE, rect.y, SHADOW_SIZE, rect.height, [(0, (self.background_color, 0)), (1, (self.background_color, 1))]) # Draw background. (similar_color_name, similar_color_value) = find_similar_color(self.background_color) print(similar_color_name, self.background_color, similar_color_value) cr.set_source_rgb(*color_hex_to_cairo(similar_color_value)) cr.rectangle(rect.x + self.pixbuf.get_width(), rect.y, rect.width - self.pixbuf.get_width(), rect.height) cr.fill() cr.set_source_rgb(*color_hex_to_cairo(self.background_color)) cr.rectangle(rect.x, rect.y + self.pixbuf.get_height(), rect.width, rect.height - self.pixbuf.get_height()) cr.fill() # cr.set_source_rgb(*color_hex_to_cairo(self.background_color)) # cr.rectangle(rect.x + self.pixbuf.get_width(), rect.y, # rect.width - self.pixbuf.get_width(), rect.height) # cr.rectangle(rect.x, rect.y + self.pixbuf.get_height(), # rect.width, rect.height - self.pixbuf.get_height()) # cr.fill() propagate_expose(widget, event) return True
def expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation rect = (0, rect.y, rect.width, rect.height) if self.hover: color = THEME['hover'] font_color = THEME['bg'] else: color = THEME['bg'] font_color = THEME['font_color'] self._titleLabel.font_color = font_color self._subtitleLabel.font_color = font_color cr.set_source_rgb(*color_hex_to_cairo(color)) cr.rectangle(*rect) cr.fill() propagate_expose(widget, event) return True
def on_expose_combo_frame(self, widget, event): # Init. cr = widget.window.cairo_create() rect = widget.allocation # Draw frame. with cairo_disable_antialias(cr): cr.set_line_width(1) if self.get_sensitive(): cr.set_source_rgb(*color_hex_to_cairo( ui_theme.get_color("combo_entry_frame").get_color())) else: cr.set_source_rgb(*color_hex_to_cairo( ui_theme.get_color("disable_frame").get_color())) cr.rectangle(rect.x, rect.y, rect.width, rect.height) cr.stroke() if self.focus_flag: color = (ui_theme.get_color( "combo_entry_select_background").get_color(), 0.9) cr.set_source_rgba(*alpha_color_hex_to_cairo(color)) cr.rectangle(rect.x, rect.y, rect.width - 1 - self.drop_button_width, rect.height - 1) cr.fill() cr.set_source_rgba(*alpha_color_hex_to_cairo(( ui_theme.get_color("combo_entry_background").get_color(), 0.9))) cr.rectangle(rect.x + rect.width - 1 - self.drop_button_width, rect.y, self.drop_button_width, rect.height - 1) cr.fill() else: cr.set_source_rgba(*alpha_color_hex_to_cairo(( ui_theme.get_color("combo_entry_background").get_color(), 0.9))) cr.rectangle(rect.x, rect.y, rect.width - 1, rect.height - 1) cr.fill() # Propagate expose to children. propagate_expose(widget, event) return True
def expose_display_button(self, widget, event): ''' Callback for `expose-event` signal. @param widget: Gtk.Widget instance. @param event: Expose event. @return: Always return True ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation cr.set_source_rgb(*color_hex_to_cairo(self.color_string)) cr.rectangle(rect.x, rect.y, rect.width, rect.height) cr.fill() # Propagate expose. propagate_expose(widget, event) return True
def expose_droplist_item(self, widget, event, item_content): ''' Internal function to handle `expose-event` signal of item. @param widget: DropItem widget. @param event: Expose event. @param item_content: Item content. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation font_color = ui_theme.get_color("menu_font").get_color() # Draw select effect. if self.subdroplist_active or widget.state in [ gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE ]: # 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() # Draw item content. draw_text( cr, item_content, rect.x + self.item_padding_left, rect.y, rect.width, rect.height, self.font_size, font_color, ) # Propagate expose to children. propagate_expose(widget, event) return True
def expose_toggle_button_item(self, widget, event): ''' Internal callback for `expose-event` signal. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation select_index = self.get_index() if widget.state == gtk.STATE_NORMAL: if select_index == self.index: self.set_index(-1) pixbuf = self.inactive_dpixbuf.get_pixbuf() elif widget.state == gtk.STATE_PRELIGHT: if not self.inactive_hover_dpixbuf and not self.active_hover_dpixbuf: if widget.get_active(): pixbuf = self.active_dpixbuf.get_pixbuf() else: pixbuf = self.inactive_dpixbuf.get_pixbuf() else: if self.inactive_hover_dpixbuf and self.active_hover_dpixbuf: if widget.get_active(): pixbuf = self.active_hover_dpixbuf.get_pixbuf() else: pixbuf = self.inactive_hover_dpixbuf.get_pixbuf() elif self.inactive_hover_dpixbuf: pixbuf = self.inactive_hover_dpixbuf.get_pixbuf() elif self.active_hover_dpixbuf: pixbuf = self.active_hover_dpixbuf.get_pixbuf() elif widget.state == gtk.STATE_ACTIVE: if select_index == self.index: pixbuf = self.active_dpixbuf.get_pixbuf() else: widget.set_active(False) pixbuf = self.inactive_dpixbuf.get_pixbuf() draw_pixbuf(cr, pixbuf, rect.x, rect.y) propagate_expose(widget, event) return True
def expose_image_button_item(self, widget, event): ''' Internal callback for `expose-event` signal. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation select_index = self.get_index() # Draw background 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: pixbuf = self.press_dpixbuf.get_pixbuf() elif select_status == BUTTON_NORMAL: pixbuf = self.normal_dpixbuf.get_pixbuf() elif select_status == BUTTON_HOVER: pixbuf = self.hover_dpixbuf.get_pixbuf() draw_pixbuf(cr, pixbuf, rect.x, rect.y) propagate_expose(widget, event) return True
def __expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation # cr.rectangle(*rect) cr.set_source_rgba(1, 1, 1, 0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() # cr = widget.window.cairo_create() # ''' if self.__sahow_check: # 是否显示阴影. self.draw_surface_expose_event(cr) else: # 如果不开启阴影. cr.set_source_rgba(1, 1, 1, 1.0) cr.paint() # ''' if self.on_paint_expose_event: self.on_paint_expose_event(widget, event) # propagate_expose(widget, event) return True
def expose_window_background(self, widget, event): ''' Internal function to expose the window background. @param widget: A window of type Gtk.Widget. @param event: The expose event of type gtk.gdk.Event. @return: Always return True. ''' if self.expose_background_function: self.expose_background_function(widget, event) else: # Init. cr = widget.window.cairo_create() rect = widget.allocation # Draw background. self.draw_background(cr, rect.x, rect.y, rect.width, rect.height) # Save cairo context. if self.shadow_is_visible: x = rect.x + self.shadow_padding y = rect.y + self.shadow_padding w = rect.width - self.shadow_padding * 2 h = rect.height - self.shadow_padding * 2 else: x, y, w, h = rect.x, rect.y, rect.width, rect.height # Draw skin and mask. with cairo_state(cr): if self.window.get_state( ) & gtk.gdk.WINDOW_STATE_MAXIMIZED != gtk.gdk.WINDOW_STATE_MAXIMIZED: cr.rectangle(x + 2, y, w - 4, 1) cr.rectangle(x + 1, y + 1, w - 2, 1) cr.rectangle(x, y + 2, w, h - 4) cr.rectangle(x + 2, y + h - 1, w - 4, 1) cr.rectangle(x + 1, y + h - 2, w - 2, 1) cr.clip() # Draw background. self.draw_skin(cr, x, y, w, h) # Draw mask. self.draw_mask(cr, x, y, w, h) # Draw corner shadow. with cairo_state(cr): cr.set_source_rgba(*alpha_color_hex_to_cairo( ui_theme.get_alpha_color( "window_shadow_corner").get_color_info())) cr.rectangle(x, y + 1, 1, 1) # top-left cr.rectangle(x + 1, y, 1, 1) cr.rectangle(x + w - 1, y + 1, 1, 1) # top-right cr.rectangle(x + w - 2, y, 1, 1) cr.rectangle(x, y + h - 2, 1, 1) # bottom-left cr.rectangle(x + 1, y + h - 1, 1, 1) cr.rectangle(x + w - 1, y + h - 2, 1, 1) # bottom-right cr.rectangle(x + w - 2, y + h - 1, 1, 1) cr.fill() # Draw background corner. with cairo_state(cr): cr.rectangle(x, y + 1, 1, 1) # top-left cr.rectangle(x + 1, y, 1, 1) cr.rectangle(x + w - 1, y + 1, 1, 1) # top-right cr.rectangle(x + w - 2, y, 1, 1) cr.rectangle(x, y + h - 2, 1, 1) # bottom-left cr.rectangle(x + 1, y + h - 1, 1, 1) cr.rectangle(x + w - 1, y + h - 2, 1, 1) # bottom-right cr.rectangle(x + w - 2, y + h - 1, 1, 1) cr.clip() self.draw_skin(cr, x, y, w, h) # Propagate expose. propagate_expose(widget, event) return True
def expose_nav_item(self, widget, event): ''' Internal callback `expose-event` signal. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation select_index = self.get_index() hover_pixbuf = self.item_hover_pixbuf.get_pixbuf() press_pixbuf = self.item_press_pixbuf.get_pixbuf() # Draw background. if widget.state == gtk.STATE_NORMAL: if select_index == self.index: select_pixbuf = press_pixbuf else: select_pixbuf = None elif widget.state == gtk.STATE_PRELIGHT: if select_index == self.index: select_pixbuf = press_pixbuf else: select_pixbuf = hover_pixbuf elif widget.state == gtk.STATE_ACTIVE: select_pixbuf = press_pixbuf if select_pixbuf: select_pixbuf = select_pixbuf.scale_simple(rect.width, rect.height, gtk.gdk.INTERP_BILINEAR) draw_pixbuf(cr, select_pixbuf, rect.x, rect.y) # Draw navigate item. if self.vertical: draw_pixbuf( cr, self.nav_item_pixbuf, rect.x + (rect.width - self.nav_item_pixbuf.get_width()) / 2, rect.y) draw_text( cr, self.content, rect.x, rect.y + self.nav_item_pixbuf.get_height() - 3, rect.width, rect.height - self.nav_item_pixbuf.get_height(), text_size=self.font_size, text_color="#FFFFFF", alignment=pango.ALIGN_CENTER, gaussian_radious=2, gaussian_color="#000000", border_radious=1, border_color="#000000", ) else: padding_x = (rect.width - self.nav_item_pixbuf.get_width() - self.text_width) / 2 draw_pixbuf( cr, self.nav_item_pixbuf, rect.x + padding_x, rect.y + (rect.height - self.nav_item_pixbuf.get_height()) / 2) draw_text( cr, self.content, rect.x + self.nav_item_pixbuf.get_width() + padding_x, rect.y, rect.width, rect.height, text_size=self.font_size, text_color="#FFFFFF", gaussian_radious=2, gaussian_color="#000000", border_radious=1, border_color="#000000", ) # Draw notify number. text_size = 8 (number_width, number_height) = get_content_size(str(self.notify_num), text_size) padding_x = 2 padding_y = 0 radious = 3 draw_offset_x = -5 draw_offset_y = 8 draw_x = rect.x + self.nav_item_pixbuf.get_width( ) + padding_x + draw_offset_x draw_y = rect.y + draw_offset_y if self.notify_num > 0: cr.set_source_rgb(*color_hex_to_cairo("#BF0000")) draw_round_rectangle(cr, draw_x, draw_y, number_width + padding_x * 2, number_height + padding_y * 2, radious) cr.fill() draw_text( cr, str(self.notify_num), draw_x + padding_x, draw_y + padding_y, number_width, number_height, text_color="#FFFFFF", text_size=text_size, ) # Propagate expose to children. propagate_expose(widget, event) return True
def on_expose_event(win, e): cr = win.swindow.cairo_create() cr.set_source_rgba(1, 1, 1, 0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() winfo = TooltipInfo.winfo if winfo.has_shadow: (x, y, width, height) = (0, 0, win.allocation.width, win.allocation.height) (o_x, o_y) = (5, 5) #right-bottom corner radial = cairo.RadialGradient(width - o_x, height - o_y, 1, width - o_x, height - o_y, o_x) radial.add_color_stop_rgba(0.0, 0, 0, 0, 0.3) radial.add_color_stop_rgba(0.6, 0, 0, 0, 0.1) radial.add_color_stop_rgba(1, 0, 0, 0, 0) cr.set_source(radial) cr.rectangle(width - o_x, height - o_y, o_x, o_y) cr.fill() #left-bottom corner radial = cairo.RadialGradient(o_x, height - o_y, 1, o_x, height - o_y, o_x) radial.add_color_stop_rgba(0.0, 0, 0, 0, 0.3) radial.add_color_stop_rgba(0.6, 0, 0, 0, 0.1) radial.add_color_stop_rgba(1, 0, 0, 0, 0) cr.set_source(radial) cr.rectangle(0, height - o_y, o_x, o_y) cr.fill() #left-top corner radial = cairo.RadialGradient(width - o_x, o_y, 1, width - o_x, o_y, o_x) radial.add_color_stop_rgba(0.0, 0, 0, 0, 0.3) radial.add_color_stop_rgba(0.6, 0, 0, 0, 0.1) radial.add_color_stop_rgba(1, 0, 0, 0, 0) cr.set_source(radial) cr.rectangle(width - o_x, 0, o_x, o_y) cr.fill() vradial = cairo.LinearGradient(0, height - o_y, 0, height) vradial.add_color_stop_rgba(0.0, 0, 0, 0, .5) vradial.add_color_stop_rgba(0.4, 0, 0, 0, 0.25) vradial.add_color_stop_rgba(1, 0, 0, 0, 0.0) cr.set_source(vradial) cr.rectangle(o_x, height - o_x, width - 2 * o_x, height) cr.fill() hradial = cairo.LinearGradient(width - o_x, 0, width, 0) hradial.add_color_stop_rgba(0.0, 0, 0, 0, .5) hradial.add_color_stop_rgba(0.4, 0, 0, 0, 0.25) hradial.add_color_stop_rgba(1, 0, 0, 0, 0.0) cr.set_source(hradial) cr.rectangle(width - o_x, o_y, width, height - 2 * o_y) cr.fill() gtk.Alignment.do_expose_event(TooltipInfo.alignment, e) propagate_expose(win, e) return True
def expose_menu_item(self, widget, event): ''' Internal callback for `expose` signal. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation font_color = ui_theme.get_color("menu_font").get_color() (item_icons, item_content, item_node) = self.item[0:3] # Draw select effect. if widget.state == gtk.STATE_INSENSITIVE: # Set font color. font_color = ui_theme.get_color("menu_disable_font").get_color() elif self.submenu_active or widget.state in [ gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE ]: # Draw background. if self.menu_item_select_color: item_select_color = self.menu_item_select_color else: item_select_color = ui_theme.get_shadow_color( "menu_item_select").get_color_info() draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, item_select_color, MENU_ITEM_RADIUS) # Set font color. font_color = ui_theme.get_color("menu_select_font").get_color() # Draw item icon. pixbuf = None pixbuf_width = 0 if item_icons: (item_normal_dpixbuf, item_hover_dpixbuf, item_disable_dpixbuf) = item_icons if widget.state == gtk.STATE_INSENSITIVE: pixbuf = item_disable_dpixbuf.get_pixbuf() elif self.submenu_active or widget.state in [ gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE ]: if item_hover_dpixbuf == None: pixbuf = item_normal_dpixbuf.get_pixbuf() else: pixbuf = item_hover_dpixbuf.get_pixbuf() else: pixbuf = item_normal_dpixbuf.get_pixbuf() pixbuf_width += pixbuf.get_width() draw_pixbuf(cr, pixbuf, rect.x + self.item_padding_x, rect.y + (rect.height - pixbuf.get_height()) / 2) # Draw item content. draw_text( cr, item_content, rect.x + self.item_padding_x * 2 + self.icon_width, rect.y, rect.width, rect.height, self.font_size, font_color, ) # Draw submenu arrow. if isinstance(item_node, Menu): if widget.state == gtk.STATE_INSENSITIVE: submenu_pixbuf = ui_theme.get_pixbuf( "menu/arrow_disable.png").get_pixbuf() elif self.submenu_active or widget.state in [ gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE ]: submenu_pixbuf = ui_theme.get_pixbuf( "menu/arrow_hover.png").get_pixbuf() else: submenu_pixbuf = ui_theme.get_pixbuf( "menu/arrow_normal.png").get_pixbuf() draw_pixbuf( cr, submenu_pixbuf, rect.x + rect.width - self.item_padding_x - submenu_pixbuf.get_width() - self.arrow_padding_x, rect.y + (rect.height - submenu_pixbuf.get_height()) / 2) # Propagate expose to children. propagate_expose(widget, event) return True
def expose_notebook(self, widget, event): ''' Internal callback for `expose-event` signal. @param widget: Notebook wiget. @param event: Expose event. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation foreground_left_pixbuf = self.foreground_left_pixbuf.get_pixbuf() self.cache_fg_pixbuf.scale( self.foreground_middle_pixbuf.get_pixbuf(), self.tab_width - foreground_left_pixbuf.get_width() * 2, self.tab_height) foreground_middle_pixbuf = self.cache_fg_pixbuf.get_cache() foreground_right_pixbuf = self.foreground_right_pixbuf.get_pixbuf() background_left_pixbuf = self.background_left_pixbuf.get_pixbuf() self.cache_bg_pixbuf.scale( self.background_middle_pixbuf.get_pixbuf(), self.tab_width - background_left_pixbuf.get_width() * 2, self.tab_height) background_middle_pixbuf = self.cache_bg_pixbuf.get_cache() background_right_pixbuf = self.background_right_pixbuf.get_pixbuf() # Draw tab. for (index, (item_icon, item_content, item_callback)) in enumerate(self.items): # Draw background. if self.current_item_index == index: draw_pixbuf(cr, foreground_left_pixbuf, rect.x + index * self.tab_width, rect.y) draw_pixbuf( cr, foreground_middle_pixbuf, rect.x + index * self.tab_width + foreground_left_pixbuf.get_width(), rect.y) draw_pixbuf( cr, foreground_right_pixbuf, rect.x + (index + 1) * self.tab_width - foreground_left_pixbuf.get_width(), rect.y) else: draw_pixbuf(cr, background_left_pixbuf, rect.x + index * self.tab_width, rect.y) draw_pixbuf( cr, background_middle_pixbuf, rect.x + index * self.tab_width + background_left_pixbuf.get_width(), rect.y) draw_pixbuf( cr, background_right_pixbuf, rect.x + (index + 1) * self.tab_width - background_left_pixbuf.get_width(), rect.y) # Draw content. (content_width, content_height) = get_content_size(item_content, DEFAULT_FONT_SIZE) if item_icon != None: tab_render_width = self.icon_width + self.padding_middle + content_width draw_pixbuf( cr, item_icon.get_pixbuf(), rect.x + index * self.tab_width + (self.tab_width - tab_render_width) / 2, rect.y + (self.tab_height - item_icon.get_pixbuf().get_height()) / 2) draw_text( cr, item_content, rect.x + index * self.tab_width + (self.tab_width - tab_render_width) / 2 + self.icon_width + self.padding_middle, rect.y + (self.tab_height - content_height) / 2, content_width, content_height, DEFAULT_FONT_SIZE, ui_theme.get_color("notebook_font").get_color(), ) else: tab_render_width = content_width draw_text( cr, item_content, rect.x + index * self.tab_width + (self.tab_width - tab_render_width) / 2 + self.icon_width + self.padding_middle, rect.y + (self.tab_height - content_height) / 2, content_width, content_height, DEFAULT_FONT_SIZE, ui_theme.get_color("notebook_font").get_color(), ) propagate_expose(widget, event) return True
def expose_time_spin(self, widget, event): ''' Internal callback for `expose-event` signal. ''' # Init. cr = widget.window.cairo_create() rect = widget.allocation x, y, w, h = rect.x, rect.y, rect.width, rect.height # Draw frame. with cairo_disable_antialias(cr): cr.set_line_width(1) if widget.state == gtk.STATE_INSENSITIVE: cr.set_source_rgb(*color_hex_to_cairo( ui_theme.get_color("disable_frame").get_color())) else: cr.set_source_rgb(*color_hex_to_cairo( ui_theme.get_color("combo_entry_frame").get_color())) cr.rectangle(x, y, w, h) cr.stroke() if widget.state == gtk.STATE_INSENSITIVE: cr.set_source_rgba(*alpha_color_hex_to_cairo(( ui_theme.get_color("disable_background").get_color(), 0.9))) else: cr.set_source_rgba(*alpha_color_hex_to_cairo(( ui_theme.get_color("combo_entry_background").get_color(), 0.9))) cr.rectangle(x, y, w - 1, h - 1) cr.fill() if self.set_time == self.SET_HOUR: cr.set_source_rgba(*color_hex_to_cairo(self.set_time_bg_color)) cr.rectangle(x + self.padding_x, y, self.time_width, h) cr.fill() if self.set_time == self.SET_MIN: cr.set_source_rgba(*color_hex_to_cairo(self.set_time_bg_color)) cr.rectangle( x + self.padding_x + self.time_width + self.time_comma_width, y, self.time_width, h) cr.fill() if self.set_time == self.SET_SEC: cr.set_source_rgba(*color_hex_to_cairo(self.set_time_bg_color)) cr.rectangle( x + self.padding_x + (self.time_width + self.time_comma_width) * 2, y, self.time_width, h) cr.fill() if not self.__pressed_button: if self.__24hour: self.hour_value = time.localtime().tm_hour else: self.hour_value = int(time.strftime('%I')) self.min_value = time.localtime().tm_min self.sec_value = time.localtime().tm_sec draw_text( cr, "%02d : %02d : %02d" % (self.hour_value, self.min_value, self.sec_value), x + self.padding_x, y, w, h) propagate_expose(widget, event) return False