| 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 #include "views/controls/menu/menu_host_win.h" | 5 #include "views/controls/menu/menu_host_win.h" |
| 6 | 6 |
| 7 #include "views/controls/menu/native_menu_host_delegate.h" | 7 #include "views/controls/menu/native_menu_host_delegate.h" |
| 8 | 8 |
| 9 namespace views { | 9 namespace views { |
| 10 | 10 |
| 11 //////////////////////////////////////////////////////////////////////////////// | 11 //////////////////////////////////////////////////////////////////////////////// |
| 12 // MenuHostWin, public: | 12 // MenuHostWin, public: |
| 13 | 13 |
| 14 MenuHostWin::MenuHostWin(internal::NativeMenuHostDelegate* delegate) | 14 MenuHostWin::MenuHostWin(internal::NativeMenuHostDelegate* delegate) |
| 15 : delegate_(delegate) { | 15 : WidgetWin(delegate->AsNativeWidgetDelegate()), |
| 16 delegate_(delegate) { |
| 16 } | 17 } |
| 17 | 18 |
| 18 MenuHostWin::~MenuHostWin() { | 19 MenuHostWin::~MenuHostWin() { |
| 19 } | 20 } |
| 20 | 21 |
| 21 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 22 // MenuHostWin, NativeMenuHost implementation: | 23 // MenuHostWin, NativeMenuHost implementation: |
| 23 | 24 |
| 24 void MenuHostWin::StartCapturing() { | 25 void MenuHostWin::StartCapturing() { |
| 25 SetMouseCapture(); | 26 SetMouseCapture(); |
| 26 } | 27 } |
| 27 | 28 |
| 28 NativeWidget* MenuHostWin::AsNativeWidget() { | 29 NativeWidget* MenuHostWin::AsNativeWidget() { |
| 29 return this; | 30 return this; |
| 30 } | 31 } |
| 31 | 32 |
| 32 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
| 33 // MenuHostWin, WidgetWin overrides: | 34 // MenuHostWin, WidgetWin overrides: |
| 34 | 35 |
| 35 void MenuHostWin::OnDestroy() { | 36 void MenuHostWin::OnDestroy() { |
| 36 delegate_->OnNativeMenuHostDestroy(); | 37 delegate_->OnNativeMenuHostDestroy(); |
| 37 WidgetWin::OnDestroy(); | 38 WidgetWin::OnDestroy(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void MenuHostWin::OnCancelMode() { | 41 void MenuHostWin::OnCancelMode() { |
| 41 delegate_->OnNativeMenuHostCancelCapture(); | 42 delegate_->OnNativeMenuHostCancelCapture(); |
| 42 WidgetWin::OnCancelMode(); | 43 WidgetWin::OnCancelMode(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 // TODO(beng): remove once MenuHost is-a Widget | |
| 46 RootView* MenuHostWin::CreateRootView() { | |
| 47 return delegate_->CreateRootView(); | |
| 48 } | |
| 49 | |
| 50 // TODO(beng): remove once MenuHost is-a Widget | |
| 51 bool MenuHostWin::ShouldReleaseCaptureOnMouseReleased() const { | |
| 52 return delegate_->ShouldReleaseCaptureOnMouseRelease(); | |
| 53 } | |
| 54 | |
| 55 //////////////////////////////////////////////////////////////////////////////// | 46 //////////////////////////////////////////////////////////////////////////////// |
| 56 // NativeMenuHost, public: | 47 // NativeMenuHost, public: |
| 57 | 48 |
| 58 // static | 49 // static |
| 59 NativeMenuHost* NativeMenuHost::CreateNativeMenuHost( | 50 NativeMenuHost* NativeMenuHost::CreateNativeMenuHost( |
| 60 internal::NativeMenuHostDelegate* delegate) { | 51 internal::NativeMenuHostDelegate* delegate) { |
| 61 return new MenuHostWin(delegate); | 52 return new MenuHostWin(delegate); |
| 62 } | 53 } |
| 63 | 54 |
| 64 } // namespace views | 55 } // namespace views |
| OLD | NEW |