summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-28 17:48:11 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-28 17:48:11 +0000
commitbead2c9fb8932fde4bf40a61b9563401d11c69ef (patch)
tree3253e54b789680322ae26e6eaa9c7af380652af5 /views/controls
parent805ca7ed20f92d79e02772ab8b28636a863b21bb (diff)
downloadchromium_src-bead2c9fb8932fde4bf40a61b9563401d11c69ef.zip
chromium_src-bead2c9fb8932fde4bf40a61b9563401d11c69ef.tar.gz
chromium_src-bead2c9fb8932fde4bf40a61b9563401d11c69ef.tar.bz2
Menus in the views desktop. Adds MenuHostViews. This is buggy due to rendering issues I believe.
Moves IsMouseButtonDown to a static method on Widget that is implemented by each platform. It needs to be static as it can be called before the NativeWidget is fully initialized, and does not depend on any NativeWidget state. BUG=none TEST=none Review URL: http://codereview.chromium.org/7253018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90793 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/menu/menu_host_gtk.cc6
-rw-r--r--views/controls/menu/menu_host_views.cc33
-rw-r--r--views/controls/menu/menu_host_views.h40
-rw-r--r--views/controls/menu/menu_host_win.cc6
4 files changed, 85 insertions, 0 deletions
diff --git a/views/controls/menu/menu_host_gtk.cc b/views/controls/menu/menu_host_gtk.cc
index 962d701..c3ff9cd 100644
--- a/views/controls/menu/menu_host_gtk.cc
+++ b/views/controls/menu/menu_host_gtk.cc
@@ -11,7 +11,9 @@
#include <X11/extensions/XInput2.h>
#endif
+#include "views/controls/menu/menu_host_views.h"
#include "views/controls/menu/native_menu_host_delegate.h"
+#include "views/views_delegate.h"
#if defined(HAVE_XINPUT2) && defined(TOUCH_UI)
#include "views/touchui/touch_factory.h"
@@ -132,6 +134,10 @@ void MenuHostGtk::HandleGtkGrabBroke() {
// static
NativeMenuHost* NativeMenuHost::CreateNativeMenuHost(
internal::NativeMenuHostDelegate* delegate) {
+ if (Widget::IsPureViews() &&
+ ViewsDelegate::views_delegate->GetDefaultParentView()) {
+ return new MenuHostViews(delegate);
+ }
return new MenuHostGtk(delegate);
}
diff --git a/views/controls/menu/menu_host_views.cc b/views/controls/menu/menu_host_views.cc
new file mode 100644
index 0000000..6896d67
--- /dev/null
+++ b/views/controls/menu/menu_host_views.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "views/controls/menu/menu_host_views.h"
+
+#include "views/controls/menu/native_menu_host_delegate.h"
+
+namespace views {
+
+MenuHostViews::MenuHostViews(internal::NativeMenuHostDelegate* delegate)
+ : NativeWidgetViews(delegate->AsNativeWidgetDelegate()),
+ delegate_(delegate) {
+}
+
+MenuHostViews::~MenuHostViews() {
+}
+
+void MenuHostViews::StartCapturing() {
+ SetMouseCapture();
+}
+
+NativeWidget* MenuHostViews::AsNativeWidget() {
+ return this;
+}
+
+void MenuHostViews::InitNativeWidget(const Widget::InitParams& params) {
+ NativeWidgetViews::InitNativeWidget(params);
+ GetView()->SetVisible(false);
+}
+
+} // namespace views
+
diff --git a/views/controls/menu/menu_host_views.h b/views/controls/menu/menu_host_views.h
new file mode 100644
index 0000000..7ab1729
--- /dev/null
+++ b/views/controls/menu/menu_host_views.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef VIEWS_CONTROLS_MENU_MENU_HOST_VIEWS_H_
+#define VIEWS_CONTROLS_MENU_MENU_HOST_VIEWS_H_
+#pragma once
+
+#include "views/controls/menu/native_menu_host.h"
+#include "views/widget/native_widget_views.h"
+
+namespace views {
+namespace internal {
+class NativeMenuHostDelegate;
+}
+
+// MenuHost implementation for views.
+class MenuHostViews : public NativeWidgetViews,
+ public NativeMenuHost {
+ public:
+ explicit MenuHostViews(internal::NativeMenuHostDelegate* delegate);
+ virtual ~MenuHostViews();
+
+ private:
+ // Overridden from NativeMenuHost:
+ virtual void StartCapturing() OVERRIDE;
+ virtual NativeWidget* AsNativeWidget() OVERRIDE;
+
+ // Overridden from NativeWidgetViews:
+ virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
+
+ internal::NativeMenuHostDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(MenuHostViews);
+};
+
+} // namespace views
+
+#endif // VIEWS_CONTROLS_MENU_MENU_HOST_VIEWS_H_
+
diff --git a/views/controls/menu/menu_host_win.cc b/views/controls/menu/menu_host_win.cc
index 7e01134..2190b29 100644
--- a/views/controls/menu/menu_host_win.cc
+++ b/views/controls/menu/menu_host_win.cc
@@ -4,7 +4,9 @@
#include "views/controls/menu/menu_host_win.h"
+#include "views/controls/menu/menu_host_views.h"
#include "views/controls/menu/native_menu_host_delegate.h"
+#include "views/views_delegate.h"
namespace views {
@@ -49,6 +51,10 @@ void MenuHostWin::OnCancelMode() {
// static
NativeMenuHost* NativeMenuHost::CreateNativeMenuHost(
internal::NativeMenuHostDelegate* delegate) {
+ if (Widget::IsPureViews() &&
+ ViewsDelegate::views_delegate->GetDefaultParentView()) {
+ return new MenuHostViews(delegate);
+ }
return new MenuHostWin(delegate);
}