1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ui/native_theme/fallback_theme.h"
6
7#include "base/basictypes.h"
8#include "base/logging.h"
9#include "ui/gfx/color_utils.h"
10#include "ui/gfx/skia_utils_gtk.h"
11#include "ui/native_theme/common_theme.h"
12
13namespace ui {
14
15FallbackTheme::FallbackTheme() {
16}
17
18FallbackTheme::~FallbackTheme() {
19}
20
21SkColor FallbackTheme::GetSystemColor(ColorId color_id) const {
22  // This implementation returns hardcoded colors.
23
24  static const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
25  // Menu:
26  static const SkColor kMenuBackgroundColor = SK_ColorWHITE;
27  // Windows:
28  static const SkColor kWindowBackgroundColor = SK_ColorWHITE;
29  // Dialogs:
30  static const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251);
31  // FocusableBorder:
32  static const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE);
33  static const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9);
34  // Button:
35  static const SkColor kButtonBackgroundColor = SkColorSetRGB(0xDE, 0xDE, 0xDE);
36  static const SkColor kButtonEnabledColor = SkColorSetRGB(0x22, 0x22, 0x22);
37  static const SkColor kButtonDisabledColor = SkColorSetRGB(0x99, 0x99, 0x99);
38  static const SkColor kButtonHighlightColor = SkColorSetRGB(0, 0, 0);
39  static const SkColor kButtonHoverColor = kButtonEnabledColor;
40  // MenuItem:
41  static const SkColor kEnabledMenuItemForegroundColor = kButtonEnabledColor;
42  static const SkColor kDisabledMenuItemForegroundColor = kButtonDisabledColor;
43  static const SkColor kFocusedMenuItemBackgroundColor =
44      SkColorSetRGB(0xF1, 0xF1, 0xF1);
45  static const SkColor kHoverMenuItemBackgroundColor =
46      SkColorSetARGB(204, 255, 255, 255);
47  static const SkColor kMenuSeparatorColor = SkColorSetRGB(0xED, 0xED, 0xED);
48  static const SkColor kEnabledMenuButtonBorderColor =
49      SkColorSetARGB(36, 0, 0, 0);
50  static const SkColor kFocusedMenuButtonBorderColor =
51      SkColorSetARGB(72, 0, 0, 0);
52  static const SkColor kHoverMenuButtonBorderColor =
53      SkColorSetARGB(72, 0, 0, 0);
54  // Label:
55  static const SkColor kLabelEnabledColor = kButtonEnabledColor;
56  static const SkColor kLabelDisabledColor = kButtonDisabledColor;
57  static const SkColor kLabelBackgroundColor = SK_ColorWHITE;
58  // Textfield:
59  static const SkColor kTextfieldDefaultColor = SK_ColorBLACK;
60  static const SkColor kTextfieldDefaultBackground = SK_ColorWHITE;
61  static const SkColor kTextfieldReadOnlyColor = SK_ColorDKGRAY;
62  static const SkColor kTextfieldReadOnlyBackground = SK_ColorWHITE;
63  static const SkColor kTextfieldSelectionBackgroundFocused =
64      SkColorSetARGB(0x54, 0x60, 0xA8, 0xEB);
65  static const SkColor kTextfieldSelectionColor =
66      color_utils::AlphaBlend(SK_ColorBLACK,
67          kTextfieldSelectionBackgroundFocused, 0xdd);
68  // Tree
69  static const SkColor kTreeBackground = SK_ColorWHITE;
70  static const SkColor kTreeTextColor = SK_ColorBLACK;
71  static const SkColor kTreeSelectedTextColor = SK_ColorBLACK;
72  static const SkColor kTreeSelectionBackgroundColor =
73      SkColorSetRGB(0xEE, 0xEE, 0xEE);
74  static const SkColor kTreeArrowColor = SkColorSetRGB(0x7A, 0x7A, 0x7A);
75  // Table
76  static const SkColor kTableBackground = SK_ColorWHITE;
77  static const SkColor kTableTextColor = SK_ColorBLACK;
78  static const SkColor kTableSelectedTextColor = SK_ColorBLACK;
79  static const SkColor kTableSelectionBackgroundColor =
80      SkColorSetRGB(0xEE, 0xEE, 0xEE);
81  static const SkColor kTableGroupingIndicatorColor =
82      SkColorSetRGB(0xCC, 0xCC, 0xCC);
83
84  SkColor color;
85  if (CommonThemeGetSystemColor(color_id, &color))
86    return color;
87
88  switch (color_id) {
89    // Windows
90    case kColorId_WindowBackground:
91      return kWindowBackgroundColor;
92
93    // Dialogs
94    case kColorId_DialogBackground:
95      return kDialogBackgroundColor;
96
97    // FocusableBorder
98    case kColorId_FocusedBorderColor:
99      return kFocusedBorderColor;
100    case kColorId_UnfocusedBorderColor:
101      return kUnfocusedBorderColor;
102
103    // Button
104    case kColorId_ButtonBackgroundColor:
105      return kButtonBackgroundColor;
106    case kColorId_ButtonEnabledColor:
107      return kButtonEnabledColor;
108    case kColorId_ButtonDisabledColor:
109      return kButtonDisabledColor;
110    case kColorId_ButtonHighlightColor:
111      return kButtonHighlightColor;
112    case kColorId_ButtonHoverColor:
113      return kButtonHoverColor;
114
115    // MenuItem
116    case kColorId_EnabledMenuItemForegroundColor:
117      return kEnabledMenuItemForegroundColor;
118    case kColorId_DisabledMenuItemForegroundColor:
119      return kDisabledMenuItemForegroundColor;
120    case kColorId_SelectedMenuItemForegroundColor:
121      return kEnabledMenuItemForegroundColor;
122    case kColorId_FocusedMenuItemBackgroundColor:
123      return kFocusedMenuItemBackgroundColor;
124    case kColorId_HoverMenuItemBackgroundColor:
125      return kHoverMenuItemBackgroundColor;
126    case kColorId_MenuSeparatorColor:
127      return kMenuSeparatorColor;
128    case kColorId_EnabledMenuButtonBorderColor:
129      return kEnabledMenuButtonBorderColor;
130    case kColorId_FocusedMenuButtonBorderColor:
131      return kFocusedMenuButtonBorderColor;
132    case kColorId_HoverMenuButtonBorderColor:
133      return kHoverMenuButtonBorderColor;
134
135    // Label
136    case kColorId_LabelEnabledColor:
137      return kLabelEnabledColor;
138    case kColorId_LabelDisabledColor:
139      return kLabelDisabledColor;
140    case kColorId_LabelBackgroundColor:
141      return kLabelBackgroundColor;
142
143    // Textfield
144    case kColorId_TextfieldDefaultColor:
145      return kTextfieldDefaultColor;
146    case kColorId_TextfieldDefaultBackground:
147      return kTextfieldDefaultBackground;
148    case kColorId_TextfieldReadOnlyColor:
149      return kTextfieldReadOnlyColor;
150    case kColorId_TextfieldReadOnlyBackground:
151      return kTextfieldReadOnlyBackground;
152    case kColorId_TextfieldSelectionColor:
153      return kTextfieldSelectionColor;
154    case kColorId_TextfieldSelectionBackgroundFocused:
155      return kTextfieldSelectionBackgroundFocused;
156
157    // Tree
158    case kColorId_TreeBackground:
159      return kTreeBackground;
160    case kColorId_TreeText:
161      return kTreeTextColor;
162    case kColorId_TreeSelectedText:
163    case kColorId_TreeSelectedTextUnfocused:
164      return kTreeSelectedTextColor;
165    case kColorId_TreeSelectionBackgroundFocused:
166    case kColorId_TreeSelectionBackgroundUnfocused:
167      return kTreeSelectionBackgroundColor;
168    case kColorId_TreeArrow:
169      return kTreeArrowColor;
170
171    // Table
172    case kColorId_TableBackground:
173      return kTableBackground;
174    case kColorId_TableText:
175      return kTableTextColor;
176    case kColorId_TableSelectedText:
177    case kColorId_TableSelectedTextUnfocused:
178      return kTableSelectedTextColor;
179    case kColorId_TableSelectionBackgroundFocused:
180    case kColorId_TableSelectionBackgroundUnfocused:
181      return kTableSelectionBackgroundColor;
182    case kColorId_TableGroupingIndicatorColor:
183      return kTableGroupingIndicatorColor;
184
185    case kColorId_MenuBackgroundColor:
186      return kMenuBackgroundColor;
187    case kColorId_MenuBorderColor:
188      NOTREACHED();
189      break;
190  }
191
192  return kInvalidColorIdColor;
193}
194
195}  // namespace ui
196