diff options
author | marc_culler <marc.culler@gmail.com> | 2020-11-09 16:06:51 (GMT) |
---|---|---|
committer | marc_culler <marc.culler@gmail.com> | 2020-11-09 16:06:51 (GMT) |
commit | 4621757eccd06843ee0a0b7b6d35f0e673ac6f25 (patch) | |
tree | 74f6f3164029665a5aee8bc95f2fb77b6256f1c8 /macosx/tkMacOSXColor.c | |
parent | 167c8ef54e27e04346e18429ebc4688b954bf3ee (diff) | |
download | tk-4621757eccd06843ee0a0b7b6d35f0e673ac6f25.zip tk-4621757eccd06843ee0a0b7b6d35f0e673ac6f25.tar.gz tk-4621757eccd06843ee0a0b7b6d35f0e673ac6f25.tar.bz2 |
Remove some more unneeded code.
Diffstat (limited to 'macosx/tkMacOSXColor.c')
-rw-r--r-- | macosx/tkMacOSXColor.c | 52 |
1 files changed, 10 insertions, 42 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index d3c76e5..82fc572 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -282,6 +282,7 @@ GetRGBA( if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; } + switch (entry->type) { case rgbColor: rgba[0] = ((pixel >> 16) & 0xff) / 255.0; @@ -455,22 +456,21 @@ TkMacOSXInDarkMode(Tk_Window tkwin) * Sets the components of a CGColorRef from an XColor pixel value. The * pixel value is used to look up the color in the system color table, and * then SetCGColorComponents is called with the table entry and the pixel - * value. + * value. The parameter macColor should be a pointer to a CGColorRef. * * Results: * Returns false if the color is not found, true otherwise. * * Side effects: - * The variable macColor is set to a new CGColorRef, the caller is - * responsible for releasing it! + * The CGColorRef referenced by the variable macColor may be modified. * *---------------------------------------------------------------------- */ int TkSetMacColor( - unsigned long pixel, /* Pixel value to convert. */ - void *macColor) /* CGColorRef to modify. */ + unsigned long pixel, /* Pixel value to convert. */ + void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; SystemColorDatum *entry = GetEntryFromPixel(pixel); @@ -485,32 +485,6 @@ TkSetMacColor( /* *---------------------------------------------------------------------- * - * TkMacOSXCreateCGColor -- - * - * Creates a CGColorRef from a X style pixel value. - * - * Results: - * Returns NULL if not a real pixel, CGColorRef otherwise. - * - * Side effects: - * None - * - *---------------------------------------------------------------------- - */ - -CGColorRef -TkMacOSXCreateCGColor( - GC gc, - unsigned long pixel) /* Pixel value to convert. */ -{ - CGColorRef cgColor; - TkSetMacColor(pixel, &cgColor); - return cgColor; -} - -/* - *---------------------------------------------------------------------- - * * TkMacOSXGetNSColor -- * * Creates an autoreleased NSColor from a X style pixel value. @@ -530,19 +504,13 @@ TkMacOSXGetNSColor( GC gc, unsigned long pixel) /* Pixel value to convert. */ { - CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel); + CGColorRef cgColor; NSColor *nsColor = nil; - if (cgColor) { - NSColorSpace *colorSpace = [[NSColorSpace alloc] - initWithCGColorSpace:CGColorGetColorSpace(cgColor)]; - - nsColor = [NSColor colorWithColorSpace:colorSpace - components:CGColorGetComponents(cgColor) - count:CGColorGetNumberOfComponents(cgColor)]; - [colorSpace release]; - CFRelease(cgColor); - } + TkSetMacColor(pixel, &cgColor); + nsColor = [NSColor colorWithColorSpace:sRGB + components:CGColorGetComponents(cgColor) + count:CGColorGetNumberOfComponents(cgColor)]; return nsColor; } |