OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_VIEWS_CONTROLS_STYLED_LABEL_H_ | 5 #ifndef UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
6 #define UI_VIEWS_CONTROLS_STYLED_LABEL_H_ | 6 #define UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 static RangeStyleInfo CreateForLink(); | 37 static RangeStyleInfo CreateForLink(); |
38 | 38 |
39 // The font style that will be applied to the range. Should be a bitmask of | 39 // The font style that will be applied to the range. Should be a bitmask of |
40 // values defined in gfx::Font::FontStyle (BOLD, ITALIC, UNDERLINE). | 40 // values defined in gfx::Font::FontStyle (BOLD, ITALIC, UNDERLINE). |
41 int font_style; | 41 int font_style; |
42 | 42 |
43 // The text color for the range. | 43 // The text color for the range. |
44 SkColor color; | 44 SkColor color; |
45 | 45 |
46 // Tooltip for the range. | 46 // Tooltip for the range. |
47 string16 tooltip; | 47 base::string16 tooltip; |
48 | 48 |
49 // If set, the whole range will be put on a single line. | 49 // If set, the whole range will be put on a single line. |
50 bool disable_line_wrapping; | 50 bool disable_line_wrapping; |
51 | 51 |
52 // If set, the range will be created as a link. | 52 // If set, the range will be created as a link. |
53 bool is_link; | 53 bool is_link; |
54 }; | 54 }; |
55 | 55 |
56 // Note that any trailing whitespace in |text| will be trimmed. | 56 // Note that any trailing whitespace in |text| will be trimmed. |
57 StyledLabel(const string16& text, StyledLabelListener* listener); | 57 StyledLabel(const base::string16& text, StyledLabelListener* listener); |
58 virtual ~StyledLabel(); | 58 virtual ~StyledLabel(); |
59 | 59 |
60 // Sets the text to be displayed, and clears any previous styling. | 60 // Sets the text to be displayed, and clears any previous styling. |
61 void SetText(const string16& text); | 61 void SetText(const base::string16& text); |
62 | 62 |
63 // Marks the given range within |text_| with style defined by |style_info|. | 63 // Marks the given range within |text_| with style defined by |style_info|. |
64 // |range| must be contained in |text_|. | 64 // |range| must be contained in |text_|. |
65 void AddStyleRange(const gfx::Range& range, const RangeStyleInfo& style_info); | 65 void AddStyleRange(const gfx::Range& range, const RangeStyleInfo& style_info); |
66 | 66 |
67 // Sets the default style to use for any part of the text that isn't within | 67 // Sets the default style to use for any part of the text that isn't within |
68 // a range set by AddStyleRange. | 68 // a range set by AddStyleRange. |
69 void SetDefaultStyle(const RangeStyleInfo& style_info); | 69 void SetDefaultStyle(const RangeStyleInfo& style_info); |
70 | 70 |
71 // Sets the color of the background on which the label is drawn. This won't | 71 // Sets the color of the background on which the label is drawn. This won't |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 RangeStyleInfo style_info; | 104 RangeStyleInfo style_info; |
105 }; | 105 }; |
106 | 106 |
107 // Calculates how to layout child views, creates them and sets their size | 107 // Calculates how to layout child views, creates them and sets their size |
108 // and position. |width| is the horizontal space, in pixels, that the view | 108 // and position. |width| is the horizontal space, in pixels, that the view |
109 // has to work with. If |dry_run| is true, the view hierarchy is not touched. | 109 // has to work with. If |dry_run| is true, the view hierarchy is not touched. |
110 // The return value is the height in pixels. | 110 // The return value is the height in pixels. |
111 int CalculateAndDoLayout(int width, bool dry_run); | 111 int CalculateAndDoLayout(int width, bool dry_run); |
112 | 112 |
113 // The text to display. | 113 // The text to display. |
114 string16 text_; | 114 base::string16 text_; |
115 | 115 |
116 // The default style to use for any part of the text that isn't within | 116 // The default style to use for any part of the text that isn't within |
117 // a range in |style_ranges_|. | 117 // a range in |style_ranges_|. |
118 RangeStyleInfo default_style_info_; | 118 RangeStyleInfo default_style_info_; |
119 | 119 |
120 // The listener that will be informed of link clicks. | 120 // The listener that will be informed of link clicks. |
121 StyledLabelListener* listener_; | 121 StyledLabelListener* listener_; |
122 | 122 |
123 // The ranges that should be linkified, sorted by start position. | 123 // The ranges that should be linkified, sorted by start position. |
124 std::priority_queue<StyleRange> style_ranges_; | 124 std::priority_queue<StyleRange> style_ranges_; |
(...skipping 13 matching lines...) Expand all Loading... |
138 // Controls whether the text is automatically re-colored to be readable on the | 138 // Controls whether the text is automatically re-colored to be readable on the |
139 // background. | 139 // background. |
140 bool auto_color_readability_enabled_; | 140 bool auto_color_readability_enabled_; |
141 | 141 |
142 DISALLOW_COPY_AND_ASSIGN(StyledLabel); | 142 DISALLOW_COPY_AND_ASSIGN(StyledLabel); |
143 }; | 143 }; |
144 | 144 |
145 } // namespace views | 145 } // namespace views |
146 | 146 |
147 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ | 147 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
OLD | NEW |