summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Rumney <jasonr@gnu.org>2000-11-15 23:48:42 +0000
committerJason Rumney <jasonr@gnu.org>2000-11-15 23:48:42 +0000
commite5fa381b67363460a72e26350fb968bd132f8d6f (patch)
treeccf53c3c879af5e3bffd612f920311cc2373e47c
parent3f6f5e0cbef756114ca706288c849b9d84af4d28 (diff)
downloademacs-e5fa381b67363460a72e26350fb968bd132f8d6f.tar.gz
(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 @@
+2000-11-15 Jason Rumney <jasonr@gnu.org>
+
+ * w32term.c (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.
+
2000-11-15 Gerd Moellmann <gerd@gnu.org>
* 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)
SelectObject (s->hdc, old_font);
}
+
+/* Brightness beyond which a color won't have its highlight brightness
+ boosted.
+
+ Nominally, highlight colors for `3d' faces are calculated by
+ brightening an object's color by a constant scale factor, but this
+ doesn't yield good results for dark colors, so for colors who's
+ brightness is less than this value (on a scale of 0-255) have to
+ use an additional additive factor.
+
+ The value here is set so that the default menu-bar/mode-line color
+ (grey75) will not have its highlights changed at all. */
+#define HIGHLIGHT_COLOR_DARK_BOOST_LIMIT 187
+
+
/* Allocate a color which is lighter or darker than *COLOR by FACTOR
or DELTA. Try a color with RGB values multiplied by FACTOR first.
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)
int delta;
{
COLORREF new;
+ long bright;
+
+ /* On Windows, RGB values are 0-255, not 0-65535, so scale delta. */
+ delta /= 256;
/* Change RGB values by specified FACTOR. Avoid overflow! */
xassert (factor >= 0);
new = PALETTERGB (min (0xff, factor * GetRValue (*color)),
min (0xff, factor * GetGValue (*color)),
min (0xff, factor * GetBValue (*color)));
+
+ /* Calculate brightness of COLOR. */
+ bright = (2 * GetRValue (*color) + 3 * GetGValue (*color)
+ + GetBValue (*color)) / 6;
+
+ /* We only boost colors that are darker than
+ HIGHLIGHT_COLOR_DARK_BOOST_LIMIT. */
+ if (bright < HIGHLIGHT_COLOR_DARK_BOOST_LIMIT)
+ /* Make an additive adjustment to NEW, because it's dark enough so
+ that scaling by FACTOR alone isn't enough. */
+ {
+ /* How far below the limit this color is (0 - 1, 1 being darker). */
+ double dimness = 1 - (double)bright / HIGHLIGHT_COLOR_DARK_BOOST_LIMIT;
+ /* The additive adjustment. */
+ int min_delta = delta * dimness * factor / 2;
+
+ if (factor < 1)
+ new = PALETTERGB (max (0, min (0xff, min_delta - GetRValue (*color))),
+ max (0, min (0xff, min_delta - GetGValue (*color))),
+ max (0, min (0xff, min_delta - GetBValue (*color))));
+ else
+ new = PALETTERGB (max (0, min (0xff, min_delta + GetRValue (*color))),
+ max (0, min (0xff, min_delta + GetGValue (*color))),
+ max (0, min (0xff, min_delta + GetBValue (*color))));
+ }
+
if (new == *color)
new = PALETTERGB (max (0, min (0xff, delta + GetRValue (*color))),
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,
HDC hdc = get_frame_dc (f);
if (raised_p)
- gc.foreground = PALETTERGB (255, 255, 255);
+ gc.foreground = f->output_data.w32->white_relief.gc->foreground;
else
- gc.foreground = PALETTERGB (0, 0, 0);
+ gc.foreground = f->output_data.w32->black_relief.gc->foreground;
w32_set_clip_rectangle (hdc, clip_rect);
@@ -3597,9 +3642,10 @@ w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
w32_set_clip_rectangle (hdc, NULL);
if (raised_p)
- gc.foreground = PALETTERGB (0, 0, 0);
+ gc.foreground = f->output_data.w32->black_relief.gc->foreground;
else
- gc.foreground = PALETTERGB (255, 255, 255);
+ gc.foreground = f->output_data.w32->white_relief.gc->foreground;
+
w32_set_clip_rectangle (hdc, clip_rect);