3
* Color handling for Mac OS X.
5
* Copyright (c) 1999. See accompanying LEGAL file for details.
11
p_color(p_win *w, unsigned long color)
15
CGContextRef cr = w->cr;
16
if (w->parent) w = w->parent;
21
if (w->color != color) change = 1;
22
/* p_color may be called before p_rect, without p_clip getting
23
* called first. In that case, the focus is not yet locked on the
25
if (s->lockedView != view)
26
{ CGAffineTransform tf = CGContextGetTextMatrix(cr);
28
tf.d = -1.0; /* -1.0 so that text appears upright in a flipped view */
29
CGContextSetTextMatrix(cr, tf);
30
if (s->lockedView) [s->lockedView unlockFocus];
36
/* It seems that Cocoa doesn't support XOR drawing at this point.
37
const int de_xor = (w->color == P_XOR);
38
if (de_xor || color==P_XOR) {
40
SetROP2(w->dc, de_xor? R2_COPYPEN : R2_NOT);
44
if (!P_IS_RGB(color)) {
45
w->components[0] = w->pixels[color][0];
46
w->components[1] = w->pixels[color][1];
47
w->components[2] = w->pixels[color][2];
48
w->components[3] = w->pixels[color][3];
50
w->components[0] = P_R(color) / 255.0;
51
w->components[1] = P_G(color) / 255.0;
52
w->components[2] = P_B(color) / 255.0;
53
w->components[3] = 1.0;
55
CGContextSetStrokeColorSpace(cr, s->colorspace);
56
CGContextSetStrokeColor(cr, w->components);
57
CGContextSetFillColorSpace(cr, s->colorspace);
58
CGContextSetFillColor(cr, w->components);