| 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" | |
| 17 #include "ui/native_theme/native_theme_win.h" | 16 #include "ui/native_theme/native_theme_win.h" |
| 18 | 17 |
| 19 using ui::NativeTheme; | 18 using ui::NativeTheme; |
| 20 using ui::NativeThemeWin; | 19 using ui::NativeThemeWin; |
| 21 | 20 |
| 22 namespace views { | 21 namespace views { |
| 23 | 22 |
| 24 void MenuConfig::Init(const NativeTheme* theme) { | 23 void MenuConfig::Init() { |
| 25 if (theme == ui::NativeThemeAura::instance()) { | |
| 26 InitAura(theme); | |
| 27 return; | |
| 28 } | |
| 29 | |
| 30 arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); | 24 arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); |
| 31 | 25 |
| 32 NONCLIENTMETRICS_XP metrics; | 26 NONCLIENTMETRICS_XP metrics; |
| 33 base::win::GetNonClientMetrics(&metrics); | 27 base::win::GetNonClientMetrics(&metrics); |
| 34 l10n_util::AdjustUIFont(&(metrics.lfMenuFont)); | 28 l10n_util::AdjustUIFont(&(metrics.lfMenuFont)); |
| 35 { | 29 { |
| 36 base::win::ScopedHFONT new_font(CreateFontIndirect(&metrics.lfMenuFont)); | 30 base::win::ScopedHFONT new_font(CreateFontIndirect(&metrics.lfMenuFont)); |
| 37 DLOG_ASSERT(new_font.Get()); | 31 DLOG_ASSERT(new_font.Get()); |
| 38 font_list = gfx::FontList(gfx::Font(new_font)); | 32 font_list = gfx::FontList(gfx::Font(new_font)); |
| 39 } | 33 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 show_mnemonics = | 65 show_mnemonics = |
| 72 (SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &show_cues, 0) && | 66 (SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &show_cues, 0) && |
| 73 show_cues == TRUE); | 67 show_cues == TRUE); |
| 74 | 68 |
| 75 SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &show_delay, 0); | 69 SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &show_delay, 0); |
| 76 | 70 |
| 77 separator_upper_height = 5; | 71 separator_upper_height = 5; |
| 78 separator_lower_height = 7; | 72 separator_lower_height = 7; |
| 79 } | 73 } |
| 80 | 74 |
| 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 | |
| 96 } // namespace views | 75 } // namespace views |
| OLD | NEW |