changeset 55026:08e4e7c06ffc

(w32_draw_relief_rect): Add top_p and bot_p args. (x_draw_glyph_string_box): Fix call to x_draw_relief_rect. (x_draw_image_foreground, x_draw_image_relief) (w32_draw_image_foreground_1, x_draw_image_glyph_string): Draw sliced images.
author Kim F. Storm <storm@cua.dk>
date Tue, 20 Apr 2004 22:17:56 +0000
parents 5cbecea4d4ad
children 91ab946dfd86
files src/w32term.c
diffstat 1 files changed, 86 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32term.c	Tue Apr 20 22:17:34 2004 +0000
+++ b/src/w32term.c	Tue Apr 20 22:17:56 2004 +0000
@@ -1220,7 +1220,8 @@
 static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
 					   int, int, int));
 static void w32_draw_relief_rect P_ ((struct frame *, int, int, int, int,
-				    int, int, int, int, RECT *));
+				      int, int, int, int, int, int,
+				      RECT *));
 static void w32_draw_box_rect P_ ((struct glyph_string *, int, int, int, int,
 				 int, int, int, RECT *));
 
@@ -1801,9 +1802,10 @@
 
 static void
 w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
-                      raised_p, left_p, right_p, clip_rect)
+                      raised_p, top_p, bot_p, left_p, right_p, clip_rect)
      struct frame *f;
-     int left_x, top_y, right_x, bottom_y, width, left_p, right_p, raised_p;
+     int left_x, top_y, right_x, bottom_y, width;
+     int top_p, bot_p, left_p, right_p, raised_p;
      RECT *clip_rect;
 {
   int i;
@@ -1818,10 +1820,11 @@
   w32_set_clip_rectangle (hdc, clip_rect);
 
   /* Top.  */
-  for (i = 0; i < width; ++i)
-    w32_fill_area (f, hdc, gc.foreground,
-		   left_x + i * left_p, top_y + i,
-		   right_x - left_x - i * (left_p + right_p ) + 1, 1);
+  if (top_p)
+    for (i = 0; i < width; ++i)
+      w32_fill_area (f, hdc, gc.foreground,
+		     left_x + i * left_p, top_y + i,
+		     right_x - left_x - i * (left_p + right_p ) + 1, 1);
 
   /* Left.  */
   if (left_p)
@@ -1836,10 +1839,11 @@
     gc.foreground = f->output_data.w32->white_relief.gc->foreground;
 
   /* Bottom.  */
-  for (i = 0; i < width; ++i)
-    w32_fill_area (f, hdc, gc.foreground,
-		   left_x + i * left_p, bottom_y - i,
-		   right_x - left_x - i * (left_p + right_p) + 1, 1);
+  if (bot_p)
+    for (i = 0; i < width; ++i)
+      w32_fill_area (f, hdc, gc.foreground,
+		     left_x + i * left_p, bottom_y - i,
+		     right_x - left_x - i * (left_p + right_p) + 1, 1);
 
   /* Right.  */
   if (right_p)
@@ -1949,7 +1953,7 @@
     {
       x_setup_relief_colors (s);
       w32_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y,
-                            width, raised_p, left_p, right_p, &clip_rect);
+                            width, raised_p, 1, 1, left_p, right_p, &clip_rect);
     }
 }
 
@@ -1960,21 +1964,22 @@
 x_draw_image_foreground (s)
      struct glyph_string *s;
 {
-  int x;
-  int y = s->ybase - image_ascent (s->img, s->face);
+  int x = s->x;
+  int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
 
   /* If first glyph of S has a left box line, start drawing it to the
      right of that line.  */
   if (s->face->box != FACE_NO_BOX
-      && s->first_glyph->left_box_line_p)
-    x = s->x + abs (s->face->box_line_width);
-  else
-    x = s->x;
+      && s->first_glyph->left_box_line_p
+      && s->slice.x == 0)
+    x += abs (s->face->box_line_width);
 
   /* If there is a margin around the image, adjust x- and y-position
      by that margin.  */
-  x += s->img->hmargin;
-  y += s->img->vmargin;
+  if (s->slice.x == 0)
+    x += s->img->hmargin;
+  if (s->slice.y == 0)
+    y += s->img->vmargin;
 
   SaveDC (s->hdc);
 
