OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/textfield/native_textfield_win.h" | 5 #include "ui/views/controls/textfield/native_textfield_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | |
oshima
2012/06/07 21:11:41
do you need this?
msw
2012/06/07 21:43:37
Removed, thanks for catching that!
| |
9 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
10 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "base/win/metro.h" | 14 #include "base/win/metro.h" |
14 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
15 #include "grit/ui_strings.h" | 16 #include "grit/ui_strings.h" |
16 #include "skia/ext/skia_utils_win.h" | 17 #include "skia/ext/skia_utils_win.h" |
17 #include "ui/base/accessibility/accessible_view_state.h" | 18 #include "ui/base/accessibility/accessible_view_state.h" |
18 #include "ui/base/clipboard/clipboard.h" | 19 #include "ui/base/clipboard/clipboard.h" |
19 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 20 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
20 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | |
21 #include "ui/base/keycodes/keyboard_codes.h" | 21 #include "ui/base/keycodes/keyboard_codes.h" |
22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/l10n/l10n_util_win.h" | 23 #include "ui/base/l10n/l10n_util_win.h" |
24 #include "ui/base/native_theme/native_theme_win.h" | 24 #include "ui/base/native_theme/native_theme_win.h" |
25 #include "ui/base/range/range.h" | 25 #include "ui/base/range/range.h" |
26 #include "ui/base/ui_base_switches.h" | |
oshima
2012/06/07 21:11:41
ditto
msw
2012/06/07 21:43:37
Done.
| |
26 #include "ui/base/win/mouse_wheel_util.h" | 27 #include "ui/base/win/mouse_wheel_util.h" |
27 #include "ui/views/controls/label.h" | 28 #include "ui/views/controls/label.h" |
28 #include "ui/views/controls/menu/menu_item_view.h" | 29 #include "ui/views/controls/menu/menu_item_view.h" |
29 #include "ui/views/controls/menu/menu_model_adapter.h" | 30 #include "ui/views/controls/menu/menu_model_adapter.h" |
30 #include "ui/views/controls/menu/menu_runner.h" | 31 #include "ui/views/controls/menu/menu_runner.h" |
31 #include "ui/views/controls/native/native_view_host.h" | 32 #include "ui/views/controls/native/native_view_host.h" |
32 #include "ui/views/controls/textfield/native_textfield_views.h" | |
33 #include "ui/views/controls/textfield/textfield.h" | 33 #include "ui/views/controls/textfield/textfield.h" |
34 #include "ui/views/controls/textfield/textfield_controller.h" | 34 #include "ui/views/controls/textfield/textfield_controller.h" |
35 #include "ui/views/focus/focus_manager.h" | 35 #include "ui/views/focus/focus_manager.h" |
36 #include "ui/views/metrics.h" | 36 #include "ui/views/metrics.h" |
37 #include "ui/views/views_delegate.h" | 37 #include "ui/views/views_delegate.h" |
38 #include "ui/views/widget/widget.h" | 38 #include "ui/views/widget/widget.h" |
39 | 39 |
40 namespace views { | 40 namespace views { |
41 | 41 |
42 /////////////////////////////////////////////////////////////////////////////// | 42 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 const POINT& current, | 145 const POINT& current, |
146 DWORD elapsed_time) { | 146 DWORD elapsed_time) { |
147 // The CXDOUBLECLK and CYDOUBLECLK system metrics describe the width and | 147 // The CXDOUBLECLK and CYDOUBLECLK system metrics describe the width and |
148 // height of a rectangle around the origin position, inside of which clicks | 148 // height of a rectangle around the origin position, inside of which clicks |
149 // within the double click time are considered double clicks. | 149 // within the double click time are considered double clicks. |
150 return (elapsed_time <= GetDoubleClickTime()) && | 150 return (elapsed_time <= GetDoubleClickTime()) && |
151 (abs(current.x - origin.x) <= (GetSystemMetrics(SM_CXDOUBLECLK) / 2)) && | 151 (abs(current.x - origin.x) <= (GetSystemMetrics(SM_CXDOUBLECLK) / 2)) && |
152 (abs(current.y - origin.y) <= (GetSystemMetrics(SM_CYDOUBLECLK) / 2)); | 152 (abs(current.y - origin.y) <= (GetSystemMetrics(SM_CYDOUBLECLK) / 2)); |
153 } | 153 } |
154 | 154 |
155 // static | |
156 bool NativeTextfieldWin::IsNumPadDigit(int key_code, bool extended_key) { | |
157 if (key_code >= VK_NUMPAD0 && key_code <= VK_NUMPAD9) | |
158 return true; | |
159 | |
160 // Check for num pad keys without NumLock. | |
161 // Note: there is no easy way to know if a the key that was pressed comes from | |
162 // the num pad or the rest of the keyboard. Investigating how | |
163 // TranslateMessage() generates the WM_KEYCHAR from an | |
164 // ALT + <NumPad sequences> it appears it looks at the extended key flag | |
165 // (which is on if the key pressed comes from one of the 3 clusters to | |
166 // the left of the numeric keypad). So we use it as well. | |
167 return !extended_key && | |
168 ((key_code >= VK_PRIOR && key_code <= VK_DOWN) || // All keys but 5 | |
169 // and 0. | |
170 (key_code == VK_CLEAR) || // Key 5. | |
171 (key_code == VK_INSERT)); // Key 0. | |
172 } | |
173 | |
174 void NativeTextfieldWin::AttachHack() { | 155 void NativeTextfieldWin::AttachHack() { |
175 // See the code in textfield.cc that calls this for why this is here. | 156 // See the code in textfield.cc that calls this for why this is here. |
176 container_view_->set_focus_view(textfield_); | 157 container_view_->set_focus_view(textfield_); |
177 container_view_->Attach(m_hWnd); | 158 container_view_->Attach(m_hWnd); |
178 } | 159 } |
179 | 160 |
180 //////////////////////////////////////////////////////////////////////////////// | 161 //////////////////////////////////////////////////////////////////////////////// |
181 // NativeTextfieldWin, NativeTextfieldWrapper implementation: | 162 // NativeTextfieldWin, NativeTextfieldWrapper implementation: |
182 | 163 |
183 string16 NativeTextfieldWin::GetText() const { | 164 string16 NativeTextfieldWin::GetText() const { |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1199 context_menu_contents_->AddItemWithStringId(IDS_APP_UNDO, IDS_APP_UNDO); | 1180 context_menu_contents_->AddItemWithStringId(IDS_APP_UNDO, IDS_APP_UNDO); |
1200 context_menu_contents_->AddSeparator(); | 1181 context_menu_contents_->AddSeparator(); |
1201 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); | 1182 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); |
1202 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); | 1183 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); |
1203 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); | 1184 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); |
1204 context_menu_contents_->AddSeparator(); | 1185 context_menu_contents_->AddSeparator(); |
1205 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, | 1186 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, |
1206 IDS_APP_SELECT_ALL); | 1187 IDS_APP_SELECT_ALL); |
1207 } | 1188 } |
1208 | 1189 |
1209 //////////////////////////////////////////////////////////////////////////////// | |
1210 // NativeTextfieldWrapper, public: | |
1211 | |
1212 // static | |
1213 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | |
1214 Textfield* field) { | |
1215 #if defined(USE_AURA) | |
1216 return new NativeTextfieldViews(field); | |
1217 #else | |
1218 return new NativeTextfieldWin(field); | |
1219 #endif | |
1220 } | |
1221 | |
1222 } // namespace views | 1190 } // namespace views |
OLD | NEW |