OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_VIEWS_H_ | |
6 #define UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_VIEWS_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/compiler_specific.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "ui/views/controls/menu/menu_delegate.h" | |
13 #include "ui/views/controls/menu/menu_wrapper.h" | |
14 | |
15 namespace ui { | |
16 class MenuModel; | |
17 } | |
18 | |
19 namespace views { | |
20 | |
21 class MenuItemView; | |
22 class MenuRunner; | |
23 | |
24 // A views implementation of MenuWrapper, used currently for touchui. | |
25 class NativeMenuViews : public MenuWrapper, | |
26 public MenuDelegate { | |
27 public: | |
28 explicit NativeMenuViews(Menu2* menu); | |
29 virtual ~NativeMenuViews(); | |
30 | |
31 // Overridden from MenuWrapper: | |
32 virtual void RunMenuAt(const gfx::Point& point, int alignment) OVERRIDE; | |
33 virtual void CancelMenu() OVERRIDE; | |
34 virtual void Rebuild() OVERRIDE; | |
35 virtual void UpdateStates() OVERRIDE; | |
36 virtual gfx::NativeMenu GetNativeMenu() const OVERRIDE; | |
37 virtual MenuAction GetMenuAction() const OVERRIDE; | |
38 virtual void AddMenuListener(MenuListener* listener) OVERRIDE; | |
39 virtual void RemoveMenuListener(MenuListener* listener) OVERRIDE; | |
40 virtual void SetMinimumWidth(int width) OVERRIDE; | |
41 | |
42 // Overridden from MenuDelegate: | |
43 virtual bool IsItemChecked(int id) const OVERRIDE; | |
44 virtual bool IsCommandEnabled(int id) const OVERRIDE; | |
45 virtual void ExecuteCommand(int id) OVERRIDE; | |
46 virtual bool GetAccelerator(int id, ui::Accelerator* accelerator) OVERRIDE; | |
47 | |
48 private: | |
49 void AddMenuItemsFromModel(MenuItemView* parent, ui::MenuModel* model); | |
50 void UpdateMenuFromModel(SubmenuView* menu, ui::MenuModel* model); | |
51 | |
52 // The attached model and delegate. Does not assume ownership. | |
53 ui::MenuModel* model_; | |
54 MenuItemView* root_; | |
55 scoped_ptr<MenuRunner> menu_runner_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(NativeMenuViews); | |
58 }; | |
59 | |
60 } // namespace views | |
61 | |
62 #endif // UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_VIEWS_H_ | |
OLD | NEW |