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 // This file defines utility functions for eliding and formatting UI text. | 5 // This file defines utility functions for eliding and formatting UI text. |
6 | 6 |
7 #ifndef UI_GFX_TEXT_ELIDER_H_ | 7 #ifndef UI_GFX_TEXT_ELIDER_H_ |
8 #define UI_GFX_TEXT_ELIDER_H_ | 8 #define UI_GFX_TEXT_ELIDER_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // too long are broken into pieces. For words that are too wide to fit on a | 143 // too long are broken into pieces. For words that are too wide to fit on a |
144 // single line, the wrapping behavior can be specified with the |wrap_behavior| | 144 // single line, the wrapping behavior can be specified with the |wrap_behavior| |
145 // param. Returns a combination of |ReformattingResultFlags| that indicate | 145 // param. Returns a combination of |ReformattingResultFlags| that indicate |
146 // whether the given rectangle had insufficient space to accommodate |text|, | 146 // whether the given rectangle had insufficient space to accommodate |text|, |
147 // leading to elision or truncation (and not just reformatting). | 147 // leading to elision or truncation (and not just reformatting). |
148 GFX_EXPORT int ElideRectangleText(const base::string16& text, | 148 GFX_EXPORT int ElideRectangleText(const base::string16& text, |
149 const gfx::FontList& font_list, | 149 const gfx::FontList& font_list, |
150 float available_pixel_width, | 150 float available_pixel_width, |
151 int available_pixel_height, | 151 int available_pixel_height, |
152 WordWrapBehavior wrap_behavior, | 152 WordWrapBehavior wrap_behavior, |
153 std::vector<base::string16>* lines); | 153 std::vector<base::string16>* lines, |
| 154 float* max_width); |
154 | 155 |
155 // Truncates |string| to |length| characters. This breaks the string according | 156 // Truncates |string| to |length| characters. This breaks the string according |
156 // to the specified |break_type|, which must be either WORD_BREAK or | 157 // to the specified |break_type|, which must be either WORD_BREAK or |
157 // CHARACTER_BREAK, and adds the horizontal ellipsis character (unicode | 158 // CHARACTER_BREAK, and adds the horizontal ellipsis character (unicode |
158 // character 0x2026) to render "...". The supplied string is returned if the | 159 // character 0x2026) to render "...". The supplied string is returned if the |
159 // string has |length| characters or less. | 160 // string has |length| characters or less. |
160 GFX_EXPORT base::string16 TruncateString(const base::string16& string, | 161 GFX_EXPORT base::string16 TruncateString(const base::string16& string, |
161 size_t length, | 162 size_t length, |
162 BreakType break_type); | 163 BreakType break_type); |
163 | 164 |
164 } // namespace gfx | 165 } // namespace gfx |
165 | 166 |
166 #endif // UI_GFX_TEXT_ELIDER_H_ | 167 #endif // UI_GFX_TEXT_ELIDER_H_ |
OLD | NEW |