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

Side by Side Diff: ui/base/text/text_elider.h

Issue 7348010: Added Header and Footer support using Skia (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Indent Fix Created 9 years, 5 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
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 #ifndef UI_BASE_TEXT_TEXT_ELIDER_H_ 5 #ifndef UI_BASE_TEXT_TEXT_ELIDER_H_
6 #define UI_BASE_TEXT_TEXT_ELIDER_H_ 6 #define UI_BASE_TEXT_TEXT_ELIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <unicode/coll.h> 9 #include <unicode/coll.h>
10 #include <unicode/uchar.h> 10 #include <unicode/uchar.h>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "ui/gfx/font.h" 14 #include "ui/gfx/font.h"
15 #include "third_party/skia/include/core/SkPaint.h"
16 #include "third_party/skia/include/core/SkScalar.h"
15 17
16 class FilePath; 18 class FilePath;
17 class GURL; 19 class GURL;
18 20
19 namespace ui { 21 namespace ui {
20 22
21 extern const char kEllipsis[]; 23 extern const char kEllipsis[];
22 24
25 // Specifies what type of object is passed into the Elide functions.
26 // These are used to measure the width of the text string.
27 enum ObjectType {
28 Skia_Paint, // SkPaint object.
29 GFX_Font // gfx::Font object.
30 };
31
23 // This function takes a GURL object and elides it. It returns a string 32 // This function takes a GURL object and elides it. It returns a string
24 // which composed of parts from subdomain, domain, path, filename and query. 33 // which composed of parts from subdomain, domain, path, filename and query.
25 // A "..." is added automatically at the end if the elided string is bigger 34 // A "..." is added automatically at the end if the elided string is bigger
26 // than the available pixel width. For available pixel width = 0, empty 35 // than the available pixel width. For available pixel width = 0, empty
27 // string is returned. |languages| is a comma separted list of ISO 639 36 // string is returned. |languages| is a comma separted list of ISO 639
28 // language codes and is used to determine what characters are understood 37 // language codes and is used to determine what characters are understood
29 // by a user. It should come from |prefs::kAcceptLanguages|. 38 // by a user. It should come from |prefs::kAcceptLanguages|.
30 // 39 //
31 // Note: in RTL locales, if the URL returned by this function is going to be 40 // Note: in RTL locales, if the URL returned by this function is going to be
32 // displayed in the UI, then it is likely that the string needs to be marked 41 // displayed in the UI, then it is likely that the string needs to be marked
33 // as an LTR string (using base::i18n::WrapStringWithLTRFormatting()) so that it 42 // as an LTR string (using base::i18n::WrapStringWithLTRFormatting()) so that it
34 // is displayed properly in an RTL context. Please refer to 43 // is displayed properly in an RTL context. Please refer to
35 // http://crbug.com/6487 for more information. 44 // http://crbug.com/6487 for more information.
36 string16 ElideUrl(const GURL& url, 45 string16 ElideUrl(const GURL& url,
37 const gfx::Font& font, 46 const gfx::Font& font,
38 int available_pixel_width, 47 int available_pixel_width,
39 const std::string& languages); 48 const std::string& languages);
40 49
50 // Overloaded function.
51 // Takes a SkPaint object to determine the width of the text on the screen.
52 string16 ElideUrl(const GURL& url,
53 const SkPaint paint,
54 SkScalar available_point_width,
55 const std::string& languages);
56
41 // Elides |text| to fit in |available_pixel_width|. If |elide_in_middle| is 57 // Elides |text| to fit in |available_pixel_width|. If |elide_in_middle| is
42 // set the ellipsis is placed in the middle of the string; otherwise it is 58 // set the ellipsis is placed in the middle of the string; otherwise it is
43 // placed at the end. 59 // placed at the end.
44 string16 ElideText(const string16& text, 60 string16 ElideText(const string16& text,
45 const gfx::Font& font, 61 const gfx::Font& font,
46 int available_pixel_width, 62 int available_pixel_width,
47 bool elide_in_middle); 63 bool elide_in_middle);
48 64
65 // Overloaded function.
66 // Takes a SkPaint object to determine the width of the text on the screen.
67 string16 ElideText(const string16& text,
68 const SkPaint paint,
69 SkScalar available_point_width,
70 bool elide_in_middle);
71
49 // Elide a filename to fit a given pixel width, with an emphasis on not hiding 72 // Elide a filename to fit a given pixel width, with an emphasis on not hiding
50 // the extension unless we have to. If filename contains a path, the path will 73 // the extension unless we have to. If filename contains a path, the path will
51 // be removed if filename doesn't fit into available_pixel_width. The elided 74 // be removed if filename doesn't fit into available_pixel_width. The elided
52 // filename is forced to have LTR directionality, which means that in RTL UI 75 // filename is forced to have LTR directionality, which means that in RTL UI
53 // the elided filename is wrapped with LRE (Left-To-Right Embedding) mark and 76 // the elided filename is wrapped with LRE (Left-To-Right Embedding) mark and
54 // PDF (Pop Directional Formatting) mark. 77 // PDF (Pop Directional Formatting) mark.
55 string16 ElideFilename(const FilePath& filename, 78 string16 ElideFilename(const FilePath& filename,
56 const gfx::Font& font, 79 const gfx::Font& font,
57 int available_pixel_width); 80 int available_pixel_width);
58 81
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // intra-word (respecting UTF-16 surrogate pairs) as necssary. Truncation 136 // intra-word (respecting UTF-16 surrogate pairs) as necssary. Truncation
114 // (indicated by an added 3 dots) occurs if the result is still too long. 137 // (indicated by an added 3 dots) occurs if the result is still too long.
115 // Returns true if the input had to be truncated (and not just reformatted). 138 // Returns true if the input had to be truncated (and not just reformatted).
116 bool ElideRectangleString(const string16& input, size_t max_rows, 139 bool ElideRectangleString(const string16& input, size_t max_rows,
117 size_t max_cols, bool strict, string16* output); 140 size_t max_cols, bool strict, string16* output);
118 141
119 142
120 } // namespace ui 143 } // namespace ui
121 144
122 #endif // UI_BASE_TEXT_TEXT_ELIDER_H_ 145 #endif // UI_BASE_TEXT_TEXT_ELIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698