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.
5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_WRAPPER_H_
6 #define UI_VIEWS_CONTROLS_MENU_MENU_WRAPPER_H_
8 #include "ui/gfx/native_widget_types.h"
9 #include "ui/views/views_export.h"
21 class MenuInsertionDelegateWin
;
24 // An interface that wraps an object that implements a menu.
25 class VIEWS_EXPORT MenuWrapper
{
27 // All of the possible actions that can result from RunMenuAt.
29 MENU_ACTION_NONE
, // Menu cancelled, or never opened.
30 MENU_ACTION_SELECTED
, // An item was selected.
31 MENU_ACTION_PREVIOUS
, // User wants to navigate to the previous menu.
32 MENU_ACTION_NEXT
, // User wants to navigate to the next menu.
35 virtual ~MenuWrapper() {}
37 // Creates the appropriate instance of this wrapper for the current platform.
38 static MenuWrapper
* CreateWrapper(ui::MenuModel
* model
);
40 // Runs the menu at the specified point. This blocks until done.
41 virtual void RunMenuAt(const gfx::Point
& point
, int alignment
) = 0;
43 // Cancels the active menu.
44 virtual void CancelMenu() = 0;
46 // Called when the model supplying data to this menu has changed, and the menu
48 virtual void Rebuild(MenuInsertionDelegateWin
* delegate
) = 0;
50 // Called when the states of the items in the menu must be updated from the
52 virtual void UpdateStates() = 0;
54 // Retrieve a native menu handle.
55 virtual HMENU
GetNativeMenu() const = 0;
57 // Get the result of the last call to RunMenuAt to determine whether an
58 // item was selected, the user navigated to a next or previous menu, or
60 virtual MenuAction
GetMenuAction() const = 0;
62 // Add a listener to receive a callback when the menu opens.
63 virtual void AddMenuListener(MenuListener
* listener
) = 0;
65 // Remove a menu listener.
66 virtual void RemoveMenuListener(MenuListener
* listener
) = 0;
68 // Sets the minimum width of the menu.
69 virtual void SetMinimumWidth(int width
) = 0;
74 #endif // UI_VIEWS_CONTROLS_MENU_MENU_WRAPPER_H_