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_model_adapter.h" |
| 6 |
5 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
6 #include "ui/base/l10n/l10n_util.h" | 8 #include "ui/base/l10n/l10n_util.h" |
7 #include "ui/base/models/menu_model.h" | 9 #include "ui/base/models/menu_model.h" |
8 #include "ui/base/models/menu_model_delegate.h" | 10 #include "ui/base/models/menu_model_delegate.h" |
9 #include "ui/views/controls/menu/menu_item_view.h" | 11 #include "ui/views/controls/menu/menu_item_view.h" |
10 #include "ui/views/controls/menu/menu_model_adapter.h" | |
11 #include "ui/views/controls/menu/menu_runner.h" | 12 #include "ui/views/controls/menu/menu_runner.h" |
12 #include "ui/views/controls/menu/submenu_view.h" | 13 #include "ui/views/controls/menu/submenu_view.h" |
13 #include "ui/views/test/views_test_base.h" | 14 #include "ui/views/test/views_test_base.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // Base command id for test menu and its submenu. | 18 // Base command id for test menu and its submenu. |
18 const int kRootIdBase = 100; | 19 const int kRootIdBase = 100; |
19 const int kSubmenuIdBase = 200; | 20 const int kSubmenuIdBase = 200; |
20 | 21 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 53 } |
53 | 54 |
54 virtual base::string16 GetLabelAt(int index) const OVERRIDE { | 55 virtual base::string16 GetLabelAt(int index) const OVERRIDE { |
55 return items_[index].label; | 56 return items_[index].label; |
56 } | 57 } |
57 | 58 |
58 virtual bool IsItemDynamicAt(int index) const OVERRIDE { | 59 virtual bool IsItemDynamicAt(int index) const OVERRIDE { |
59 return false; | 60 return false; |
60 } | 61 } |
61 | 62 |
62 virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE { | 63 virtual const gfx::FontList* GetLabelFontListAt(int index) const OVERRIDE { |
63 return NULL; | 64 return NULL; |
64 } | 65 } |
65 | 66 |
66 virtual bool GetAcceleratorAt(int index, | 67 virtual bool GetAcceleratorAt(int index, |
67 ui::Accelerator* accelerator) const OVERRIDE { | 68 ui::Accelerator* accelerator) const OVERRIDE { |
68 return false; | 69 return false; |
69 } | 70 } |
70 | 71 |
71 virtual bool IsItemCheckedAt(int index) const OVERRIDE { | 72 virtual bool IsItemCheckedAt(int index) const OVERRIDE { |
72 return false; | 73 return false; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 submodel->set_last_activation(-1); | 301 submodel->set_last_activation(-1); |
301 } | 302 } |
302 | 303 |
303 // Check that selecting the root item is safe. The MenuModel does | 304 // Check that selecting the root item is safe. The MenuModel does |
304 // not care about the root so MenuModelAdapter should do nothing | 305 // not care about the root so MenuModelAdapter should do nothing |
305 // (not hit the NOTREACHED check) when the root is selected. | 306 // (not hit the NOTREACHED check) when the root is selected. |
306 static_cast<views::MenuDelegate*>(&delegate)->SelectionChanged(menu); | 307 static_cast<views::MenuDelegate*>(&delegate)->SelectionChanged(menu); |
307 } | 308 } |
308 | 309 |
309 } // namespace views | 310 } // namespace views |
OLD | NEW |