void QCairoPaintEngine::updateClip() { cairo_reset_clip(cr); //qDebug()<<cclipenabled<<cclippath<<cclipregion<<(!cclipregion.boundingRect().size().isEmpty() || cclippath.elementCount()>0); if (cclipenabled && (!cclipregion.boundingRect().size().isEmpty() || cclippath.elementCount()>0)) { cairo_matrix_t cm, cmBak; cairo_get_matrix(cr, &cmBak); cairo_matrix_init_identity(&cm); cairo_set_matrix(cr, &cm); bool fill=false; QPainterPath path=cclippath; path.addRegion(cclipregion); updatePath(path, fill); cairo_clip(cr); cairo_set_matrix(cr, &cmBak); } }
static void gtk_plot_cairo_clip (GtkPlotPC *pc, const GdkRectangle *area) { /* discard CairoRectangle* const: * cairo_gc_set_clip_rectangle should have a const arg. * I've checked the code and it doesn't change it or keep it. murrayc. */ cairo_t *cairo = GTK_PLOT_CAIRO(pc)->cairo; /* Shortcut */ if (!cairo) return; cairo_reset_clip(cairo); cairo_new_path(cairo); if (area) { cairo_move_to(cairo, area->x, area->y); cairo_line_to(cairo, area->x+area->width, area->y); cairo_line_to(cairo, area->x+area->width, area->y+area->height); cairo_line_to(cairo, area->x, area->y+area->height); cairo_close_path(cairo); cairo_clip(cairo); } }
static gboolean um_strength_bar_expose (GtkWidget *widget, GdkEventExpose *event) { UmStrengthBar *bar = UM_STRENGTH_BAR (widget); gdouble r, g, b; if (GTK_WIDGET_DRAWABLE (widget)) { cairo_t *cr; cr = gdk_cairo_create (widget->window); cairo_set_line_width (cr, 1); cairo_rectangle (cr, widget->allocation.x, widget->allocation.y, bar->priv->strength * widget->allocation.width, widget->allocation.height); cairo_clip (cr); curved_rectangle (cr, widget->allocation.x + 0.5, widget->allocation.y + 0.5, widget->allocation.width - 1, widget->allocation.height - 1, 4); get_color (bar->priv->strength, &r, &g ,&b); cairo_set_source_rgb (cr, r, g, b); cairo_fill_preserve (cr); cairo_reset_clip (cr); cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr); cairo_destroy (cr); } return FALSE; }
static cairo_test_status_t record_replay (cairo_t *cr, cairo_t *(*func)(cairo_t *), int width, int height) { cairo_surface_t *surface; int x, y; surface = record_get (func (record_create (cr))); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_surface (cr, surface, 0, 0); cairo_surface_destroy (surface); cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_NONE); for (y = 0; y < height; y += 2) { for (x = 0; x < width; x += 2) { cairo_rectangle (cr, x, y, 2, 2); cairo_clip (cr); cairo_paint (cr); cairo_reset_clip (cr); } } return CAIRO_TEST_SUCCESS; }
//----------------------------------------------------------------------------------- void ofxCairoTexture::viewport(float x, float y, float width, float height, bool invertY){ if(width == 0) width = ofGetWindowWidth(); if(height == 0) height = ofGetWindowHeight(); if (invertY){ y = ofGetWindowHeight() - (y + height); } viewportRect.set(x, y, width, height); cairo_reset_clip(cr); cairo_new_path(cr); cairo_move_to(cr,viewportRect.x,viewportRect.y); cairo_line_to(cr,viewportRect.x+viewportRect.width,viewportRect.y); cairo_line_to(cr,viewportRect.x+viewportRect.width,viewportRect.y+viewportRect.height); cairo_line_to(cr,viewportRect.x,viewportRect.y+viewportRect.height); /* cairo_clip(cr); */ };
void gt_graphics_cairo_draw_arrowhead(GtGraphics *gg, double x, double y, GtColor color, ArrowStatus arrow_status) { GtGraphicsCairo *g = gt_graphics_cairo_cast(gg); double arrow_height = 8, arrow_width = 5; gt_assert(g); /* save cairo context */ cairo_save(g->cr); cairo_reset_clip(g->cr); cairo_set_source_rgb(g->cr, color.red, color.green, color.blue); switch (arrow_status) { case ARROW_LEFT: cairo_move_to(g->cr, x+arrow_width, y); cairo_line_to(g->cr, x, y+(arrow_height/2)); cairo_line_to(g->cr, x+arrow_width, y+arrow_height); cairo_close_path(g->cr); /* fill area */ cairo_fill_preserve(g->cr); cairo_stroke(g->cr); break; case ARROW_RIGHT: cairo_move_to(g->cr, x, y); cairo_line_to(g->cr, x+arrow_width, y+(arrow_height/2)); cairo_line_to(g->cr, x, y+arrow_height); cairo_close_path(g->cr); /* fill area */ cairo_fill_preserve(g->cr); cairo_stroke(g->cr); break; case ARROW_BOTH: /* XXX */ case ARROW_NONE: break; } /* restore cairo context */ cairo_restore(g->cr); }
static void clearlooks_style_draw_box (DRAW_ARGS) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); const ClearlooksColors *colors; cairo_t *cr; cr = ge_gdk_drawable_to_cairo (window, area); colors = &clearlooks_style->colors; CHECK_ARGS SANITIZE_SIZE if (DETAIL ("menubar") && !ge_is_panel_widget_item(widget)) { WidgetParameters params; MenuBarParameters menubar; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); menubar.style = clearlooks_style->menubarstyle; STYLE_FUNCTION(draw_menubar) (cr, colors, ¶ms, &menubar, x, y, width, height); } else if (DETAIL ("button") && widget && widget->parent && (GE_IS_TREE_VIEW(widget->parent) || GE_IS_CLIST (widget->parent) || ge_object_is_a (G_OBJECT(widget->parent), "ETree"))) /* ECanvas inside ETree */ { WidgetParameters params; ListViewHeaderParameters header; gint columns, column_index; gboolean resizable = TRUE; /* XXX: This makes unknown treeview header CL_ORDER_MIDDLE, in need for something nicer */ columns = 3; column_index = 1; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; if (GE_IS_TREE_VIEW (widget->parent)) { clearlooks_treeview_get_header_index (GTK_TREE_VIEW(widget->parent), widget, &column_index, &columns, &resizable); } else if (GE_IS_CLIST (widget->parent)) { clearlooks_clist_get_header_index (GTK_CLIST(widget->parent), widget, &column_index, &columns); } header.resizable = resizable; if (column_index == 0) header.order = params.ltr ? CL_ORDER_FIRST : CL_ORDER_LAST; else if (column_index == columns-1) header.order = params.ltr ? CL_ORDER_LAST : CL_ORDER_FIRST; else header.order = CL_ORDER_MIDDLE; gtk_style_apply_default_background (style, window, FALSE, state_type, area, x, y, width, height); STYLE_FUNCTION(draw_list_view_header) (cr, colors, ¶ms, &header, x, y, width, height); } else if (DETAIL ("button") || DETAIL ("buttondefault")) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (ge_is_in_combo_box(widget)) { if (params.ltr) params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT; else params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT; if (params.xthickness > 2) { if (params.ltr) x--; width++; } } else { params.corners = CR_CORNER_ALL; /* if (!(ge_is_combo_box (widget, FALSE))) */ params.enable_glow = TRUE; } if (GE_IS_TOGGLE_BUTTON (widget) && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) params.active = TRUE; STYLE_FUNCTION(draw_button) (cr, &clearlooks_style->colors, ¶ms, x, y, width, height); } else if (DETAIL ("spinbutton_up") || DETAIL ("spinbutton_down")) { if (state_type == GTK_STATE_ACTIVE) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (style->xthickness == 3) { width++; if (params.ltr) x--; } if (DETAIL ("spinbutton_up")) { height+=2; if (params.ltr) params.corners = CR_CORNER_TOPRIGHT; else params.corners = CR_CORNER_TOPLEFT; } else { if (params.ltr) params.corners = CR_CORNER_BOTTOMRIGHT; else params.corners = CR_CORNER_BOTTOMLEFT; } STYLE_FUNCTION(draw_spinbutton_down) (cr, &clearlooks_style->colors, ¶ms, x, y, width, height); } } else if (DETAIL ("spinbutton")) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (params.ltr) params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT; else params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT; if (style->xthickness == 3) { if (params.ltr) x--; width++; } STYLE_FUNCTION(draw_spinbutton) (cr, &clearlooks_style->colors, ¶ms, x, y, width, height); } else if (detail && g_str_has_prefix (detail, "trough") && GE_IS_SCALE (widget)) { WidgetParameters params; SliderParameters slider; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; slider.lower = DETAIL ("trough-lower"); slider.fill_level = DETAIL ("trough-fill-level") || DETAIL ("trough-fill-level-full"); slider.horizontal = (GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL); STYLE_FUNCTION(draw_scale_trough) (cr, &clearlooks_style->colors, ¶ms, &slider, x, y, width, height); } else if (DETAIL ("trough") && widget && GE_IS_PROGRESS_BAR (widget)) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); STYLE_FUNCTION(draw_progressbar_trough) (cr, colors, ¶ms, x, y, width, height); } else if (DETAIL ("trough") && widget && (GE_IS_VSCROLLBAR (widget) || GE_IS_HSCROLLBAR (widget))) { WidgetParameters params; ScrollBarParameters scrollbar; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; scrollbar.horizontal = TRUE; scrollbar.junction = clearlooks_scrollbar_get_junction (widget); if (GE_IS_RANGE (widget)) scrollbar.horizontal = GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL; if (scrollbar.horizontal) { x += 2; width -= 4; } else { y += 2; height -= 4; } STYLE_FUNCTION(draw_scrollbar_trough) (cr, colors, ¶ms, &scrollbar, x, y, width, height); } else if (DETAIL ("bar")) { WidgetParameters params; ProgressBarParameters progressbar; gdouble elapsed = 0.0; #ifdef HAVE_ANIMATION if(clearlooks_style->animation && CL_IS_PROGRESS_BAR (widget)) { gboolean activity_mode = GTK_PROGRESS (widget)->activity_mode; if (!activity_mode) clearlooks_animation_progressbar_add ((gpointer)widget); } elapsed = clearlooks_animation_elapsed (widget); #endif clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (widget && GE_IS_PROGRESS_BAR (widget)) { progressbar.orientation = gtk_progress_bar_get_orientation (GTK_PROGRESS_BAR (widget)); progressbar.value = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widget)); progressbar.pulsing = GTK_PROGRESS (widget)->activity_mode; } else { progressbar.orientation = CL_ORIENTATION_LEFT_TO_RIGHT; progressbar.value = 0; progressbar.pulsing = FALSE; } if (!params.ltr) { if (progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_LEFT_TO_RIGHT) progressbar.orientation = GTK_PROGRESS_RIGHT_TO_LEFT; else if (progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_RIGHT_TO_LEFT) progressbar.orientation = GTK_PROGRESS_LEFT_TO_RIGHT; } /* Following is a hack to have a larger clip area, the one passed in * does not allow for the shadow. */ if (area) { GdkRectangle tmp = *area; if (!progressbar.pulsing) { switch (progressbar.orientation) { case GTK_PROGRESS_RIGHT_TO_LEFT: tmp.x -= 1; case GTK_PROGRESS_LEFT_TO_RIGHT: tmp.width += 1; break; case GTK_PROGRESS_BOTTOM_TO_TOP: tmp.y -= 1; case GTK_PROGRESS_TOP_TO_BOTTOM: tmp.height += 1; break; } } else { if (progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_RIGHT_TO_LEFT || progressbar.orientation == (ClearlooksOrientation)GTK_PROGRESS_LEFT_TO_RIGHT) { tmp.x -= 1; tmp.width += 2; } else { tmp.y -= 1; tmp.height += 2; } } cairo_reset_clip (cr); gdk_cairo_rectangle (cr, &tmp); cairo_clip (cr); } STYLE_FUNCTION(draw_progressbar_fill) (cr, colors, ¶ms, &progressbar, x, y, width, height, 10 - (int)(elapsed * 10.0) % 10); } else if (DETAIL ("optionmenu")) { WidgetParameters params; OptionMenuParameters optionmenu; GtkRequisition indicator_size; GtkBorder indicator_spacing; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.enable_glow = TRUE; ge_option_menu_get_props (widget, &indicator_size, &indicator_spacing); if (ge_widget_is_ltr (widget)) optionmenu.linepos = width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - 1; else optionmenu.linepos = (indicator_size.width + indicator_spacing.left + indicator_spacing.right) + 1; STYLE_FUNCTION(draw_optionmenu) (cr, colors, ¶ms, &optionmenu, x, y, width, height); } else if (DETAIL ("menuitem")) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (widget && GE_IS_MENU_BAR (widget->parent)) { params.corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT; height += 1; STYLE_FUNCTION(draw_menubaritem) (cr, colors, ¶ms, x, y, width, height); } else { params.corners = CR_CORNER_ALL; STYLE_FUNCTION(draw_menuitem) (cr, colors, ¶ms, x, y, width, height); } } else if (DETAIL ("hscrollbar") || DETAIL ("vscrollbar")) /* This can't be "stepper" for scrollbars ... */ { WidgetParameters params; ScrollBarParameters scrollbar; ScrollBarStepperParameters stepper; GdkRectangle this_rectangle; this_rectangle.x = x; this_rectangle.y = y; this_rectangle.width = width; this_rectangle.height = height; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_NONE; scrollbar.has_color = FALSE; scrollbar.horizontal = TRUE; scrollbar.junction = clearlooks_scrollbar_get_junction (widget); if (clearlooks_style->colorize_scrollbar || clearlooks_style->has_scrollbar_color) { scrollbar.has_color = TRUE; } scrollbar.horizontal = DETAIL ("hscrollbar"); stepper.stepper = clearlooks_scrollbar_get_stepper (widget, &this_rectangle); STYLE_FUNCTION(draw_scrollbar_stepper) (cr, colors, ¶ms, &scrollbar, &stepper, x, y, width, height); } else if (DETAIL ("toolbar") || DETAIL ("handlebox_bin") || DETAIL ("dockitem_bin")) { WidgetParameters params; ToolbarParameters toolbar; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); clearlooks_set_toolbar_parameters (&toolbar, widget, window, x, y); toolbar.style = clearlooks_style->toolbarstyle; /* Only draw the shadows on horizontal toolbars */ if (shadow_type != GTK_SHADOW_NONE && height < 2*width ) STYLE_FUNCTION(draw_toolbar) (cr, colors, ¶ms, &toolbar, x, y, width, height); } else if (DETAIL ("trough")) { } else if (DETAIL ("menu")) { WidgetParameters params; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); STYLE_FUNCTION(draw_menu_frame) (cr, colors, ¶ms, x, y, width, height); } else if (DETAIL ("hseparator") || DETAIL ("vseparator")) { const gchar *new_detail = detail; /* Draw a normal separator, we just use this because it gives more control * over sizing (currently). */ /* This isn't nice ... but it seems like the best cleanest way to me right now. * It will get slightly nicer in the future hopefully. */ if (GE_IS_MENU_ITEM (widget)) new_detail = "menuitem"; if (DETAIL ("hseparator")) { gtk_paint_hline (style, window, state_type, area, widget, new_detail, x, x + width - 1, y + height/2); } else gtk_paint_vline (style, window, state_type, area, widget, new_detail, y, y + height - 1, x + width/2); } else { clearlooks_parent_class->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } cairo_destroy (cr); }
void Frame::unset_frame_clipping( cairo_t *cairo ) { cairo_reset_clip( cairo ); }
static PyObject * pycairo_reset_clip (PycairoContext *o) { cairo_reset_clip (o->ctx); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); Py_RETURN_NONE; }
void Context::resetClip() { cairo_reset_clip( mCairo ); }
static void _paint_lyrics (OlScrollWindow *scroll, cairo_t *cr) { ol_assert (OL_IS_SCROLL_WINDOW (scroll)); GtkWidget *widget = GTK_WIDGET (scroll); ol_assert (GTK_WIDGET_REALIZED (widget)); OlScrollWindowPrivate *priv = OL_SCROLL_WINDOW_GET_PRIVATE (scroll); int line_height = ol_scroll_window_get_font_height (scroll) + priv->line_margin; int count = ol_scroll_window_compute_line_count (scroll); gint width, height; gdk_drawable_get_size (gtk_widget_get_window (GTK_WIDGET (scroll)), &width, &height); /* set the font */ PangoLayout *layout = _get_pango (scroll, cr); /* paint the lyrics*/ cairo_save (cr); cairo_new_path (cr); cairo_rectangle (cr, priv->padding_x, 0, width - priv->padding_x * 2, height - priv->padding_y * 2); cairo_close_path (cr); cairo_clip (cr); int i; gint current_lyric_id; gint lrc_y; _calc_paint_pos (scroll, ¤t_lyric_id, &lrc_y); int begin = current_lyric_id - count / 2; int end = current_lyric_id + count / 2 + 1; int ypos = height / 2 - lrc_y - (count / 2 + 1) * line_height; cairo_set_source_rgb(cr, priv->inactive_color.r, priv->inactive_color.g, priv->inactive_color.b); if (scroll->whole_lyrics != NULL) { for (i = begin; i < end; i++) { ypos += line_height; if (i < 0) continue; if (i >= scroll->whole_lyrics->len) break; pango_layout_set_text (layout, g_ptr_array_index (scroll->whole_lyrics, i), -1); cairo_save (cr); double ratio = _get_active_color_ratio (scroll, i); double alpha = 1.0; if (ypos < line_height / 2.0 + priv->padding_y) alpha = 1.0 - (line_height / 2.0 + priv->padding_y - ypos) * 1.0 / line_height * 2; else if (ypos > height - line_height * 1.5 - priv->padding_y) alpha = (height - line_height - priv->padding_y - ypos) * 1.0 / line_height * 2; if (alpha < 0.0) alpha = 0.0; cairo_set_source_rgba (cr, priv->active_color.r * ratio + priv->inactive_color.r * (1 - ratio), priv->active_color.g * ratio + priv->inactive_color.g * (1 - ratio), priv->active_color.b * ratio + priv->inactive_color.b * (1 - ratio), alpha); cairo_move_to (cr, priv->padding_x, ypos); pango_cairo_update_layout (cr, layout); pango_cairo_show_layout (cr, layout); cairo_restore (cr); } } g_object_unref (layout); cairo_reset_clip (cr); cairo_restore (cr); }
static int cr_reset_clip (lua_State *L) { cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT); cairo_reset_clip(*obj); return 0; }
static void terranova_draw_candy_slider (cairo_t *cr, const terranovaColors *colors, const WidgetParameters *params, int x, int y, int width, int height) { CairoColor border = colors->shade[params->disabled ? 4 : 6]; const CairoColor *fill = &colors->bg[params->state_type]; double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0)); cairo_pattern_t *pattern; cairo_set_line_width (cr, 1.0); cairo_translate (cr, x, y); if (params->prelight) border = colors->spot[2]; /* fill the widget */ tn_cairo_rounded_rectangle (cr, 1.0, 1.0, width-2, height-2, radius, params->corners); /* Fake light */ if (!params->disabled) { const CairoColor *top = &colors->shade[0]; const CairoColor *bot = &colors->shade[2]; pattern = cairo_pattern_create_linear (0, 0, 0, height); cairo_pattern_add_color_stop_rgb (pattern, 0.0, top->r, top->g, top->b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, top->r, top->g, top->b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, bot->r, bot->g, bot->b); cairo_pattern_add_color_stop_rgb (pattern, 1.0, bot->r, bot->g, bot->b); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); } else { tn_cairo_set_color (cr, fill); cairo_rectangle (cr, 0.5, 0.5, width-2, height-2); cairo_fill (cr); } /* Set the clip */ cairo_save (cr); cairo_rectangle (cr, 1.0, 1.0, 6, height-2); cairo_rectangle (cr, width-7.0, 0.5, 6, height-2); cairo_clip (cr); cairo_new_path (cr); /* Draw the handles */ tn_cairo_rounded_rectangle (cr, 1.0, 1.0, width-1, height-1, radius, params->corners); pattern = cairo_pattern_create_linear (0, 0, 0, height); if (params->slider_style == 1) { if (params->prelight || params->active) { CairoColor highlight, low; tn_shade_color (fill, 1.10, &highlight); tn_shade_color (fill, 0.90, &low); cairo_pattern_add_color_stop_rgb (pattern, 0.0, highlight.r, highlight.g, highlight.b); cairo_pattern_add_color_stop_rgb (pattern, 0.50, highlight.r, highlight.g, highlight.b); cairo_pattern_add_color_stop_rgb (pattern, 0.50, low.r, low.g, low.b); cairo_pattern_add_color_stop_rgb (pattern, 1.0, low.r, low.g, low.b); cairo_set_source (cr, pattern); } } cairo_fill (cr); cairo_pattern_destroy (pattern); cairo_reset_clip (cr); /* Draw the border */ tn_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners); if (params->prelight || params->disabled) tn_cairo_set_color (cr, &border); else terranova_draw_border_gradient (cr, &border, 1.2, 0, height); cairo_stroke (cr); /* Draw handle lines */ if (width > 14) { cairo_move_to (cr, x+6, 0.5); cairo_line_to (cr, x+6, height-0.5); cairo_move_to (cr, x+width-7, 0.5); cairo_line_to (cr, x+width-7, height-0.5); cairo_set_line_width (cr, 1.0); cairo_set_source_rgba (cr, border.r, border.g, border.b, 0.3); cairo_stroke (cr); } }
static void BM_NewPage(const pGEcontext gc, pDevDesc dd) { pX11Desc xd = (pX11Desc) dd->deviceSpecific; char buf[PATH_MAX]; cairo_status_t res; xd->npages++; if (xd->type == PNG || xd->type == JPEG || xd->type == BMP) { if (xd->npages > 1) { /* try to preserve the page we do have */ BM_Close_bitmap(xd); if (xd->fp) fclose(xd->fp); } snprintf(buf, PATH_MAX, xd->filename, xd->npages); xd->fp = R_fopen(R_ExpandFileName(buf), "wb"); if (!xd->fp) error(_("could not open file '%s'"), buf); } else if(xd->type == PNGdirect || xd->type == TIFF) { if (xd->npages > 1) { xd->npages--; BM_Close_bitmap(xd); xd->npages++; } } #ifdef HAVE_CAIRO_SVG else if(xd->type == SVG) { if (xd->npages > 1 && xd->cs) { cairo_show_page(xd->cc); if(!xd->onefile) { cairo_surface_destroy(xd->cs); cairo_destroy(xd->cc); } } if(xd->npages == 1 || !xd->onefile) { snprintf(buf, PATH_MAX, xd->filename, xd->npages); xd->cs = cairo_svg_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { xd->cs = NULL; error("cairo error '%s'", cairo_status_to_string(res)); } if(xd->onefile) cairo_svg_surface_restrict_to_version(xd->cs, CAIRO_SVG_VERSION_1_2); xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } cairo_set_antialias(xd->cc, xd->antialias); } } #endif #ifdef HAVE_CAIRO_PDF else if(xd->type == PDF) { if (xd->npages > 1) { cairo_show_page(xd->cc); if(!xd->onefile) { cairo_surface_destroy(xd->cs); cairo_destroy(xd->cc); } } if(xd->npages == 1 || !xd->onefile) { snprintf(buf, PATH_MAX, xd->filename, xd->npages); xd->cs = cairo_pdf_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } cairo_set_antialias(xd->cc, xd->antialias); } } #endif #ifdef HAVE_CAIRO_PS else if(xd->type == PS) { if (xd->npages > 1 && !xd->onefile) { cairo_show_page(xd->cc); cairo_surface_destroy(xd->cs); cairo_destroy(xd->cc); } if(xd->npages == 1 || !xd->onefile) { snprintf(buf, PATH_MAX, xd->filename, xd->npages); xd->cs = cairo_ps_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } // We already require >= 1.2 #if CAIRO_VERSION_MAJOR > 2 || CAIRO_VERSION_MINOR >= 6 if(!xd->onefile) cairo_ps_surface_set_eps(xd->cs, TRUE); #endif xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { error("cairo error '%s'", cairo_status_to_string(res)); } cairo_set_antialias(xd->cc, xd->antialias); } } #endif else error(_("unimplemented cairo-based device")); cairo_reset_clip(xd->cc); if (xd->type == PNG || xd->type == TIFF|| xd->type == PNGdirect) { /* First clear it */ cairo_set_operator (xd->cc, CAIRO_OPERATOR_CLEAR); cairo_paint (xd->cc); cairo_set_operator (xd->cc, CAIRO_OPERATOR_OVER); xd->fill = gc->fill; } else xd->fill = R_OPAQUE(gc->fill) ? gc->fill: xd->canvas; CairoColor(xd->fill, xd); cairo_new_path(xd->cc); cairo_paint(xd->cc); }
void draw_column_data (DdbListview *listview, cairo_t *cr, DdbListviewIter it, DdbListviewIter group_it, int column, int group_y, int group_height, int group_pinned, int grp_next_y, int x, int y, int width, int height) { const char *ctitle; int cwidth; int calign_right; col_info_t *cinf; int minheight; int res = ddb_listview_column_get_info (listview, column, &ctitle, &cwidth, &calign_right, &minheight, (void **)&cinf); if (res == -1) { return; } DB_playItem_t *playing_track = deadbeef->streamer_get_playing_track (); int theming = !gtkui_override_listview_colors (); if (cinf->id == DB_COLUMN_ALBUM_ART) { if (theming) { #if GTK_CHECK_VERSION(3,0,0) cairo_rectangle (cr, x, y, width, height); cairo_clip (cr); gtk_paint_flat_box (gtk_widget_get_style (theme_treeview), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, theme_treeview, "cell_even_ruled", x-1, y, width+2, height); cairo_reset_clip (cr); #else GdkRectangle clip = { .x = x, .y = y, .width = width, .height = height, }; gtk_paint_flat_box (gtk_widget_get_style (theme_treeview), gtk_widget_get_window (listview->list), GTK_STATE_NORMAL, GTK_SHADOW_NONE, &clip, theme_treeview, "cell_even_ruled", x-1, y, width+2, height); #endif } else { GdkColor clr; gtkui_get_listview_even_row_color (&clr); cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); } int real_art_width = width - ART_PADDING_HORZ * 2; if (real_art_width > 0 && group_it) { const char *album = deadbeef->pl_find_meta (group_it, "album"); const char *artist = deadbeef->pl_find_meta (group_it, "artist"); if (!album || !*album) { album = deadbeef->pl_find_meta (group_it, "title"); } if (listview->new_cover_size != real_art_width) { listview->new_cover_size = real_art_width; if (listview->cover_refresh_timeout_id) { g_source_remove (listview->cover_refresh_timeout_id); listview->cover_refresh_timeout_id = 0; } if (listview->cover_size == -1) { listview->cover_size = real_art_width; } else { if (!listview->cover_refresh_timeout_id) { listview->cover_refresh_timeout_id = g_timeout_add (1000, deferred_cover_load_cb, listview); } } } int art_width = listview->cover_size; int art_y = y; // dest y int art_h = height; int sy; // source y if (group_y < ART_PADDING_VERT) { art_y = y - group_y + ART_PADDING_VERT; art_h = height - (art_y - y); sy = group_y; } else { sy = group_y - ART_PADDING_VERT; } int h = cwidth - group_y; h = min (height, art_h); int hq = 0; GdkPixbuf *pixbuf = get_cover_art_callb (deadbeef->pl_find_meta (((DB_playItem_t *)group_it), ":URI"), artist, album, real_art_width == art_width ? art_width : -1, redraw_playlist_single, listview); if (!pixbuf) { pixbuf = cover_get_default_pixbuf (); } if (pixbuf) { art_width = gdk_pixbuf_get_width (pixbuf); float art_scale = (float)real_art_width / art_width; int pw = real_art_width; int ph; if (gdk_pixbuf_get_width (pixbuf) < gdk_pixbuf_get_height (pixbuf)) { art_scale *= (float)gdk_pixbuf_get_width (pixbuf) / gdk_pixbuf_get_height (pixbuf); } if (group_pinned == 1 && gtkui_groups_pinned) { ph = group_height; } else { ph = pw; } if (sy < ph) { cairo_save (cr); if (group_pinned == 1 && gtkui_groups_pinned) { int ph_real = gdk_pixbuf_get_height (pixbuf); if (grp_next_y <= ph_real * art_scale + listview->grouptitle_height) { cairo_rectangle (cr, x + ART_PADDING_HORZ, grp_next_y - ph_real * art_scale, pw, ph); cairo_translate (cr, (x + ART_PADDING_HORZ)-0, grp_next_y - ph_real * art_scale); } else { cairo_rectangle (cr, x + ART_PADDING_HORZ, listview->grouptitle_height, pw, ph); cairo_translate (cr, (x + ART_PADDING_HORZ)-0, listview->grouptitle_height); } } else { ph -= sy; ph = min (ph, h); cairo_rectangle (cr, x + ART_PADDING_HORZ, art_y, pw, ph); cairo_translate (cr, (x + ART_PADDING_HORZ)-0, art_y - sy); } cairo_scale (cr, art_scale, art_scale); gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); cairo_pattern_set_filter (cairo_get_source(cr), gtkui_is_default_pixbuf (pixbuf) ? CAIRO_FILTER_GAUSSIAN : CAIRO_FILTER_FAST); cairo_fill (cr); cairo_restore (cr); } g_object_unref (pixbuf); } } }
void GR_UnixCairoGraphics::_resetClip(void) { cairo_reset_clip (m_cr); xxx_UT_DEBUGMSG(("Reset clip in gtk cairo \n")); }
void engine_draw_frame (decor_t * d, cairo_t * cr) { double x1, y1, x2, y2, h; int top; frame_settings * fs = d->fs; private_fs * pfs = fs->engine_fs; window_settings * ws = fs->ws; private_ws * pws = ws->engine_ws; gdouble pleft; gdouble ptop; gdouble pwidth; gdouble pheight; top = ws->win_extents.top + ws->titlebar_height; x1 = ws->left_space - ws->win_extents.left; y1 = ws->top_space - ws->win_extents.top; x2 = d->width - ws->right_space + ws->win_extents.right; y2 = d->height - ws->bottom_space + ws->win_extents.bottom; pleft = x1 + ws->win_extents.left - 0.5; ptop = y1 + top - 0.5; pwidth = x2 - x1 - ws->win_extents.left - ws->win_extents.right + 1; pheight = y2 - y1 - top-ws->win_extents.bottom + 1; h = d->height - ws->top_space - ws->titlebar_height - ws->bottom_space; int corners = ((pws->round_top_left) ? CORNER_TOPLEFT : 0) | ((pws->round_top_right) ? CORNER_TOPRIGHT : 0) | ((pws->round_bottom_left) ? CORNER_BOTTOMLEFT : 0) | ((pws->round_bottom_right) ? CORNER_BOTTOMRIGHT : 0); /* maximize work-a-round */ if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) corners = 0; cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_line_width (cr, 1.0); fill_rounded_rectangle (cr, x1 + 0.5, y1 + 0.5, ws->win_extents.left - 0.5, top - 0.5, CORNER_TOPLEFT & corners, &pfs->title_inner, &pfs->title_outer, SHADE_TOP | SHADE_LEFT, ws, pws->corner_radius); fill_rounded_rectangle (cr, x1 + ws->win_extents.left, y1 + 0.5, x2 - x1 - ws->win_extents.left - ws->win_extents.right, top - 0.5, 0, &pfs->title_inner, &pfs->title_outer, SHADE_TOP, ws, pws->corner_radius); fill_rounded_rectangle (cr, x2 - ws->win_extents.right, y1 + 0.5, ws->win_extents.right - 0.5, top - 0.5, CORNER_TOPRIGHT & corners, &pfs->title_inner, &pfs->title_outer, SHADE_TOP | SHADE_RIGHT, ws, pws->corner_radius); fill_rounded_rectangle (cr, x1 + 0.5, y1 + top, ws->win_extents.left - 0.5, h, 0, &pfs->inner, &pfs->outer, SHADE_LEFT, ws, pws->corner_radius); fill_rounded_rectangle (cr, x2 - ws->win_extents.right, y1 + top, ws->win_extents.right - 0.5, h, 0, &pfs->inner, &pfs->outer, SHADE_RIGHT, ws, pws->corner_radius); fill_rounded_rectangle (cr, x1 + 0.5, y2 - ws->win_extents.bottom, ws->win_extents.left - 0.5, ws->win_extents.bottom - 0.5, CORNER_BOTTOMLEFT & corners, &pfs->inner, &pfs->outer, SHADE_BOTTOM | SHADE_LEFT, ws, pws->corner_radius); fill_rounded_rectangle (cr, x1 + ws->win_extents.left, y2 - ws->win_extents.bottom, x2 - x1 - ws->win_extents.left - ws->win_extents.right, ws->win_extents.bottom - 0.5, 0, &pfs->inner, &pfs->outer, SHADE_BOTTOM, ws, pws->corner_radius); fill_rounded_rectangle (cr, x2 - ws->win_extents.right, y2 - ws->win_extents.bottom, ws->win_extents.right - 0.5, ws->win_extents.bottom - 0.5, CORNER_BOTTOMRIGHT & corners, &pfs->inner, &pfs->outer, SHADE_BOTTOM | SHADE_RIGHT, ws, pws->corner_radius); /* ======= NEW LAYER ======= */ cairo_set_operator (cr, CAIRO_OPERATOR_OVER); /* titlebar separator line */ cairo_set_source_alpha_color(cr, &pfs->separator_line); cairo_move_to (cr, x1 + 0.5, y1 + top - 0.5); cairo_rel_line_to (cr, x2 - x1 - 1.0, 0.0); cairo_stroke (cr); /* do not draw outside the decoration area */ rounded_rectangle (cr, x1 + 0.5, y1 + 0.5, x2 - x1 - 1.0, y2 - y1 - 1.0, (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT) & corners, ws, pws->corner_radius); cairo_clip (cr); cairo_translate (cr, 1.0, 1.0); /* highlight */ rounded_rectangle (cr, x1 + 0.5, y1 + 0.5, x2 - x1 - 1.0, y2 - y1 - 1.0, (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT) & corners, ws, pws->corner_radius); cairo_set_source_alpha_color (cr, &pfs->window_highlight); cairo_stroke (cr); cairo_translate (cr, -2.0, -2.0); /* shadow */ rounded_rectangle (cr, x1 + 0.5, y1 + 0.5, x2 - x1 - 1.0, y2 - y1 - 1.0, (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT) & corners, ws, pws->corner_radius); cairo_set_source_alpha_color (cr, &pfs->window_shadow); cairo_stroke (cr); cairo_translate (cr, 1.0, 1.0); cairo_reset_clip (cr); /* halo */ rounded_rectangle (cr, x1 + 0.5, y1 + 0.5, x2 - x1 - 1.0, y2 - y1 - 1.0, (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | CORNER_BOTTOMRIGHT) & corners, ws, pws->corner_radius); cairo_set_source_alpha_color (cr, &pfs->window_halo); cairo_stroke (cr); /* inner border TODO: make this a bit more pixel-perfect... but it works for now */ cairo_set_line_width (cr, 1.0); cairo_move_to (cr, pleft + pwidth + 1.5, ptop - 1); cairo_rel_line_to (cr, -pwidth - 2.5, 0); cairo_rel_line_to (cr, 0, pheight + 2.5); cairo_set_source_alpha_color (cr, &pfs->contents_shadow); cairo_stroke (cr); cairo_move_to (cr, pleft + pwidth + 1, ptop - 1.5); cairo_rel_line_to (cr, 0, pheight + 2.5); cairo_rel_line_to (cr, -pwidth - 2.5, 0); cairo_set_source_alpha_color (cr, &pfs->contents_highlight); cairo_stroke (cr); cairo_move_to (cr, pleft, ptop); cairo_rel_line_to (cr, pwidth, 0); cairo_rel_line_to (cr, 0, pheight); cairo_rel_line_to (cr, -pwidth, 0); cairo_rel_line_to (cr, 0, -pheight); cairo_set_source_alpha_color (cr, &pfs->contents_halo); cairo_stroke(cr); }
static Rboolean BM_Open(pDevDesc dd, pX11Desc xd, int width, int height) { char buf[PATH_MAX]; cairo_status_t res; if (xd->type == PNG || xd->type == JPEG || xd->type == TIFF || xd->type == BMP || xd->type == PNGdirect) { xd->cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, xd->windowWidth, xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_set_operator(xd->cc, CAIRO_OPERATOR_OVER); cairo_reset_clip(xd->cc); cairo_set_antialias(xd->cc, xd->antialias); } #ifdef HAVE_CAIRO_SVG else if(xd->type == SVG) { snprintf(buf, PATH_MAX, xd->filename, xd->npages + 1); xd->cs = cairo_svg_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { xd->cs = NULL; warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } if(xd->onefile) cairo_svg_surface_restrict_to_version(xd->cs, CAIRO_SVG_VERSION_1_2); xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_set_antialias(xd->cc, xd->antialias); } #endif #ifdef HAVE_CAIRO_PDF else if(xd->type == PDF) { snprintf(buf, PATH_MAX, xd->filename, xd->npages + 1); xd->cs = cairo_pdf_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_surface_set_fallback_resolution(xd->cs, xd->fallback_dpi, xd->fallback_dpi); xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_set_antialias(xd->cc, xd->antialias); } #endif #ifdef HAVE_CAIRO_PS else if(xd->type == PS) { snprintf(buf, PATH_MAX, xd->filename, xd->npages + 1); xd->cs = cairo_ps_surface_create(R_ExpandFileName(buf), (double)xd->windowWidth, (double)xd->windowHeight); res = cairo_surface_status(xd->cs); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } // We already require >= 1.2 #if CAIRO_VERSION_MAJOR > 2 || CAIRO_VERSION_MINOR >= 6 if(!xd->onefile) cairo_ps_surface_set_eps(xd->cs, TRUE); #endif cairo_surface_set_fallback_resolution(xd->cs, xd->fallback_dpi, xd->fallback_dpi); xd->cc = cairo_create(xd->cs); res = cairo_status(xd->cc); if (res != CAIRO_STATUS_SUCCESS) { warning("cairo error '%s'", cairo_status_to_string(res)); return FALSE; } cairo_set_antialias(xd->cc, xd->antialias); } #endif else error(_("unimplemented cairo-based device")); return TRUE; }
static void test_clip (cairo_t *cr, double width, double height) { cairo_t *cr2; /* Basic test; set a square clip and draw a circle to be clipped * against it.*/ cairo_rectangle (cr, 100, 100, 400, 400); cairo_clip (cr); cairo_arc (cr, 300, 300, 210, 0, 2 * M_PI); cairo_set_source_rgb (cr, 1, 0, 0); cairo_fill (cr); /* Add a plus shaped clip path to the square clip and draw a big * green square to test the new clip path. */ cairo_save (cr); cairo_rectangle (cr, 250, 100, 100, 400); cairo_rectangle (cr, 100, 250, 400, 100); cairo_clip (cr); cairo_rectangle (cr, 0, 0, 600, 600); cairo_set_source_rgb (cr, 0, 1, 0); cairo_fill (cr); cairo_restore (cr); /* Set a bezier shape in addition to the rectangle clip set before * the cairo_save() to verify that we successfully removed the * plus shaped clip path and can set a new clip.*/ cairo_move_to (cr, 600, 0); cairo_curve_to (cr, 300, 600, 0, 300, 600, 0); cairo_clip (cr); cairo_rectangle (cr, 0, 0, 600, 600); cairo_set_source_rgb (cr, 0, 0, 1); cairo_fill (cr); /* Create a new context for this surface to test overlapped * drawing from two contexts */ cr2 = cairo_create (cairo_get_group_target (cr)); /* Using the new context, draw a black vertical line, which should * appear unclipped on top of everything drawn so far. */ cairo_move_to (cr2, 110, 0); cairo_line_to (cr2, 110, 600); cairo_stroke (cr2); /* Using the first context, draw another black vertical line. * This line should be clipped agaist the bezier clipping path set * earlier. */ cairo_set_source_rgb (cr, 0, 0, 0); cairo_move_to (cr, 400, 0); cairo_line_to (cr, 400, 600); cairo_stroke (cr); cairo_destroy (cr2); /* Test reset clip. Draw a transparent black circle over * everything. Specifically, make sure the circle extends outside * the square clip set at the top of this function. */ cairo_reset_clip (cr); cairo_arc (cr, 300, 300, 220, 0, 2 * M_PI); cairo_set_source_rgba (cr, 0, 0, 0, 0.2); cairo_fill (cr); }
void draw_column_data (DdbListview *listview, cairo_t *cr, DdbListviewIter it, DdbListviewIter group_it, int column, int group_y, int x, int y, int width, int height) { const char *ctitle; int cwidth; int calign_right; col_info_t *cinf; int minheight; int res = ddb_listview_column_get_info (listview, column, &ctitle, &cwidth, &calign_right, &minheight, (void **)&cinf); if (res == -1) { return; } DB_playItem_t *playing_track = deadbeef->streamer_get_playing_track (); int theming = !gtkui_override_listview_colors (); if (cinf->id == DB_COLUMN_ALBUM_ART) { if (theming) { #if GTK_CHECK_VERSION(3,0,0) cairo_rectangle (cr, x, y, width, height); cairo_clip (cr); gtk_paint_flat_box (gtk_widget_get_style (theme_treeview), cr, GTK_STATE_NORMAL, GTK_SHADOW_NONE, theme_treeview, "cell_even_ruled", x-1, y, width+2, height); cairo_reset_clip (cr); #else GdkRectangle clip = { .x = x, .y = y, .width = width, .height = height, }; gtk_paint_flat_box (gtk_widget_get_style (theme_treeview), gtk_widget_get_window (listview->list), GTK_STATE_NORMAL, GTK_SHADOW_NONE, &clip, theme_treeview, "cell_even_ruled", x-1, y, width+2, height); #endif } else { GdkColor clr; gtkui_get_listview_even_row_color (&clr); cairo_set_source_rgb (cr, clr.red/65535.f, clr.green/65535.f, clr.blue/65535.f); cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); } int art_width = width - ART_PADDING_HORZ * 2; int art_y = y; // dest y int art_h = height; int sy; // source y if (group_y < ART_PADDING_VERT) { art_y = y - group_y + ART_PADDING_VERT; art_h = height - (art_y - y); sy = group_y; } else { sy = group_y - ART_PADDING_VERT; } if (art_width > 0) { if (group_it) { int h = cwidth - group_y; h = min (height, art_h); const char *album = deadbeef->pl_find_meta (group_it, "album"); const char *artist = deadbeef->pl_find_meta (group_it, "artist"); if (!album || !*album) { album = deadbeef->pl_find_meta (group_it, "title"); } GdkPixbuf *pixbuf = get_cover_art (deadbeef->pl_find_meta (((DB_playItem_t *)group_it), ":URI"), artist, album, art_width); if (pixbuf) { int pw = gdk_pixbuf_get_width (pixbuf); int ph = gdk_pixbuf_get_height (pixbuf); if (sy < ph) { pw = min (art_width, pw); ph -= sy; ph = min (ph, h); gdk_cairo_set_source_pixbuf (cr, pixbuf, (x + ART_PADDING_HORZ)-0, (art_y)-sy); cairo_rectangle (cr, x + ART_PADDING_HORZ, art_y, pw, ph); cairo_fill (cr); } g_object_unref (pixbuf); } } } }
static void terranova_draw_candy_scrollbar_slider (cairo_t *cr, const terranovaColors *colors, const WidgetParameters *params, const ScrollBarParameters *scrollbar, int x, int y, int width, int height) { CairoColor fill = colors->bg[GTK_STATE_SELECTED]; CairoColor hilight; double tile_pos = 0; double stroke_width; int x_step; int offset; double arrow_width; CairoColor shading; if (scrollbar->horizontal) { cairo_translate (cr, x, y); } else { int tmp = height; terranova_mirror_rotate (cr, G_PI/2, x, y, FALSE, FALSE); height = width; width = tmp; } if (params->prelight) tn_shade_color (&fill, 1.1, &fill); cairo_set_line_width (cr, 1); tn_shade_color (&fill, 1.45, &hilight); cairo_pattern_t *pattern; CairoColor shade1, shade2; tn_shade_color (&fill, 0.96, &shade1); tn_shade_color (&fill, 1.10, &shade2); pattern = cairo_pattern_create_linear (0, 1, 0, height); cairo_pattern_add_color_stop_rgb (pattern, 0.00, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.35, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.65, shade2.r, shade2.g, shade2.b); cairo_pattern_add_color_stop_rgb (pattern, 1.00, shade2.r, shade2.g, shade2.b); /* exchange rectangles when uncommenting slider-border code cairo_rectangle (cr, 3, 2, width-6, height-4); */ cairo_rectangle (cr, 0, 0, width, height); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); /* slider-border CairoColor *border = (CairoColor*)&colors->shade[6]; cairo_rectangle (cr, 2.5, 1.5, width-5, height-3); cairo_set_source_rgb (cr, hilight.r, hilight.g, hilight.b); cairo_stroke (cr); tn_cairo_rounded_rectangle (cr, 1.5, 0.5, width-3, height-1, 2, params->corners); cairo_set_source_rgb (cr, border->r, border->g, border->b); cairo_stroke (cr); */ if (scrollbar->style == 1) { stroke_width = 25; offset = 1; x_step = (((float)stroke_width/10)*offset); arrow_width = stroke_width/2; while (tile_pos <= width+x_step) { cairo_move_to (cr, stroke_width/2-x_step, 0); cairo_line_to (cr, stroke_width-x_step, height/2); cairo_line_to (cr, stroke_width/2-x_step, height); cairo_line_to (cr, stroke_width/2-x_step-arrow_width, height); cairo_line_to (cr, stroke_width-x_step-arrow_width, height/2); cairo_line_to (cr, stroke_width/2-x_step-arrow_width, 0); cairo_translate (cr, stroke_width, 0); tile_pos += stroke_width; } cairo_set_source_rgba (cr, colors->spot[2].r, colors->spot[2].g, colors->spot[2].b, 0.15); cairo_fill (cr); cairo_restore (cr); cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 0.5); cairo_rectangle (cr, 0.5, 0.5, width-2, height-1); cairo_stroke (cr); cairo_reset_clip (cr); } else if (scrollbar->style == 0) { double stroke_width = 25; x_step = (((float)stroke_width/10)*2); /* Draw strokes */ while (tile_pos <= width+x_step) { cairo_move_to (cr, stroke_width/2-x_step, 0); cairo_line_to (cr, stroke_width-x_step, 0); cairo_line_to (cr, stroke_width/2-x_step-2, height); cairo_line_to (cr, -x_step, height); cairo_translate (cr, stroke_width, 0); tile_pos += stroke_width; } cairo_set_source_rgba (cr, colors->spot[2].r, colors->spot[2].g, colors->spot[2].b, 0.15); cairo_fill (cr); cairo_restore (cr); tn_shade_color (&colors->bg[GTK_STATE_SELECTED], 1.00, &shading); cairo_set_source_rgba (cr, shading.r, shading.g, shading.b, 0.5); cairo_rectangle (cr, 0.5, 0.5, width-2, height-1); cairo_stroke (cr); cairo_reset_clip (cr); } }
static void run (const gchar *name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals) { static GimpParam values[1]; GimpPDBStatusType status = GIMP_PDB_SUCCESS; GimpRunMode run_mode; /* Plug-in variables */ gboolean single_image; gboolean defaults_proc; /* Plug-In variables */ cairo_surface_t *pdf_file; cairo_t *cr; GimpExportCapabilities capabilities; guint32 i = 0; gint32 j = 0; gdouble x_res, y_res; gdouble x_scale, y_scale; gint32 image_id; gboolean exported; GimpImageBaseType type; gint32 temp; gint *layers; gint32 num_of_layers; GimpDrawable *layer; cairo_surface_t *layer_image; gdouble opacity; gint x, y; GimpRGB layer_color; gboolean single_color; gint32 mask_id = -1; GimpDrawable *mask = NULL; cairo_surface_t *mask_image = NULL; FILE *fp; INIT_I18N (); /* Setting mandatory output values */ *nreturn_vals = 1; *return_vals = values; values[0].type = GIMP_PDB_STATUS; values[0].data.d_status = status; /* Initializing all the settings */ multi_page.image_count = 0; if (! init_vals (name, nparams, param, &single_image, &defaults_proc, &run_mode)) { values[0].data.d_status = GIMP_PDB_CALLING_ERROR; return; } /* Starting the executions */ if (run_mode == GIMP_RUN_INTERACTIVE) { if (single_image) { if (! gui_single ()) { values[0].data.d_status = GIMP_PDB_CANCEL; return; } } else if (! gui_multi ()) { values[0].data.d_status = GIMP_PDB_CANCEL; return; } if (file_name == NULL) { values[0].data.d_status = GIMP_PDB_CALLING_ERROR; gimp_message (_("You must select a file to save!")); return; } } fp = g_fopen (file_name, "wb"); pdf_file = cairo_pdf_surface_create_for_stream (write_func, fp, 1, 1); if (cairo_surface_status (pdf_file) != CAIRO_STATUS_SUCCESS) { char *str = g_strdup_printf (_("An error occured while creating the PDF file:\n" "%s\n" "Make sure you entered a valid filename and that the selected location isn't read only!"), cairo_status_to_string (cairo_surface_status (pdf_file))); gimp_message (str); g_free (str); values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; return; } cr = cairo_create (pdf_file); capabilities = GIMP_EXPORT_CAN_HANDLE_RGB | GIMP_EXPORT_CAN_HANDLE_ALPHA | GIMP_EXPORT_CAN_HANDLE_GRAY | GIMP_EXPORT_CAN_HANDLE_LAYERS | GIMP_EXPORT_CAN_HANDLE_INDEXED; if (optimize.apply_masks) capabilities |= GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS; for (i = 0; i < multi_page.image_count; i++) { /* Save the state of the surface before any changes, so that settings * from one page won't affect all the others */ cairo_save (cr); image_id = multi_page.images[i]; /* We need the active layer in order to use gimp_image_export */ temp = gimp_image_get_active_drawable (image_id); if (temp == -1) exported = gimp_export_image (&image_id, &temp, NULL, capabilities) == GIMP_EXPORT_EXPORT; else exported = FALSE; type = gimp_image_base_type (image_id); gimp_image_get_resolution (image_id, &x_res, &y_res); x_scale = 72.0 / x_res; y_scale = 72.0 / y_res; cairo_pdf_surface_set_size (pdf_file, gimp_image_width (image_id) * x_scale, gimp_image_height (image_id) * y_scale); /* This way we set how many pixels are there in every inch. * It's very important for PangoCairo */ cairo_surface_set_fallback_resolution (pdf_file, x_res, y_res); /* PDF is usually 72 points per inch. If we have a different resolution, * we will need this to fit our drawings */ cairo_scale (cr, x_scale, y_scale); /* Now, we should loop over the layers of each image */ layers = gimp_image_get_layers (image_id, &num_of_layers); for (j = 0; j < num_of_layers; j++) { layer = gimp_drawable_get (layers [num_of_layers-j-1]); opacity = gimp_layer_get_opacity (layer->drawable_id)/100.0; /* Gimp doesn't display indexed layers with opacity below 50% * And if it's above 50%, it will be rounded to 100% */ if (type == GIMP_INDEXED) { if (opacity <= 0.5) opacity = 0.0; else opacity = 1.0; } if (gimp_item_get_visible (layer->drawable_id) && (! optimize.ignore_hidden || (optimize.ignore_hidden && opacity > 0.0))) { mask_id = gimp_layer_get_mask (layer->drawable_id); if (mask_id != -1) { mask = gimp_drawable_get (mask_id); mask_image = get_drawable_image (mask); } gimp_drawable_offsets (layer->drawable_id, &x, &y); /* For raster layers */ if (!gimp_item_is_text_layer (layer->drawable_id)) { layer_color = get_layer_color (layer, &single_color); cairo_rectangle (cr, x, y, layer->width, layer->height); if (optimize.vectorize && single_color) { cairo_set_source_rgba (cr, layer_color.r, layer_color.g, layer_color.b, layer_color.a * opacity); if (mask_id != -1) cairo_mask_surface (cr, mask_image, x, y); else cairo_fill (cr); } else { cairo_clip (cr); layer_image = get_drawable_image (layer); cairo_set_source_surface (cr, layer_image, x, y); cairo_push_group (cr); cairo_paint_with_alpha (cr, opacity); cairo_pop_group_to_source (cr); if (mask_id != -1) cairo_mask_surface (cr, mask_image, x, y); else cairo_paint (cr); cairo_reset_clip (cr); cairo_surface_destroy (layer_image); } } /* For text layers */ else { drawText (layer, opacity, cr, x_res, y_res); } } /* We are done with the layer - time to free some resources */ gimp_drawable_detach (layer); if (mask_id != -1) { gimp_drawable_detach (mask); cairo_surface_destroy (mask_image); } } /* We are done with this image - Show it! */ cairo_show_page (cr); cairo_restore (cr); if (exported) gimp_image_delete (image_id); } /* We are done with all the images - time to free the resources */ cairo_surface_destroy (pdf_file); cairo_destroy (cr); fclose (fp); /* Finally done, let's save the parameters */ gimp_set_data (DATA_OPTIMIZE, &optimize, sizeof (optimize)); if (!single_image) { g_strlcpy (multi_page.file_name, file_name, MAX_FILE_NAME_LENGTH); gimp_set_data (DATA_IMAGE_LIST, &multi_page, sizeof (multi_page)); } }
static void draw_pattern (cairo_surface_t **surface_inout, int surface_size) { cairo_t *cr; int mid = surface_size/2; cr = cairo_create (*surface_inout); cairo_surface_destroy (*surface_inout); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba (cr, 0, 0, 0, 0); cairo_paint (cr); cairo_rectangle (cr, 0, 0, surface_size, surface_size); cairo_rectangle (cr, mid - SIZE/4, mid + SIZE/4, SIZE/2, -SIZE/2); cairo_clip (cr); /* outside squares -> opaque */ cairo_set_source_rgb (cr, 1, 1, 1); cairo_rectangle (cr, 0, 0, surface_size / 2, surface_size / 2); cairo_fill (cr); cairo_set_source_rgb (cr, 1, 0, 0); cairo_rectangle (cr, surface_size / 2, 0, surface_size / 2, surface_size / 2); cairo_fill (cr); cairo_set_source_rgb (cr, 0, 1, 0); cairo_rectangle (cr, 0, surface_size / 2, surface_size / 2, surface_size / 2); cairo_fill (cr); cairo_set_source_rgb (cr, 0, 0, 1); cairo_rectangle (cr, surface_size / 2, surface_size / 2, surface_size / 2, surface_size / 2); cairo_fill (cr); cairo_reset_clip (cr); cairo_rectangle (cr, mid - SIZE/4, mid - SIZE/4, SIZE/2, SIZE/2); cairo_clip (cr); /* inside squares -> translucent */ cairo_set_source_rgba (cr, 0, 0, 1, .5); cairo_rectangle (cr, 0, 0, surface_size / 2, surface_size / 2); cairo_fill (cr); cairo_set_source_rgba (cr, 0, 1, 0, .5); cairo_rectangle (cr, surface_size / 2, 0, surface_size / 2, surface_size / 2); cairo_fill (cr); cairo_set_source_rgba (cr, 1, 0, 0, .5); cairo_rectangle (cr, 0, surface_size / 2, surface_size / 2, surface_size / 2); cairo_fill (cr); cairo_set_source_rgba (cr, 1, 1, 1, .5); cairo_rectangle (cr, surface_size / 2, surface_size / 2, surface_size / 2, surface_size / 2); cairo_fill (cr); *surface_inout = cairo_surface_reference (cairo_get_target (cr)); cairo_destroy (cr); }
void stroke_in_clip(cairo_t *cr) { clip_path_rect(cr); cairo_stroke(cr); cairo_reset_clip(cr); }
void lime_cairo_reset_clip (double handle) { cairo_reset_clip ((cairo_t*)(intptr_t)handle); }
void display_present(struct display_t * disp, void * o, void (*draw)(struct display_t *, void *)) { cairo_t * cr; struct region_t rn, ro, * r; char fps[32]; int count; int i; if(disp) { if(disp->cursor.show && disp->cursor.dirty) { region_init(&rn, disp->cursor.nx, disp->cursor.ny, disp->cursor.width, disp->cursor.height); region_init(&ro, disp->cursor.ox, disp->cursor.oy, disp->cursor.width, disp->cursor.height); display_region_list_add(disp, &rn); display_region_list_add(disp, &ro); disp->cursor.dirty = 0; } if(disp->fps.show) { ktime_t now = ktime_get(); s64_t delta = ktime_ms_delta(now, disp->fps.stamp); if(delta > 0) disp->fps.rate = ((double)1000.0 / (double)delta) * 0.618 + disp->fps.rate * 0.382; disp->fps.frame++; disp->fps.stamp = now; int len = snprintf(fps, sizeof(fps), "%.2f %ld", disp->fps.rate, disp->fps.frame); region_init(&rn, 0, 0, len * (24 / 2), 24); display_region_list_add(disp, &rn); } if((count = disp->rl->count) > 0) { cr = disp->cr; cairo_reset_clip(cr); for(i = 0; i < count; i++) { r = &disp->rl->region[i]; cairo_rectangle(cr, r->x, r->y, r->w, r->h); } cairo_clip(cr); cairo_save(cr); cairo_set_source_rgb(cr, 1, 1, 1); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); cairo_paint(cr); cairo_restore(cr); if(draw) draw(disp, o); #if 0 { static int flag = 0; cairo_save(cr); flag = !flag; if(flag) cairo_set_source_rgba(cr, 1, 0, 0, 0.7); else cairo_set_source_rgba(cr, 0, 1, 0, 0.7); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); cairo_paint(cr); cairo_restore(cr); } #endif if(disp->cursor.show) { cairo_save(cr); cairo_set_source_surface(cr, disp->cursor.cs, disp->cursor.nx, disp->cursor.ny); cairo_paint(cr); cairo_restore(cr); } if(disp->fps.show) { cairo_save(cr); cairo_set_font_size(cr, 24); cairo_set_source_rgb(cr, 0.4, 0.4, 0.4); cairo_move_to(cr, 0, 24); cairo_show_text(cr, fps); cairo_restore(cr); } cairo_xboot_surface_present(disp->cs, disp->rl); } } }
void lime_cairo_reset_clip (value handle) { cairo_reset_clip ((cairo_t*)val_data (handle)); }
void gfxContext::ResetClip() { cairo_reset_clip(mCairo); }
void iupDrawResetClip(IdrawCanvas* dc) { cairo_reset_clip(dc->image_cr); }
static int gra2cairo_output(struct objlist *obj, N_VALUE *inst, N_VALUE *rval, int argc, char **argv) { char code, *cstr, *tmp; int *cpar, i, r, font_style; double x, y, w, h, fontsize, fontspace, fontdir, fontsin, fontcos, a1, a2; cairo_line_join_t join; cairo_line_cap_t cap; double *dashlist = NULL; struct gra2cairo_local *local; local = (struct gra2cairo_local *)argv[2]; code = *(char *)(argv[3]); cpar = (int *)argv[4]; cstr = argv[5]; if (local->cairo == NULL) return -1; if (code != 'T') { gra2cairo_draw_path(local); } switch (code) { case 'I': gra2cairo_set_antialias(local, local->antialias); local->linetonum = 0; r = check_cairo_status(local->cairo); if (r) { error(obj, r); return 1; } case '%': case 'X': break; case 'E': r = check_cairo_status(local->cairo); if (r) { error(obj, r); return 1; } break; case 'V': local->offsetx = mxd2pw(local, cpar[1]); local->offsety = mxd2ph(local, cpar[2]); cairo_new_path(local->cairo); if (cpar[5]) { x = mxd2pw(local, cpar[1]); y = mxd2ph(local, cpar[2]); w = mxd2pw(local, cpar[3]) - x; h = mxd2ph(local, cpar[4]) - y; cairo_reset_clip(local->cairo); cairo_rectangle(local->cairo, x, y, w, h); cairo_clip(local->cairo); } else { cairo_reset_clip(local->cairo); } if (local->region) { gra2cairo_clip_region(local, local->region); } break; case 'A': if (cpar[1] == 0) { cairo_set_dash(local->cairo, NULL, 0, 0); } else { dashlist = g_malloc(sizeof(* dashlist) * cpar[1]); if (dashlist == NULL) break; for (i = 0; i < cpar[1]; i++) { dashlist[i] = mxd2pw(local, cpar[6 + i]); if (dashlist[i] <= 0) { dashlist[i] = 1; } } cairo_set_dash(local->cairo, dashlist, cpar[1], 0); g_free(dashlist); } cairo_set_line_width(local->cairo, mxd2pw(local, cpar[2])); if (cpar[3] == 2) { cap = CAIRO_LINE_CAP_SQUARE; } else if (cpar[3] == 1) { cap = CAIRO_LINE_CAP_ROUND; } else { cap = CAIRO_LINE_CAP_BUTT; } cairo_set_line_cap(local->cairo, cap); if (cpar[4] == 2) { join = CAIRO_LINE_JOIN_BEVEL; } else if (cpar[4] == 1) { join = CAIRO_LINE_JOIN_ROUND; } else { join = CAIRO_LINE_JOIN_MITER; } cairo_set_line_join(local->cairo, join); break; case 'G': if (local->use_opacity && cpar[0] > 3 && cpar[4] < 255) { cairo_set_source_rgba(local->cairo, cpar[1] / 255.0, cpar[2] / 255.0, cpar[3] / 255.0, cpar[4] / 255.0); } else { cairo_set_source_rgb(local->cairo, cpar[1] / 255.0, cpar[2] / 255.0, cpar[3] / 255.0); } break; case 'M': cairo_move_to(local->cairo, mxd2px(local, cpar[1]), mxd2py(local, cpar[2])); break; case 'N': relative_move(local->cairo, mxd2pw(local, cpar[1]), mxd2ph(local, cpar[2])); break; case 'L': cairo_new_path(local->cairo); cairo_move_to(local->cairo, mxd2px(local, cpar[1]), mxd2py(local, cpar[2])); cairo_line_to(local->cairo, mxd2px(local, cpar[3]), mxd2py(local, cpar[4])); cairo_stroke(local->cairo); break; case 'T': cairo_line_to(local->cairo, mxd2px(local, cpar[1]), mxd2py(local, cpar[2])); local->linetonum++; break; case 'C': x = mxd2px(local, cpar[1] - cpar[3]); y = mxd2py(local, cpar[2] - cpar[4]); w = mxd2pw(local, cpar[3]); h = mxd2ph(local, cpar[4]); a1 = cpar[5] * (M_PI / 18000.0); a2 = cpar[6] * (M_PI / 18000.0) + a1; if (w == 0 || h == 0 || a1 == a2) break; cairo_new_path(local->cairo); cairo_save(local->cairo); cairo_translate(local->cairo, x + w, y + h); cairo_scale(local->cairo, w, h); cairo_arc_negative(local->cairo, 0., 0., 1., -a1, -a2); cairo_restore (local->cairo); switch (cpar[7]) { case 1: cairo_line_to(local->cairo, x + w, y + h); /* fall through */ case 2: cairo_close_path(local->cairo); cairo_fill(local->cairo); break; case 3: cairo_line_to(local->cairo, x + w, y + h); /* fall through */ case 4: cairo_close_path(local->cairo); cairo_stroke(local->cairo); break; default: cairo_stroke(local->cairo); } break; case 'B': cairo_new_path(local->cairo); if (cpar[1] <= cpar[3]) { x = mxd2px(local, cpar[1]); w = mxd2pw(local, cpar[3] - cpar[1]); } else { x = mxd2px(local, cpar[3]); w = mxd2pw(local, cpar[1] - cpar[3]); } if (cpar[2] <= cpar[4]) { y = mxd2py(local, cpar[2]); h = mxd2ph(local, cpar[4] - cpar[2]); } else { y = mxd2py(local, cpar[4]); h = mxd2ph(local, cpar[2] - cpar[4]); } cairo_rectangle(local->cairo, x, y, w, h); if (cpar[5] == 0) { cairo_stroke(local->cairo); } else { cairo_fill(local->cairo); } break; case 'P': cairo_new_path(local->cairo); cairo_arc(local->cairo, mxd2px(local, cpar[1]), mxd2py(local, cpar[2]), mxd2pw(local, 1), 0, 2 * M_PI); cairo_fill(local->cairo); break; case 'R': cairo_new_path(local->cairo); if (cpar[1] == 0) break; for (i = 0; i < cpar[1]; i++) { cairo_line_to(local->cairo, mxd2px(local, cpar[i * 2 + 2]), mxd2py(local, cpar[i * 2 + 3])); } cairo_stroke(local->cairo); break; case 'D': cairo_new_path(local->cairo); if (cpar[1] == 0) break; for (i = 0; i < cpar[1]; i++) { cairo_line_to(local->cairo, mxd2px(local, cpar[i * 2 + 3]), mxd2py(local, cpar[i * 2 + 4])); } cairo_close_path(local->cairo); switch (cpar[2]) { case 0: cairo_stroke(local->cairo); break; case 1: cairo_set_fill_rule(local->cairo, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill(local->cairo); break; case 2: cairo_set_fill_rule(local->cairo, CAIRO_FILL_RULE_WINDING); cairo_fill(local->cairo); break; } break; case 'F': g_free(local->fontalias); local->fontalias = g_strdup(cstr); break; case 'H': fontspace = cpar[2] / 72.0 * 25.4; local->fontspace = fontspace; fontsize = cpar[1] / 72.0 * 25.4; local->fontsize = fontsize; fontdir = cpar[3] * MPI / 18000.0; fontsin = sin(fontdir); fontcos = cos(fontdir); local->fontdir = (cpar[3] % 36000) / 100.0; if (local->fontdir < 0) { local->fontdir += 360; } local->fontsin = fontsin; local->fontcos = fontcos; font_style = (cpar[0] > 3) ? cpar[4] : -1; local->loadfont = loadfont(local->fontalias, font_style, &local->symbol); break; case 'S': if (local->loadfont == NULL) break; tmp = gra2cairo_get_utf8_str(cstr, local->symbol); if (tmp) { draw_str(local, TRUE, tmp, local->loadfont, local->fontsize, local->fontspace, NULL, NULL, NULL); g_free(tmp); } break; case 'K': if (local->loadfont == NULL) break; tmp = sjis_to_utf8(cstr); if (tmp) { draw_str(local, TRUE, tmp, local->loadfont, local->fontsize, local->fontspace, NULL, NULL, NULL); g_free(tmp); } break; default: break; } return 0; }