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