| 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.h" | 5 #include "views/controls/menu/menu_host.h" |
| 6 | 6 |
| 7 #include "views/controls/menu/menu_controller.h" | 7 #include "views/controls/menu/menu_controller.h" |
| 8 #include "views/controls/menu/menu_host_root_view.h" | 8 #include "views/controls/menu/menu_host_root_view.h" |
| 9 #include "views/controls/menu/menu_item_view.h" | 9 #include "views/controls/menu/menu_item_view.h" |
| 10 #include "views/controls/menu/native_menu_host.h" | 10 #include "views/controls/menu/native_menu_host.h" |
| 11 #include "views/controls/menu/submenu_view.h" | 11 #include "views/controls/menu/submenu_view.h" |
| 12 #include "views/widget/native_widget.h" | 12 #include "views/widget/native_widget.h" |
| 13 #include "views/widget/widget.h" | 13 #include "views/widget/widget.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
| 18 // MenuHost, public: | 18 // MenuHost, public: |
| 19 | 19 |
| 20 MenuHost::MenuHost(SubmenuView* submenu) | 20 MenuHost::MenuHost(SubmenuView* submenu) |
| 21 : ALLOW_THIS_IN_INITIALIZER_LIST(native_menu_host_( | 21 : ALLOW_THIS_IN_INITIALIZER_LIST(native_menu_host_( |
| 22 NativeMenuHost::CreateNativeMenuHost(this))), | 22 NativeMenuHost::CreateNativeMenuHost(this))), |
| 23 submenu_(submenu), | 23 submenu_(submenu), |
| 24 destroying_(false) { | 24 destroying_(false) { |
| 25 Widget::CreateParams params; | |
| 26 params.type = Widget::CreateParams::TYPE_MENU; | |
| 27 params.has_dropshadow = true; | |
| 28 GetWidget()->SetCreateParams(params); | |
| 29 } | 25 } |
| 30 | 26 |
| 31 MenuHost::~MenuHost() { | 27 MenuHost::~MenuHost() { |
| 32 } | 28 } |
| 33 | 29 |
| 34 void MenuHost::InitMenuHost(gfx::NativeWindow parent, | 30 void MenuHost::InitMenuHost(gfx::NativeWindow parent, |
| 35 const gfx::Rect& bounds, | 31 const gfx::Rect& bounds, |
| 36 View* contents_view, | 32 View* contents_view, |
| 37 bool do_capture) { | 33 bool do_capture) { |
| 38 native_menu_host_->InitMenuHost(parent, bounds); | 34 Widget::CreateParams params; |
| 35 params.type = Widget::CreateParams::TYPE_MENU; |
| 36 params.has_dropshadow = true; |
| 37 #if defined(OS_WIN) |
| 38 params.parent = parent; |
| 39 #elif defined(TOOLKIT_USES_GTK) |
| 40 params.parent = GTK_WIDGET(parent); |
| 41 #endif |
| 42 params.bounds = bounds; |
| 43 GetWidget()->Init(params); |
| 39 GetWidget()->SetContentsView(contents_view); | 44 GetWidget()->SetContentsView(contents_view); |
| 40 ShowMenuHost(do_capture); | 45 ShowMenuHost(do_capture); |
| 41 } | 46 } |
| 42 | 47 |
| 43 bool MenuHost::IsMenuHostVisible() { | 48 bool MenuHost::IsMenuHostVisible() { |
| 44 return GetWidget()->IsVisible(); | 49 return GetWidget()->IsVisible(); |
| 45 } | 50 } |
| 46 | 51 |
| 47 void MenuHost::ShowMenuHost(bool do_capture) { | 52 void MenuHost::ShowMenuHost(bool do_capture) { |
| 48 GetWidget()->Show(); | 53 GetWidget()->Show(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 107 |
| 103 RootView* MenuHost::CreateRootView() { | 108 RootView* MenuHost::CreateRootView() { |
| 104 return new MenuHostRootView(GetWidget(), submenu_); | 109 return new MenuHostRootView(GetWidget(), submenu_); |
| 105 } | 110 } |
| 106 | 111 |
| 107 bool MenuHost::ShouldReleaseCaptureOnMouseRelease() const { | 112 bool MenuHost::ShouldReleaseCaptureOnMouseRelease() const { |
| 108 return false; | 113 return false; |
| 109 } | 114 } |
| 110 | 115 |
| 111 } // namespace views | 116 } // namespace views |
| OLD | NEW |