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 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ui/views/background.h" | 25 #include "ui/views/background.h" |
26 #include "ui/views/controls/focusable_border.h" | 26 #include "ui/views/controls/focusable_border.h" |
27 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
28 #include "ui/views/controls/menu/menu_item_view.h" | 28 #include "ui/views/controls/menu/menu_item_view.h" |
29 #include "ui/views/controls/menu/menu_runner.h" | 29 #include "ui/views/controls/menu/menu_runner.h" |
30 #include "ui/views/controls/native/native_view_host.h" | 30 #include "ui/views/controls/native/native_view_host.h" |
31 #include "ui/views/controls/textfield/textfield_controller.h" | 31 #include "ui/views/controls/textfield/textfield_controller.h" |
32 #include "ui/views/drag_utils.h" | 32 #include "ui/views/drag_utils.h" |
33 #include "ui/views/ime/input_method.h" | 33 #include "ui/views/ime/input_method.h" |
34 #include "ui/views/metrics.h" | 34 #include "ui/views/metrics.h" |
| 35 #include "ui/views/native_cursor.h" |
35 #include "ui/views/painter.h" | 36 #include "ui/views/painter.h" |
36 #include "ui/views/views_delegate.h" | 37 #include "ui/views/views_delegate.h" |
37 #include "ui/views/widget/widget.h" | 38 #include "ui/views/widget/widget.h" |
38 | 39 |
39 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
40 #include "base/win/win_util.h" | 41 #include "base/win/win_util.h" |
41 #endif | 42 #endif |
42 | 43 |
43 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 44 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
44 #include "base/strings/utf_string_conversions.h" | 45 #include "base/strings/utf_string_conversions.h" |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 484 } |
484 | 485 |
485 const char* Textfield::GetClassName() const { | 486 const char* Textfield::GetClassName() const { |
486 return kViewClassName; | 487 return kViewClassName; |
487 } | 488 } |
488 | 489 |
489 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { | 490 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { |
490 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); | 491 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); |
491 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; | 492 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; |
492 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); | 493 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); |
493 return text_cursor ? ui::kCursorIBeam : ui::kCursorNull; | 494 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor; |
494 } | 495 } |
495 | 496 |
496 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { | 497 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { |
497 TrackMouseClicks(event); | 498 TrackMouseClicks(event); |
498 | 499 |
499 if (!controller_ || !controller_->HandleMouseEvent(this, event)) { | 500 if (!controller_ || !controller_->HandleMouseEvent(this, event)) { |
500 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) { | 501 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) { |
501 RequestFocus(); | 502 RequestFocus(); |
502 ShowImeIfNeeded(); | 503 ShowImeIfNeeded(); |
503 } | 504 } |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 const size_t length = selection_clipboard_text.length(); | 1681 const size_t length = selection_clipboard_text.length(); |
1681 range = gfx::Range(range.start() + length, range.end() + length); | 1682 range = gfx::Range(range.start() + length, range.end() + length); |
1682 } | 1683 } |
1683 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); | 1684 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); |
1684 UpdateAfterChange(true, true); | 1685 UpdateAfterChange(true, true); |
1685 OnAfterUserAction(); | 1686 OnAfterUserAction(); |
1686 } | 1687 } |
1687 } | 1688 } |
1688 | 1689 |
1689 } // namespace views | 1690 } // namespace views |
OLD | NEW |