}
+ (NSColor *)colorWithUnsignedLong:(unsigned long)c
- hasAlpha:(BOOL)alpha
{
EmacsCGFloat a = (double)((c >> 24) & 0xff) / 255.0;
EmacsCGFloat r = (double)((c >> 16) & 0xff) / 255.0;
EmacsCGFloat g = (double)((c >> 8) & 0xff) / 255.0;
EmacsCGFloat b = (double)(c & 0xff) / 255.0;
- return [NSColor colorForEmacsRed:r green:g blue:b
- alpha:(alpha ? a : (EmacsCGFloat)1.0)];
+ return [NSColor colorForEmacsRed:r green:g blue:b alpha:a];
}
- (unsigned long)unsignedLong
========================================================================== */
-NSColor *
-ns_lookup_indexed_color (unsigned long idx, struct frame *f)
-{
- NSMutableArray *color_table = FRAME_DISPLAY_INFO (f)->color_table;
- if (idx < 1 || idx >= [color_table count])
- return nil;
- return [color_table objectAtIndex:idx];
-}
-
-
-unsigned long
-ns_index_color (NSColor *color, struct frame *f)
-{
- NSMutableArray *color_table = FRAME_DISPLAY_INFO (f)->color_table;
-
- /* An index of 0 appears to be special in some way, so insert a
- dummy object. */
- if ([color_table count] == 0)
- [color_table addObject:[NSNull null]];
-
- /* Do we already have this color? */
- if ([color_table containsObject:color])
- return [color_table indexOfObject:color];
-
- [color_table addObject:color];
- return [color_table count] - 1;
-}
-
-
static int
ns_get_color (const char *name, NSColor **col)
/* --------------------------------------------------------------------------
return 1;
}
-/* Convert an index into the color table into an RGBA value. Used in
- xdisp.c:extend_face_to_end_of_line when comparing faces and frame
- color values. */
-
-unsigned long
-ns_color_index_to_rgba(int idx, struct frame *f)
-{
- NSColor *col;
- col = ns_lookup_indexed_color (idx, f);
-
- return [col unsignedLong];
-}
-
void
-ns_query_color(void *col, Emacs_Color *color_def, bool setPixel)
+ns_query_color(void *col, Emacs_Color *color_def)
/* --------------------------------------------------------------------------
- Get ARGB values out of NSColor col and put them into color_def.
- If setPixel, set the pixel to a concatenated version.
- and set color_def pixel to the resulting index.
+ Get ARGB values out of NSColor col and put them into color_def
+ and set color_def pixel to the ARGB color.
-------------------------------------------------------------------------- */
{
EmacsCGFloat r, g, b, a;
color_def->green = g * 65535;
color_def->blue = b * 65535;
- if (setPixel == YES)
- color_def->pixel = [(NSColor *)col unsignedLong];
+ color_def->pixel = [(NSColor *)col unsignedLong];
}
bool
const char *name,
Emacs_Color *color_def,
bool alloc,
- bool makeIndex)
+ bool _makeIndex)
/* --------------------------------------------------------------------------
Return true if named color found, and set color_def rgb accordingly.
- If makeIndex and alloc are nonzero put the color in the color_table,
- and set color_def pixel to the resulting index.
- If makeIndex is zero, set color_def pixel to ARGB.
Return false if not found.
-------------------------------------------------------------------------- */
{
unblock_input ();
return 0;
}
- if (makeIndex && alloc)
- color_def->pixel = ns_index_color (col, f);
- ns_query_color (col, color_def, !makeIndex);
+ ns_query_color (col, color_def);
unblock_input ();
return 1;
}
External (hook): Store F's background color into *BGCOLOR
-------------------------------------------------------------------------- */
{
- ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor, true);
+ ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor);
}
static void
block_input ();
ns_focus (f, &r, 1);
- [ns_lookup_indexed_color (NS_FACE_BACKGROUND
- (FACE_FROM_ID (f, DEFAULT_FACE_ID)), f) set];
+ [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
+ (FACE_FROM_ID (f, DEFAULT_FACE_ID))] set];
NSRectFill (r);
ns_unfocus (f);
r = NSIntersectionRect (r, [view frame]);
ns_focus (f, &r, 1);
- [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f) set];
+ [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
NSRectFill (r);
return;
ns_focus (f, NULL, 1);
- [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f) set];
-
+ [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
NSRectFill (NSMakeRect (0, margin, width, border));
NSRectFill (NSMakeRect (0, 0, border, height));
NSRectFill (NSMakeRect (0, margin, width, border));
NSRect r = NSMakeRect (0, y, FRAME_PIXEL_WIDTH (f), height);
ns_focus (f, &r, 1);
- [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f) set];
+ [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
NSRectFill (NSMakeRect (0, y, width, height));
NSRectFill (NSMakeRect (FRAME_PIXEL_WIDTH (f) - width,
y, width, height));
{
NSTRACE_RECT ("clearRect", clearRect);
- [ns_lookup_indexed_color(face->background, f) set];
+ [[NSColor colorWithUnsignedLong:face->background] set];
NSRectFill (clearRect);
}
[bmp transformUsingAffineTransform:transform];
if (!p->cursor_p)
- bm_color = ns_lookup_indexed_color(face->foreground, f);
+ bm_color = [NSColor colorWithUnsignedLong:face->foreground];
else if (p->overlay_p)
- bm_color = ns_lookup_indexed_color(face->background, f);
+ bm_color = [NSColor colorWithUnsignedLong:face->background];
else
bm_color = f->output_data.ns->cursor_color;
ns_focus (f, &r, 1);
if (face)
- [ns_lookup_indexed_color(face->foreground, f) set];
+ [[NSColor colorWithUnsignedLong:face->foreground] set];
NSRectFill(r);
ns_unfocus (f);
/* A vertical divider, at least three pixels wide: Draw first and
last pixels differently. */
{
- [ns_lookup_indexed_color(color_first, f) set];
+ [[NSColor colorWithUnsignedLong:color_first] set];
NSRectFill(NSMakeRect (x0, y0, 1, y1 - y0));
- [ns_lookup_indexed_color(color, f) set];
+ [[NSColor colorWithUnsignedLong:color] set];
NSRectFill(NSMakeRect (x0 + 1, y0, x1 - x0 - 2, y1 - y0));
- [ns_lookup_indexed_color(color_last, f) set];
+ [[NSColor colorWithUnsignedLong:color_last] set];
NSRectFill(NSMakeRect (x1 - 1, y0, 1, y1 - y0));
}
else if ((x1 - x0 > y1 - y0) && (y1 - y0 >= 3))
/* A horizontal divider, at least three pixels high: Draw first and
last pixels differently. */
{
- [ns_lookup_indexed_color(color_first, f) set];
+ [[NSColor colorWithUnsignedLong:color_first] set];
NSRectFill(NSMakeRect (x0, y0, x1 - x0, 1));
- [ns_lookup_indexed_color(color, f) set];
+ [[NSColor colorWithUnsignedLong:color] set];
NSRectFill(NSMakeRect (x0, y0 + 1, x1 - x0, y1 - y0 - 2));
- [ns_lookup_indexed_color(color_last, f) set];
+ [[NSColor colorWithUnsignedLong:color_last] set];
NSRectFill(NSMakeRect (x0, y1 - 1, x1 - x0, 1));
}
else
{
/* In any other case do not draw the first and last pixels
differently. */
- [ns_lookup_indexed_color(color, f) set];
+ [[NSColor colorWithUnsignedLong:color] set];
NSRectFill(divider);
}
if (s->face->underline == FACE_UNDER_WAVE)
{
if (!face->underline_defaulted_p)
- [ns_lookup_indexed_color (face->underline_color, s->f) set];
+ [[NSColor colorWithUnsignedLong:face->underline_color] set];
ns_draw_underwave (s, width, x);
}
r = NSMakeRect (x, s->ybase + position, width, thickness);
if (!face->underline_defaulted_p)
- [ns_lookup_indexed_color (face->underline_color, s->f) set];
+ [[NSColor colorWithUnsignedLong:face->underline_color] set];
+
NSRectFill (r);
}
}
r = NSMakeRect (x, s->y, width, 1);
if (!face->overline_color_defaulted_p)
- [ns_lookup_indexed_color (face->overline_color, s->f) set];
+ [[NSColor colorWithUnsignedLong:face->overline_color] set];
NSRectFill (r);
}
r = NSMakeRect (x, glyph_y + dy, width, 1);
if (!face->strike_through_color_defaulted_p)
- [ns_lookup_indexed_color (face->strike_through_color, s->f) set];
+ [[NSColor colorWithUnsignedLong:face->strike_through_color] set];
NSRectFill (r);
}
if (s->face->use_box_color_for_shadows_p)
{
- newBaseCol = ns_lookup_indexed_color (s->face->box_color, s->f);
+ newBaseCol = [NSColor colorWithUnsignedLong:s->face->box_color];
}
/* else if (s->first_glyph->type == IMAGE_GLYPH
&& s->img->pixmap
} */
else
{
- newBaseCol = ns_lookup_indexed_color (s->face->background, s->f);
+ newBaseCol = [NSColor colorWithUnsignedLong:s->face->background];
}
if (newBaseCol == nil)
if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
{
ns_draw_box (r, abs (hthickness), abs (vthickness),
- ns_lookup_indexed_color (face->box_color, s->f),
+ [NSColor colorWithUnsignedLong:face->box_color],
left_p, right_p);
}
else
{
if (s->hl != DRAW_CURSOR)
[(NS_FACE_BACKGROUND (face) != 0
- ? ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f)
+ ? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
: FRAME_BACKGROUND_COLOR (s->f)) set];
else
[FRAME_CURSOR_COLOR (s->f) set];
otherwise, since we composite the image under NS (instead of mucking
with its background color), we must clear just the image area. */
- [ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) set];
+ [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin
|| s->img->mask || s->img->pixmap == 0 || s->width != s->background_width)
if (s->hl == DRAW_CURSOR)
{
[FRAME_CURSOR_COLOR (s->f) set];
- tdCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
+ tdCol = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)];
}
else
{
- tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
+ tdCol = [NSColor colorWithUnsignedLong:NS_FACE_FOREGROUND (face)];
}
/* Draw underline, overline, strike-through. */
face = s->face;
- bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
- fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
+ bgCol = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)];
+ fgCol = [NSColor colorWithUnsignedLong:NS_FACE_FOREGROUND (face)];
if (s->hl == DRAW_CURSOR)
{
{
NSColor *col = (NS_FACE_FOREGROUND (s->face) != 0
- ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (s->face),
- s->f)
+ ? [NSColor colorWithUnsignedLong:NS_FACE_FOREGROUND (s->face)]
: FRAME_FOREGROUND_COLOR (s->f));
/* Draw underline, overline, strike-through. */
{
NSColor *fg_color;
- fg_color = ns_lookup_indexed_color (NS_FACE_FOREGROUND (s->face), s->f);
+ fg_color = [NSColor colorWithUnsignedLong:NS_FACE_FOREGROUND (s->face)];
ns_draw_text_decoration (s, s->face, fg_color,
s->background_width, s->x);
}
&& ![NSCalibratedWhiteColorSpace isEqualToString:
NSColorSpaceFromDepth (depth)];
dpyinfo->n_planes = NSBitsPerPixelFromDepth (depth);
- dpyinfo->color_table = [[NSMutableArray array] retain];
dpyinfo->root_window = 42; /* A placeholder. */
dpyinfo->highlight_frame = dpyinfo->ns_focus_frame = NULL;
dpyinfo->n_fonts = 0;
ns_delete_display (struct ns_display_info *dpyinfo)
{
/* TODO... */
- [dpyinfo->color_table release];
}
color = XCAR (color_map);
name = XCAR (color);
c = XFIXNUM (XCDR (color));
+ c |= 0xFF000000;
[cl setColor:
- [NSColor colorWithUnsignedLong:c hasAlpha:NO]
+ [NSColor colorWithUnsignedLong:c]
forKey: [NSString stringWithLispString: name]];
}
onFirstScreen = [[w screen] isEqual:[[NSScreen screens] objectAtIndex:0]];
f = emacsframe;
wr = [w frame];
- col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
- (FACE_FROM_ID (f, DEFAULT_FACE_ID)),
- f);
+ col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
+ (FACE_FROM_ID (f, DEFAULT_FACE_ID))];
if (fs_state != FULLSCREEN_BOTH)
{
f->border_width = [self borderWidth];
- col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
- (FACE_FROM_ID (f, DEFAULT_FACE_ID)),
- f);
+ col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
+ (FACE_FROM_ID (f, DEFAULT_FACE_ID))];
[self setBackgroundColor:col];
if ([col alphaComponent] != (EmacsCGFloat) 1.0)
[self setOpaque:NO];