summaryrefslogtreecommitdiffstats
path: root/views/examples
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 17:43:05 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 17:43:05 +0000
commitaf1fde05ba3696986ba28445ea0c74f96d456ebb (patch)
tree8986d27bfec650d279fa085767279a59442c6eaf /views/examples
parenta6ea9c6010cfa383356c3e84c2976132ce22c9d1 (diff)
downloadchromium_src-af1fde05ba3696986ba28445ea0c74f96d456ebb.zip
chromium_src-af1fde05ba3696986ba28445ea0c74f96d456ebb.tar.gz
chromium_src-af1fde05ba3696986ba28445ea0c74f96d456ebb.tar.bz2
Rework the way Widget::Init works:
- Remove SetCreateParams from the public Widget API. - Add parent/bounds fields to CreateParams - Make Widget::Init be the canonical init method (vs. WidgetWin/Gtk Init) and have it take a CreateParams. - NativeWidget now has a InitNativeWidget method, which subclasses can override. Everyone must call Widget::Init via Widget* (not WidgetWin* as this will be ambiguous to WindowImpl::Init). BUG=72040 TEST=none Review URL: http://codereview.chromium.org/6881107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/examples')
-rw-r--r--views/examples/widget_example.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/views/examples/widget_example.cc b/views/examples/widget_example.cc
index d72276c..537c028f 100644
--- a/views/examples/widget_example.cc
+++ b/views/examples/widget_example.cc
@@ -108,9 +108,7 @@ void WidgetExample::InitWidget(views::Widget* widget, bool transparent) {
#if defined(OS_LINUX)
void WidgetExample::CreateChild(views::View* parent, bool transparent) {
- views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_CONTROL);
- params.transparent = transparent;
- views::Widget* widget = views::Widget::CreateWidget(params);
+ views::Widget* widget = views::Widget::CreateWidget();
// Compute where to place the child widget.
// We'll place it at the center of the root widget.
views::Widget* parent_widget = parent->GetWidget();
@@ -119,15 +117,16 @@ void WidgetExample::CreateChild(views::View* parent, bool transparent) {
bounds.SetRect((bounds.width() - 200) / 2, (bounds.height() - 200) / 2,
200, 200);
// Initialize the child widget with the computed bounds.
- widget->InitWithWidget(parent_widget, bounds);
+ views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_CONTROL);
+ params.transparent = transparent;
+ params.parent_widget = parent_widget;
+ widget->Init(params);
InitWidget(widget, transparent);
}
#endif
void WidgetExample::CreatePopup(views::View* parent, bool transparent) {
- views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP);
- params.transparent = transparent;
- views::Widget* widget = views::Widget::CreateWidget(params);
+ views::Widget* widget = views::Widget::CreateWidget();
// Compute where to place the popup widget.
// We'll place it right below the create button.
@@ -136,9 +135,13 @@ void WidgetExample::CreatePopup(views::View* parent, bool transparent) {
views::View::ConvertPointToScreen(parent, &point);
// Add the height of create_button_.
point.Offset(0, parent->size().height());
- gfx::Rect bounds(point.x(), point.y(), 200, 300);
+
// Initialize the popup widget with the computed bounds.
- widget->InitWithWidget(parent->GetWidget(), bounds);
+ views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP);
+ params.transparent = transparent;
+ params.parent_widget = parent->GetWidget();
+ params.bounds = gfx::Rect(point.x(), point.y(), 200, 300);
+ widget->Init(params);
InitWidget(widget, transparent);
}