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

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

Issue 9966007: views: Extract SystemMenuModel from native_menu_win.*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include string16 Created 8 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 | « chrome/chrome_browser.gypi ('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) 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 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 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "ui/base/models/simple_menu_model.h" 16 #include "base/string16.h"
17 #include "ui/views/controls/menu/menu_wrapper.h" 17 #include "ui/views/controls/menu/menu_wrapper.h"
18 #include "ui/views/views_export.h" 18 #include "ui/views/views_export.h"
19 19
20 namespace ui {
21 class MenuModel;
22 }
23
20 namespace views { 24 namespace views {
21 25
22 // A Windows implementation of MenuWrapper. 26 // A Windows implementation of MenuWrapper.
23 // TODO(beng): rename to MenuWin once the old class is dead. 27 // TODO(beng): rename to MenuWin once the old class is dead.
24 class VIEWS_EXPORT NativeMenuWin : public MenuWrapper { 28 class VIEWS_EXPORT NativeMenuWin : public MenuWrapper {
25 public: 29 public:
26 // Construct a NativeMenuWin, with a model and delegate. If |system_menu_for| 30 // Construct a NativeMenuWin, with a model and delegate. If |system_menu_for|
27 // is non-NULL, the NativeMenuWin wraps the system menu for that window. 31 // is non-NULL, the NativeMenuWin wraps the system menu for that window.
28 // The caller owns the model and the delegate. 32 // The caller owns the model and the delegate.
29 NativeMenuWin(ui::MenuModel* model, HWND system_menu_for); 33 NativeMenuWin(ui::MenuModel* model, HWND system_menu_for);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 bool* destroyed_flag_; 158 bool* destroyed_flag_;
155 159
156 // Ugly: a static pointer to the instance of this class that currently 160 // Ugly: a static pointer to the instance of this class that currently
157 // has a menu open, because our hook function that receives keyboard 161 // has a menu open, because our hook function that receives keyboard
158 // events doesn't have a mechanism to get a user data pointer. 162 // events doesn't have a mechanism to get a user data pointer.
159 static NativeMenuWin* open_native_menu_win_; 163 static NativeMenuWin* open_native_menu_win_;
160 164
161 DISALLOW_COPY_AND_ASSIGN(NativeMenuWin); 165 DISALLOW_COPY_AND_ASSIGN(NativeMenuWin);
162 }; 166 };
163 167
164 // A SimpleMenuModel subclass that allows the system menu for a window to be
165 // wrapped.
166 class VIEWS_EXPORT SystemMenuModel : public ui::SimpleMenuModel {
167 public:
168 explicit SystemMenuModel(Delegate* delegate);
169 virtual ~SystemMenuModel();
170
171 // Overridden from ui::MenuModel:
172 virtual int GetFirstItemIndex(gfx::NativeMenu native_menu) const;
173
174 protected:
175 // Overridden from SimpleMenuModel:
176 virtual int FlipIndex(int index) const { return GetItemCount() - index - 1; }
177
178 private:
179 DISALLOW_COPY_AND_ASSIGN(SystemMenuModel);
180 };
181
182 } // namespace views 168 } // namespace views
183 169
184 #endif // UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ 170 #endif // UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | ui/views/controls/menu/native_menu_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698