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 12 Menu2::Menu2(ui::MenuModel* model) 13 : model_(model), 14 wrapper_(MenuWrapper::CreateWrapper(model)) { 15 Rebuild(); 16 } 17 18 Menu2::~Menu2() {} 19 20 HMENU Menu2::GetNativeMenu() const { 21 return wrapper_->GetNativeMenu(); 22 } 23 24 void Menu2::RunMenuAt(const gfx::Point& point, Alignment alignment) { 25 wrapper_->RunMenuAt(point, alignment); 26 } 27 28 void Menu2::RunContextMenuAt(const gfx::Point& point) { 29 RunMenuAt(point, ALIGN_TOPLEFT); 30 } 31 32 void Menu2::CancelMenu() { 33 wrapper_->CancelMenu(); 34 } 35 36 void Menu2::Rebuild() { 37 wrapper_->Rebuild(NULL); 38 } 39 40 void Menu2::UpdateStates() { 41 wrapper_->UpdateStates(); 42 } 43 44 MenuWrapper::MenuAction Menu2::GetMenuAction() const { 45 return wrapper_->GetMenuAction(); 46 } 47 48 void Menu2::AddMenuListener(MenuListener* listener) { 49 wrapper_->AddMenuListener(listener); 50 } 51 52 void Menu2::RemoveMenuListener(MenuListener* listener) { 53 wrapper_->RemoveMenuListener(listener); 54 } 55 56 void Menu2::SetMinimumWidth(int width) { 57 wrapper_->SetMinimumWidth(width); 58 } 59 60 } // namespace 61