>From fda76ad237ac01ce398796e02a2a9463027ce7c9 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sat, 23 Dec 2017 11:00:35 +0000 Subject: [PATCH] Allow setting tooltip colors in NS port * src/nsfns.m (Fx_show_tip): Get face colors and apply them to the tooltip. * src/nsmenu.m (EmacsTooltip::setBackgroundColor): (EmacsTooltip::setForegroundColor): New functions. * src/nsterm.h (EmacsTooltip::setBackgroundColor): (EmacsTooltip::setForegroundColor): New function prototypes. --- src/nsfns.m | 10 ++++++++++ src/nsmenu.m | 10 ++++++++++ src/nsterm.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/nsfns.m b/src/nsfns.m index 064b476fb4..05605bf657 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -2873,6 +2873,8 @@ with offset DY added (default is -10). struct frame *f; char *str; NSSize size; + NSColor *color; + Lisp_Object t; specbind (Qinhibit_redisplay, Qt); @@ -2900,6 +2902,14 @@ with offset DY added (default is -10). else Fx_hide_tip (); + t = x_get_arg (NULL, parms, Qbackground_color, NULL, NULL, RES_TYPE_STRING); + if (ns_lisp_to_color (t, &color) == 0) + [ns_tooltip setBackgroundColor: color]; + + t = x_get_arg (NULL, parms, Qforeground_color, NULL, NULL, RES_TYPE_STRING); + if (ns_lisp_to_color (t, &color) == 0) + [ns_tooltip setForegroundColor: color]; + [ns_tooltip setText: str]; size = [ns_tooltip frame].size; diff --git a/src/nsmenu.m b/src/nsmenu.m index d2e102a2a9..63ed4f5d1d 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1373,6 +1373,16 @@ - (void) setText: (char *)text [textField setFrame: r]; } +- (void) setBackgroundColor: (NSColor *)col +{ + [textField setBackgroundColor: col]; +} + +- (void) setForegroundColor: (NSColor *)col +{ + [textField setTextColor: col]; +} + - (void) showAtX: (int)x Y: (int)y for: (int)seconds { NSRect wr = [win frame]; diff --git a/src/nsterm.h b/src/nsterm.h index e669c95931..184ada99ae 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -585,6 +585,8 @@ typedef id instancetype; } - (instancetype) init; - (void) setText: (char *)text; +- (void) setBackgroundColor: (NSColor *)col; +- (void) setForegroundColor: (NSColor *)col; - (void) showAtX: (int)x Y: (int)y for: (int)seconds; - (void) hide; - (BOOL) isActive; -- 2.14.3