Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: ui/views/widget/tooltip_manager.cc

Issue 8917011: Change signature of |ui::ElideText()|. Add a truncate mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/label.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_split.h" 9 #include "base/string_split.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 base::SplitString(*text, '\n', &lines); 44 base::SplitString(*text, '\n', &lines);
45 if (lines.size() > kMaxLines) 45 if (lines.size() > kMaxLines)
46 lines.resize(kMaxLines); 46 lines.resize(kMaxLines);
47 *line_count = static_cast<int>(lines.size()); 47 *line_count = static_cast<int>(lines.size());
48 48
49 // Format each line to fit. 49 // Format each line to fit.
50 gfx::Font font = GetDefaultFont(); 50 gfx::Font font = GetDefaultFont();
51 string16 result; 51 string16 result;
52 for (std::vector<string16>::iterator i = lines.begin(); i != lines.end(); 52 for (std::vector<string16>::iterator i = lines.begin(); i != lines.end();
53 ++i) { 53 ++i) {
54 string16 elided_text = ui::ElideText(*i, font, available_width, false); 54 string16 elided_text =
55 ui::ElideText(*i, font, available_width, ui::ELIDE_AT_END);
55 *max_width = std::max(*max_width, font.GetStringWidth(elided_text)); 56 *max_width = std::max(*max_width, font.GetStringWidth(elided_text));
56 if (!result.empty()) 57 if (!result.empty())
57 result.push_back('\n'); 58 result.push_back('\n');
58 result.append(elided_text); 59 result.append(elided_text);
59 } 60 }
60 *text = result; 61 *text = result;
61 } 62 }
62 63
63 } // namespace views 64 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698