comparison src/redisplay-msw.c @ 294:4b85ae5eabfb r21-0b45

Import from CVS: tag r21-0b45
author cvs
date Mon, 13 Aug 2007 10:38:01 +0200
parents e11d67e05968
children 8626e4521993
comparison
equal deleted inserted replaced
293:403535bfea94 294:4b85ae5eabfb
238 } 238 }
239 } 239 }
240 240
241 241
242 /***************************************************************************** 242 /*****************************************************************************
243 mswindows_apply_face_effects
244
245 Draw underline and strikeout as if this was X.
246 #### On mswindows this really should be done as part of drawing the font.
247 The line width used is chosen arbitrarily from the font height.
248 ****************************************************************************/
249 static void
250 mswindows_apply_face_effects (HDC hdc, struct display_line *dl, int xpos,
251 int width, struct Lisp_Font_Instance *fi,
252 struct face_cachel *cachel,
253 struct face_cachel *color_cachel)
254 {
255 int yclip;
256 HBRUSH brush, oldbrush;
257 RECT rect;
258
259 brush = CreateSolidBrush (COLOR_INSTANCE_MSWINDOWS_COLOR (
260 XCOLOR_INSTANCE (color_cachel->foreground)));
261 if (brush)
262 {
263 yclip = dl->ypos + dl->descent - dl->clip;
264 rect.left = xpos;
265 rect.right = xpos + width;
266 oldbrush = SelectObject (hdc, brush);
267
268 if (cachel->underline)
269 {
270 rect.top = dl->ypos + dl->descent/2;
271 rect.bottom = rect.top + (fi->height >= 0x20 ? 2 : 1);
272 if (rect.bottom <= yclip)
273 FillRect (hdc, &rect, brush);
274 }
275 if (cachel->strikethru)
276 {
277 rect.top = dl->ypos + dl->descent - (dl->ascent + dl->descent)/2;
278 rect.bottom = rect.top + (fi->height >= 0x20 ? 2 : 1);
279 if (rect.bottom <= yclip)
280 FillRect (hdc, &rect, brush);
281 }
282
283 SelectObject (hdc, oldbrush);
284 DeleteObject (brush);
285 }
286 }
287
288
289 /*****************************************************************************
243 mswindows_output_hline 290 mswindows_output_hline
244 291
245 Output a horizontal line in the foreground of its face. 292 Output a horizontal line in the foreground of its face.
246 ****************************************************************************/ 293 ****************************************************************************/
247 static void 294 static void
324 if (real_char_p) 371 if (real_char_p)
325 { 372 {
326 /* Use the font from the underlying character */ 373 /* Use the font from the underlying character */
327 cachel = WINDOW_FACE_CACHEL (w, findex); 374 cachel = WINDOW_FACE_CACHEL (w, findex);
328 375
329 /* XXX MULE: Need to know the charset! */ 376 /* #### MULE: Need to know the charset! */
330 font = FACE_CACHEL_FONT (cachel, Vcharset_ascii); 377 font = FACE_CACHEL_FONT (cachel, Vcharset_ascii);
331 } 378 }
332 379
333 if ((focus || bar_p) && real_char_p) 380 if ((focus || bar_p) && real_char_p)
334 { 381 {
336 n_char = 1; 383 n_char = 1;
337 } 384 }
338 385
339 if (!image_p) 386 if (!image_p)
340 { 387 {
388 struct face_cachel *color_cachel;
389
341 /* Use cursor fg/bg for block cursor, or character fg/bg for the bar 390 /* Use cursor fg/bg for block cursor, or character fg/bg for the bar
342 or when we need to erase the cursor. Output nothing at eol if bar 391 or when we need to erase the cursor. Output nothing at eol if bar
343 cursor */ 392 cursor */
344 face_index = get_builtin_face_cache_index (w, Vtext_cursor_face); 393 face_index = get_builtin_face_cache_index (w, Vtext_cursor_face);
345 cachel = WINDOW_FACE_CACHEL (w, ((!cursor_p || bar_p) 394 color_cachel = WINDOW_FACE_CACHEL (w, ((!cursor_p || bar_p) ?
346 ? findex : face_index)); 395 findex : face_index));
347 mswindows_update_dc (hdc, font, cachel->foreground, 396 mswindows_update_dc (hdc, font, color_cachel->foreground,
348 cachel->background, Qnil); 397 color_cachel->background, Qnil);
349 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect, p_char, n_char, NULL); 398 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect, p_char, n_char, NULL);
399 if (real_char_p && (cachel->underline || cachel->strikethru))
400 mswindows_apply_face_effects (hdc, dl, xpos, width,
401 XFONT_INSTANCE (font),
402 cachel, color_cachel);
350 } 403 }
351 404
352 if (!cursor_p) 405 if (!cursor_p)
353 return; 406 return;
354 407
360 mswindows_update_dc (hdc, Qnil, Qnil, cachel->background, Qnil); 413 mswindows_update_dc (hdc, Qnil, Qnil, cachel->background, Qnil);
361 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE, &rect, NULL, 0, NULL); 414 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE, &rect, NULL, 0, NULL);
362 } 415 }
363 else if (!focus) 416 else if (!focus)
364 { 417 {
365 /* Now have real character drawn in its own color. We defalte 418 /* Now have real character drawn in its own color. We deflate
366 the rectangle so character cell will be bounded by the 419 the rectangle so character cell will be bounded by the
367 previously drawn cursor shape */ 420 previously drawn cursor shape */
368 InflateRect (&rect, -1, -1); 421 InflateRect (&rect, -1, -1);
369 422
370 if (real_char_p) 423 if (real_char_p)
377 cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? findex : face_index)); 430 cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? findex : face_index));
378 mswindows_update_dc (hdc, Qnil, cachel->foreground, 431 mswindows_update_dc (hdc, Qnil, cachel->foreground,
379 cachel->background, Qnil); 432 cachel->background, Qnil);
380 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED, 433 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED,
381 &rect, p_char, n_char, NULL); 434 &rect, p_char, n_char, NULL);
435 if (cachel->underline || cachel->strikethru)
436 mswindows_apply_face_effects (hdc, dl, xpos+1, width-2,
437 XFONT_INSTANCE (font),
438 cachel, cachel);
382 } 439 }
383 } 440 }
384 441
385 442
386 /***************************************************************************** 443 /*****************************************************************************
426 RECT rect; 483 RECT rect;
427 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex); 484 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
428 485
429 XSETWINDOW (window, w); 486 XSETWINDOW (window, w);
430 487
431 #if 0 /* XXX: FIXME? */ 488 #if 0 /* #### FIXME? */
432 /* We can't work out the width before we've set the font in the DC */ 489 /* We can't work out the width before we've set the font in the DC */
433 if (width < 0) 490 if (width < 0)
434 width = mswindows_text_width (cachel, Dynarr_atp (buf, 0), Dynarr_length (buf)); 491 width = mswindows_text_width (cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
435 #else 492 #else
436 assert(width>=0); 493 assert(width>=0);
506 references */ 563 references */
507 cachel = WINDOW_FACE_CACHEL (w, findex); 564 cachel = WINDOW_FACE_CACHEL (w, findex);
508 } 565 }
509 } 566 }
510 567
511 assert (runs[i].dimension == 1); /* XXX FIXME */ 568 assert (runs[i].dimension == 1); /* #### FIXME: Broken when Mule? */
512 ExtTextOut (hdc, xpos, dl->ypos, 569 ExtTextOut (hdc, xpos, dl->ypos,
513 NILP(bg_pmap) ? ETO_CLIPPED | ETO_OPAQUE : ETO_CLIPPED, 570 NILP(bg_pmap) ? ETO_CLIPPED | ETO_OPAQUE : ETO_CLIPPED,
514 &rect, (char *) runs[i].ptr, runs[i].len, NULL); 571 &rect, (char *) runs[i].ptr, runs[i].len, NULL);
515 572
516 /* XXX FIXME? X does underline/strikethrough here 573 /* #### X does underline/strikethrough here so we do the same.
517 we will do it as part of face's font */ 574 On mswindows, underline/strikethrough really belongs to the font */
518 575 if (cachel->underline || cachel->strikethru)
576 mswindows_apply_face_effects (hdc, dl, xpos, this_width, fi,
577 cachel, cachel);
519 xpos += this_width; 578 xpos += this_width;
520 } 579 }
521 } 580 }
522 581
523 static void 582 static void