summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-12 00:59:16 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-12 00:59:16 +0000
commit33c90eba54629044ddde7cc3aad60b4318d7688a (patch)
tree5ba3b69551ed2fdb3428db18ea6ca0efddc2e108 /views
parent058ec576e37cbffd972f8713831160e9a6b0f7b4 (diff)
downloadchromium_src-33c90eba54629044ddde7cc3aad60b4318d7688a.zip
chromium_src-33c90eba54629044ddde7cc3aad60b4318d7688a.tar.gz
chromium_src-33c90eba54629044ddde7cc3aad60b4318d7688a.tar.bz2
Add stub WidgetImpl class. This will become the cross platform replacement for Widget, and will merge the common functionality between NativeWidgetWin and WidgetGtk.
Right now it does nothing other than implement Widget (for compatibility) and the new NativeWidgetListener interface, imported from ui/views/widget. This new interface is the NativeWidget's way of notifying the Widget of events. Also bring across the NativeWidget interface from ui/views/widget, which will be implemented by NativeWidgetWin in a future changelist. BUG=72040 TEST=none TBR=sky Review URL: http://codereview.chromium.org/6510008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74708 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/views.gyp4
-rw-r--r--views/widget/native_widget.h77
-rw-r--r--views/widget/native_widget_listener.h62
-rw-r--r--views/widget/widget_impl.cc220
-rw-r--r--views/widget/widget_impl.h94
5 files changed, 457 insertions, 0 deletions
diff --git a/views/views.gyp b/views/views.gyp
index 881085e..045a2de 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -342,11 +342,15 @@
'widget/tooltip_window_gtk.h',
'widget/monitor_win.cc',
'widget/monitor_win.h',
+ 'widget/native_widget.h',
+ 'widget/native_widget_listener.h',
'widget/native_widget_win.cc',
'widget/native_widget_win.h',
'widget/widget.h',
'widget/widget_gtk.cc',
'widget/widget_gtk.h',
+ 'widget/widget_impl.cc',
+ 'widget/widget_impl.h',
'widget/widget_utils.cc',
'widget/widget_utils.h',
'window/client_view.cc',
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
new file mode 100644
index 0000000..a173fc2
--- /dev/null
+++ b/views/widget/native_widget.h
@@ -0,0 +1,77 @@
+// 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_WIDGET_NATIVE_WIDGET_H_
+#define VIEWS_WIDGET_NATIVE_WIDGET_H_
+
+#include "ui/views/native_types.h"
+
+namespace gfx{
+class Path;
+class Rect;
+}
+
+namespace views {
+namespace internal {
+class NativeWidgetListener;
+}
+class View;
+class Widget;
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeWidget interface
+//
+// An interface implemented by an object that encapsulates rendering, event
+// handling and widget management provided by an underlying native toolkit.
+//
+class NativeWidget {
+ public:
+ virtual ~NativeWidget() {}
+
+ static NativeWidget* CreateNativeWidget(
+ internal::NativeWidgetListener* listener);
+
+ // Retrieves the NativeWidget implementation associated with the given
+ // NativeView or Window, or NULL if the supplied handle has no associated
+ // NativeView.
+ static NativeWidget* GetNativeWidgetForNativeView(
+ gfx::NativeView native_view);
+ static NativeWidget* GetNativeWidgetForNativeWindow(
+ gfx::NativeWindow native_window);
+
+ // Retrieves the top NativeWidget in the hierarchy containing the given
+ // NativeView, or NULL if there is no NativeWidget that contains it.
+ static NativeWidget* GetTopLevelNativeWidget(gfx::NativeView native_view);
+
+ // See Widget for documentation and notes.
+ virtual void InitWithNativeViewParent(gfx::NativeView parent,
+ const gfx::Rect& bounds) = 0;
+ virtual void SetNativeWindowProperty(const char* name, void* value) = 0;
+ virtual void* GetNativeWindowProperty(const char* name) const = 0;
+ virtual gfx::Rect GetWindowScreenBounds() const = 0;
+ virtual gfx::Rect GetClientAreaScreenBounds() const = 0;
+ virtual void SetBounds(const gfx::Rect& bounds) = 0;
+ virtual void SetShape(const gfx::Path& shape) = 0;
+ virtual gfx::NativeView GetNativeView() const = 0;
+ virtual void Show() = 0;
+ virtual void Hide() = 0;
+ virtual void Close() = 0;
+ virtual void MoveAbove(NativeWidget* other) = 0;
+ virtual void SetAlwaysOnTop(bool always_on_top) = 0;
+ virtual bool IsVisible() const = 0;
+ virtual bool IsActive() const = 0;
+ virtual void SetMouseCapture() = 0;
+ virtual void ReleaseMouseCapture() = 0;
+ virtual bool HasMouseCapture() const = 0;
+ virtual bool ShouldReleaseCaptureOnMouseReleased() const = 0;
+ virtual void Invalidate() = 0;
+ virtual void InvalidateRect(const gfx::Rect& invalid_rect) = 0;
+ virtual void Paint() = 0;
+ virtual void FocusNativeView(gfx::NativeView native_view) = 0;
+ virtual Widget* GetWidget() const = 0;
+};
+
+} // namespace views
+
+#endif // VIEWS_WIDGET_NATIVE_WIDGET_H_
diff --git a/views/widget/native_widget_listener.h b/views/widget/native_widget_listener.h
new file mode 100644
index 0000000..e3e5de1
--- /dev/null
+++ b/views/widget/native_widget_listener.h
@@ -0,0 +1,62 @@
+// 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_WIDGET_NATIVE_WIDGET_LISTENER_H_
+#define VIEWS_WIDGET_NATIVE_WIDGET_LISTENER_H_
+
+#include "ui/gfx/native_widget_types.h"
+
+namespace gfx {
+class Canvas;
+class Point;
+class Size;
+}
+
+namespace views {
+class KeyEvent;
+class MouseEvent;
+class MouseWheelEvent;
+class WidgetImpl;
+
+namespace internal {
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeWidgetListener interface
+//
+// An interface implemented by the Widget that handles events sent from a
+// NativeWidget implementation.
+//
+class NativeWidgetListener {
+ public:
+ virtual ~NativeWidgetListener() {}
+
+ virtual void OnClose() = 0;
+
+ virtual void OnDestroy() = 0;
+ virtual void OnDisplayChanged() = 0;
+
+ virtual bool OnKeyEvent(const KeyEvent& event) = 0;
+
+ virtual void OnMouseCaptureLost() = 0;
+
+ virtual bool OnMouseEvent(const MouseEvent& event) = 0;
+ virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) = 0;
+
+ virtual void OnNativeWidgetCreated() = 0;
+
+ virtual void OnPaint(gfx::Canvas* canvas) = 0;
+ virtual void OnSizeChanged(const gfx::Size& size) = 0;
+
+ virtual void OnNativeFocus(gfx::NativeView focused_view) = 0;
+ virtual void OnNativeBlur(gfx::NativeView focused_view) = 0;
+
+ virtual void OnWorkAreaChanged() = 0;
+
+ virtual WidgetImpl* GetWidgetImpl() const = 0;
+};
+
+} // namespace internal
+} // namespace views
+
+#endif // VIEWS_WIDGET_NATIVE_WIDGET_LISTENER_H_
diff --git a/views/widget/widget_impl.cc b/views/widget/widget_impl.cc
new file mode 100644
index 0000000..c3292c9
--- /dev/null
+++ b/views/widget/widget_impl.cc
@@ -0,0 +1,220 @@
+// 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/widget/widget_impl.h"
+
+namespace views {
+
+////////////////////////////////////////////////////////////////////////////////
+// WidgetImpl, public:
+
+WidgetImpl::WidgetImpl() {
+}
+
+WidgetImpl::~WidgetImpl() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WidgetImpl, Widget implementation:
+
+void WidgetImpl::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
+
+}
+
+void WidgetImpl::InitWithWidget(Widget* parent, const gfx::Rect& bounds) {
+
+}
+
+WidgetDelegate* WidgetImpl::GetWidgetDelegate() {
+ return NULL;
+}
+
+void WidgetImpl::SetWidgetDelegate(WidgetDelegate* delegate) {
+
+}
+
+void WidgetImpl::SetContentsView(View* view) {
+
+}
+
+void WidgetImpl::GetBounds(gfx::Rect* out, bool including_frame) const {
+
+}
+
+void WidgetImpl::SetBounds(const gfx::Rect& bounds) {
+
+}
+
+void WidgetImpl::MoveAbove(Widget* other) {
+
+}
+
+void WidgetImpl::SetShape(gfx::NativeRegion region) {
+
+}
+
+void WidgetImpl::Close() {
+
+}
+
+void WidgetImpl::CloseNow() {
+
+}
+
+void WidgetImpl::Show() {
+
+}
+
+void WidgetImpl::Hide() {
+
+}
+
+gfx::NativeView WidgetImpl::GetNativeView() const {
+ return NULL;
+}
+
+void WidgetImpl::PaintNow(const gfx::Rect& update_rect) {
+
+}
+
+void WidgetImpl::SetOpacity(unsigned char opacity) {
+}
+
+void WidgetImpl::SetAlwaysOnTop(bool on_top) {
+
+}
+
+RootView* WidgetImpl::GetRootView() {
+ return NULL;
+}
+
+Widget* WidgetImpl::GetRootWidget() const {
+ return NULL;
+}
+
+bool WidgetImpl::IsVisible() const {
+ return false;
+}
+
+bool WidgetImpl::IsActive() const {
+ return false;
+}
+
+bool WidgetImpl::IsAccessibleWidget() const {
+ return false;
+}
+
+TooltipManager* WidgetImpl::GetTooltipManager() {
+ return NULL;
+}
+
+void WidgetImpl::GenerateMousePressedForView(View* view,
+ const gfx::Point& point) {
+
+}
+
+bool WidgetImpl::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
+ return false;
+}
+
+Window* WidgetImpl::GetWindow() {
+ return NULL;
+}
+
+const Window* WidgetImpl::GetWindow() const {
+ return NULL;
+}
+
+void WidgetImpl::SetNativeWindowProperty(const char* name, void* value) {
+
+}
+
+void* WidgetImpl::GetNativeWindowProperty(const char* name) {
+ return NULL;
+}
+
+ThemeProvider* WidgetImpl::GetThemeProvider() const {
+ return NULL;
+}
+
+ThemeProvider* WidgetImpl::GetDefaultThemeProvider() const {
+ return NULL;
+}
+
+FocusManager* WidgetImpl::GetFocusManager() {
+ return NULL;
+}
+
+void WidgetImpl::ViewHierarchyChanged(bool is_add, View *parent,
+ View *child) {
+
+}
+
+bool WidgetImpl::ContainsNativeView(gfx::NativeView native_view) {
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WidgetImpl, NativeWidgetListener implementation:
+
+void WidgetImpl::OnClose() {
+
+}
+
+void WidgetImpl::OnDestroy() {
+
+}
+
+void WidgetImpl::OnDisplayChanged() {
+
+}
+
+bool WidgetImpl::OnKeyEvent(const KeyEvent& event) {
+ return false;
+}
+
+void WidgetImpl::OnMouseCaptureLost() {
+
+}
+
+bool WidgetImpl::OnMouseEvent(const MouseEvent& event) {
+ return false;
+}
+
+bool WidgetImpl::OnMouseWheelEvent(const MouseWheelEvent& event) {
+ return false;
+}
+
+void WidgetImpl::OnNativeWidgetCreated() {
+
+}
+
+void WidgetImpl::OnPaint(gfx::Canvas* canvas) {
+
+}
+
+void WidgetImpl::OnSizeChanged(const gfx::Size& size) {
+
+}
+
+void WidgetImpl::OnNativeFocus(gfx::NativeView focused_view) {
+
+}
+
+void WidgetImpl::OnNativeBlur(gfx::NativeView focused_view) {
+
+}
+
+void WidgetImpl::OnWorkAreaChanged() {
+
+}
+
+WidgetImpl* WidgetImpl::GetWidgetImpl() const {
+ return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WidgetImpl, private:
+
+} // namespace views
diff --git a/views/widget/widget_impl.h b/views/widget/widget_impl.h
new file mode 100644
index 0000000..8f00711
--- /dev/null
+++ b/views/widget/widget_impl.h
@@ -0,0 +1,94 @@
+// 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_WIDGET_WIDGET_IMPL_H_
+#define VIEWS_WIDGET_WIDGET_IMPL_H_
+#pragma once
+
+#include "views/widget/native_widget_listener.h"
+#include "views/widget/widget.h"
+
+namespace views {
+
+class NativeWidget;
+
+////////////////////////////////////////////////////////////////////////////////
+// WidgetImpl class
+//
+// An object that represents a native widget that hosts a view hierarchy.
+// A WidgetImpl is owned by a NativeWidget implementation.
+//
+// TODO(beng): This class should be renamed Widget after the transition to the
+// V2 API is complete.
+//
+class WidgetImpl : public Widget,
+ internal::NativeWidgetListener {
+ public:
+ WidgetImpl();
+ virtual ~WidgetImpl();
+
+ private:
+ // Overridden from Widget:
+ virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds);
+ virtual void InitWithWidget(Widget* parent, const gfx::Rect& bounds);
+ virtual WidgetDelegate* GetWidgetDelegate();
+ virtual void SetWidgetDelegate(WidgetDelegate* delegate);
+ virtual void SetContentsView(View* view);
+ virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
+ virtual void SetBounds(const gfx::Rect& bounds);
+ virtual void MoveAbove(Widget* other);
+ virtual void SetShape(gfx::NativeRegion region);
+ virtual void Close();
+ virtual void CloseNow();
+ virtual void Show();
+ virtual void Hide();
+ virtual gfx::NativeView GetNativeView() const;
+ virtual void PaintNow(const gfx::Rect& update_rect);
+ virtual void SetOpacity(unsigned char opacity);
+ virtual void SetAlwaysOnTop(bool on_top);
+ virtual RootView* GetRootView();
+ virtual Widget* GetRootWidget() const;
+ virtual bool IsVisible() const;
+ virtual bool IsActive() const;
+ virtual bool IsAccessibleWidget() const;
+ virtual TooltipManager* GetTooltipManager();
+ virtual void GenerateMousePressedForView(View* view,
+ const gfx::Point& point);
+ virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
+ virtual Window* GetWindow();
+ virtual const Window* GetWindow() const;
+ virtual void SetNativeWindowProperty(const char* name, void* value);
+ virtual void* GetNativeWindowProperty(const char* name);
+ virtual ThemeProvider* GetThemeProvider() const;
+ virtual ThemeProvider* GetDefaultThemeProvider() const;
+ virtual FocusManager* GetFocusManager();
+ virtual void ViewHierarchyChanged(bool is_add, View *parent,
+ View *child);
+ virtual bool ContainsNativeView(gfx::NativeView native_view);
+
+ // Overridden from NativeWidgetListener:
+ virtual void OnClose();
+ virtual void OnDestroy();
+ virtual void OnDisplayChanged();
+ virtual bool OnKeyEvent(const KeyEvent& event);
+ virtual void OnMouseCaptureLost();
+ virtual bool OnMouseEvent(const MouseEvent& event);
+ virtual bool OnMouseWheelEvent(const MouseWheelEvent& event);
+ virtual void OnNativeWidgetCreated();
+ virtual void OnPaint(gfx::Canvas* canvas);
+ virtual void OnSizeChanged(const gfx::Size& size);
+ virtual void OnNativeFocus(gfx::NativeView focused_view);
+ virtual void OnNativeBlur(gfx::NativeView focused_view);
+ virtual void OnWorkAreaChanged();
+ virtual WidgetImpl* GetWidgetImpl() const;
+
+ // Weak.
+ NativeWidget* native_widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(WidgetImpl);
+};
+
+} // namespace views
+
+#endif // VIEWS_WIDGET_WIDGET_H_