OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/controls/menu/menu_config.h" | 5 #include "ui/views/controls/menu/menu_config.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <uxtheme.h> | 8 #include <uxtheme.h> |
9 #include <Vssym32.h> | 9 #include <Vssym32.h> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/win/scoped_gdi_object.h" | 12 #include "base/win/scoped_gdi_object.h" |
13 #include "base/win/win_util.h" | 13 #include "base/win/win_util.h" |
14 #include "ui/base/l10n/l10n_util_win.h" | 14 #include "ui/base/l10n/l10n_util_win.h" |
15 #include "ui/gfx/color_utils.h" | 15 #include "ui/gfx/color_utils.h" |
| 16 #include "ui/native_theme/native_theme_aura.h" |
16 #include "ui/native_theme/native_theme_win.h" | 17 #include "ui/native_theme/native_theme_win.h" |
17 | 18 |
18 using ui::NativeTheme; | 19 using ui::NativeTheme; |
19 using ui::NativeThemeWin; | 20 using ui::NativeThemeWin; |
20 | 21 |
21 namespace views { | 22 namespace views { |
22 | 23 |
23 void MenuConfig::Init() { | 24 void MenuConfig::Init(const NativeTheme* theme) { |
| 25 if (theme == ui::NativeThemeAura::instance()) { |
| 26 InitAura(theme); |
| 27 return; |
| 28 } |
| 29 |
24 arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); | 30 arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); |
25 | 31 |
26 NONCLIENTMETRICS_XP metrics; | 32 NONCLIENTMETRICS_XP metrics; |
27 base::win::GetNonClientMetrics(&metrics); | 33 base::win::GetNonClientMetrics(&metrics); |
28 l10n_util::AdjustUIFont(&(metrics.lfMenuFont)); | 34 l10n_util::AdjustUIFont(&(metrics.lfMenuFont)); |
29 { | 35 { |
30 base::win::ScopedHFONT new_font(CreateFontIndirect(&metrics.lfMenuFont)); | 36 base::win::ScopedHFONT new_font(CreateFontIndirect(&metrics.lfMenuFont)); |
31 DLOG_ASSERT(new_font.Get()); | 37 DLOG_ASSERT(new_font.Get()); |
32 font_list = gfx::FontList(gfx::Font(new_font)); | 38 font_list = gfx::FontList(gfx::Font(new_font)); |
33 } | 39 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 show_mnemonics = | 71 show_mnemonics = |
66 (SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &show_cues, 0) && | 72 (SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &show_cues, 0) && |
67 show_cues == TRUE); | 73 show_cues == TRUE); |
68 | 74 |
69 SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &show_delay, 0); | 75 SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &show_delay, 0); |
70 | 76 |
71 separator_upper_height = 5; | 77 separator_upper_height = 5; |
72 separator_lower_height = 7; | 78 separator_lower_height = 7; |
73 } | 79 } |
74 | 80 |
| 81 // static |
| 82 const MenuConfig& MenuConfig::instance(const ui::NativeTheme* theme) { |
| 83 // NOTE: |theme| may be NULL if used before the menu is running. |
| 84 if (!theme || theme == NativeThemeWin::instance()) { |
| 85 static MenuConfig* win_instance = NULL; |
| 86 if (!win_instance) |
| 87 win_instance = new MenuConfig(NativeThemeWin::instance()); |
| 88 return *win_instance; |
| 89 } |
| 90 static MenuConfig* views_instance = NULL; |
| 91 if (!views_instance) |
| 92 views_instance = new MenuConfig(theme); |
| 93 return *views_instance; |
| 94 } |
| 95 |
75 } // namespace views | 96 } // namespace views |
OLD | NEW |