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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 GetRenderText()->set_selection_color(GetSelectionTextColor()); | 402 GetRenderText()->set_selection_color(GetSelectionTextColor()); |
403 SchedulePaint(); | 403 SchedulePaint(); |
404 } | 404 } |
405 | 405 |
406 void Textfield::UseDefaultSelectionTextColor() { | 406 void Textfield::UseDefaultSelectionTextColor() { |
407 use_default_selection_text_color_ = true; | 407 use_default_selection_text_color_ = true; |
408 GetRenderText()->set_selection_color(GetSelectionTextColor()); | 408 GetRenderText()->set_selection_color(GetSelectionTextColor()); |
409 SchedulePaint(); | 409 SchedulePaint(); |
410 } | 410 } |
411 | 411 |
| 412 void Textfield::SetShadows(const gfx::ShadowValues& shadows) { |
| 413 GetRenderText()->set_shadows(shadows); |
| 414 SchedulePaint(); |
| 415 } |
| 416 |
412 SkColor Textfield::GetSelectionBackgroundColor() const { | 417 SkColor Textfield::GetSelectionBackgroundColor() const { |
413 return use_default_selection_background_color_ ? | 418 return use_default_selection_background_color_ ? |
414 GetNativeTheme()->GetSystemColor( | 419 GetNativeTheme()->GetSystemColor( |
415 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused) : | 420 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused) : |
416 selection_background_color_; | 421 selection_background_color_; |
417 } | 422 } |
418 | 423 |
419 void Textfield::SetSelectionBackgroundColor(SkColor color) { | 424 void Textfield::SetSelectionBackgroundColor(SkColor color) { |
420 selection_background_color_ = color; | 425 selection_background_color_ = color; |
421 use_default_selection_background_color_ = false; | 426 use_default_selection_background_color_ = false; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 599 |
595 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 600 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
596 if (event.IsOnlyMiddleMouseButton()) { | 601 if (event.IsOnlyMiddleMouseButton()) { |
597 if (GetRenderText()->IsPointInSelection(event.location())) { | 602 if (GetRenderText()->IsPointInSelection(event.location())) { |
598 OnBeforeUserAction(); | 603 OnBeforeUserAction(); |
599 ClearSelection(); | 604 ClearSelection(); |
600 ui::ScopedClipboardWriter( | 605 ui::ScopedClipboardWriter( |
601 ui::Clipboard::GetForCurrentThread(), | 606 ui::Clipboard::GetForCurrentThread(), |
602 ui::CLIPBOARD_TYPE_SELECTION).WriteText(base::string16()); | 607 ui::CLIPBOARD_TYPE_SELECTION).WriteText(base::string16()); |
603 OnAfterUserAction(); | 608 OnAfterUserAction(); |
604 } else if(!read_only()) { | 609 } else if (!read_only()) { |
605 PasteSelectionClipboard(event); | 610 PasteSelectionClipboard(event); |
606 } | 611 } |
607 } | 612 } |
608 #endif | 613 #endif |
609 } | 614 } |
610 | 615 |
611 return true; | 616 return true; |
612 } | 617 } |
613 | 618 |
614 bool Textfield::OnMouseDragged(const ui::MouseEvent& event) { | 619 bool Textfield::OnMouseDragged(const ui::MouseEvent& event) { |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 const size_t length = selection_clipboard_text.length(); | 1778 const size_t length = selection_clipboard_text.length(); |
1774 range = gfx::Range(range.start() + length, range.end() + length); | 1779 range = gfx::Range(range.start() + length, range.end() + length); |
1775 } | 1780 } |
1776 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); | 1781 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); |
1777 UpdateAfterChange(true, true); | 1782 UpdateAfterChange(true, true); |
1778 OnAfterUserAction(); | 1783 OnAfterUserAction(); |
1779 } | 1784 } |
1780 } | 1785 } |
1781 | 1786 |
1782 } // namespace views | 1787 } // namespace views |
OLD | NEW |