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/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/win/metro.h" | 13 #include "base/win/metro.h" |
14 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
15 #include "grit/ui_strings.h" | 15 #include "grit/ui_strings.h" |
16 #include "skia/ext/skia_utils_win.h" | 16 #include "skia/ext/skia_utils_win.h" |
17 #include "ui/base/accessibility/accessible_view_state.h" | 17 #include "ui/base/accessibility/accessible_view_state.h" |
18 #include "ui/base/clipboard/clipboard.h" | 18 #include "ui/base/clipboard/clipboard.h" |
19 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 19 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 20 #include "ui/base/event.h" |
20 #include "ui/base/keycodes/keyboard_codes.h" | 21 #include "ui/base/keycodes/keyboard_codes.h" |
21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/base/l10n/l10n_util_win.h" | 23 #include "ui/base/l10n/l10n_util_win.h" |
23 #include "ui/base/native_theme/native_theme_win.h" | 24 #include "ui/base/native_theme/native_theme_win.h" |
24 #include "ui/base/range/range.h" | 25 #include "ui/base/range/range.h" |
25 #include "ui/base/win/mouse_wheel_util.h" | 26 #include "ui/base/win/mouse_wheel_util.h" |
26 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
27 #include "ui/views/controls/menu/menu_item_view.h" | 28 #include "ui/views/controls/menu/menu_item_view.h" |
28 #include "ui/views/controls/menu/menu_model_adapter.h" | 29 #include "ui/views/controls/menu/menu_model_adapter.h" |
29 #include "ui/views/controls/menu/menu_runner.h" | 30 #include "ui/views/controls/menu/menu_runner.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 // TODO(tommi): Implement. | 368 // TODO(tommi): Implement. |
368 NOTIMPLEMENTED(); | 369 NOTIMPLEMENTED(); |
369 } | 370 } |
370 | 371 |
371 size_t NativeTextfieldWin::GetCursorPosition() const { | 372 size_t NativeTextfieldWin::GetCursorPosition() const { |
372 // TODO(tommi): Implement. | 373 // TODO(tommi): Implement. |
373 NOTIMPLEMENTED(); | 374 NOTIMPLEMENTED(); |
374 return 0U; | 375 return 0U; |
375 } | 376 } |
376 | 377 |
377 bool NativeTextfieldWin::HandleKeyPressed(const views::KeyEvent& event) { | 378 bool NativeTextfieldWin::HandleKeyPressed(const ui::KeyEvent& event) { |
378 return false; | 379 return false; |
379 } | 380 } |
380 | 381 |
381 bool NativeTextfieldWin::HandleKeyReleased(const views::KeyEvent& event) { | 382 bool NativeTextfieldWin::HandleKeyReleased(const ui::KeyEvent& event) { |
382 return false; | 383 return false; |
383 } | 384 } |
384 | 385 |
385 void NativeTextfieldWin::HandleFocus() { | 386 void NativeTextfieldWin::HandleFocus() { |
386 } | 387 } |
387 | 388 |
388 void NativeTextfieldWin::HandleBlur() { | 389 void NativeTextfieldWin::HandleBlur() { |
389 } | 390 } |
390 | 391 |
391 ui::TextInputClient* NativeTextfieldWin::GetTextInputClient() { | 392 ui::TextInputClient* NativeTextfieldWin::GetTextInputClient() { |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 SetMsgHandled(false); | 1009 SetMsgHandled(false); |
1009 } | 1010 } |
1010 | 1011 |
1011 void NativeTextfieldWin::HandleKeystroke() { | 1012 void NativeTextfieldWin::HandleKeystroke() { |
1012 const MSG* msg = GetCurrentMessage(); | 1013 const MSG* msg = GetCurrentMessage(); |
1013 ScopedFreeze freeze(this, GetTextObjectModel()); | 1014 ScopedFreeze freeze(this, GetTextObjectModel()); |
1014 | 1015 |
1015 TextfieldController* controller = textfield_->GetController(); | 1016 TextfieldController* controller = textfield_->GetController(); |
1016 bool handled = false; | 1017 bool handled = false; |
1017 if (controller) { | 1018 if (controller) { |
1018 KeyEvent event(*msg); | 1019 ui::KeyEvent event(*msg, msg->message == WM_CHAR); |
1019 handled = controller->HandleKeyEvent(textfield_, event); | 1020 handled = controller->HandleKeyEvent(textfield_, event); |
1020 } | 1021 } |
1021 | 1022 |
1022 if (!handled) { | 1023 if (!handled) { |
1023 OnBeforePossibleChange(); | 1024 OnBeforePossibleChange(); |
1024 | 1025 |
1025 if (msg->wParam == ui::VKEY_HOME || msg->wParam == ui::VKEY_END) { | 1026 if (msg->wParam == ui::VKEY_HOME || msg->wParam == ui::VKEY_END) { |
1026 // DefWindowProc() might reset the keyboard layout when it receives a | 1027 // DefWindowProc() might reset the keyboard layout when it receives a |
1027 // keydown event for VKEY_HOME or VKEY_END. When the window was created | 1028 // keydown event for VKEY_HOME or VKEY_END. When the window was created |
1028 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, | 1029 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 context_menu_contents_->AddSeparator(); | 1200 context_menu_contents_->AddSeparator(); |
1200 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); | 1201 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); |
1201 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); | 1202 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); |
1202 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); | 1203 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); |
1203 context_menu_contents_->AddSeparator(); | 1204 context_menu_contents_->AddSeparator(); |
1204 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, | 1205 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, |
1205 IDS_APP_SELECT_ALL); | 1206 IDS_APP_SELECT_ALL); |
1206 } | 1207 } |
1207 | 1208 |
1208 } // namespace views | 1209 } // namespace views |
OLD | NEW |