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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/textfield/native_textfield_win.h ('k') | views/controls/textfield/textfield.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/controls/textfield/native_textfield_win.h" 5 #include "views/controls/textfield/native_textfield_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/win/win_util.h"
10 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
11 #include "base/string_util.h" 10 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
13 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
14 #include "gfx/native_theme_win.h" 13 #include "gfx/native_theme_win.h"
15 #include "grit/app_strings.h" 14 #include "grit/app_strings.h"
16 #include "skia/ext/skia_utils_win.h" 15 #include "skia/ext/skia_utils_win.h"
17 #include "ui/base/clipboard/clipboard.h" 16 #include "ui/base/clipboard/clipboard.h"
18 #include "ui/base/clipboard/scoped_clipboard_writer.h" 17 #include "ui/base/clipboard/scoped_clipboard_writer.h"
19 #include "ui/base/keycodes/keyboard_codes.h" 18 #include "ui/base/keycodes/keyboard_codes.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 text_object_model_.QueryFrom(ole_interface); 123 text_object_model_.QueryFrom(ole_interface);
125 124
126 InitializeAccessibilityInfo(); 125 InitializeAccessibilityInfo();
127 } 126 }
128 127
129 NativeTextfieldWin::~NativeTextfieldWin() { 128 NativeTextfieldWin::~NativeTextfieldWin() {
130 if (IsWindow()) 129 if (IsWindow())
131 DestroyWindow(); 130 DestroyWindow();
132 } 131 }
133 132
133 // static
134 bool NativeTextfieldWin::IsDoubleClick(const POINT& origin,
135 const POINT& current,
136 DWORD elapsed_time) {
137 // The CXDOUBLECLK and CYDOUBLECLK system metrics describe the width and
138 // height of a rectangle around the origin position, inside of which clicks
139 // within the double click time are considered double clicks.
140 return (elapsed_time <= GetDoubleClickTime()) &&
141 (abs(current.x - origin.x) <= (GetSystemMetrics(SM_CXDOUBLECLK) / 2)) &&
142 (abs(current.y - origin.y) <= (GetSystemMetrics(SM_CYDOUBLECLK) / 2));
143 }
144
145 // static
146 bool NativeTextfieldWin::IsNumPadDigit(int key_code, bool extended_key) {
147 if (key_code >= VK_NUMPAD0 && key_code <= VK_NUMPAD9)
148 return true;
149
150 // Check for num pad keys without NumLock.
151 // Note: there is no easy way to know if a the key that was pressed comes from
152 // the num pad or the rest of the keyboard. Investigating how
153 // TranslateMessage() generates the WM_KEYCHAR from an
154 // ALT + <NumPad sequences> it appears it looks at the extended key flag
155 // (which is on if the key pressed comes from one of the 3 clusters to
156 // the left of the numeric keypad). So we use it as well.
157 return !extended_key &&
158 ((key_code >= VK_PRIOR && key_code <= VK_DOWN) || // All keys but 5
159 // and 0.
160 (key_code == VK_CLEAR) || // Key 5.
161 (key_code == VK_INSERT)); // Key 0.
162 }
163
134 void NativeTextfieldWin::AttachHack() { 164 void NativeTextfieldWin::AttachHack() {
135 // See the code in textfield.cc that calls this for why this is here. 165 // See the code in textfield.cc that calls this for why this is here.
136 container_view_->set_focus_view(textfield_); 166 container_view_->set_focus_view(textfield_);
137 container_view_->Attach(m_hWnd); 167 container_view_->Attach(m_hWnd);
138 } 168 }
139 169
140 //////////////////////////////////////////////////////////////////////////////// 170 ////////////////////////////////////////////////////////////////////////////////
141 // NativeTextfieldWin, NativeTextfieldWrapper implementation: 171 // NativeTextfieldWin, NativeTextfieldWrapper implementation:
142 172
143 string16 NativeTextfieldWin::GetText() const { 173 string16 NativeTextfieldWin::GetText() const {
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 DefWindowProc(WM_LBUTTONDBLCLK, keys, 701 DefWindowProc(WM_LBUTTONDBLCLK, keys,
672 MAKELPARAM(ClipXCoordToVisibleText(point.x, false), point.y)); 702 MAKELPARAM(ClipXCoordToVisibleText(point.x, false), point.y));
673 OnAfterPossibleChange(true); 703 OnAfterPossibleChange(true);
674 } 704 }
675 705
676 void NativeTextfieldWin::OnLButtonDown(UINT keys, const CPoint& point) { 706 void NativeTextfieldWin::OnLButtonDown(UINT keys, const CPoint& point) {
677 // Check for triple click, then reset tracker. Should be safe to subtract 707 // Check for triple click, then reset tracker. Should be safe to subtract
678 // double_click_time_ from the current message's time even if the timer has 708 // double_click_time_ from the current message's time even if the timer has
679 // wrapped in between. 709 // wrapped in between.
680 const bool is_triple_click = tracking_double_click_ && 710 const bool is_triple_click = tracking_double_click_ &&
681 app::win::IsDoubleClick(double_click_point_, point, 711 IsDoubleClick(double_click_point_, point,
682 GetCurrentMessage()->time - double_click_time_); 712 GetCurrentMessage()->time - double_click_time_);
683 tracking_double_click_ = false; 713 tracking_double_click_ = false;
684 714
685 ScopedFreeze freeze(this, GetTextObjectModel()); 715 ScopedFreeze freeze(this, GetTextObjectModel());
686 OnBeforePossibleChange(); 716 OnBeforePossibleChange();
687 DefWindowProc(WM_LBUTTONDOWN, keys, 717 DefWindowProc(WM_LBUTTONDOWN, keys,
688 MAKELPARAM(ClipXCoordToVisibleText(point.x, is_triple_click), 718 MAKELPARAM(ClipXCoordToVisibleText(point.x, is_triple_click),
689 point.y)); 719 point.y));
690 OnAfterPossibleChange(true); 720 OnAfterPossibleChange(true);
691 } 721 }
692 722
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 1162 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
1133 Textfield* field) { 1163 Textfield* field) {
1134 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { 1164 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) {
1135 return new NativeTextfieldViews(field); 1165 return new NativeTextfieldViews(field);
1136 } else { 1166 } else {
1137 return new NativeTextfieldWin(field); 1167 return new NativeTextfieldWin(field);
1138 } 1168 }
1139 } 1169 }
1140 1170
1141 } // namespace views 1171 } // namespace views
OLDNEW
« 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