aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2004-04-20 22:19:23 +0000
committerKim F. Storm2004-04-20 22:19:23 +0000
commit57326d99989c8f05c5820ef5689198610e2043df (patch)
tree3c143fd374eb8efdb95fd654f97e625ec5a37130
parente893970b97c690266e0016c27c0ce497277e8e91 (diff)
downloademacs-57326d99989c8f05c5820ef5689198610e2043df.tar.gz
emacs-57326d99989c8f05c5820ef5689198610e2043df.zip
(x_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) (x_draw_image_foreground_1, x_draw_image_glyph_string): Draw sliced images.
-rw-r--r--src/xterm.c154
1 files changed, 90 insertions, 64 deletions
diff --git a/src/xterm.c b/src/xterm.c
index da875b6156f..bed9842fdc8 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -981,7 +981,8 @@ static void x_draw_image_foreground_1 P_ ((struct glyph_string *, Pixmap));
981static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, 981static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
982 int, int, int)); 982 int, int, int));
983static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int, 983static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int,
984 int, int, int, int, XRectangle *)); 984 int, int, int, int, int, int,
985 XRectangle *));
985static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, 986static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int,
986 int, int, int, XRectangle *)); 987 int, int, int, XRectangle *));
987 988
@@ -2019,9 +2020,10 @@ x_setup_relief_colors (s)
2019 2020
2020static void 2021static void
2021x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, 2022x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2022 raised_p, left_p, right_p, clip_rect) 2023 raised_p, top_p, bot_p, left_p, right_p, clip_rect)
2023 struct frame *f; 2024 struct frame *f;
2024 int left_x, top_y, right_x, bottom_y, width, left_p, right_p, raised_p; 2025 int left_x, top_y, right_x, bottom_y, width;
2026 int top_p, bot_p, left_p, right_p, raised_p;
2025 XRectangle *clip_rect; 2027 XRectangle *clip_rect;
2026{ 2028{
2027 Display *dpy = FRAME_X_DISPLAY (f); 2029 Display *dpy = FRAME_X_DISPLAY (f);
@@ -2036,10 +2038,11 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2036 XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted); 2038 XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted);
2037 2039
2038 /* Top. */ 2040 /* Top. */
2039 for (i = 0; i < width; ++i) 2041 if (top_p)
2040 XDrawLine (dpy, window, gc, 2042 for (i = 0; i < width; ++i)
2041 left_x + i * left_p, top_y + i, 2043 XDrawLine (dpy, window, gc,
2042 right_x + 1 - i * right_p, top_y + i); 2044 left_x + i * left_p, top_y + i,
2045 right_x + 1 - i * right_p, top_y + i);
2043 2046
2044 /* Left. */ 2047 /* Left. */
2045 if (left_p) 2048 if (left_p)
@@ -2055,10 +2058,11 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2055 XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted); 2058 XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted);
2056 2059
2057 /* Bottom. */ 2060 /* Bottom. */
2058 for (i = 0; i < width; ++i) 2061 if (bot_p)
2059 XDrawLine (dpy, window, gc, 2062 for (i = 0; i < width; ++i)
2060 left_x + i * left_p, bottom_y - i, 2063 XDrawLine (dpy, window, gc,
2061 right_x + 1 - i * right_p, bottom_y - i); 2064 left_x + i * left_p, bottom_y - i,
2065 right_x + 1 - i * right_p, bottom_y - i);
2062 2066
2063 /* Right. */ 2067 /* Right. */
2064 if (right_p) 2068 if (right_p)
@@ -2166,7 +2170,7 @@ x_draw_glyph_string_box (s)
2166 { 2170 {
2167 x_setup_relief_colors (s); 2171 x_setup_relief_colors (s);
2168 x_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y, 2172 x_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y,
2169 width, raised_p, left_p, right_p, &clip_rect); 2173 width, raised_p, 1, 1, left_p, right_p, &clip_rect);
2170 } 2174 }
2171} 2175}
2172 2176
@@ -2177,21 +2181,22 @@ static void
2177x_draw_image_foreground (s) 2181x_draw_image_foreground (s)
2178 struct glyph_string *s; 2182 struct glyph_string *s;
2179{ 2183{
2180 int x; 2184 int x = s->x;
2181 int y = s->ybase - image_ascent (s->img, s->face); 2185 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2182 2186
2183 /* If first glyph of S has a left box line, start drawing it to the 2187 /* If first glyph of S has a left box line, start drawing it to the
2184 right of that line. */ 2188 right of that line. */
2185 if (s->face->box != FACE_NO_BOX 2189 if (s->face->box != FACE_NO_BOX
2186 && s->first_glyph->left_box_line_p) 2190 && s->first_glyph->left_box_line_p
2187 x = s->x + abs (s->face->box_line_width); 2191 && s->slice.x == 0)
2188 else 2192 x += abs (s->face->box_line_width);
2189 x = s->x;
2190 2193
2191 /* If there is a margin around the image, adjust x- and y-position 2194 /* If there is a margin around the image, adjust x- and y-position
2192 by that margin. */ 2195 by that margin. */
2193 x += s->img->hmargin; 2196 if (s->slice.x == 0)
2194 y += s->img->vmargin; 2197 x += s->img->hmargin;
2198 if (s->slice.y == 0)
2199 y += s->img->vmargin;
2195 2200
2196 if (s->img->pixmap) 2201 if (s->img->pixmap)
2197 { 2202 {
@@ -2216,11 +2221,12 @@ x_draw_image_foreground (s)
2216 get_glyph_string_clip_rect (s, &clip_rect); 2221 get_glyph_string_clip_rect (s, &clip_rect);
2217 image_rect.x = x; 2222 image_rect.x = x;
2218 image_rect.y = y; 2223 image_rect.y = y;
2219 image_rect.width = s->img->width; 2224 image_rect.width = s->slice.width;
2220 image_rect.height = s->img->height; 2225 image_rect.height = s->slice.height;
2221 if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) 2226 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2222 XCopyArea (s->display, s->img->pixmap, s->window, s->gc, 2227 XCopyArea (s->display, s->img->pixmap, s->window, s->gc,
2223 r.x - x, r.y - y, r.width, r.height, r.x, r.y); 2228 s->slice.x + r.x - x, s->slice.y + r.y - y,
2229 r.width, r.height, r.x, r.y);
2224 } 2230 }
2225 else 2231 else
2226 { 2232 {
@@ -2229,11 +2235,12 @@ x_draw_image_foreground (s)
2229 get_glyph_string_clip_rect (s, &clip_rect); 2235 get_glyph_string_clip_rect (s, &clip_rect);
2230 image_rect.x = x; 2236 image_rect.x = x;
2231 image_rect.y = y; 2237 image_rect.y = y;
2232 image_rect.width = s->img->width; 2238 image_rect.width = s->slice.width;
2233 image_rect.height = s->img->height; 2239 image_rect.height = s->slice.height;
2234 if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) 2240 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2235 XCopyArea (s->display, s->img->pixmap, s->window, s->gc, 2241 XCopyArea (s->display, s->img->pixmap, s->window, s->gc,
2236 r.x - x, r.y - y, r.width, r.height, r.x, r.y); 2242 s->slice.x + r.x - x, s->slice.y + r.y - y,
2243 r.width, r.height, r.x, r.y);
2237 2244
2238 /* When the image has a mask, we can expect that at 2245 /* When the image has a mask, we can expect that at
2239 least part of a mouse highlight or a block cursor will 2246 least part of a mouse highlight or a block cursor will
@@ -2245,15 +2252,17 @@ x_draw_image_foreground (s)
2245 { 2252 {
2246 int r = s->img->relief; 2253 int r = s->img->relief;
2247 if (r < 0) r = -r; 2254 if (r < 0) r = -r;
2248 XDrawRectangle (s->display, s->window, s->gc, x - r, y - r, 2255 XDrawRectangle (s->display, s->window, s->gc,
2249 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 2256 x - r, y - r,
2257 s->slice.width + r*2 - 1,
2258 s->slice.height + r*2 - 1);
2250 } 2259 }
2251 } 2260 }
2252 } 2261 }
2253 else 2262 else
2254 /* Draw a rectangle if image could not be loaded. */ 2263 /* Draw a rectangle if image could not be loaded. */
2255 XDrawRectangle (s->display, s->window, s->gc, x, y, 2264 XDrawRectangle (s->display, s->window, s->gc, x, y,
2256 s->img->width - 1, s->img->height - 1); 2265 s->slice.width - 1, s->slice.height - 1);
2257} 2266}
2258 2267
2259 2268
@@ -2265,21 +2274,22 @@ x_draw_image_relief (s)
2265{ 2274{
2266 int x0, y0, x1, y1, thick, raised_p; 2275 int x0, y0, x1, y1, thick, raised_p;
2267 XRectangle r; 2276 XRectangle r;
2268 int x; 2277 int x = s->x;
2269 int y = s->ybase - image_ascent (s->img, s->face); 2278 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2270 2279
2271 /* If first glyph of S has a left box line, start drawing it to the 2280 /* If first glyph of S has a left box line, start drawing it to the
2272 right of that line. */ 2281 right of that line. */
2273 if (s->face->box != FACE_NO_BOX 2282 if (s->face->box != FACE_NO_BOX
2274 && s->first_glyph->left_box_line_p) 2283 && s->first_glyph->left_box_line_p
2275 x = s->x + abs (s->face->box_line_width); 2284 && s->slice.x == 0)
2276 else 2285 x += abs (s->face->box_line_width);
2277 x = s->x;
2278 2286
2279 /* If there is a margin around the image, adjust x- and y-position 2287 /* If there is a margin around the image, adjust x- and y-position
2280 by that margin. */ 2288 by that margin. */
2281 x += s->img->hmargin; 2289 if (s->slice.x == 0)
2282 y += s->img->vmargin; 2290 x += s->img->hmargin;
2291 if (s->slice.y == 0)
2292 y += s->img->vmargin;
2283 2293
2284 if (s->hl == DRAW_IMAGE_SUNKEN 2294 if (s->hl == DRAW_IMAGE_SUNKEN
2285 || s->hl == DRAW_IMAGE_RAISED) 2295 || s->hl == DRAW_IMAGE_RAISED)
@@ -2295,12 +2305,17 @@ x_draw_image_relief (s)
2295 2305
2296 x0 = x - thick; 2306 x0 = x - thick;
2297 y0 = y - thick; 2307 y0 = y - thick;
2298 x1 = x + s->img->width + thick - 1; 2308 x1 = x + s->slice.width + thick - 1;
2299 y1 = y + s->img->height + thick - 1; 2309 y1 = y + s->slice.height + thick - 1;
2300 2310
2301 x_setup_relief_colors (s); 2311 x_setup_relief_colors (s);
2302 get_glyph_string_clip_rect (s, &r); 2312 get_glyph_string_clip_rect (s, &r);
2303 x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r); 2313 x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p,
2314 s->slice.y == 0,
2315 s->slice.y + s->slice.height == s->img->height,
2316 s->slice.x == 0,
2317 s->slice.x + s->slice.width == s->img->width,
2318 &r);
2304} 2319}
2305 2320
2306 2321
@@ -2311,21 +2326,22 @@ x_draw_image_foreground_1 (s, pixmap)
2311 struct glyph_string *s; 2326 struct glyph_string *s;
2312 Pixmap pixmap; 2327 Pixmap pixmap;
2313{ 2328{
2314 int x; 2329 int x = 0;
2315 int y = s->ybase - s->y - image_ascent (s->img, s->face); 2330 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
2316 2331
2317 /* If first glyph of S has a left box line, start drawing it to the 2332 /* If first glyph of S has a left box line, start drawing it to the
2318 right of that line. */ 2333 right of that line. */
2319 if (s->face->box != FACE_NO_BOX 2334 if (s->face->box != FACE_NO_BOX
2320 && s->first_glyph->left_box_line_p) 2335 && s->first_glyph->left_box_line_p
2321 x = abs (s->face->box_line_width); 2336 && s->slice.x == 0)
2322 else 2337 x += abs (s->face->box_line_width);
2323 x = 0;
2324 2338
2325 /* If there is a margin around the image, adjust x- and y-position 2339 /* If there is a margin around the image, adjust x- and y-position
2326 by that margin. */ 2340 by that margin. */
2327 x += s->img->hmargin; 2341 if (s->slice.x == 0)
2328 y += s->img->vmargin; 2342 x += s->img->hmargin;
2343 if (s->slice.y == 0)
2344 y += s->img->vmargin;
2329 2345
2330 if (s->img->pixmap) 2346 if (s->img->pixmap)
2331 { 2347 {
@@ -2347,13 +2363,15 @@ x_draw_image_foreground_1 (s, pixmap)
2347 XChangeGC (s->display, s->gc, mask, &xgcv); 2363 XChangeGC (s->display, s->gc, mask, &xgcv);
2348 2364
2349 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, 2365 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc,
2350 0, 0, s->img->width, s->img->height, x, y); 2366 s->slice.x, s->slice.y,
2367 s->slice.width, s->slice.height, x, y);
2351 XSetClipMask (s->display, s->gc, None); 2368 XSetClipMask (s->display, s->gc, None);
2352 } 2369 }
2353 else 2370 else
2354 { 2371 {
2355 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc, 2372 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc,
2356 0, 0, s->img->width, s->img->height, x, y); 2373 s->slice.x, s->slice.y,
2374 s->slice.width, s->slice.height, x, y);
2357 2375
2358 /* When the image has a mask, we can expect that at 2376 /* When the image has a mask, we can expect that at
2359 least part of a mouse highlight or a block cursor will 2377 least part of a mouse highlight or a block cursor will
@@ -2366,14 +2384,15 @@ x_draw_image_foreground_1 (s, pixmap)
2366 int r = s->img->relief; 2384 int r = s->img->relief;
2367 if (r < 0) r = -r; 2385 if (r < 0) r = -r;
2368 XDrawRectangle (s->display, s->window, s->gc, x - r, y - r, 2386 XDrawRectangle (s->display, s->window, s->gc, x - r, y - r,
2369 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 2387 s->slice.width + r*2 - 1,
2388 s->slice.height + r*2 - 1);
2370 } 2389 }
2371 } 2390 }
2372 } 2391 }
2373 else 2392 else
2374 /* Draw a rectangle if image could not be loaded. */ 2393 /* Draw a rectangle if image could not be loaded. */
2375 XDrawRectangle (s->display, pixmap, s->gc, x, y, 2394 XDrawRectangle (s->display, pixmap, s->gc, x, y,
2376 s->img->width - 1, s->img->height - 1); 2395 s->slice.width - 1, s->slice.height - 1);
2377} 2396}
2378 2397
2379 2398
@@ -2415,33 +2434,28 @@ static void
2415x_draw_image_glyph_string (s) 2434x_draw_image_glyph_string (s)
2416 struct glyph_string *s; 2435 struct glyph_string *s;
2417{ 2436{
2418 int x, y;
2419 int box_line_hwidth = abs (s->face->box_line_width); 2437 int box_line_hwidth = abs (s->face->box_line_width);
2420 int box_line_vwidth = max (s->face->box_line_width, 0); 2438 int box_line_vwidth = max (s->face->box_line_width, 0);
2421 int height; 2439 int height;
2422 Pixmap pixmap = None; 2440 Pixmap pixmap = None;
2423 2441
2424 height = s->height - 2 * box_line_vwidth; 2442 height = s->height;
2425 2443 if (s->slice.y == 0)
2444 height -= box_line_vwidth;
2445 if (s->slice.y + s->slice.height >= s->img->height)
2446 height -= box_line_vwidth;
2426 2447
2427 /* Fill background with face under the image. Do it only if row is 2448 /* Fill background with face under the image. Do it only if row is
2428 taller than image or if image has a clip mask to reduce 2449 taller than image or if image has a clip mask to reduce
2429 flickering. */ 2450 flickering. */
2430 s->stippled_p = s->face->stipple != 0; 2451 s->stippled_p = s->face->stipple != 0;
2431 if (height > s->img->height 2452 if (height > s->slice.height
2432 || s->img->hmargin 2453 || s->img->hmargin
2433 || s->img->vmargin 2454 || s->img->vmargin
2434 || s->img->mask 2455 || s->img->mask
2435 || s->img->pixmap == 0 2456 || s->img->pixmap == 0
2436 || s->width != s->background_width) 2457 || s->width != s->background_width)
2437 { 2458 {
2438 if (box_line_hwidth && s->first_glyph->left_box_line_p)
2439 x = s->x + box_line_hwidth;
2440 else
2441 x = s->x;
2442
2443 y = s->y + box_line_vwidth;
2444
2445 if (s->img->mask) 2459 if (s->img->mask)
2446 { 2460 {
2447 /* Create a pixmap as large as the glyph string. Fill it 2461 /* Create a pixmap as large as the glyph string. Fill it
@@ -2480,7 +2494,19 @@ x_draw_image_glyph_string (s)
2480 } 2494 }
2481 } 2495 }
2482 else 2496 else
2483 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height); 2497 {
2498 int x = s->x;
2499 int y = s->y;
2500
2501 if (s->first_glyph->left_box_line_p
2502 && s->slice.x == 0)
2503 x += box_line_hwidth;
2504
2505 if (s->slice.y == 0)
2506 y += box_line_vwidth;
2507
2508 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
2509 }
2484 2510
2485 s->background_filled_p = 1; 2511 s->background_filled_p = 1;
2486 } 2512 }