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

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

Issue 6257006: Move a bunch of random other files to src/ui/base... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months 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 | « views/widget/default_theme_provider.h ('k') | views/widget/tooltip_window_gtk.h » ('j') | 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) 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/widget/tooltip_manager.h" 5 #include "views/widget/tooltip_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/text_elider.h"
10 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "ui/base/text/text_elider.h"
11 11
12 namespace views { 12 namespace views {
13 13
14 // Maximum number of characters we allow in a tooltip. 14 // Maximum number of characters we allow in a tooltip.
15 static const size_t kMaxTooltipLength = 1024; 15 static 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 static const size_t kMaxLines = 6; 18 static const size_t kMaxLines = 6;
19 19
20 // Breaks |text| along line boundaries, placing each line of text into lines. 20 // Breaks |text| along line boundaries, placing each line of text into lines.
(...skipping 30 matching lines...) Expand all
51 // Split the string. 51 // Split the string.
52 std::vector<std::wstring> lines; 52 std::vector<std::wstring> lines;
53 SplitTooltipString(*text, &lines); 53 SplitTooltipString(*text, &lines);
54 *line_count = static_cast<int>(lines.size()); 54 *line_count = static_cast<int>(lines.size());
55 55
56 // Format each line to fit. 56 // Format each line to fit.
57 gfx::Font font = GetDefaultFont(); 57 gfx::Font font = GetDefaultFont();
58 std::wstring result; 58 std::wstring result;
59 for (std::vector<std::wstring>::iterator i = lines.begin(); i != lines.end(); 59 for (std::vector<std::wstring>::iterator i = lines.begin(); i != lines.end();
60 ++i) { 60 ++i) {
61 string16 elided_text = gfx::ElideText(WideToUTF16Hack(*i), 61 string16 elided_text = ui::ElideText(WideToUTF16Hack(*i),
62 font, available_width, false); 62 font, available_width, false);
63 *max_width = std::max(*max_width, font.GetStringWidth(elided_text)); 63 *max_width = std::max(*max_width, font.GetStringWidth(elided_text));
64 if (i == lines.begin() && i + 1 == lines.end()) { 64 if (i == lines.begin() && i + 1 == lines.end()) {
65 *text = UTF16ToWideHack(elided_text); 65 *text = UTF16ToWideHack(elided_text);
66 return; 66 return;
67 } 67 }
68 if (!result.empty()) 68 if (!result.empty())
69 result.append(GetLineSeparator()); 69 result.append(GetLineSeparator());
70 result.append(UTF16ToWideHack(elided_text)); 70 result.append(UTF16ToWideHack(elided_text));
71 } 71 }
72 *text = result; 72 *text = result;
73 } 73 }
74 74
75 } // namespace views 75 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/default_theme_provider.h ('k') | views/widget/tooltip_window_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698