Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: trunk/src/ui/views/controls/menu/native_menu_win.h

Issue 14320040: Revert 194356 "views: Finally get rid of the deprecated Menu2 API." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #ifndef UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ 5 #ifndef UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_
6 #define UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ 6 #define UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 14 #include "base/observer_list.h"
14 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "ui/views/controls/menu/menu_wrapper.h"
15 #include "ui/views/views_export.h" 17 #include "ui/views/views_export.h"
16 18
17 namespace gfx {
18 class Point;
19 }
20
21 namespace ui { 19 namespace ui {
22 class MenuModel; 20 class MenuModel;
23 } 21 }
24 22
25 namespace views { 23 namespace views {
26 24
27 class MenuInsertionDelegate; 25 // A Windows implementation of MenuWrapper.
28 class MenuListener; 26 // TODO(beng): rename to MenuWin once the old class is dead.
29 27 class VIEWS_EXPORT NativeMenuWin : public MenuWrapper {
30 class VIEWS_EXPORT NativeMenuWin {
31 public: 28 public:
32 // All of the possible actions that can result from RunMenuAt.
33 enum MenuAction {
34 MENU_ACTION_NONE, // Menu cancelled, or never opened.
35 MENU_ACTION_SELECTED, // An item was selected.
36 MENU_ACTION_PREVIOUS, // User wants to navigate to the previous menu.
37 MENU_ACTION_NEXT, // User wants to navigate to the next menu.
38 };
39
40 // How the menu is aligned relative to the point it is shown at.
41 // The alignment is reversed by menu if text direction is right to left.
42 enum Alignment {
43 ALIGN_TOPLEFT,
44 ALIGN_TOPRIGHT
45 };
46
47 // Construct a NativeMenuWin, with a model and delegate. If |system_menu_for| 29 // Construct a NativeMenuWin, with a model and delegate. If |system_menu_for|
48 // is non-NULL, the NativeMenuWin wraps the system menu for that window. 30 // is non-NULL, the NativeMenuWin wraps the system menu for that window.
49 // The caller owns the model and the delegate. 31 // The caller owns the model and the delegate.
50 NativeMenuWin(ui::MenuModel* model, HWND system_menu_for); 32 NativeMenuWin(ui::MenuModel* model, HWND system_menu_for);
51 ~NativeMenuWin(); 33 virtual ~NativeMenuWin();
52 34
53 void RunMenuAt(const gfx::Point& point, int alignment); 35 // Overridden from MenuWrapper:
54 void CancelMenu(); 36 virtual void RunMenuAt(const gfx::Point& point, int alignment) OVERRIDE;
55 void Rebuild(MenuInsertionDelegate* delegate); 37 virtual void CancelMenu() OVERRIDE;
56 void UpdateStates(); 38 virtual void Rebuild(InsertionDelegate* delegate) OVERRIDE;
57 HMENU GetNativeMenu() const; 39 virtual void UpdateStates() OVERRIDE;
58 MenuAction GetMenuAction() const; 40 virtual HMENU GetNativeMenu() const OVERRIDE;
59 void AddMenuListener(MenuListener* listener); 41 virtual MenuAction GetMenuAction() const OVERRIDE;
60 void RemoveMenuListener(MenuListener* listener); 42 virtual void AddMenuListener(MenuListener* listener) OVERRIDE;
61 void SetMinimumWidth(int width); 43 virtual void RemoveMenuListener(MenuListener* listener) OVERRIDE;
44 virtual void SetMinimumWidth(int width) OVERRIDE;
62 45
63 private: 46 private:
64 // IMPORTANT: Note about indices. 47 // IMPORTANT: Note about indices.
65 // Functions in this class deal in two index spaces: 48 // Functions in this class deal in two index spaces:
66 // 1. menu_index - the index of an item within the actual Windows 49 // 1. menu_index - the index of an item within the actual Windows
67 // native menu. 50 // native menu.
68 // 2. model_index - the index of the item within our model. 51 // 2. model_index - the index of the item within our model.
69 // These two are most often but not always the same value! The 52 // These two are most often but not always the same value! The
70 // notable exception is when this object is used to wrap the 53 // notable exception is when this object is used to wrap the
71 // Windows System Menu. In this instance, the model indices start 54 // Windows System Menu. In this instance, the model indices start
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // has a menu open, because our hook function that receives keyboard 160 // has a menu open, because our hook function that receives keyboard
178 // events doesn't have a mechanism to get a user data pointer. 161 // events doesn't have a mechanism to get a user data pointer.
179 static NativeMenuWin* open_native_menu_win_; 162 static NativeMenuWin* open_native_menu_win_;
180 163
181 DISALLOW_COPY_AND_ASSIGN(NativeMenuWin); 164 DISALLOW_COPY_AND_ASSIGN(NativeMenuWin);
182 }; 165 };
183 166
184 } // namespace views 167 } // namespace views
185 168
186 #endif // UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ 169 #endif // UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_
OLDNEW
« no previous file with comments | « trunk/src/ui/views/controls/menu/menu_wrapper.h ('k') | trunk/src/ui/views/controls/menu/native_menu_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698