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

Side by Side Diff: views/controls/textfield/native_textfield_views.cc

Issue 6480001: Migrate Event API methods to Google Style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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
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_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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 canvas->DrawRectInt(kCursorColor, 524 canvas->DrawRectInt(kCursorColor,
525 cursor_bounds_.x(), 525 cursor_bounds_.x(),
526 cursor_bounds_.y(), 526 cursor_bounds_.y(),
527 insert_ ? 0 : cursor_bounds_.width(), 527 insert_ ? 0 : cursor_bounds_.width(),
528 cursor_bounds_.height()); 528 cursor_bounds_.height());
529 } 529 }
530 } 530 }
531 531
532 bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) { 532 bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) {
533 // TODO(oshima): handle IME. 533 // TODO(oshima): handle IME.
534 if (key_event.GetType() == views::Event::ET_KEY_PRESSED) { 534 if (key_event.type() == views::Event::ET_KEY_PRESSED) {
535 ui::KeyboardCode key_code = key_event.GetKeyCode(); 535 ui::KeyboardCode key_code = key_event.key_code();
536 // TODO(oshima): shift-tab does not work. Figure out why and fix. 536 // TODO(oshima): shift-tab does not work. Figure out why and fix.
537 if (key_code == ui::VKEY_TAB) 537 if (key_code == ui::VKEY_TAB)
538 return false; 538 return false;
539 bool editable = !textfield_->read_only(); 539 bool editable = !textfield_->read_only();
540 bool selection = key_event.IsShiftDown(); 540 bool selection = key_event.IsShiftDown();
541 bool control = key_event.IsControlDown(); 541 bool control = key_event.IsControlDown();
542 bool text_changed = false; 542 bool text_changed = false;
543 bool cursor_changed = false; 543 bool cursor_changed = false;
544 switch (key_code) { 544 switch (key_code) {
545 case ui::VKEY_A: 545 case ui::VKEY_A:
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 635
636 UpdateAfterChange(text_changed, cursor_changed); 636 UpdateAfterChange(text_changed, cursor_changed);
637 return (text_changed || cursor_changed); 637 return (text_changed || cursor_changed);
638 } 638 }
639 return false; 639 return false;
640 } 640 }
641 641
642 char16 NativeTextfieldViews::GetPrintableChar(const KeyEvent& key_event) { 642 char16 NativeTextfieldViews::GetPrintableChar(const KeyEvent& key_event) {
643 // TODO(oshima): IME, i18n support. 643 // TODO(oshima): IME, i18n support.
644 // This only works for UCS-2 characters. 644 // This only works for UCS-2 characters.
645 ui::KeyboardCode key_code = key_event.GetKeyCode(); 645 ui::KeyboardCode key_code = key_event.key_code();
646 bool shift = key_event.IsShiftDown(); 646 bool shift = key_event.IsShiftDown();
647 bool upper = shift ^ key_event.IsCapsLockDown(); 647 bool upper = shift ^ key_event.IsCapsLockDown();
648 // TODO(oshima): We should have a utility function 648 // TODO(oshima): We should have a utility function
649 // under app to convert a KeyboardCode to a printable character, 649 // under app to convert a KeyboardCode to a printable character,
650 // probably in keyboard_code_conversion{.h, _x 650 // probably in keyboard_code_conversion{.h, _x
651 switch (key_code) { 651 switch (key_code) {
652 case ui::VKEY_NUMPAD0: 652 case ui::VKEY_NUMPAD0:
653 return '0'; 653 return '0';
654 case ui::VKEY_NUMPAD1: 654 case ui::VKEY_NUMPAD1:
655 return '1'; 655 return '1';
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 } else { 783 } else {
784 right = pivot; 784 right = pivot;
785 right_pos = pivot_pos; 785 right_pos = pivot_pos;
786 } 786 }
787 } 787 }
788 return left_pos; 788 return left_pos;
789 } 789 }
790 790
791 bool NativeTextfieldViews::HandleMousePressed(const views::MouseEvent& e) { 791 bool NativeTextfieldViews::HandleMousePressed(const views::MouseEvent& e) {
792 textfield_->RequestFocus(); 792 textfield_->RequestFocus();
793 base::TimeDelta time_delta = e.GetTimeStamp() - last_mouse_press_time_; 793 base::TimeDelta time_delta = e.time_stamp() - last_mouse_press_time_;
794 gfx::Point location_delta = e.location().Subtract(last_mouse_press_location_); 794 gfx::Point location_delta = e.location().Subtract(last_mouse_press_location_);
795 last_mouse_press_time_ = e.GetTimeStamp(); 795 last_mouse_press_time_ = e.time_stamp();
796 last_mouse_press_location_ = e.location(); 796 last_mouse_press_location_ = e.location();
797 if (e.IsLeftMouseButton()) { 797 if (e.IsLeftMouseButton()) {
798 if (!ExceededDragThreshold(location_delta.x(), location_delta.y()) 798 if (!ExceededDragThreshold(location_delta.x(), location_delta.y())
799 && time_delta.InMilliseconds() <= GetDoubleClickTimeMS()) { 799 && time_delta.InMilliseconds() <= GetDoubleClickTimeMS()) {
800 // Multiple mouse press detected. Check for double or triple. 800 // Multiple mouse press detected. Check for double or triple.
801 switch (click_state_) { 801 switch (click_state_) {
802 case TRACKING_DOUBLE_CLICK: 802 case TRACKING_DOUBLE_CLICK:
803 click_state_ = TRACKING_TRIPLE_CLICK; 803 click_state_ = TRACKING_TRIPLE_CLICK;
804 model_->SelectWord(); 804 model_->SelectWord();
805 return true; 805 return true;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 } 912 }
913 913
914 void NativeTextfieldViews::TextfieldBorder::SetInsets(int top, 914 void NativeTextfieldViews::TextfieldBorder::SetInsets(int top,
915 int left, 915 int left,
916 int bottom, 916 int bottom,
917 int right) { 917 int right) {
918 insets_.Set(top, left, bottom, right); 918 insets_.Set(top, left, bottom, right);
919 } 919 }
920 920
921 } // namespace views 921 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698