summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-05 00:58:06 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-05 00:58:06 +0000
commita55bfd3d8f23c22003cf6a0754aa320fe7b7d3e4 (patch)
treef90c20acb5701e17d66fabfce5ca90c827ca9c2e /views/widget
parentbd205617c4f7eca4bb28c0343ed2f071189393c3 (diff)
downloadchromium_src-a55bfd3d8f23c22003cf6a0754aa320fe7b7d3e4.zip
chromium_src-a55bfd3d8f23c22003cf6a0754aa320fe7b7d3e4.tar.gz
chromium_src-a55bfd3d8f23c22003cf6a0754aa320fe7b7d3e4.tar.bz2
Add cross platform Widget::InitWithWidget(parent, const gfx::Rect& bounds);
On linux, native parent has to be either window_contents or widget depending of the type of wiget. InitWithWidget takes a parent Widget instead of native and hides these details. I also cleaned up a few dead/duplicated code. BUG=none TEST=none Review URL: http://codereview.chromium.org/2355003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/widget.h7
-rw-r--r--views/widget/widget_gtk.cc15
-rw-r--r--views/widget/widget_gtk.h1
-rw-r--r--views/widget/widget_win.cc4
-rw-r--r--views/widget/widget_win.h1
5 files changed, 28 insertions, 0 deletions
diff --git a/views/widget/widget.h b/views/widget/widget.h
index d4ddcfc..cf893ee 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -97,6 +97,13 @@ class Widget {
// contents as the window is sized.
virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds) = 0;
+ // 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;
+
// Returns the WidgetDelegate for delegating certain events.
virtual WidgetDelegate* GetWidgetDelegate() = 0;
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 055c855..78137c5 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -456,6 +456,21 @@ void WidgetGtk::ActiveWindowChanged(GdkWindow* active_window) {
////////////////////////////////////////////////////////////////////////////////
// WidgetGtk, Widget implementation:
+void WidgetGtk::InitWithWidget(Widget* parent,
+ const gfx::Rect& bounds) {
+ WidgetGtk* parent_gtk = static_cast<WidgetGtk*>(parent);
+ GtkWidget* native_parent = NULL;
+ if (parent != NULL) {
+ if (type_ != TYPE_CHILD) {
+ // window's parent has to be window.
+ native_parent = parent_gtk->GetNativeView();
+ } else {
+ native_parent = parent_gtk->window_contents();
+ }
+ }
+ Init(native_parent, bounds);
+}
+
void WidgetGtk::Init(GtkWidget* parent,
const gfx::Rect& bounds) {
if (type_ != TYPE_CHILD)
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index 980baaf..beb629f 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -152,6 +152,7 @@ class WidgetGtk
// 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);
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 2b4c649..72431b0 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -170,6 +170,10 @@ void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
ImmAssociateContextEx(hwnd(), NULL, 0);
}
+void WidgetWin::InitWithWidget(Widget* parent, const gfx::Rect& bounds) {
+ Init(parent->GetNativeView(), bounds);
+}
+
WidgetDelegate* WidgetWin::GetWidgetDelegate() {
return delegate_;
}
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index f5ac2d1..e0cdc44d 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -181,6 +181,7 @@ class WidgetWin : public app::WindowImpl,
// 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);