• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "ui/views/controls/menu/menu_2.h"
6 
7 #include "ui/base/models/menu_model.h"
8 #include "ui/views/controls/menu/menu_listener.h"
9 
10 namespace views {
11 
Menu2(ui::MenuModel * model)12 Menu2::Menu2(ui::MenuModel* model)
13     : model_(model),
14       wrapper_(MenuWrapper::CreateWrapper(model)) {
15   Rebuild();
16 }
17 
~Menu2()18 Menu2::~Menu2() {}
19 
GetNativeMenu() const20 HMENU Menu2::GetNativeMenu() const {
21   return wrapper_->GetNativeMenu();
22 }
23 
RunMenuAt(const gfx::Point & point,Alignment alignment)24 void Menu2::RunMenuAt(const gfx::Point& point, Alignment alignment) {
25   wrapper_->RunMenuAt(point, alignment);
26 }
27 
RunContextMenuAt(const gfx::Point & point)28 void Menu2::RunContextMenuAt(const gfx::Point& point) {
29   RunMenuAt(point, ALIGN_TOPLEFT);
30 }
31 
CancelMenu()32 void Menu2::CancelMenu() {
33   wrapper_->CancelMenu();
34 }
35 
Rebuild()36 void Menu2::Rebuild() {
37   wrapper_->Rebuild(NULL);
38 }
39 
UpdateStates()40 void Menu2::UpdateStates() {
41   wrapper_->UpdateStates();
42 }
43 
GetMenuAction() const44 MenuWrapper::MenuAction Menu2::GetMenuAction() const {
45   return wrapper_->GetMenuAction();
46 }
47 
AddMenuListener(MenuListener * listener)48 void Menu2::AddMenuListener(MenuListener* listener) {
49   wrapper_->AddMenuListener(listener);
50 }
51 
RemoveMenuListener(MenuListener * listener)52 void Menu2::RemoveMenuListener(MenuListener* listener) {
53   wrapper_->RemoveMenuListener(listener);
54 }
55 
SetMinimumWidth(int width)56 void Menu2::SetMinimumWidth(int width) {
57   wrapper_->SetMinimumWidth(width);
58 }
59 
60 }  // namespace
61