Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsNativeThemeColors_h_
7 #define nsNativeThemeColors_h_
9 #include "nsCocoaFeatures.h"
10 #import <Cocoa/Cocoa.h>
12 extern "C" {
13 typedef CFTypeRef CUIRendererRef;
14 void CUIDraw(CUIRendererRef r, CGRect rect, CGContextRef ctx, CFDictionaryRef options, CFDictionaryRef* result);
15 }
17 @interface NSWindow(CoreUIRendererPrivate)
18 + (CUIRendererRef)coreUIRenderer;
19 @end
21 enum ColorName {
22 toolbarTopBorderGrey,
23 toolbarFillGrey,
24 toolbarBottomBorderGrey,
25 };
27 static const int sSnowLeopardThemeColors[][2] = {
28 /* { active window, inactive window } */
29 // toolbar:
30 { 0xD0, 0xF1 }, // top separator line
31 { 0xA7, 0xD8 }, // fill color
32 { 0x51, 0x99 }, // bottom separator line
33 };
35 static const int sLionThemeColors[][2] = {
36 /* { active window, inactive window } */
37 // toolbar:
38 { 0xD0, 0xF0 }, // top separator line
39 { 0xB2, 0xE1 }, // fill color
40 { 0x59, 0x87 }, // bottom separator line
41 };
43 __attribute__((unused))
44 static int NativeGreyColorAsInt(ColorName name, BOOL isMain)
45 {
46 if (nsCocoaFeatures::OnLionOrLater())
47 return sLionThemeColors[name][isMain ? 0 : 1];
49 return sSnowLeopardThemeColors[name][isMain ? 0 : 1];
50 }
52 __attribute__((unused))
53 static float NativeGreyColorAsFloat(ColorName name, BOOL isMain)
54 {
55 return NativeGreyColorAsInt(name, isMain) / 255.0f;
56 }
58 __attribute__((unused))
59 static void DrawNativeGreyColorInRect(CGContextRef context, ColorName name,
60 CGRect rect, BOOL isMain)
61 {
62 float grey = NativeGreyColorAsFloat(name, isMain);
63 CGContextSetRGBFillColor(context, grey, grey, grey, 1.0f);
64 CGContextFillRect(context, rect);
65 }
67 #endif // nsNativeThemeColors_h_