OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/widget/tooltip_manager.h" | 5 #include "ui/views/widget/tooltip_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "ui/base/text/text_elider.h" | 11 #include "ui/gfx/text_elider.h" |
12 #include "ui/gfx/text_utils.h" | 12 #include "ui/gfx/text_utils.h" |
13 | 13 |
14 // Maximum number of characters we allow in a tooltip. | 14 // Maximum number of characters we allow in a tooltip. |
15 const size_t kMaxTooltipLength = 1024; | 15 const size_t kMaxTooltipLength = 1024; |
16 | 16 |
17 // Maximum number of lines we allow in the tooltip. | 17 // Maximum number of lines we allow in the tooltip. |
18 const size_t kMaxLines = 6; | 18 const size_t kMaxLines = 6; |
19 | 19 |
20 namespace views { | 20 namespace views { |
21 | 21 |
(...skipping 21 matching lines...) Expand all Loading... |
43 if (lines.size() > kMaxLines) | 43 if (lines.size() > kMaxLines) |
44 lines.resize(kMaxLines); | 44 lines.resize(kMaxLines); |
45 *line_count = static_cast<int>(lines.size()); | 45 *line_count = static_cast<int>(lines.size()); |
46 | 46 |
47 // Format each line to fit. | 47 // Format each line to fit. |
48 const gfx::FontList& font_list = GetDefaultFontList(); | 48 const gfx::FontList& font_list = GetDefaultFontList(); |
49 string16 result; | 49 string16 result; |
50 for (std::vector<string16>::iterator i = lines.begin(); i != lines.end(); | 50 for (std::vector<string16>::iterator i = lines.begin(); i != lines.end(); |
51 ++i) { | 51 ++i) { |
52 string16 elided_text = | 52 string16 elided_text = |
53 ui::ElideText(*i, font_list, available_width, ui::ELIDE_AT_END); | 53 gfx::ElideText(*i, font_list, available_width, gfx::ELIDE_AT_END); |
54 *max_width = std::max(*max_width, | 54 *max_width = std::max(*max_width, |
55 gfx::GetStringWidth(elided_text, font_list)); | 55 gfx::GetStringWidth(elided_text, font_list)); |
56 if (!result.empty()) | 56 if (!result.empty()) |
57 result.push_back('\n'); | 57 result.push_back('\n'); |
58 result.append(elided_text); | 58 result.append(elided_text); |
59 } | 59 } |
60 *text = result; | 60 *text = result; |
61 } | 61 } |
62 | 62 |
63 } // namespace views | 63 } // namespace views |
OLD | NEW |