>From 3616af8c05a89d31e506d5343ec07e08c0c5282a Mon Sep 17 00:00:00 2001 From: "Elias G. Perez" Date: Fri, 10 May 2024 20:36:42 -0600 Subject: [PATCH] [WIP] Stipple implementation for MS Windows --- src/w32term.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/w32term.c b/src/w32term.c index a9aff304771..dc810cf294b 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -1248,6 +1248,36 @@ w32_clear_glyph_string_rect (struct glyph_string *s, real_w, real_h); } +static void +XFillRectangle (struct glyph_string *s, Emacs_GC *gc, + int x, int y, unsigned int width, unsigned int height) +{ + HDC hdc; + HBITMAP hbm; + HBRUSH hb; + + COLORREF bg = gc->background; /* Only for tests */ + COLORREF fg = gc->foreground; + COLORREF bits[] = { + bg, bg, fg, fg, fg, fg, fg, fg, fg, + bg, bg, fg, fg, fg, fg, fg, fg, fg + }; + + hdc = s->hdc; + hbm = CreateBitmap(9, 2, 1, sizeof(COLORREF) * 8, bits); /* TODO: s->face->stipple */ + hb = CreatePatternBrush (hbm); + + RECT r; + r.left = x; + r.top = y; + r.right = x + width + 1; + r.bottom = y + height + 1; + + FillRect (hdc, &r, hb); + + DeleteObject(hb); + DeleteObject(hbm); +} /* Draw the background of glyph_string S. If S->background_filled_p is non-zero don't draw it. FORCE_P non-zero means draw the @@ -1264,16 +1294,15 @@ w32_draw_glyph_string_background (struct glyph_string *s, bool force_p) { int box_line_width = max (s->face->box_horizontal_line_width, 0); -#if 0 /* TODO: stipple */ +#if 1 /* TODO: stipple */ if (s->stippled_p) { /* Fill background with a stipple pattern. */ - XSetFillStyle (s->display, s->gc, FillOpaqueStippled); - XFillRectangle (s->display, FRAME_W32_WINDOW (s->f), s->gc, s->x, - s->y + box_line_width, - s->background_width, + /* XSetFillStyle (s->display, s->gc, FillOpaqueStippled); */ + XFillRectangle (s, s->gc, s->x, + s->y + box_line_width, s->background_width, s->height - 2 * box_line_width); - XSetFillStyle (s->display, s->gc, FillSolid); + /* XSetFillStyle (s->display, s->gc, FillSolid); */ s->background_filled_p = true; } else -- 2.44.0.windows.1