summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-25 03:18:47 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-25 03:18:47 +0000
commit4b1e10d42edc03ee1ecea2d408ec63f5f7d804b5 (patch)
treec3b03fc1a4d364ab485b2e4fbcd478ea08fcd545 /views
parent67fc03984940b07daa38970e6876fcec1fce0e8e (diff)
downloadchromium_src-4b1e10d42edc03ee1ecea2d408ec63f5f7d804b5.zip
chromium_src-4b1e10d42edc03ee1ecea2d408ec63f5f7d804b5.tar.gz
chromium_src-4b1e10d42edc03ee1ecea2d408ec63f5f7d804b5.tar.bz2
Make Widget non-abstract.
BUG=72040 TEST=none TBR=sky Review URL: http://codereview.chromium.org/6574052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/views.gyp1
-rw-r--r--views/widget/widget.cc155
-rw-r--r--views/widget/widget.h110
3 files changed, 214 insertions, 52 deletions
diff --git a/views/views.gyp b/views/views.gyp
index b97d617..6611d6e 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -346,6 +346,7 @@
'widget/tooltip_window_gtk.h',
'widget/monitor_win.cc',
'widget/monitor_win.h',
+ 'widget/widget.cc',
'widget/widget.h',
'widget/widget_gtk.cc',
'widget/widget_gtk.h',
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
new file mode 100644
index 0000000..64c6af0
--- /dev/null
+++ b/views/widget/widget.cc
@@ -0,0 +1,155 @@
+// 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.h"
+
+namespace views {
+
+////////////////////////////////////////////////////////////////////////////////
+// Widget, public:
+
+Widget::Widget() {
+}
+
+void Widget::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
+}
+
+void Widget::InitWithWidget(Widget* parent, const gfx::Rect& bounds) {
+}
+
+WidgetDelegate* Widget::GetWidgetDelegate() {
+ return NULL;
+}
+
+void Widget::SetWidgetDelegate(WidgetDelegate* delegate) {
+}
+
+void Widget::SetContentsView(View* view) {
+}
+
+void Widget::GetBounds(gfx::Rect* out, bool including_frame) const {
+}
+
+void Widget::SetBounds(const gfx::Rect& bounds) {
+}
+
+void Widget::MoveAbove(Widget* widget) {
+}
+
+void Widget::SetShape(gfx::NativeRegion shape) {
+}
+
+void Widget::Close() {
+}
+
+void Widget::CloseNow() {
+}
+
+void Widget::Show() {
+}
+
+void Widget::Hide() {
+}
+
+gfx::NativeView Widget::GetNativeView() const {
+ return NULL;
+}
+
+void Widget::SetOpacity(unsigned char opacity) {
+}
+
+void Widget::SetAlwaysOnTop(bool on_top) {
+}
+
+RootView* Widget::GetRootView() {
+ return NULL;
+}
+
+Widget* Widget::GetRootWidget() const {
+ return NULL;
+}
+
+bool Widget::IsVisible() const {
+ return false;
+}
+
+bool Widget::IsActive() const {
+ return false;
+}
+
+bool Widget::IsAccessibleWidget() const {
+ return false;
+}
+
+void Widget::GenerateMousePressedForView(View* view, const gfx::Point& point) {
+}
+
+TooltipManager* Widget::GetTooltipManager() {
+ return NULL;
+}
+
+bool Widget::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
+ return false;
+}
+
+Window* Widget::GetWindow() {
+ return NULL;
+}
+
+const Window* Widget::GetWindow() const {
+ return NULL;
+}
+
+void Widget::SetNativeWindowProperty(const char* name, void* value) {
+}
+
+void* Widget::GetNativeWindowProperty(const char* name) {
+ return NULL;
+}
+
+ThemeProvider* Widget::GetThemeProvider() const {
+ return NULL;
+}
+
+ThemeProvider* Widget::GetDefaultThemeProvider() const {
+ return NULL;
+}
+
+FocusManager* Widget::GetFocusManager() {
+ return NULL;
+}
+
+void Widget::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
+}
+
+bool Widget::ContainsNativeView(gfx::NativeView native_view) {
+ return false;
+}
+
+void Widget::StartDragForViewFromMouseEvent(View* view,
+ const ui::OSExchangeData& data,
+ int operation) {
+}
+
+View* Widget::GetDraggedView() {
+ return NULL;
+}
+
+void Widget::SchedulePaintInRect(const gfx::Rect& rect) {
+}
+
+void Widget::SetCursor(gfx::NativeCursor cursor) {
+}
+
+FocusTraversable* Widget::GetFocusTraversable() {
+ return NULL;
+}
+
+void Widget::ThemeChanged() {
+}
+
+void Widget::LocaleChanged() {
+}
+
+} // namespace views
diff --git a/views/widget/widget.h b/views/widget/widget.h
index 2e12a74..45e128c 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -34,20 +34,22 @@ class WidgetDelegate;
class Window;
////////////////////////////////////////////////////////////////////////////////
+// Widget class
//
-// Widget interface
+// Encapsulates the platform-specific rendering, event receiving and widget
+// management aspects of the UI framework.
//
-// Widget is an abstract class that defines the API that should be implemented
-// by a native window in order to host a view hierarchy.
+// Owns a RootView and thus a View hierarchy. Can contain child Widgets.
+// Widget is a platform-independent type that communicates with a platform or
+// context specific NativeWidget implementation.
//
-// Widget wraps a hierarchy of View objects (see view.h) that implement
-// painting and flexible layout within the bounds of the Widget's window.
+// TODO(beng): Note that this class being non-abstract means that we have a
+// violation of Google style in that we are using multiple
+// inheritance. The intention is to split this into a separate
+// object associated with but not equal to a NativeWidget
+// implementation. Multiple inheritance is required for this
+// transitional step.
//
-// The Widget is responsible for handling various system events and forwarding
-// them to the appropriate view.
-//
-/////////////////////////////////////////////////////////////////////////////
-
class Widget {
public:
virtual ~Widget() { }
@@ -101,6 +103,8 @@ class Widget {
// view hierarchies that the locale has changed.
static void NotifyLocaleChanged();
+ Widget();
+
// Initialize the Widget with a parent and an initial desired size.
// |contents_view| is the view that will be the single child of RootView
// within this Widget. As contents_view is inserted into RootView's tree,
@@ -108,125 +112,124 @@ class Widget {
// this view, you are responsible for its destruction. If this value is NULL,
// the caller is responsible for populating the RootView, and sizing its
// contents as the window is sized.
- virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds) = 0;
+ virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds);
// Initialize the widget with a views::Widget parent and an initial
// desired size. This internally invokes |Init(gfx::NativeView,
// const gfx::Rect&)| but it determines the correct native view
// for each platform and the type of widget. Passing NULL to
// |parent| is same as invoking |Init(NULL, bounds)|.
- virtual void InitWithWidget(Widget* parent, const gfx::Rect& bounds) = 0;
+ virtual void InitWithWidget(Widget* parent, const gfx::Rect& bounds);
// Returns the WidgetDelegate for delegating certain events.
- virtual WidgetDelegate* GetWidgetDelegate() = 0;
+ virtual WidgetDelegate* GetWidgetDelegate();
// Sets the WidgetDelegate.
- virtual void SetWidgetDelegate(WidgetDelegate* delegate) = 0;
+ virtual void SetWidgetDelegate(WidgetDelegate* delegate);
// Sets the specified view as the contents of this Widget. There can only
// be one contents view child of this Widget's RootView. This view is sized to
// fit the entire size of the RootView. The RootView takes ownership of this
// View, unless it is set as not being parent-owned.
- virtual void SetContentsView(View* view) = 0;
+ virtual void SetContentsView(View* view);
// Returns the bounds of this Widget in the screen coordinate system.
// If the receiving Widget is a frame which is larger than its client area,
// this method returns the client area if including_frame is false and the
// frame bounds otherwise. If the receiving Widget is not a frame,
// including_frame is ignored.
- virtual void GetBounds(gfx::Rect* out, bool including_frame) const = 0;
+ virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
// Sizes and/or places the widget to the specified bounds, size or position.
- virtual void SetBounds(const gfx::Rect& bounds) = 0;
+ virtual void SetBounds(const gfx::Rect& bounds);
// Places the widget in front of the specified widget in z-order.
- virtual void MoveAbove(Widget* widget) = 0;
+ virtual void MoveAbove(Widget* widget);
// Sets a shape on the widget. This takes ownership of shape.
- virtual void SetShape(gfx::NativeRegion shape) = 0;
+ virtual void SetShape(gfx::NativeRegion shape);
// Hides the widget then closes it after a return to the message loop.
- virtual void Close() = 0;
+ virtual void Close();
// Closes the widget immediately. Compare to |Close|. This will destroy the
// window handle associated with this Widget, so should not be called from
// any code that expects it to be valid beyond this call.
- virtual void CloseNow() = 0;
+ virtual void CloseNow();
// Shows or hides the widget, without changing activation state.
- virtual void Show() = 0;
- virtual void Hide() = 0;
+ virtual void Show();
+ virtual void Hide();
// Returns the gfx::NativeView associated with this Widget.
- virtual gfx::NativeView GetNativeView() const = 0;
+ virtual gfx::NativeView GetNativeView() const;
// Sets the opacity of the widget. This may allow widgets behind the widget
// in the Z-order to become visible, depending on the capabilities of the
// underlying windowing system. Note that the caller must then schedule a
// repaint to allow this change to take effect.
- virtual void SetOpacity(unsigned char opacity) = 0;
+ virtual void SetOpacity(unsigned char opacity);
// Sets the widget to be on top of all other widgets in the windowing system.
- virtual void SetAlwaysOnTop(bool on_top) = 0;
+ virtual void SetAlwaysOnTop(bool on_top);
// Returns the RootView contained by this Widget.
- virtual RootView* GetRootView() = 0;
+ virtual RootView* GetRootView();
// Returns the Widget associated with the root ancestor.
- virtual Widget* GetRootWidget() const = 0;
+ virtual Widget* GetRootWidget() const;
// Returns whether the Widget is visible to the user.
- virtual bool IsVisible() const = 0;
+ virtual bool IsVisible() const;
// Returns whether the Widget is the currently active window.
- virtual bool IsActive() const = 0;
+ virtual bool IsActive() const;
// Returns whether the Widget is customized for accessibility.
- virtual bool IsAccessibleWidget() const = 0;
+ virtual bool IsAccessibleWidget() const;
// Starts a drag operation for the specified view. |point| is a position in
// |view| coordinates that the drag was initiated from.
virtual void GenerateMousePressedForView(View* view,
- const gfx::Point& point) = 0;
+ const gfx::Point& point);
// Returns the TooltipManager for this Widget. If this Widget does not support
// tooltips, NULL is returned.
- virtual TooltipManager* GetTooltipManager() = 0;
+ virtual TooltipManager* GetTooltipManager();
// Returns the accelerator given a command id. Returns false if there is
// no accelerator associated with a given id, which is a common condition.
- virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator) = 0;
+ virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
// Returns the Window containing this Widget, or NULL if not contained in a
// window.
- virtual Window* GetWindow() = 0;
- virtual const Window* GetWindow() const = 0;
+ virtual Window* GetWindow();
+ virtual const Window* GetWindow() const;
// Sets/Gets a native window property on the underlying native window object.
// Returns NULL if the property does not exist. Setting the property value to
// NULL removes the property.
- virtual void SetNativeWindowProperty(const char* name, void* value) = 0;
- virtual void* GetNativeWindowProperty(const char* name) = 0;
+ virtual void SetNativeWindowProperty(const char* name, void* value);
+ virtual void* GetNativeWindowProperty(const char* name);
// Gets the theme provider.
- virtual ThemeProvider* GetThemeProvider() const = 0;
+ virtual ThemeProvider* GetThemeProvider() const;
// Gets the default theme provider; this is necessary for when a widget has
// no profile (and ThemeProvider) associated with it. The default theme
// provider provides a default set of bitmaps that such widgets can use.
- virtual ThemeProvider* GetDefaultThemeProvider() const = 0;
+ virtual ThemeProvider* GetDefaultThemeProvider() const;
// Returns the FocusManager for this widget.
// Note that all widgets in a widget hierarchy share the same focus manager.
- virtual FocusManager* GetFocusManager() = 0;
+ virtual FocusManager* GetFocusManager();
// Forwarded from the RootView so that the widget can do any cleanup.
- virtual void ViewHierarchyChanged(bool is_add, View *parent,
- View *child) = 0;
+ virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
// Returns true if the native view |native_view| is contained in the
// views::View hierarchy rooted at this widget.
- virtual bool ContainsNativeView(gfx::NativeView native_view) = 0;
+ virtual bool ContainsNativeView(gfx::NativeView native_view);
// Starts a drag operation for the specified view. This blocks until done.
// If the view has not been deleted during the drag, OnDragDone is invoked
@@ -234,25 +237,28 @@ class Widget {
// NOTE: |view| may be NULL.
virtual void StartDragForViewFromMouseEvent(View* view,
const ui::OSExchangeData& data,
- int operation) = 0;
+ int operation);
// If a view is dragging, this returns it. Otherwise returns NULL.
- virtual View* GetDraggedView() = 0;
+ virtual View* GetDraggedView();
- virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0;
+ virtual void SchedulePaintInRect(const gfx::Rect& rect);
- virtual void SetCursor(gfx::NativeCursor cursor) = 0;
+ virtual void SetCursor(gfx::NativeCursor cursor);
// Retrieves the focus traversable for this widget.
- virtual FocusTraversable* GetFocusTraversable() = 0;
+ virtual FocusTraversable* GetFocusTraversable();
// Notifies the view hierarchy contained in this widget that theme resources
// changed.
- virtual void ThemeChanged() = 0;
+ virtual void ThemeChanged();
// Notifies the view hierarchy contained in this widget that locale resources
// changed.
- virtual void LocaleChanged() = 0;
+ virtual void LocaleChanged();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Widget);
};
} // namespace views