• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_BROWSER_NATIVE_MENU_WRAPPER_H_
6 #define CEF_LIBCEF_BROWSER_NATIVE_MENU_WRAPPER_H_
7 
8 #include "ui/gfx/native_widget_types.h"
9 
10 namespace gfx {
11 class Point;
12 }
13 
14 namespace ui {
15 class MenuModel;
16 }
17 
18 namespace views {
19 
20 class MenuInsertionDelegateWin;
21 
22 // An interface that wraps an object that implements a menu.
23 class MenuWrapper {
24  public:
25   // All of the possible actions that can result from RunMenuAt.
26   enum MenuAction {
27     MENU_ACTION_NONE,      // Menu cancelled, or never opened.
28     MENU_ACTION_SELECTED,  // An item was selected.
29     MENU_ACTION_PREVIOUS,  // User wants to navigate to the previous menu.
30     MENU_ACTION_NEXT,      // User wants to navigate to the next menu.
31   };
32 
~MenuWrapper()33   virtual ~MenuWrapper() {}
34 
35   // Creates the appropriate instance of this wrapper for the current platform.
36   static MenuWrapper* CreateWrapper(ui::MenuModel* model);
37 
38   // Runs the menu at the specified point. This blocks until done.
39   virtual void RunMenuAt(const gfx::Point& point, int alignment) = 0;
40 
41   // Cancels the active menu.
42   virtual void CancelMenu() = 0;
43 
44   // Called when the model supplying data to this menu has changed, and the menu
45   // must be rebuilt.
46   virtual void Rebuild(MenuInsertionDelegateWin* delegate) = 0;
47 
48   // Called when the states of the items in the menu must be updated from the
49   // model.
50   virtual void UpdateStates() = 0;
51 
52   // Retrieve a native menu handle.
53   virtual HMENU GetNativeMenu() const = 0;
54 
55   // Get the result of the last call to RunMenuAt to determine whether an
56   // item was selected, the user navigated to a next or previous menu, or
57   // nothing.
58   virtual MenuAction GetMenuAction() const = 0;
59 
60   // Sets the minimum width of the menu.
61   virtual void SetMinimumWidth(int width) = 0;
62 };
63 
64 }  // namespace views
65 
66 #endif  // CEF_LIBCEF_BROWSER_NATIVE_MENU_WRAPPER_H_
67