Add ICU message format support
[chromium-blink-merge.git] / ui / views / controls / menu / menu_wrapper.h
blob39a6fc5c46ea3ceaa30371f59769f03006fc0bb9
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"
11 namespace gfx {
12 class Point;
15 namespace ui {
16 class MenuModel;
19 namespace views {
21 class MenuInsertionDelegateWin;
22 class MenuListener;
24 // An interface that wraps an object that implements a menu.
25 class VIEWS_EXPORT MenuWrapper {
26 public:
27 // All of the possible actions that can result from RunMenuAt.
28 enum MenuAction {
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
47 // must be rebuilt.
48 virtual void Rebuild(MenuInsertionDelegateWin* delegate) = 0;
50 // Called when the states of the items in the menu must be updated from the
51 // model.
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
59 // nothing.
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;
72 } // namespace views
74 #endif // UI_VIEWS_CONTROLS_MENU_MENU_WRAPPER_H_