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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 } | 350 } |
351 | 351 |
352 bool Textfield::HasSelection() const { | 352 bool Textfield::HasSelection() const { |
353 return !GetSelectedRange().is_empty(); | 353 return !GetSelectedRange().is_empty(); |
354 } | 354 } |
355 | 355 |
356 SkColor Textfield::GetTextColor() const { | 356 SkColor Textfield::GetTextColor() const { |
357 if (!use_default_text_color_) | 357 if (!use_default_text_color_) |
358 return text_color_; | 358 return text_color_; |
359 | 359 |
360 return GetNativeTheme()->GetSystemColor(read_only() ? | 360 return GetNativeTheme()->GetSystemColor(read_only() || !enabled() ? |
361 ui::NativeTheme::kColorId_TextfieldReadOnlyColor : | 361 ui::NativeTheme::kColorId_TextfieldReadOnlyColor : |
362 ui::NativeTheme::kColorId_TextfieldDefaultColor); | 362 ui::NativeTheme::kColorId_TextfieldDefaultColor); |
363 } | 363 } |
364 | 364 |
365 void Textfield::SetTextColor(SkColor color) { | 365 void Textfield::SetTextColor(SkColor color) { |
366 text_color_ = color; | 366 text_color_ = color; |
367 use_default_text_color_ = false; | 367 use_default_text_color_ = false; |
368 SetColor(color); | 368 SetColor(color); |
369 } | 369 } |
370 | 370 |
371 void Textfield::UseDefaultTextColor() { | 371 void Textfield::UseDefaultTextColor() { |
372 use_default_text_color_ = true; | 372 use_default_text_color_ = true; |
373 SetColor(GetTextColor()); | 373 SetColor(GetTextColor()); |
374 } | 374 } |
375 | 375 |
376 SkColor Textfield::GetBackgroundColor() const { | 376 SkColor Textfield::GetBackgroundColor() const { |
377 if (!use_default_background_color_) | 377 if (!use_default_background_color_) |
378 return background_color_; | 378 return background_color_; |
379 | 379 |
380 return GetNativeTheme()->GetSystemColor(read_only() ? | 380 return GetNativeTheme()->GetSystemColor(read_only() || !enabled() ? |
381 ui::NativeTheme::kColorId_TextfieldReadOnlyBackground : | 381 ui::NativeTheme::kColorId_TextfieldReadOnlyBackground : |
382 ui::NativeTheme::kColorId_TextfieldDefaultBackground); | 382 ui::NativeTheme::kColorId_TextfieldDefaultBackground); |
383 } | 383 } |
384 | 384 |
385 void Textfield::SetBackgroundColor(SkColor color) { | 385 void Textfield::SetBackgroundColor(SkColor color) { |
386 background_color_ = color; | 386 background_color_ = color; |
387 use_default_background_color_ = false; | 387 use_default_background_color_ = false; |
388 UpdateBackgroundColor(); | 388 UpdateBackgroundColor(); |
389 } | 389 } |
390 | 390 |
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 RequestFocus(); | 2027 RequestFocus(); |
2028 model_->MoveCursorTo(mouse); | 2028 model_->MoveCursorTo(mouse); |
2029 if (!selection_clipboard_text.empty()) { | 2029 if (!selection_clipboard_text.empty()) { |
2030 model_->InsertText(selection_clipboard_text); | 2030 model_->InsertText(selection_clipboard_text); |
2031 UpdateAfterChange(true, true); | 2031 UpdateAfterChange(true, true); |
2032 } | 2032 } |
2033 OnAfterUserAction(); | 2033 OnAfterUserAction(); |
2034 } | 2034 } |
2035 | 2035 |
2036 } // namespace views | 2036 } // namespace views |
OLD | NEW |