summaryrefslogtreecommitdiffstats
path: root/views
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
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')
-rw-r--r--views/controls/text_field.h18
-rw-r--r--views/focus/focus_manager.h8
-rw-r--r--views/widget/widget_gtk.cc23
-rw-r--r--views/widget/widget_gtk.h7
-rw-r--r--views/window/window_gtk.cc2
5 files changed, 48 insertions, 10 deletions
diff --git a/views/controls/text_field.h b/views/controls/text_field.h
index a53c325..3c4571a 100644
--- a/views/controls/text_field.h
+++ b/views/controls/text_field.h
@@ -71,8 +71,11 @@ class TextField : public View {
STYLE_LOWERCASE = 1<<2
};
- TextField::TextField()
- : native_view_(NULL),
+ TextField()
+ :
+#if defined(OS_WIN)
+ native_view_(NULL),
+#endif
edit_(NULL),
controller_(NULL),
style_(STYLE_DEFAULT),
@@ -83,8 +86,11 @@ class TextField : public View {
num_lines_(1) {
SetFocusable(true);
}
- explicit TextField::TextField(StyleFlags style)
- : native_view_(NULL),
+ explicit TextField(StyleFlags style)
+ :
+#if defined(OS_WIN)
+ native_view_(NULL),
+#endif
edit_(NULL),
controller_(NULL),
style_(style),
@@ -122,7 +128,9 @@ class TextField : public View {
// Overridden from Chrome::View.
virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e);
+#if defined(OS_WIN)
virtual HWND GetNativeComponent();
+#endif
// Returns the text currently displayed in the text field.
std::wstring GetText() const;
@@ -197,8 +205,10 @@ class TextField : public View {
// Resets the background color of the edit.
void UpdateEditBackgroundColor();
+#if defined(OS_WIN)
// This encapsulates the HWND of the native text field.
HWNDView* native_view_;
+#endif
// This inherits from the native text field.
Edit* edit_;
diff --git a/views/focus/focus_manager.h b/views/focus/focus_manager.h
index 98fc1e5..b4fd3b6 100644
--- a/views/focus/focus_manager.h
+++ b/views/focus/focus_manager.h
@@ -5,14 +5,14 @@
#ifndef VIEWS_FOCUS_FOCUS_MANAGER_H_
#define VIEWS_FOCUS_FOCUS_MANAGER_H_
-#include "base/basictypes.h"
-
#if defined(OS_WIN)
#include <windows.h>
#endif
#include <vector>
#include <map>
+#include "base/basictypes.h"
+#include "base/gfx/native_widget_types.h"
#include "views/accelerator.h"
// The FocusManager class is used to handle focus traversal, store/restore
@@ -169,9 +169,11 @@ class FocusManager {
// Uninstalls the window subclass installed by InstallFocusSubclass.
static void UninstallFocusSubclass(HWND window);
+#endif
- static FocusManager* GetFocusManager(HWND window);
+ static FocusManager* GetFocusManager(gfx::NativeView window);
+#if defined(OS_WIN)
// Message handlers (for messages received from registered windows).
// Should return true if the message should be forwarded to the window
// original proc function, false otherwise.
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;
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index 087bf11..8363a66 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -199,7 +199,7 @@ void WindowGtk::Init(const gfx::Rect& bounds) {
// BecomeModal();
}
- WidgetGtk::Init(bounds, true);
+ WidgetGtk::Init(NULL, bounds, true);
// Create the ClientView, add it to the NonClientView and add the
// NonClientView to the RootView. This will cause everything to be parented.