| 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> |
| 11 | 11 |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/string_split.h" | 14 #include "base/string_split.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "ui/base/accessibility/accessible_view_state.h" | 17 #include "ui/base/accessibility/accessible_view_state.h" |
| 18 #include "ui/base/native_theme/native_theme.h" | |
| 19 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/base/text/text_elider.h" | 19 #include "ui/base/text/text_elider.h" |
| 21 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/color_utils.h" | 21 #include "ui/gfx/color_utils.h" |
| 23 #include "ui/gfx/font.h" | 22 #include "ui/gfx/font.h" |
| 24 #include "ui/gfx/insets.h" | 23 #include "ui/gfx/insets.h" |
| 24 #include "ui/gfx/native_theme.h" |
| 25 #include "ui/views/background.h" | 25 #include "ui/views/background.h" |
| 26 | 26 |
| 27 namespace views { | 27 namespace views { |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 const char Label::kViewClassName[] = "views/Label"; | 30 const char Label::kViewClassName[] = "views/Label"; |
| 31 | 31 |
| 32 const int Label::kFocusBorderPadding = 1; | 32 const int Label::kFocusBorderPadding = 1; |
| 33 | 33 |
| 34 Label::Label() { | 34 Label::Label() { |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 352 |
| 353 // static | 353 // static |
| 354 gfx::Font Label::GetDefaultFont() { | 354 gfx::Font Label::GetDefaultFont() { |
| 355 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); | 355 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); |
| 356 } | 356 } |
| 357 | 357 |
| 358 void Label::Init(const string16& text, const gfx::Font& font) { | 358 void Label::Init(const string16& text, const gfx::Font& font) { |
| 359 contains_mouse_ = false; | 359 contains_mouse_ = false; |
| 360 font_ = font; | 360 font_ = font; |
| 361 text_size_valid_ = false; | 361 text_size_valid_ = false; |
| 362 requested_enabled_color_ = ui::NativeTheme::instance()->GetSystemColor( | 362 requested_enabled_color_ = gfx::NativeTheme::instance()->GetSystemColor( |
| 363 ui::NativeTheme::kColorId_LabelEnabledColor); | 363 gfx::NativeTheme::kColorId_LabelEnabledColor); |
| 364 requested_disabled_color_ = ui::NativeTheme::instance()->GetSystemColor( | 364 requested_disabled_color_ = gfx::NativeTheme::instance()->GetSystemColor( |
| 365 ui::NativeTheme::kColorId_LabelDisabledColor); | 365 gfx::NativeTheme::kColorId_LabelDisabledColor); |
| 366 background_color_ = ui::NativeTheme::instance()->GetSystemColor( | 366 background_color_ = gfx::NativeTheme::instance()->GetSystemColor( |
| 367 ui::NativeTheme::kColorId_LabelBackgroundColor); | 367 gfx::NativeTheme::kColorId_LabelBackgroundColor); |
| 368 auto_color_readability_ = true; | 368 auto_color_readability_ = true; |
| 369 RecalculateColors(); | 369 RecalculateColors(); |
| 370 horiz_alignment_ = ALIGN_CENTER; | 370 horiz_alignment_ = ALIGN_CENTER; |
| 371 is_multi_line_ = false; | 371 is_multi_line_ = false; |
| 372 allow_character_break_ = false; | 372 allow_character_break_ = false; |
| 373 elide_in_middle_ = false; | 373 elide_in_middle_ = false; |
| 374 is_email_ = false; | 374 is_email_ = false; |
| 375 collapse_when_hidden_ = false; | 375 collapse_when_hidden_ = false; |
| 376 directionality_mode_ = USE_UI_DIRECTIONALITY; | 376 directionality_mode_ = USE_UI_DIRECTIONALITY; |
| 377 paint_as_focused_ = false; | 377 paint_as_focused_ = false; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 ui::ELIDE_IN_MIDDLE); | 518 ui::ELIDE_IN_MIDDLE); |
| 519 } else { | 519 } else { |
| 520 *paint_text = text_; | 520 *paint_text = text_; |
| 521 } | 521 } |
| 522 | 522 |
| 523 *text_bounds = GetTextBounds(); | 523 *text_bounds = GetTextBounds(); |
| 524 *flags = ComputeDrawStringFlags(); | 524 *flags = ComputeDrawStringFlags(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 } // namespace views | 527 } // namespace views |
| OLD | NEW |