| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/label.h" | 5 #include "views/controls/label.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding, | 224 insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding, |
| 225 kFocusBorderPadding, kFocusBorderPadding); | 225 kFocusBorderPadding, kFocusBorderPadding); |
| 226 } | 226 } |
| 227 return insets; | 227 return insets; |
| 228 } | 228 } |
| 229 | 229 |
| 230 void Label::SizeToFit(int max_width) { | 230 void Label::SizeToFit(int max_width) { |
| 231 DCHECK(is_multi_line_); | 231 DCHECK(is_multi_line_); |
| 232 | 232 |
| 233 std::vector<std::wstring> lines; | 233 std::vector<std::wstring> lines; |
| 234 SplitString(text_, L'\n', &lines); | 234 base::SplitString(text_, L'\n', &lines); |
| 235 | 235 |
| 236 int label_width = 0; | 236 int label_width = 0; |
| 237 for (std::vector<std::wstring>::const_iterator iter = lines.begin(); | 237 for (std::vector<std::wstring>::const_iterator iter = lines.begin(); |
| 238 iter != lines.end(); ++iter) | 238 iter != lines.end(); ++iter) |
| 239 label_width = std::max(label_width, font_.GetStringWidth(*iter)); | 239 label_width = std::max(label_width, font_.GetStringWidth(*iter)); |
| 240 | 240 |
| 241 label_width += GetInsets().width(); | 241 label_width += GetInsets().width(); |
| 242 | 242 |
| 243 if (max_width > 0) | 243 if (max_width > 0) |
| 244 label_width = std::min(label_width, max_width); | 244 label_width = std::min(label_width, max_width); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 *paint_text = gfx::ElideText(text_, font_, width(), true); | 440 *paint_text = gfx::ElideText(text_, font_, width(), true); |
| 441 } else { | 441 } else { |
| 442 *paint_text = text_; | 442 *paint_text = text_; |
| 443 } | 443 } |
| 444 | 444 |
| 445 *text_bounds = GetTextBounds(); | 445 *text_bounds = GetTextBounds(); |
| 446 *flags = ComputeMultiLineFlags(); | 446 *flags = ComputeMultiLineFlags(); |
| 447 } | 447 } |
| 448 | 448 |
| 449 } // namespace views | 449 } // namespace views |
| OLD | NEW |