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

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

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

Powered by Google App Engine
This is Rietveld 408576698