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

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

Issue 6732007: Native menu implementation for bug 5679. Followup to http://codereview.chromium.org/2928005/ Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ 5 #ifndef VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_
6 #define VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ 6 #define VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
12 #include "ui/base/models/simple_menu_model.h" 12 #include "ui/base/models/simple_menu_model.h"
13 #include "views/controls/menu/menu_wrapper.h" 13 #include "views/controls/menu/menu_wrapper.h"
14 14
15 namespace views { 15 namespace views {
16 16
17 // A Windows implementation of MenuWrapper. 17 // A Windows implementation of MenuWrapper.
18 // TODO(beng): rename to MenuWin once the old class is dead. 18 // TODO(beng): rename to MenuWin once the old class is dead.
19 class NativeMenuWin : public MenuWrapper { 19 class NativeMenuWin : public MenuWrapper,
20 public ui::MenuModelDelegate {
20 public: 21 public:
21 // Construct a NativeMenuWin, with a model and delegate. If |system_menu_for| 22 // Construct a NativeMenuWin, with a model and delegate. If |system_menu_for|
22 // is non-NULL, the NativeMenuWin wraps the system menu for that window. 23 // is non-NULL, the NativeMenuWin wraps the system menu for that window.
23 // The caller owns the model and the delegate. 24 // The caller owns the model and the delegate.
24 NativeMenuWin(ui::MenuModel* model, HWND system_menu_for); 25 NativeMenuWin(ui::MenuModel* model, HWND system_menu_for);
25 virtual ~NativeMenuWin(); 26 virtual ~NativeMenuWin();
26 27
27 // Overridden from MenuWrapper: 28 // Overridden from MenuWrapper:
28 virtual void RunMenuAt(const gfx::Point& point, int alignment); 29 virtual void RunMenuAt(const gfx::Point& point, int alignment);
29 virtual void CancelMenu(); 30 virtual void CancelMenu();
30 virtual void Rebuild(); 31 virtual void Rebuild();
31 virtual void UpdateStates(); 32 virtual void UpdateStates();
32 virtual gfx::NativeMenu GetNativeMenu() const; 33 virtual gfx::NativeMenu GetNativeMenu() const;
33 virtual MenuAction GetMenuAction() const; 34 virtual MenuAction GetMenuAction() const;
34 virtual void AddMenuListener(MenuListener* listener); 35 virtual void AddMenuListener(MenuListener* listener);
35 virtual void RemoveMenuListener(MenuListener* listener); 36 virtual void RemoveMenuListener(MenuListener* listener);
36 virtual void SetMinimumWidth(int width); 37 virtual void SetMinimumWidth(int width);
38 // MenuModel:Delegate called when a favicon is loaded from history.
sky 2011/03/24 22:39:29 Newline between 37/38. Also, add OVERRIDE.
39 virtual void OnIconChanged(int model_index);
37 40
38 private: 41 private:
39 // IMPORTANT: Note about indices. 42 // IMPORTANT: Note about indices.
40 // Functions in this class deal in two index spaces: 43 // Functions in this class deal in two index spaces:
41 // 1. menu_index - the index of an item within the actual Windows 44 // 1. menu_index - the index of an item within the actual Windows
42 // native menu. 45 // native menu.
43 // 2. model_index - the index of the item within our model. 46 // 2. model_index - the index of the item within our model.
44 // These two are most often but not always the same value! The 47 // These two are most often but not always the same value! The
45 // notable exception is when this object is used to wrap the 48 // notable exception is when this object is used to wrap the
46 // Windows System Menu. In this instance, the model indices start 49 // Windows System Menu. In this instance, the model indices start
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // Overridden from SimpleMenuModel: 160 // Overridden from SimpleMenuModel:
158 virtual int FlipIndex(int index) const { return GetItemCount() - index - 1; } 161 virtual int FlipIndex(int index) const { return GetItemCount() - index - 1; }
159 162
160 private: 163 private:
161 DISALLOW_COPY_AND_ASSIGN(SystemMenuModel); 164 DISALLOW_COPY_AND_ASSIGN(SystemMenuModel);
162 }; 165 };
163 166
164 } // namespace views 167 } // namespace views
165 168
166 #endif // VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ 169 #endif // VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698