OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/task.h" | 12 #include "base/task.h" |
13 #include "ui/base/models/simple_menu_model.h" | 13 #include "ui/base/models/simple_menu_model.h" |
14 #include "views/controls/menu/menu_wrapper.h" | 14 #include "views/controls/menu/menu_wrapper.h" |
15 #include "views/views_api.h" | 15 #include "views/views_export.h" |
16 | 16 |
17 namespace views { | 17 namespace views { |
18 | 18 |
19 // A Windows implementation of MenuWrapper. | 19 // A Windows implementation of MenuWrapper. |
20 // TODO(beng): rename to MenuWin once the old class is dead. | 20 // TODO(beng): rename to MenuWin once the old class is dead. |
21 class VIEWS_API NativeMenuWin : public MenuWrapper { | 21 class VIEWS_EXPORT NativeMenuWin : public MenuWrapper { |
22 public: | 22 public: |
23 // Construct a NativeMenuWin, with a model and delegate. If |system_menu_for| | 23 // Construct a NativeMenuWin, with a model and delegate. If |system_menu_for| |
24 // is non-NULL, the NativeMenuWin wraps the system menu for that window. | 24 // is non-NULL, the NativeMenuWin wraps the system menu for that window. |
25 // The caller owns the model and the delegate. | 25 // The caller owns the model and the delegate. |
26 NativeMenuWin(ui::MenuModel* model, HWND system_menu_for); | 26 NativeMenuWin(ui::MenuModel* model, HWND system_menu_for); |
27 virtual ~NativeMenuWin(); | 27 virtual ~NativeMenuWin(); |
28 | 28 |
29 // Overridden from MenuWrapper: | 29 // Overridden from MenuWrapper: |
30 virtual void RunMenuAt(const gfx::Point& point, int alignment); | 30 virtual void RunMenuAt(const gfx::Point& point, int alignment); |
31 virtual void CancelMenu(); | 31 virtual void CancelMenu(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // Ugly: a static pointer to the instance of this class that currently | 153 // Ugly: a static pointer to the instance of this class that currently |
154 // has a menu open, because our hook function that receives keyboard | 154 // has a menu open, because our hook function that receives keyboard |
155 // events doesn't have a mechanism to get a user data pointer. | 155 // events doesn't have a mechanism to get a user data pointer. |
156 static NativeMenuWin* open_native_menu_win_; | 156 static NativeMenuWin* open_native_menu_win_; |
157 | 157 |
158 DISALLOW_COPY_AND_ASSIGN(NativeMenuWin); | 158 DISALLOW_COPY_AND_ASSIGN(NativeMenuWin); |
159 }; | 159 }; |
160 | 160 |
161 // A SimpleMenuModel subclass that allows the system menu for a window to be | 161 // A SimpleMenuModel subclass that allows the system menu for a window to be |
162 // wrapped. | 162 // wrapped. |
163 class VIEWS_API SystemMenuModel : public ui::SimpleMenuModel { | 163 class VIEWS_EXPORT SystemMenuModel : public ui::SimpleMenuModel { |
164 public: | 164 public: |
165 explicit SystemMenuModel(Delegate* delegate); | 165 explicit SystemMenuModel(Delegate* delegate); |
166 virtual ~SystemMenuModel(); | 166 virtual ~SystemMenuModel(); |
167 | 167 |
168 // Overridden from ui::MenuModel: | 168 // Overridden from ui::MenuModel: |
169 virtual int GetFirstItemIndex(gfx::NativeMenu native_menu) const; | 169 virtual int GetFirstItemIndex(gfx::NativeMenu native_menu) const; |
170 | 170 |
171 protected: | 171 protected: |
172 // Overridden from SimpleMenuModel: | 172 // Overridden from SimpleMenuModel: |
173 virtual int FlipIndex(int index) const { return GetItemCount() - index - 1; } | 173 virtual int FlipIndex(int index) const { return GetItemCount() - index - 1; } |
174 | 174 |
175 private: | 175 private: |
176 DISALLOW_COPY_AND_ASSIGN(SystemMenuModel); | 176 DISALLOW_COPY_AND_ASSIGN(SystemMenuModel); |
177 }; | 177 }; |
178 | 178 |
179 } // namespace views | 179 } // namespace views |
180 | 180 |
181 #endif // VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ | 181 #endif // VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ |
OLD | NEW |