| 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 gfx::RenderText* Textfield::GetRenderText() { |
| 562 return static_cast<const Textfield*>(this)->GetRenderText(); |
| 563 } |
| 564 |
| 561 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { | 565 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { |
| 562 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); | 566 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); |
| 563 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; | 567 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; |
| 564 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); | 568 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); |
| 565 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor; | 569 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor; |
| 566 } | 570 } |
| 567 | 571 |
| 568 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { | 572 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { |
| 569 TrackMouseClicks(event); | 573 TrackMouseClicks(event); |
| 570 | 574 |
| (...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 RequestFocus(); | 2031 RequestFocus(); |
| 2028 model_->MoveCursorTo(mouse); | 2032 model_->MoveCursorTo(mouse); |
| 2029 if (!selection_clipboard_text.empty()) { | 2033 if (!selection_clipboard_text.empty()) { |
| 2030 model_->InsertText(selection_clipboard_text); | 2034 model_->InsertText(selection_clipboard_text); |
| 2031 UpdateAfterChange(true, true); | 2035 UpdateAfterChange(true, true); |
| 2032 } | 2036 } |
| 2033 OnAfterUserAction(); | 2037 OnAfterUserAction(); |
| 2034 } | 2038 } |
| 2035 | 2039 |
| 2036 } // namespace views | 2040 } // namespace views |
| OLD | NEW |