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/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 gfx::Size Textfield::GetPreferredSize() const { | 551 gfx::Size Textfield::GetPreferredSize() const { |
552 const gfx::Insets& insets = GetInsets(); | 552 const gfx::Insets& insets = GetInsets(); |
553 return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) + | 553 return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) + |
554 insets.width(), GetFontList().GetHeight() + insets.height()); | 554 insets.width(), GetFontList().GetHeight() + insets.height()); |
555 } | 555 } |
556 | 556 |
557 const char* Textfield::GetClassName() const { | 557 const char* Textfield::GetClassName() const { |
558 return kViewClassName; | 558 return kViewClassName; |
559 } | 559 } |
560 | 560 |
| 561 bool Textfield::GetWordAtPoint(const gfx::Point& point, |
| 562 gfx::NativeStyledString word, |
| 563 gfx::Point* baseline_point) { |
| 564 return GetRenderText()->GetWordAtPoint(point, word, baseline_point); |
| 565 } |
| 566 |
561 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { | 567 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { |
562 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); | 568 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); |
563 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; | 569 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; |
564 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); | 570 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); |
565 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor; | 571 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor; |
566 } | 572 } |
567 | 573 |
568 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { | 574 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { |
569 TrackMouseClicks(event); | 575 TrackMouseClicks(event); |
570 | 576 |
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 RequestFocus(); | 2033 RequestFocus(); |
2028 model_->MoveCursorTo(mouse); | 2034 model_->MoveCursorTo(mouse); |
2029 if (!selection_clipboard_text.empty()) { | 2035 if (!selection_clipboard_text.empty()) { |
2030 model_->InsertText(selection_clipboard_text); | 2036 model_->InsertText(selection_clipboard_text); |
2031 UpdateAfterChange(true, true); | 2037 UpdateAfterChange(true, true); |
2032 } | 2038 } |
2033 OnAfterUserAction(); | 2039 OnAfterUserAction(); |
2034 } | 2040 } |
2035 | 2041 |
2036 } // namespace views | 2042 } // namespace views |
OLD | NEW |