static void item_grid_draw_background (cairo_t *cr, GnmItemGrid *ig, GnmStyle const *style, int col, int row, int x, int y, int w, int h, gboolean draw_selection, GtkStyleContext *ctxt) { SheetView const *sv = scg_view (ig->scg); gboolean const is_selected = draw_selection && (sv->edit_pos.col != col || sv->edit_pos.row != row) && sv_is_pos_selected (sv, col, row); gboolean const has_back = gnumeric_background_set (style, cr, is_selected, ctxt); #if DEBUG_SELECTION_PAINT if (is_selected) { g_printerr ("x = %d, w = %d\n", x, w+1); } #endif if (has_back || is_selected) { /* Fill the entire cell (API excludes far pixel) */ cairo_rectangle (cr, x, y, w+1, h+1); cairo_fill (cr); } gnm_style_border_draw_diag (style, cr, x, y, x+w, y+h); }
static void preview_grid_draw_background (cairo_t *cr, GnmPreviewGrid const *pg, GnmStyle const *mstyle, int col, int row, int x, int y, int w, int h) { if (gnm_pattern_background_set (mstyle, cr, FALSE, NULL)) { cairo_rectangle (cr, x, y, w+1, h+1); cairo_fill (cr); } gnm_style_border_draw_diag (mstyle, cr, x, y, x+w, y+h); }
static void item_grid_draw_merged_range (cairo_t *cr, GnmItemGrid *ig, int start_x, int start_y, GnmRange const *view, GnmRange const *range, gboolean draw_selection, GtkStyleContext *ctxt) { int l, r, t, b, last; SheetView const *sv = scg_view (ig->scg); WorkbookView *wbv = sv_wbv (sv); gboolean show_function_cell_markers = wbv->show_function_cell_markers; gboolean show_extension_markers = wbv->show_extension_markers; Sheet const *sheet = sv->sheet; GnmCell const *cell = sheet_cell_get (sheet, range->start.col, range->start.row); int const dir = sheet->text_is_rtl ? -1 : 1; /* load style from corner which may not be visible */ GnmStyle const *style = sheet_style_get (sheet, range->start.col, range->start.row); gboolean const is_selected = draw_selection && (sv->edit_pos.col != range->start.col || sv->edit_pos.row != range->start.row) && sv_is_full_range_selected (sv, range); /* Get the coordinates of the visible region */ l = r = start_x; if (view->start.col < range->start.col) l += dir * scg_colrow_distance_get (ig->scg, TRUE, view->start.col, range->start.col); if (range->end.col <= (last = view->end.col)) last = range->end.col; r += dir * scg_colrow_distance_get (ig->scg, TRUE, view->start.col, last+1); t = b = start_y; if (view->start.row < range->start.row) t += scg_colrow_distance_get (ig->scg, FALSE, view->start.row, range->start.row); if (range->end.row <= (last = view->end.row)) last = range->end.row; b += scg_colrow_distance_get (ig->scg, FALSE, view->start.row, last+1); if (l == r || t == b) return; if (style->conditions) { GnmEvalPos ep; int res; eval_pos_init (&ep, (Sheet *)sheet, range->start.col, range->start.row); if ((res = gnm_style_conditions_eval (style->conditions, &ep)) >= 0) style = g_ptr_array_index (style->cond_styles, res); } /* Check for background THEN selection */ if (gnumeric_background_set (style, cr, is_selected, ctxt) || is_selected) { /* Remember X excludes the far pixels */ if (dir > 0) cairo_rectangle (cr, l, t, r-l+1, b-t+1); else cairo_rectangle (cr, r, t, l-r+1, b-t+1); cairo_fill (cr); } /* Expand the coords to include non-visible areas too. The clipped * region is only necessary when drawing the background */ if (range->start.col < view->start.col) l -= dir * scg_colrow_distance_get (ig->scg, TRUE, range->start.col, view->start.col); if (view->end.col < range->end.col) r += dir * scg_colrow_distance_get (ig->scg, TRUE, view->end.col+1, range->end.col+1); if (range->start.row < view->start.row) t -= scg_colrow_distance_get (ig->scg, FALSE, range->start.row, view->start.row); if (view->end.row < range->end.row) b += scg_colrow_distance_get (ig->scg, FALSE, view->end.row+1, range->end.row+1); if (cell != NULL) { ColRowInfo *ri = sheet_row_get (sheet, range->start.row); if (ri->needs_respan) row_calc_spans (ri, cell->pos.row, sheet); if (dir > 0) { if (show_function_cell_markers) draw_function_marker (ig, cell, cr, l, t, r - l, b - t, dir); cell_draw (cell, cr, l, t, r - l, b - t, -1, show_extension_markers); } else { if (show_function_cell_markers) draw_function_marker (ig, cell, cr, r, t, l - r, b - t, dir); cell_draw (cell, cr, r, t, l - r, b - t, -1, show_extension_markers); } } if (dir > 0) gnm_style_border_draw_diag (style, cr, l, t, r, b); else gnm_style_border_draw_diag (style, cr, r, t, l, b); }