| 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/label.h" | 5 #include "ui/views/controls/label.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 state->AddStateFlag(ui::AX_STATE_READ_ONLY); | 316 state->AddStateFlag(ui::AX_STATE_READ_ONLY); |
| 317 state->name = layout_text(); | 317 state->name = layout_text(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void Label::PaintText(gfx::Canvas* canvas, | 320 void Label::PaintText(gfx::Canvas* canvas, |
| 321 const base::string16& text, | 321 const base::string16& text, |
| 322 const gfx::Rect& text_bounds, | 322 const gfx::Rect& text_bounds, |
| 323 int flags) { | 323 int flags) { |
| 324 gfx::ShadowValues shadows; | 324 gfx::ShadowValues shadows; |
| 325 if (has_shadow_) | 325 if (has_shadow_) |
| 326 shadows.push_back(gfx::ShadowValue(shadow_offset_, 0, | 326 shadows.push_back(gfx::ShadowValue(shadow_offset_, shadow_blur_, |
| 327 enabled() ? enabled_shadow_color_ : disabled_shadow_color_)); | 327 enabled() ? enabled_shadow_color_ : disabled_shadow_color_)); |
| 328 canvas->DrawStringRectWithShadows(text, font_list_, | 328 canvas->DrawStringRectWithShadows(text, font_list_, |
| 329 enabled() ? actual_enabled_color_ : actual_disabled_color_, | 329 enabled() ? actual_enabled_color_ : actual_disabled_color_, |
| 330 text_bounds, line_height_, flags, shadows); | 330 text_bounds, line_height_, flags, shadows); |
| 331 | 331 |
| 332 if (HasFocus()) { | 332 if (HasFocus()) { |
| 333 gfx::Rect focus_bounds = text_bounds; | 333 gfx::Rect focus_bounds = text_bounds; |
| 334 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); | 334 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); |
| 335 canvas->DrawFocusRect(focus_bounds); | 335 canvas->DrawFocusRect(focus_bounds); |
| 336 } | 336 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 is_multi_line_ = false; | 391 is_multi_line_ = false; |
| 392 is_obscured_ = false; | 392 is_obscured_ = false; |
| 393 allow_character_break_ = false; | 393 allow_character_break_ = false; |
| 394 elide_behavior_ = ELIDE_AT_END; | 394 elide_behavior_ = ELIDE_AT_END; |
| 395 collapse_when_hidden_ = false; | 395 collapse_when_hidden_ = false; |
| 396 directionality_mode_ = USE_UI_DIRECTIONALITY; | 396 directionality_mode_ = USE_UI_DIRECTIONALITY; |
| 397 enabled_shadow_color_ = 0; | 397 enabled_shadow_color_ = 0; |
| 398 disabled_shadow_color_ = 0; | 398 disabled_shadow_color_ = 0; |
| 399 shadow_offset_.SetPoint(1, 1); | 399 shadow_offset_.SetPoint(1, 1); |
| 400 has_shadow_ = false; | 400 has_shadow_ = false; |
| 401 shadow_blur_ = 0; |
| 401 cached_heights_.resize(kCachedSizeLimit); | 402 cached_heights_.resize(kCachedSizeLimit); |
| 402 ResetCachedSize(); | 403 ResetCachedSize(); |
| 403 | 404 |
| 404 SetText(text); | 405 SetText(text); |
| 405 } | 406 } |
| 406 | 407 |
| 407 void Label::RecalculateColors() { | 408 void Label::RecalculateColors() { |
| 408 actual_enabled_color_ = auto_color_readability_ ? | 409 actual_enabled_color_ = auto_color_readability_ ? |
| 409 color_utils::GetReadableColor(requested_enabled_color_, | 410 color_utils::GetReadableColor(requested_enabled_color_, |
| 410 background_color_) : | 411 background_color_) : |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 cached_heights_[i] = gfx::Size(); | 557 cached_heights_[i] = gfx::Size(); |
| 557 } | 558 } |
| 558 | 559 |
| 559 bool Label::ShouldShowDefaultTooltip() const { | 560 bool Label::ShouldShowDefaultTooltip() const { |
| 560 return !is_multi_line_ && !is_obscured_ && | 561 return !is_multi_line_ && !is_obscured_ && |
| 561 gfx::GetStringWidth(layout_text(), font_list_) > | 562 gfx::GetStringWidth(layout_text(), font_list_) > |
| 562 GetAvailableRect().width(); | 563 GetAvailableRect().width(); |
| 563 } | 564 } |
| 564 | 565 |
| 565 } // namespace views | 566 } // namespace views |
| OLD | NEW |