| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/keyboard_codes.h" | |
| 10 #include "app/keyboard_code_conversion_win.h" | |
| 11 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 12 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
| 13 #include "app/win/win_util.h" | 11 #include "app/win/win_util.h" |
| 14 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 15 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 16 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 17 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
| 18 #include "gfx/native_theme_win.h" | 16 #include "gfx/native_theme_win.h" |
| 19 #include "grit/app_strings.h" | 17 #include "grit/app_strings.h" |
| 20 #include "skia/ext/skia_utils_win.h" | 18 #include "skia/ext/skia_utils_win.h" |
| 21 #include "ui/base/clipboard/clipboard.h" | 19 #include "ui/base/clipboard/clipboard.h" |
| 22 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 20 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 21 #include "ui/base/keycodes/keyboard_codes.h" |
| 22 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
| 23 #include "views/controls/label.h" | 23 #include "views/controls/label.h" |
| 24 #include "views/controls/menu/menu_win.h" | 24 #include "views/controls/menu/menu_win.h" |
| 25 #include "views/controls/menu/menu_2.h" | 25 #include "views/controls/menu/menu_2.h" |
| 26 #include "views/controls/native/native_view_host.h" | 26 #include "views/controls/native/native_view_host.h" |
| 27 #include "views/controls/textfield/native_textfield_views.h" | 27 #include "views/controls/textfield/native_textfield_views.h" |
| 28 #include "views/controls/textfield/textfield.h" | 28 #include "views/controls/textfield/textfield.h" |
| 29 #include "views/focus/focus_manager.h" | 29 #include "views/focus/focus_manager.h" |
| 30 #include "views/focus/focus_util_win.h" | 30 #include "views/focus/focus_util_win.h" |
| 31 #include "views/views_delegate.h" | 31 #include "views/views_delegate.h" |
| 32 #include "views/widget/widget.h" | 32 #include "views/widget/widget.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 return false; | 341 return false; |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 bool NativeTextfieldWin::GetAcceleratorForCommandId(int command_id, | 345 bool NativeTextfieldWin::GetAcceleratorForCommandId(int command_id, |
| 346 menus::Accelerator* accelerator) { | 346 menus::Accelerator* accelerator) { |
| 347 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators | 347 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators |
| 348 // anywhere so we need to check for them explicitly here. | 348 // anywhere so we need to check for them explicitly here. |
| 349 switch (command_id) { | 349 switch (command_id) { |
| 350 case IDS_APP_CUT: | 350 case IDS_APP_CUT: |
| 351 *accelerator = views::Accelerator(app::VKEY_X, false, true, false); | 351 *accelerator = views::Accelerator(ui::VKEY_X, false, true, false); |
| 352 return true; | 352 return true; |
| 353 case IDS_APP_COPY: | 353 case IDS_APP_COPY: |
| 354 *accelerator = views::Accelerator(app::VKEY_C, false, true, false); | 354 *accelerator = views::Accelerator(ui::VKEY_C, false, true, false); |
| 355 return true; | 355 return true; |
| 356 case IDS_APP_PASTE: | 356 case IDS_APP_PASTE: |
| 357 *accelerator = views::Accelerator(app::VKEY_V, false, true, false); | 357 *accelerator = views::Accelerator(ui::VKEY_V, false, true, false); |
| 358 return true; | 358 return true; |
| 359 } | 359 } |
| 360 return container_view_->GetWidget()->GetAccelerator(command_id, accelerator); | 360 return container_view_->GetWidget()->GetAccelerator(command_id, accelerator); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void NativeTextfieldWin::ExecuteCommand(int command_id) { | 363 void NativeTextfieldWin::ExecuteCommand(int command_id) { |
| 364 ScopedFreeze freeze(this, GetTextObjectModel()); | 364 ScopedFreeze freeze(this, GetTextObjectModel()); |
| 365 OnBeforePossibleChange(); | 365 OnBeforePossibleChange(); |
| 366 switch (command_id) { | 366 switch (command_id) { |
| 367 case IDS_APP_UNDO: Undo(); break; | 367 case IDS_APP_UNDO: Undo(); break; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 case WM_KEYUP: | 908 case WM_KEYUP: |
| 909 case WM_SYSKEYUP: | 909 case WM_SYSKEYUP: |
| 910 type = Event::ET_KEY_RELEASED; | 910 type = Event::ET_KEY_RELEASED; |
| 911 break; | 911 break; |
| 912 default: | 912 default: |
| 913 NOTREACHED() << "Unknown message:" << message; | 913 NOTREACHED() << "Unknown message:" << message; |
| 914 // Passing through to avoid crash on release build. | 914 // Passing through to avoid crash on release build. |
| 915 type = Event::ET_KEY_PRESSED; | 915 type = Event::ET_KEY_PRESSED; |
| 916 } | 916 } |
| 917 KeyEvent key_event(type, | 917 KeyEvent key_event(type, |
| 918 app::KeyboardCodeForWindowsKeyCode(key), | 918 ui::KeyboardCodeForWindowsKeyCode(key), |
| 919 KeyEvent::GetKeyStateFlags(), | 919 KeyEvent::GetKeyStateFlags(), |
| 920 repeat_count, | 920 repeat_count, |
| 921 flags, | 921 flags, |
| 922 message); | 922 message); |
| 923 handled = controller->HandleKeyEvent(textfield_, key_event); | 923 handled = controller->HandleKeyEvent(textfield_, key_event); |
| 924 } | 924 } |
| 925 | 925 |
| 926 if (!handled) { | 926 if (!handled) { |
| 927 OnBeforePossibleChange(); | 927 OnBeforePossibleChange(); |
| 928 | 928 |
| 929 if (key == app::VKEY_HOME || key == app::VKEY_END) { | 929 if (key == ui::VKEY_HOME || key == ui::VKEY_END) { |
| 930 // DefWindowProc() might reset the keyboard layout when it receives a | 930 // DefWindowProc() might reset the keyboard layout when it receives a |
| 931 // keydown event for VKEY_HOME or VKEY_END. When the window was created | 931 // keydown event for VKEY_HOME or VKEY_END. When the window was created |
| 932 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, | 932 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, |
| 933 // if the input text is pure LTR text, the layout changes to the first RTL | 933 // if the input text is pure LTR text, the layout changes to the first RTL |
| 934 // keyboard layout in keyboard layout queue; if the input text is | 934 // keyboard layout in keyboard layout queue; if the input text is |
| 935 // bidirectional text, the layout changes to the keyboard layout of the | 935 // bidirectional text, the layout changes to the keyboard layout of the |
| 936 // first RTL character in input text. When the window was created without | 936 // first RTL character in input text. When the window was created without |
| 937 // WS_EX_LAYOUTRTL and the current keyboard layout is not a LTR one, if | 937 // WS_EX_LAYOUTRTL and the current keyboard layout is not a LTR one, if |
| 938 // the input text is pure RTL text, the layout changes to English; if the | 938 // the input text is pure RTL text, the layout changes to English; if the |
| 939 // input text is bidirectional text, the layout changes to the keyboard | 939 // input text is bidirectional text, the layout changes to the keyboard |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 1119 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
| 1120 Textfield* field) { | 1120 Textfield* field) { |
| 1121 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { | 1121 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { |
| 1122 return new NativeTextfieldViews(field); | 1122 return new NativeTextfieldViews(field); |
| 1123 } else { | 1123 } else { |
| 1124 return new NativeTextfieldWin(field); | 1124 return new NativeTextfieldWin(field); |
| 1125 } | 1125 } |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 } // namespace views | 1128 } // namespace views |
| OLD | NEW |