aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Rumney2000-11-15 23:48:42 +0000
committerJason Rumney2000-11-15 23:48:42 +0000
commite5fa381b67363460a72e26350fb968bd132f8d6f (patch)
treeccf53c3c879af5e3bffd612f920311cc2373e47c
parent3f6f5e0cbef756114ca706288c849b9d84af4d28 (diff)
downloademacs-e5fa381b67363460a72e26350fb968bd132f8d6f.tar.gz
emacs-e5fa381b67363460a72e26350fb968bd132f8d6f.zip
(HIGHLIGHT_COLOR_DARK_BOOST_LIMIT): New constant.
(w32_alloc_lighter_color): Use new brightness calculations from xterm.c. Scale delta to be in the range expected by W32. (w32_draw_relief_rect): Use frame relief colors.
-rw-r--r--src/ChangeLog7
-rw-r--r--src/w32term.c54
2 files changed, 57 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 477002db4f1..0e770d811c7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12000-11-15 Jason Rumney <jasonr@gnu.org>
2
3 * w32term.c (HIGHLIGHT_COLOR_DARK_BOOST_LIMIT): New constant.
4 (w32_alloc_lighter_color): Use new brightness calculations from
5 xterm.c. Scale delta to be in the range expected by W32.
6 (w32_draw_relief_rect): Use frame relief colors.
7
12000-11-15 Gerd Moellmann <gerd@gnu.org> 82000-11-15 Gerd Moellmann <gerd@gnu.org>
2 9
3 * frame.c (syms_of_frame_1): Removed; code moved to syms_of_frame. 10 * frame.c (syms_of_frame_1): Removed; code moved to syms_of_frame.
diff --git a/src/w32term.c b/src/w32term.c
index fe2ae116ac1..c5161b489c7 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3441,6 +3441,21 @@ x_draw_composite_glyph_string_foreground (s)
3441 SelectObject (s->hdc, old_font); 3441 SelectObject (s->hdc, old_font);
3442} 3442}
3443 3443
3444
3445/* Brightness beyond which a color won't have its highlight brightness
3446 boosted.
3447
3448 Nominally, highlight colors for `3d' faces are calculated by
3449 brightening an object's color by a constant scale factor, but this
3450 doesn't yield good results for dark colors, so for colors who's
3451 brightness is less than this value (on a scale of 0-255) have to
3452 use an additional additive factor.
3453
3454 The value here is set so that the default menu-bar/mode-line color
3455 (grey75) will not have its highlights changed at all. */
3456#define HIGHLIGHT_COLOR_DARK_BOOST_LIMIT 187
3457
3458
3444/* Allocate a color which is lighter or darker than *COLOR by FACTOR 3459/* Allocate a color which is lighter or darker than *COLOR by FACTOR
3445 or DELTA. Try a color with RGB values multiplied by FACTOR first. 3460 or DELTA. Try a color with RGB values multiplied by FACTOR first.
3446 If this produces the same color as COLOR, try a color where all RGB 3461 If this produces the same color as COLOR, try a color where all RGB
@@ -3456,12 +3471,42 @@ w32_alloc_lighter_color (f, color, factor, delta)
3456 int delta; 3471 int delta;
3457{ 3472{
3458 COLORREF new; 3473 COLORREF new;
3474 long bright;
3475
3476 /* On Windows, RGB values are 0-255, not 0-65535, so scale delta. */
3477 delta /= 256;
3459 3478
3460 /* Change RGB values by specified FACTOR. Avoid overflow! */ 3479 /* Change RGB values by specified FACTOR. Avoid overflow! */
3461 xassert (factor >= 0); 3480 xassert (factor >= 0);
3462 new = PALETTERGB (min (0xff, factor * GetRValue (*color)), 3481 new = PALETTERGB (min (0xff, factor * GetRValue (*color)),
3463 min (0xff, factor * GetGValue (*color)), 3482 min (0xff, factor * GetGValue (*color)),
3464 min (0xff, factor * GetBValue (*color))); 3483 min (0xff, factor * GetBValue (*color)));
3484
3485 /* Calculate brightness of COLOR. */
3486 bright = (2 * GetRValue (*color) + 3 * GetGValue (*color)
3487 + GetBValue (*color)) / 6;
3488
3489 /* We only boost colors that are darker than
3490 HIGHLIGHT_COLOR_DARK_BOOST_LIMIT. */
3491 if (bright < HIGHLIGHT_COLOR_DARK_BOOST_LIMIT)
3492 /* Make an additive adjustment to NEW, because it's dark enough so
3493 that scaling by FACTOR alone isn't enough. */
3494 {
3495 /* How far below the limit this color is (0 - 1, 1 being darker). */
3496 double dimness = 1 - (double)bright / HIGHLIGHT_COLOR_DARK_BOOST_LIMIT;
3497 /* The additive adjustment. */
3498 int min_delta = delta * dimness * factor / 2;
3499
3500 if (factor < 1)
3501 new = PALETTERGB (max (0, min (0xff, min_delta - GetRValue (*color))),
3502 max (0, min (0xff, min_delta - GetGValue (*color))),
3503 max (0, min (0xff, min_delta - GetBValue (*color))));
3504 else
3505 new = PALETTERGB (max (0, min (0xff, min_delta + GetRValue (*color))),
3506 max (0, min (0xff, min_delta + GetGValue (*color))),
3507 max (0, min (0xff, min_delta + GetBValue (*color))));
3508 }
3509
3465 if (new == *color) 3510 if (new == *color)
3466 new = PALETTERGB (max (0, min (0xff, delta + GetRValue (*color))), 3511 new = PALETTERGB (max (0, min (0xff, delta + GetRValue (*color))),
3467 max (0, min (0xff, delta + GetGValue (*color))), 3512 max (0, min (0xff, delta + GetGValue (*color))),
@@ -3571,9 +3616,9 @@ w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
3571 HDC hdc = get_frame_dc (f); 3616 HDC hdc = get_frame_dc (f);
3572 3617
3573 if (raised_p) 3618 if (raised_p)
3574 gc.foreground = PALETTERGB (255, 255, 255); 3619 gc.foreground = f->output_data.w32->white_relief.gc->foreground;
3575 else 3620 else
3576 gc.foreground = PALETTERGB (0, 0, 0); 3621 gc.foreground = f->output_data.w32->black_relief.gc->foreground;
3577 3622
3578 w32_set_clip_rectangle (hdc, clip_rect); 3623 w32_set_clip_rectangle (hdc, clip_rect);
3579 3624
@@ -3597,9 +3642,10 @@ w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
3597 w32_set_clip_rectangle (hdc, NULL); 3642 w32_set_clip_rectangle (hdc, NULL);
3598 3643
3599 if (raised_p) 3644 if (raised_p)
3600 gc.foreground = PALETTERGB (0, 0, 0); 3645 gc.foreground = f->output_data.w32->black_relief.gc->foreground;
3601 else 3646 else
3602 gc.foreground = PALETTERGB (255, 255, 255); 3647 gc.foreground = f->output_data.w32->white_relief.gc->foreground;
3648
3603 3649
3604 w32_set_clip_rectangle (hdc, clip_rect); 3650 w32_set_clip_rectangle (hdc, clip_rect);
3605 3651