summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
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);