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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 gfx::Insets insets = GetInsets(); | 226 gfx::Insets insets = GetInsets(); |
227 size.Enlarge(insets.width(), insets.height()); | 227 size.Enlarge(insets.width(), insets.height()); |
228 return size; | 228 return size; |
229 } | 229 } |
230 | 230 |
231 gfx::Size Label::GetMinimumSize() { | 231 gfx::Size Label::GetMinimumSize() { |
232 gfx::Size text_size(GetTextSize()); | 232 gfx::Size text_size(GetTextSize()); |
233 if ((!visible() && collapse_when_hidden_) || text_size.IsEmpty()) | 233 if ((!visible() && collapse_when_hidden_) || text_size.IsEmpty()) |
234 return gfx::Size(); | 234 return gfx::Size(); |
235 | 235 |
236 gfx::Size size(font_list_.GetStringWidth(string16(gfx::kEllipsisUTF16)), | 236 gfx::Size size(font_list_.GetStringWidth(base::string16(gfx::kEllipsisUTF16)), |
237 font_list_.GetHeight()); | 237 font_list_.GetHeight()); |
238 size.SetToMin(text_size); // The actual text may be shorter than an ellipsis. | 238 size.SetToMin(text_size); // The actual text may be shorter than an ellipsis. |
239 gfx::Insets insets = GetInsets(); | 239 gfx::Insets insets = GetInsets(); |
240 size.Enlarge(insets.width(), insets.height()); | 240 size.Enlarge(insets.width(), insets.height()); |
241 return size; | 241 return size; |
242 } | 242 } |
243 | 243 |
244 int Label::GetHeightForWidth(int w) { | 244 int Label::GetHeightForWidth(int w) { |
245 if (!is_multi_line_) | 245 if (!is_multi_line_) |
246 return View::GetHeightForWidth(w); | 246 return View::GetHeightForWidth(w); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 for (int i = 0; i < kCachedSizeLimit; ++i) | 537 for (int i = 0; i < kCachedSizeLimit; ++i) |
538 cached_heights_[i] = gfx::Size(); | 538 cached_heights_[i] = gfx::Size(); |
539 } | 539 } |
540 | 540 |
541 bool Label::ShouldShowDefaultTooltip() const { | 541 bool Label::ShouldShowDefaultTooltip() const { |
542 return !is_multi_line_ && | 542 return !is_multi_line_ && |
543 gfx::GetStringWidth(text_, font_list_) > GetAvailableRect().width(); | 543 gfx::GetStringWidth(text_, font_list_) > GetAvailableRect().width(); |
544 } | 544 } |
545 | 545 |
546 } // namespace views | 546 } // namespace views |
OLD | NEW |