michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsNativeThemeColors_h_ michael@0: #define nsNativeThemeColors_h_ michael@0: michael@0: #include "nsCocoaFeatures.h" michael@0: #import michael@0: michael@0: extern "C" { michael@0: typedef CFTypeRef CUIRendererRef; michael@0: void CUIDraw(CUIRendererRef r, CGRect rect, CGContextRef ctx, CFDictionaryRef options, CFDictionaryRef* result); michael@0: } michael@0: michael@0: @interface NSWindow(CoreUIRendererPrivate) michael@0: + (CUIRendererRef)coreUIRenderer; michael@0: @end michael@0: michael@0: enum ColorName { michael@0: toolbarTopBorderGrey, michael@0: toolbarFillGrey, michael@0: toolbarBottomBorderGrey, michael@0: }; michael@0: michael@0: static const int sSnowLeopardThemeColors[][2] = { michael@0: /* { active window, inactive window } */ michael@0: // toolbar: michael@0: { 0xD0, 0xF1 }, // top separator line michael@0: { 0xA7, 0xD8 }, // fill color michael@0: { 0x51, 0x99 }, // bottom separator line michael@0: }; michael@0: michael@0: static const int sLionThemeColors[][2] = { michael@0: /* { active window, inactive window } */ michael@0: // toolbar: michael@0: { 0xD0, 0xF0 }, // top separator line michael@0: { 0xB2, 0xE1 }, // fill color michael@0: { 0x59, 0x87 }, // bottom separator line michael@0: }; michael@0: michael@0: __attribute__((unused)) michael@0: static int NativeGreyColorAsInt(ColorName name, BOOL isMain) michael@0: { michael@0: if (nsCocoaFeatures::OnLionOrLater()) michael@0: return sLionThemeColors[name][isMain ? 0 : 1]; michael@0: michael@0: return sSnowLeopardThemeColors[name][isMain ? 0 : 1]; michael@0: } michael@0: michael@0: __attribute__((unused)) michael@0: static float NativeGreyColorAsFloat(ColorName name, BOOL isMain) michael@0: { michael@0: return NativeGreyColorAsInt(name, isMain) / 255.0f; michael@0: } michael@0: michael@0: __attribute__((unused)) michael@0: static void DrawNativeGreyColorInRect(CGContextRef context, ColorName name, michael@0: CGRect rect, BOOL isMain) michael@0: { michael@0: float grey = NativeGreyColorAsFloat(name, isMain); michael@0: CGContextSetRGBFillColor(context, grey, grey, grey, 1.0f); michael@0: CGContextFillRect(context, rect); michael@0: } michael@0: michael@0: #endif // nsNativeThemeColors_h_