From 7e42e34fa75ef30467423b7a43c18b0ab0c93bd6 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 | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/w32term.c b/src/w32term.c index a9aff304771..8e9ffcb8c43 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -1248,6 +1248,33 @@ w32_clear_glyph_string_rect (struct glyph_string *s, real_w, real_h); } +/* Fill background with bitmap S glyph, with GC, X, Y, WIDTH, HEIGHT, HDC. */ +static void +XFillRectangle (HDC hdc, struct glyph_string *s, Emacs_GC *gc, + int x, int y, unsigned int width, unsigned int height) +{ + Emacs_Pixmap bm; + HBRUSH hb; + + /* Only for tests */ + /* COLORREF bg = gc->background; */ + /* COLORREF fg = gc->foreground; */ + /* COLORREF bits[] = { fg, bg, bg, bg, bg, bg, bg, bg, bg, bg }; */ + /* bm = CreateBitmap(bw, bh, FRAME_DISPLAY_INFO(s->f)->n_planes, FRAME_DISPLAY_INFO(s->f)->n_cbits, pix); */ + /* FIXME: ? */ + bm = FRAME_DISPLAY_INFO (s->f)->bitmaps[s->face->stipple - 1].pixmap; + hb = CreatePatternBrush (bm); + + RECT r; + r.left = x; + r.top = y; + r.right = x + width + 1; + r.bottom = y + height + 1; + + FillRect (hdc, &r, hb); + + DeleteObject(hb); +} /* 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 +1291,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->hdc, 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