summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorsuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 21:12:08 +0000
committersuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 21:12:08 +0000
commit9fa3de1a55d71308441b6066ac84b983e75c7fb7 (patch)
tree88a2efe897e067518f21c57b75eee0d686f3267b /views/widget
parent6b5b0cdd4a0f98bd79bb891d0081f53bebaf7765 (diff)
downloadchromium_src-9fa3de1a55d71308441b6066ac84b983e75c7fb7.zip
chromium_src-9fa3de1a55d71308441b6066ac84b983e75c7fb7.tar.gz
chromium_src-9fa3de1a55d71308441b6066ac84b983e75c7fb7.tar.bz2
New InputMethod api for Views.
This CL adds: 1. Interfaces: InputMethod, InputMethodDelegate, TextInputClient. 2. InputMethodGtk: an InputMethod implementation based on GtkIMContext. 3. MockInputMethod: a mock InputMethod implementation for unit tests. BUG=75003 TEST=none Review URL: http://codereview.chromium.org/6688049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80076 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/widget.h8
-rw-r--r--views/widget/widget_gtk.cc26
-rw-r--r--views/widget/widget_win.cc22
3 files changed, 56 insertions, 0 deletions
diff --git a/views/widget/widget.h b/views/widget/widget.h
index 39bb915..c57375d 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -95,6 +95,14 @@ class Widget : public internal::NativeWidgetDelegate,
// view hierarchies that the locale has changed.
static void NotifyLocaleChanged();
+ // Converts a rectangle from one Widget's coordinate system to another's.
+ // Returns false if the conversion couldn't be made, because either these two
+ // Widgets do not have a common ancestor or they are not on the screen yet.
+ // The value of |*rect| won't be changed when false is returned.
+ static bool ConvertRect(const Widget* source,
+ const Widget* target,
+ gfx::Rect* rect);
+
// Unconverted methods -------------------------------------------------------
// TODO(beng):
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 1be51c9..9f53543 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -1561,6 +1561,32 @@ void Widget::NotifyLocaleChanged() {
g_list_free(window_list);
}
+// static
+bool Widget::ConvertRect(const Widget* source,
+ const Widget* target,
+ gfx::Rect* rect) {
+ DCHECK(source);
+ DCHECK(target);
+ DCHECK(rect);
+
+ GtkWidget* source_widget = source->GetNativeView();
+ GtkWidget* target_widget = target->GetNativeView();
+ if (source_widget == target_widget)
+ return true;
+
+ if (!source_widget || !target_widget)
+ return false;
+
+ GdkRectangle gdk_rect = rect->ToGdkRectangle();
+ if (gtk_widget_translate_coordinates(source_widget, target_widget,
+ gdk_rect.x, gdk_rect.y,
+ &gdk_rect.x, &gdk_rect.y)) {
+ *rect = gdk_rect;
+ return true;
+ }
+ return false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidget, public:
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 4c8b974..613ddb6 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -1072,6 +1072,28 @@ void Widget::NotifyLocaleChanged() {
NOTIMPLEMENTED();
}
+bool Widget::ConvertRect(const Widget* source,
+ const Widget* target,
+ gfx::Rect* rect) {
+ DCHECK(source);
+ DCHECK(target);
+ DCHECK(rect);
+
+ HWND source_hwnd = source->GetNativeView();
+ HWND target_hwnd = target->GetNativeView();
+ if (source_hwnd == target_hwnd)
+ return true;
+
+ RECT win_rect = rect->ToRECT();
+ if (::MapWindowPoints(source_hwnd, target_hwnd,
+ reinterpret_cast<LPPOINT>(&win_rect),
+ sizeof(RECT)/sizeof(POINT))) {
+ *rect = win_rect;
+ return true;
+ }
+ return false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidget, public: