| 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/native_menu_win.h" | 5 #include "ui/views/controls/menu/native_menu_win.h" |
| 6 | 6 |
| 7 #include <Windowsx.h> | 7 #include <Windowsx.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/win/wrapped_window_proc.h" | 14 #include "base/win/wrapped_window_proc.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "ui/base/accelerators/accelerator.h" | 16 #include "ui/base/accelerators/accelerator.h" |
| 17 #include "ui/base/keycodes/keyboard_codes.h" | 17 #include "ui/base/keycodes/keyboard_codes.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/l10n/l10n_util_win.h" | 19 #include "ui/base/l10n/l10n_util_win.h" |
| 20 #include "ui/base/models/menu_model.h" |
| 20 #include "ui/base/win/hwnd_util.h" | 21 #include "ui/base/win/hwnd_util.h" |
| 21 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/font.h" | 23 #include "ui/gfx/font.h" |
| 23 #include "ui/gfx/native_theme.h" | 24 #include "ui/gfx/native_theme.h" |
| 24 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 25 #include "ui/views/controls/menu/menu_2.h" | 26 #include "ui/views/controls/menu/menu_2.h" |
| 26 #include "ui/views/controls/menu/menu_config.h" | 27 #include "ui/views/controls/menu/menu_config.h" |
| 27 #include "ui/views/controls/menu/menu_listener.h" | 28 #include "ui/views/controls/menu/menu_listener.h" |
| 28 | 29 |
| 29 using gfx::NativeTheme; | 30 using gfx::NativeTheme; |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 | 733 |
| 733 void NativeMenuWin::CreateHostWindow() { | 734 void NativeMenuWin::CreateHostWindow() { |
| 734 // This only gets called from RunMenuAt, and as such there is only ever one | 735 // This only gets called from RunMenuAt, and as such there is only ever one |
| 735 // host window per menu hierarchy, no matter how many NativeMenuWin objects | 736 // host window per menu hierarchy, no matter how many NativeMenuWin objects |
| 736 // exist wrapping submenus. | 737 // exist wrapping submenus. |
| 737 if (!host_window_.get()) | 738 if (!host_window_.get()) |
| 738 host_window_.reset(new MenuHostWindow(this)); | 739 host_window_.reset(new MenuHostWindow(this)); |
| 739 } | 740 } |
| 740 | 741 |
| 741 //////////////////////////////////////////////////////////////////////////////// | 742 //////////////////////////////////////////////////////////////////////////////// |
| 742 // SystemMenuModel: | |
| 743 | |
| 744 SystemMenuModel::SystemMenuModel(ui::SimpleMenuModel::Delegate* delegate) | |
| 745 : SimpleMenuModel(delegate) { | |
| 746 } | |
| 747 | |
| 748 SystemMenuModel::~SystemMenuModel() { | |
| 749 } | |
| 750 | |
| 751 int SystemMenuModel::GetFirstItemIndex(gfx::NativeMenu native_menu) const { | |
| 752 // We allow insertions before last item (Close). | |
| 753 return std::max(0, GetMenuItemCount(native_menu) - 1); | |
| 754 } | |
| 755 | |
| 756 //////////////////////////////////////////////////////////////////////////////// | |
| 757 // MenuWrapper, public: | 743 // MenuWrapper, public: |
| 758 | 744 |
| 759 // static | 745 // static |
| 760 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { | 746 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { |
| 761 return new NativeMenuWin(menu->model(), NULL); | 747 return new NativeMenuWin(menu->model(), NULL); |
| 762 } | 748 } |
| 763 | 749 |
| 764 } // namespace views | 750 } // namespace views |
| OLD | NEW |