| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| 11 #include <limits> | 11 #include <limits> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
| 18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "ui/accessibility/ax_view_state.h" | 20 #include "ui/accessibility/ax_view_state.h" |
| 21 #include "ui/base/default_style.h" |
| 22 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/color_utils.h" | 24 #include "ui/gfx/color_utils.h" |
| 23 #include "ui/gfx/geometry/insets.h" | 25 #include "ui/gfx/geometry/insets.h" |
| 24 #include "ui/gfx/text_elider.h" | 26 #include "ui/gfx/text_elider.h" |
| 25 #include "ui/native_theme/native_theme.h" | 27 #include "ui/native_theme/native_theme.h" |
| 26 | 28 |
| 27 namespace views { | 29 namespace views { |
| 30 namespace { |
| 31 |
| 32 const gfx::FontList& GetDefaultFontList() { |
| 33 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 34 return rb.GetFontListWithDelta(ui::kLabelFontSizeDelta); |
| 35 } |
| 36 |
| 37 } // namespace |
| 28 | 38 |
| 29 // static | 39 // static |
| 30 const char Label::kViewClassName[] = "Label"; | 40 const char Label::kViewClassName[] = "Label"; |
| 31 const int Label::kFocusBorderPadding = 1; | 41 const int Label::kFocusBorderPadding = 1; |
| 32 | 42 |
| 33 Label::Label() { | 43 Label::Label() : Label(base::string16()) { |
| 34 Init(base::string16(), gfx::FontList()); | |
| 35 } | 44 } |
| 36 | 45 |
| 37 Label::Label(const base::string16& text) { | 46 Label::Label(const base::string16& text) : Label(text, GetDefaultFontList()) { |
| 38 Init(text, gfx::FontList()); | |
| 39 } | 47 } |
| 40 | 48 |
| 41 Label::Label(const base::string16& text, const gfx::FontList& font_list) { | 49 Label::Label(const base::string16& text, const gfx::FontList& font_list) { |
| 42 Init(text, font_list); | 50 Init(text, font_list); |
| 43 } | 51 } |
| 44 | 52 |
| 45 Label::~Label() { | 53 Label::~Label() { |
| 46 } | 54 } |
| 47 | 55 |
| 48 void Label::SetFontList(const gfx::FontList& font_list) { | 56 void Label::SetFontList(const gfx::FontList& font_list) { |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 } | 585 } |
| 578 | 586 |
| 579 bool Label::ShouldShowDefaultTooltip() const { | 587 bool Label::ShouldShowDefaultTooltip() const { |
| 580 const gfx::Size text_size = GetTextSize(); | 588 const gfx::Size text_size = GetTextSize(); |
| 581 const gfx::Size size = GetContentsBounds().size(); | 589 const gfx::Size size = GetContentsBounds().size(); |
| 582 return !obscured() && (text_size.width() > size.width() || | 590 return !obscured() && (text_size.width() > size.width() || |
| 583 (multi_line() && text_size.height() > size.height())); | 591 (multi_line() && text_size.height() > size.height())); |
| 584 } | 592 } |
| 585 | 593 |
| 586 } // namespace views | 594 } // namespace views |
| OLD | NEW |