Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: views/controls/textfield/native_textfield_win.cc

Issue 6386009: Remove app/win/win_util.h,cc etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with NSApp changes in r73581 Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/textfield/native_textfield_win.h ('k') | views/controls/textfield/textfield.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/textfield/native_textfield_win.cc
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index ecdb38f1d3a7baadf052d7b18b0c0e35a98f290e..14c53172b06ae98ece789c240880dcdca3a2455a 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -6,7 +6,6 @@
#include <algorithm>
-#include "app/win/win_util.h"
#include "base/i18n/rtl.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -131,6 +130,37 @@ NativeTextfieldWin::~NativeTextfieldWin() {
DestroyWindow();
}
+// static
+bool NativeTextfieldWin::IsDoubleClick(const POINT& origin,
+ const POINT& current,
+ DWORD elapsed_time) {
+ // The CXDOUBLECLK and CYDOUBLECLK system metrics describe the width and
+ // height of a rectangle around the origin position, inside of which clicks
+ // within the double click time are considered double clicks.
+ return (elapsed_time <= GetDoubleClickTime()) &&
+ (abs(current.x - origin.x) <= (GetSystemMetrics(SM_CXDOUBLECLK) / 2)) &&
+ (abs(current.y - origin.y) <= (GetSystemMetrics(SM_CYDOUBLECLK) / 2));
+}
+
+// static
+bool NativeTextfieldWin::IsNumPadDigit(int key_code, bool extended_key) {
+ if (key_code >= VK_NUMPAD0 && key_code <= VK_NUMPAD9)
+ return true;
+
+ // Check for num pad keys without NumLock.
+ // Note: there is no easy way to know if a the key that was pressed comes from
+ // the num pad or the rest of the keyboard. Investigating how
+ // TranslateMessage() generates the WM_KEYCHAR from an
+ // ALT + <NumPad sequences> it appears it looks at the extended key flag
+ // (which is on if the key pressed comes from one of the 3 clusters to
+ // the left of the numeric keypad). So we use it as well.
+ return !extended_key &&
+ ((key_code >= VK_PRIOR && key_code <= VK_DOWN) || // All keys but 5
+ // and 0.
+ (key_code == VK_CLEAR) || // Key 5.
+ (key_code == VK_INSERT)); // Key 0.
+}
+
void NativeTextfieldWin::AttachHack() {
// See the code in textfield.cc that calls this for why this is here.
container_view_->set_focus_view(textfield_);
@@ -678,8 +708,8 @@ void NativeTextfieldWin::OnLButtonDown(UINT keys, const CPoint& point) {
// double_click_time_ from the current message's time even if the timer has
// wrapped in between.
const bool is_triple_click = tracking_double_click_ &&
- app::win::IsDoubleClick(double_click_point_, point,
- GetCurrentMessage()->time - double_click_time_);
+ IsDoubleClick(double_click_point_, point,
+ GetCurrentMessage()->time - double_click_time_);
tracking_double_click_ = false;
ScopedFreeze freeze(this, GetTextObjectModel());
« no previous file with comments | « views/controls/textfield/native_textfield_win.h ('k') | views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698