@@ -1996,12 +2001,12 @@
 	  SetTextColor (s->hdc, RGB (255, 255, 255));
 	  SetBkColor (s->hdc, RGB (0, 0, 0));
 
-	  BitBlt (s->hdc, x, y, s->img->width, s->img->height,
-		  compat_hdc, 0, 0, SRCINVERT);
-	  BitBlt (s->hdc, x, y, s->img->width, s->img->height,
-		  mask_dc, 0, 0, SRCAND);
-	  BitBlt (s->hdc, x, y, s->img->width, s->img->height,
-		  compat_hdc, 0, 0, SRCINVERT);
+	  BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+		  compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
+	  BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+		  mask_dc, s->slice.x, s->slice.y, SRCAND);
+	  BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+		  compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
 
 	  SelectObject (mask_dc, mask_orig_obj);
 	  DeleteDC (mask_dc);
@@ -2011,8 +2016,8 @@
 	  SetTextColor (s->hdc, s->gc->foreground);
 	  SetBkColor (s->hdc, s->gc->background);
 
-          BitBlt (s->hdc, x, y, s->img->width, s->img->height,
-                  compat_hdc, 0, 0, SRCCOPY);
+          BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+                  compat_hdc, s->slice.x, s->slice.y, SRCCOPY);
 
 	  /* When the image has a mask, we can expect that at
 	     least part of a mouse highlight or a block cursor will
@@ -2025,7 +2030,8 @@
 	      int r = s->img->relief;
 	      if (r < 0) r = -r;
 	      w32_draw_rectangle (s->hdc, s->gc, x - r, y - r ,
-				  s->img->width + r*2 - 1, s->img->height + r*2 - 1);
+				  s->slice.width + r*2 - 1,
+				  s->slice.height + r*2 - 1);
 	    }
 	}
 
@@ -2036,8 +2042,8 @@
       DeleteDC (compat_hdc);
     }
   else
-    w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width -1,
-                        s->img->height - 1);
+    w32_draw_rectangle (s->hdc, s->gc, x, y,
+			s->slice.width - 1, s->slice.height - 1);
 
   RestoreDC (s->hdc ,-1);
 }
@@ -2052,21 +2058,22 @@
 {
   int x0, y0, x1, y1, thick, raised_p;
   RECT r;
-  int x;
-  int y = s->ybase - image_ascent (s->img, s->face);
+  int x = s->x;
+  int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
 
   /* If first glyph of S has a left box line, start drawing it to the
      right of that line.  */
   if (s->face->box != FACE_NO_BOX
-      && s->first_glyph->left_box_line_p)
-    x = s->x + abs (s->face->box_line_width);
-  else
-    x = s->x;
+      && s->first_glyph->left_box_line_p
+      && s->slice.x == 0)
+    x += abs (s->face->box_line_width);
 
   /* If there is a margin around the image, adjust x- and y-position
      by that margin.  */
-  x += s->img->hmargin;
-  y += s->img->vmargin;
+  if (s->slice.x == 0)
+    x += s->img->hmargin;
+  if (s->slice.y == 0)
+    y += s->img->vmargin;
 
   if (s->hl == DRAW_IMAGE_SUNKEN
       || s->hl == DRAW_IMAGE_RAISED)
@@ -2082,12 +2089,17 @@
 
   x0 = x - thick;
   y0 = y - thick;
-  x1 = x + s->img->width + thick - 1;
-  y1 = y + s->img->height + thick - 1;
+  x1 = x + s->slice.width + thick - 1;
+  y1 = y + s->slice.height + thick - 1;
 
   x_setup_relief_colors (s);
   get_glyph_string_clip_rect (s, &r);
-  w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r);
+  w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p,
+			s->slice.y == 0,
+			s->slice.y + s->slice.height == s->img->height,
+			s->slice.x == 0,
+			s->slice.x + s->slice.width == s->img->width,
+			&r);
 }
 
 
@@ -2100,21 +2112,22 @@
 {
   HDC hdc = CreateCompatibleDC (s->hdc);
   HGDIOBJ orig_hdc_obj = SelectObject (hdc, pixmap);
-  int x;
-  int y = s->ybase - s->y - image_ascent (s->img, s->face);
+  int x = 0;
+  int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
 
   /* If first glyph of S has a left box line, start drawing it to the
      right of that line.  */
   if (s->face->box != FACE_NO_BOX
-      && s->first_glyph->left_box_line_p)
-    x = abs (s->face->box_line_width);
-  else
-    x = 0;
+      && s->first_glyph->left_box_line_p
+      && s->slice.x == 0)
+    x += abs (s->face->box_line_width);
 
   /* If there is a margin around the image, adjust x- and y-position
      by that margin.  */
-  x += s->img->hmargin;
-  y += s->img->vmargin;
+  if (s->slice.x == 0)
+    x += s->img->hmargin;
+  if (s->slice.y == 0)
+    y += s->img->vmargin;
 
   if (s->img->pixmap)
     {
@@ -2130,12 +2143,12 @@
 
 	  SetTextColor (hdc, RGB (0, 0, 0));
 	  SetBkColor (hdc, RGB (255, 255, 255));
-	  BitBlt (hdc, x, y, s->img->width, s->img->height,
-		  compat_hdc, 0, 0, SRCINVERT);
-	  BitBlt (hdc, x, y, s->img->width, s->img->height,
-		  mask_dc, 0, 0, SRCAND);
-	  BitBlt (hdc, x, y, s->img->width, s->img->height,
-		  compat_hdc, 0, 0, SRCINVERT);
+	  BitBlt (hdc, x, y, s->slice.width, s->slice.height,
+		  compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
+	  BitBlt (hdc, x, y, s->slice.width, s->slice.height,
+		  mask_dc, s->slice.x, s->slice.y, SRCAND);
+	  BitBlt (hdc, x, y, s->slice.width, s->slice.height,
+		  compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
 
 	  SelectObject (mask_dc, mask_orig_obj);
 	  DeleteDC (mask_dc);
@@ -2145,8 +2158,8 @@
 	  SetTextColor (hdc, s->gc->foreground);
 	  SetBkColor (hdc, s->gc->background);
 
-          BitBlt (hdc, x, y, s->img->width, s->img->height,
-                  compat_hdc, 0, 0, SRCCOPY);
+          BitBlt (hdc, x, y, s->slice.width, s->slice.height,
+                  compat_hdc, s->slice.x, s->slice.y, SRCCOPY);
 
 	  /* When the image has a mask, we can expect that at
 	     least part of a mouse highlight or a block cursor will
@@ -2158,8 +2171,9 @@
 	    {
 	      int r = s->img->relief;
 	      if (r < 0) r = -r;
-	      w32_draw_rectangle (hdc, s->gc, x - r, y - r ,
-				  s->img->width + r*2 - 1, s->img->height + r*2 - 1);
+	      w32_draw_rectangle (hdc, s->gc, x - r, y - r,
+				  s->slice.width + r*2 - 1,
+				  s->slice.height + r*2 - 1);
 	    }
 	}
 
@@ -2169,8 +2183,8 @@
       DeleteDC (compat_hdc);
     }
   else
-    w32_draw_rectangle (hdc, s->gc, x, y, s->img->width - 1,
-                        s->img->height - 1);
+    w32_draw_rectangle (hdc, s->gc, x, y,
+			s->slice.width - 1, s->slice.height - 1);
 
   SelectObject (hdc, orig_hdc_obj);
   DeleteDC (hdc);
@@ -2229,19 +2243,22 @@
      taller than image or if image has a clip mask to reduce
      flickering.  */
   s->stippled_p = s->face->stipple != 0;
-  if (height > s->img->height
+  if (height > s->slice.height
       || s->img->hmargin
       || s->img->vmargin
       || s->img->mask
       || s->img->pixmap == 0
       || s->width != s->background_width)
     {
-      if (box_line_hwidth && s->first_glyph->left_box_line_p)
-	x = s->x + box_line_hwidth;
-      else
-	x = s->x;
-
-      y = s->y + box_line_vwidth;
+      x = s->x;
+      if (s->first_glyph->left_box_line_p
+	  && s->slice.x == 0)
+	x += box_line_hwidth;
+
+      y = s->y;
+      if (s->slice.y == 0)
+	y += box_line_vwidth;
+
 #if 0 /* TODO: figure out if we need to do this on Windows.  */
       if (s->img->mask)
 	{