summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-23 02:49:34 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-23 02:49:34 +0000
commit232d1b83fbcadc744455b9b1615713d54f974499 (patch)
tree385ea2e2fbacc14b1604721da74a0d226609ef97 /views/widget
parent51d295b8863dc7e88568c598f908ad4c79ff38b6 (diff)
downloadchromium_src-232d1b83fbcadc744455b9b1615713d54f974499.zip
chromium_src-232d1b83fbcadc744455b9b1615713d54f974499.tar.gz
chromium_src-232d1b83fbcadc744455b9b1615713d54f974499.tar.bz2
Makes FindBarWin buildable on linux. FindBarWin should be renamed to
FindBarViews, but I'm leaving it as is for now. BUG=none TEST=none Review URL: http://codereview.chromium.org/113793 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/widget_gtk.cc23
-rw-r--r--views/widget/widget_gtk.h7
2 files changed, 28 insertions, 2 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 1f8790e..fe347a5 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -67,7 +67,8 @@ WidgetGtk::~WidgetGtk() {
MessageLoopForUI::current()->RemoveObserver(this);
}
-void WidgetGtk::Init(const gfx::Rect& bounds,
+void WidgetGtk::Init(GtkWidget* parent,
+ const gfx::Rect& bounds,
bool has_own_focus_manager) {
// Force creation of the RootView if it hasn't been created yet.
GetRootView();
@@ -148,6 +149,13 @@ void WidgetGtk::Init(const gfx::Rect& bounds,
// G_CALLBACK(drag_drop_event_cb), NULL);
// g_signal_connect(G_OBJECT(widget_), "drag_data_received",
// G_CALLBACK(drag_data_received_event_cb), NULL);
+
+ if (type_ == TYPE_CHILD) {
+ WidgetGtk* parent_widget = GetViewForNative(parent);
+ parent_widget->AddChild(widget_);
+ parent_widget->PositionChild(widget_, bounds.x(), bounds.y(),
+ bounds.width(), bounds.height());
+ }
}
void WidgetGtk::AddChild(GtkWidget* child) {
@@ -160,7 +168,9 @@ void WidgetGtk::RemoveChild(GtkWidget* child) {
void WidgetGtk::PositionChild(GtkWidget* child, int x, int y, int w, int h) {
GtkAllocation alloc = { x, y, w, h };
+ // For some reason we need to do both of these to size a widget.
gtk_widget_size_allocate(child, &alloc);
+ gtk_widget_set_size_request(child, w, h);
gtk_fixed_move(GTK_FIXED(child_widget_parent_), child, x, y);
}
@@ -208,6 +218,16 @@ void WidgetGtk::Hide() {
gtk_widget_hide(widget_);
}
+void WidgetGtk::SetBounds(const gfx::Rect& bounds) {
+ if (type_ == TYPE_CHILD) {
+ WidgetGtk* parent_widget = GetViewForNative(gtk_widget_get_parent(widget_));
+ parent_widget->PositionChild(widget_, bounds.x(), bounds.y(),
+ bounds.width(), bounds.height());
+ } else {
+ NOTIMPLEMENTED();
+ }
+}
+
void WidgetGtk::GetBounds(gfx::Rect* out, bool including_frame) const {
DCHECK(widget_);
@@ -296,6 +316,7 @@ const Window* WidgetGtk::GetWindow() const {
void WidgetGtk::CreateGtkWidget() {
if (type_ == TYPE_CHILD) {
child_widget_parent_ = widget_ = gtk_fixed_new();
+ gtk_fixed_set_has_window(GTK_FIXED(widget_), true);
SetViewForNative(widget_, this);
} else {
widget_ = gtk_window_new(
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index e1a7468..73d8b7f 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -37,7 +37,9 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer {
virtual ~WidgetGtk();
// Initializes this widget.
- void Init(const gfx::Rect& bounds, bool has_own_focus_manager);
+ void Init(GtkWidget* parent,
+ const gfx::Rect& bounds,
+ bool has_own_focus_manager);
// Sets whether or not we are deleted when the widget is destroyed. The
// default is true.
@@ -62,6 +64,9 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer {
virtual void Show();
virtual void Hide();
+ // Sets the bounds of the widget.
+ virtual void SetBounds(const gfx::Rect& bounds);
+
// Overridden from Widget:
virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
virtual gfx::NativeView GetNativeView() const;