OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/l10n/l10n_util.h" | 5 #include "ui/base/l10n/l10n_util.h" |
6 #include "ui/base/models/menu_model.h" | 6 #include "ui/base/models/menu_model.h" |
7 #include "ui/base/models/menu_model_delegate.h" | 7 #include "ui/base/models/menu_model_delegate.h" |
8 #include "views/controls/menu/menu_item_view.h" | 8 #include "views/controls/menu/menu_item_view.h" |
9 #include "views/controls/menu/menu_model_adapter.h" | 9 #include "views/controls/menu/menu_model_adapter.h" |
10 #include "views/controls/menu/submenu_view.h" | 10 #include "views/controls/menu/submenu_view.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return items_[index - GetFirstItemIndex(NULL)].submenu; | 97 return items_[index - GetFirstItemIndex(NULL)].submenu; |
98 } | 98 } |
99 | 99 |
100 virtual void HighlightChangedTo(int index) OVERRIDE { | 100 virtual void HighlightChangedTo(int index) OVERRIDE { |
101 } | 101 } |
102 | 102 |
103 virtual void ActivatedAt(int index) OVERRIDE { | 103 virtual void ActivatedAt(int index) OVERRIDE { |
104 set_last_activation(index); | 104 set_last_activation(index); |
105 } | 105 } |
106 | 106 |
107 virtual void ActivatedAtWithDisposition(int index, int disposition) OVERRIDE { | 107 virtual void ActivatedAtWithFlags(int index, int flags) OVERRIDE { |
108 ActivatedAt(index); | 108 ActivatedAt(index); |
109 } | 109 } |
110 | 110 |
111 virtual void MenuWillShow() OVERRIDE { | 111 virtual void MenuWillShow() OVERRIDE { |
112 } | 112 } |
113 | 113 |
114 virtual void MenuClosed() OVERRIDE { | 114 virtual void MenuClosed() OVERRIDE { |
115 } | 115 } |
116 | 116 |
117 virtual void SetMenuModelDelegate( | 117 virtual void SetMenuModelDelegate( |
(...skipping 12 matching lines...) Expand all Loading... |
130 | 130 |
131 ItemType type; | 131 ItemType type; |
132 string16 label; | 132 string16 label; |
133 ui::MenuModel* submenu; | 133 ui::MenuModel* submenu; |
134 }; | 134 }; |
135 | 135 |
136 const Item& GetItemDefinition(int index) { | 136 const Item& GetItemDefinition(int index) { |
137 return items_[index]; | 137 return items_[index]; |
138 } | 138 } |
139 | 139 |
140 // Access index argument to ActivatedAt() or ActivatedAtWithDisposition(). | 140 // Access index argument to ActivatedAt() or ActivatedAtWithFlags(). |
141 int last_activation() const { return last_activation_; } | 141 int last_activation() const { return last_activation_; } |
142 void set_last_activation(int last_activation) { | 142 void set_last_activation(int last_activation) { |
143 last_activation_ = last_activation; | 143 last_activation_ = last_activation; |
144 } | 144 } |
145 | 145 |
146 protected: | 146 protected: |
147 std::vector<Item> items_; | 147 std::vector<Item> items_; |
148 | 148 |
149 private: | 149 private: |
150 int command_id_base_; | 150 int command_id_base_; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 submodel->set_last_activation(-1); | 294 submodel->set_last_activation(-1); |
295 } | 295 } |
296 | 296 |
297 // Check that selecting the root item is safe. The MenuModel does | 297 // Check that selecting the root item is safe. The MenuModel does |
298 // not care about the root so MenuModelAdapter should do nothing | 298 // not care about the root so MenuModelAdapter should do nothing |
299 // (not hit the NOTREACHED check) when the root is selected. | 299 // (not hit the NOTREACHED check) when the root is selected. |
300 static_cast<views::MenuDelegate*>(&delegate)->SelectionChanged(menu.get()); | 300 static_cast<views::MenuDelegate*>(&delegate)->SelectionChanged(menu.get()); |
301 } | 301 } |
302 | 302 |
303 } // namespace views | 303 } // namespace views |
OLD | NEW |