| 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_views.h" | 5 #include "views/controls/textfield/native_textfield_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 SchedulePaint(); | 477 SchedulePaint(); |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 return false; | 480 return false; |
| 481 } | 481 } |
| 482 | 482 |
| 483 char16 NativeTextfieldViews::GetPrintableChar(const KeyEvent& key_event) { | 483 char16 NativeTextfieldViews::GetPrintableChar(const KeyEvent& key_event) { |
| 484 // TODO(oshima): IME, i18n support. | 484 // TODO(oshima): IME, i18n support. |
| 485 // This only works for UCS-2 characters. | 485 // This only works for UCS-2 characters. |
| 486 app::KeyboardCode key_code = key_event.GetKeyCode(); | 486 app::KeyboardCode key_code = key_event.GetKeyCode(); |
| 487 bool shift = key_event.IsShiftDown() ^ key_event.IsCapsLockDown(); | 487 bool shift = key_event.IsShiftDown(); |
| 488 bool upper = shift ^ key_event.IsCapsLockDown(); |
| 488 // TODO(oshima): We should have a utility function | 489 // TODO(oshima): We should have a utility function |
| 489 // under app to convert a KeyboardCode to a printable character, | 490 // under app to convert a KeyboardCode to a printable character, |
| 490 // probably in keyboard_code_conversion{.h, _x | 491 // probably in keyboard_code_conversion{.h, _x |
| 491 switch (key_code) { | 492 switch (key_code) { |
| 492 case app::VKEY_NUMPAD0: | 493 case app::VKEY_NUMPAD0: |
| 493 return '0'; | 494 return '0'; |
| 494 case app::VKEY_NUMPAD1: | 495 case app::VKEY_NUMPAD1: |
| 495 return '1'; | 496 return '1'; |
| 496 case app::VKEY_NUMPAD2: | 497 case app::VKEY_NUMPAD2: |
| 497 return '2'; | 498 return '2'; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 case app::VKEY_Q: | 562 case app::VKEY_Q: |
| 562 case app::VKEY_R: | 563 case app::VKEY_R: |
| 563 case app::VKEY_S: | 564 case app::VKEY_S: |
| 564 case app::VKEY_T: | 565 case app::VKEY_T: |
| 565 case app::VKEY_U: | 566 case app::VKEY_U: |
| 566 case app::VKEY_V: | 567 case app::VKEY_V: |
| 567 case app::VKEY_W: | 568 case app::VKEY_W: |
| 568 case app::VKEY_X: | 569 case app::VKEY_X: |
| 569 case app::VKEY_Y: | 570 case app::VKEY_Y: |
| 570 case app::VKEY_Z: | 571 case app::VKEY_Z: |
| 571 return (shift ? 'A' : 'a') + (key_code - app::VKEY_A); | 572 return (upper ? 'A' : 'a') + (key_code - app::VKEY_A); |
| 572 case app::VKEY_OEM_1: | 573 case app::VKEY_OEM_1: |
| 573 return shift ? ':' : ';'; | 574 return shift ? ':' : ';'; |
| 574 case app::VKEY_OEM_PLUS: | 575 case app::VKEY_OEM_PLUS: |
| 575 return shift ? '+' : '='; | 576 return shift ? '+' : '='; |
| 576 case app::VKEY_OEM_COMMA: | 577 case app::VKEY_OEM_COMMA: |
| 577 return shift ? '<' : ','; | 578 return shift ? '<' : ','; |
| 578 case app::VKEY_OEM_MINUS: | 579 case app::VKEY_OEM_MINUS: |
| 579 return shift ? '_' : '-'; | 580 return shift ? '_' : '-'; |
| 580 case app::VKEY_OEM_PERIOD: | 581 case app::VKEY_OEM_PERIOD: |
| 581 return shift ? '>' : '.'; | 582 return shift ? '>' : '.'; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 } | 690 } |
| 690 | 691 |
| 691 void NativeTextfieldViews::TextfieldBorder::SetInsets(int top, | 692 void NativeTextfieldViews::TextfieldBorder::SetInsets(int top, |
| 692 int left, | 693 int left, |
| 693 int bottom, | 694 int bottom, |
| 694 int right) { | 695 int right) { |
| 695 insets_.Set(top, left, bottom, right); | 696 insets_.Set(top, left, bottom, right); |
| 696 } | 697 } |
| 697 | 698 |
| 698 } // namespace views | 699 } // namespace views |
| OLD | NEW |