| 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 <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 void SetBaseFontList(const gfx::FontList& font_list); | 66 void SetBaseFontList(const gfx::FontList& font_list); |
| 67 | 67 |
| 68 // Marks the given range within |text_| with style defined by |style_info|. | 68 // Marks the given range within |text_| with style defined by |style_info|. |
| 69 // |range| must be contained in |text_|. | 69 // |range| must be contained in |text_|. |
| 70 void AddStyleRange(const gfx::Range& range, const RangeStyleInfo& style_info); | 70 void AddStyleRange(const gfx::Range& range, const RangeStyleInfo& style_info); |
| 71 | 71 |
| 72 // Sets the default style to use for any part of the text that isn't within | 72 // Sets the default style to use for any part of the text that isn't within |
| 73 // a range set by AddStyleRange. | 73 // a range set by AddStyleRange. |
| 74 void SetDefaultStyle(const RangeStyleInfo& style_info); | 74 void SetDefaultStyle(const RangeStyleInfo& style_info); |
| 75 | 75 |
| 76 // Sets line height similar to CSS line-height. Line height of 0 will overlay |
| 77 // new lines of text on top of each other. For line heights greater than |
| 78 // the height of the current font, the text will be vertically centered |
| 79 // in the space provided. Set |height| to a negative value to reset to the |
| 80 // default height. |
| 81 void SetLineHeight(int height); |
| 82 |
| 76 // Sets the color of the background on which the label is drawn. This won't | 83 // Sets the color of the background on which the label is drawn. This won't |
| 77 // be explicitly drawn, but the label will force the text color to be | 84 // be explicitly drawn, but the label will force the text color to be |
| 78 // readable over it. | 85 // readable over it. |
| 79 void SetDisplayedOnBackgroundColor(SkColor color); | 86 void SetDisplayedOnBackgroundColor(SkColor color); |
| 80 SkColor displayed_on_background_color() const { | 87 SkColor displayed_on_background_color() const { |
| 81 return displayed_on_background_color_; | 88 return displayed_on_background_color_; |
| 82 } | 89 } |
| 83 | 90 |
| 84 void set_auto_color_readability_enabled(bool auto_color_readability) { | 91 void set_auto_color_readability_enabled(bool auto_color_readability) { |
| 85 auto_color_readability_enabled_ = auto_color_readability; | 92 auto_color_readability_enabled_ = auto_color_readability; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 109 RangeStyleInfo style_info; | 116 RangeStyleInfo style_info; |
| 110 }; | 117 }; |
| 111 typedef std::list<StyleRange> StyleRanges; | 118 typedef std::list<StyleRange> StyleRanges; |
| 112 | 119 |
| 113 // Calculates how to layout child views, creates them and sets their size | 120 // Calculates how to layout child views, creates them and sets their size |
| 114 // and position. |width| is the horizontal space, in pixels, that the view | 121 // and position. |width| is the horizontal space, in pixels, that the view |
| 115 // has to work with. If |dry_run| is true, the view hierarchy is not touched. | 122 // has to work with. If |dry_run| is true, the view hierarchy is not touched. |
| 116 // The return value is the necessary size. | 123 // The return value is the necessary size. |
| 117 gfx::Size CalculateAndDoLayout(int width, bool dry_run); | 124 gfx::Size CalculateAndDoLayout(int width, bool dry_run); |
| 118 | 125 |
| 126 // Returns the line height, either default or user specified. |
| 127 int GetLineHeight() const; |
| 128 |
| 129 // Returns the vetical offset for a given line. This is necessary to |
| 130 // vertically center text when a user specifies a line height great than the |
| 131 // default. |
| 132 int GetOffsetForLine(int line) const; |
| 133 |
| 119 // The text to display. | 134 // The text to display. |
| 120 base::string16 text_; | 135 base::string16 text_; |
| 121 | 136 |
| 122 // Fonts used to display text. Can be augmented by RangeStyleInfo. | 137 // Fonts used to display text. Can be augmented by RangeStyleInfo. |
| 123 gfx::FontList font_list_; | 138 gfx::FontList font_list_; |
| 124 | 139 |
| 140 // Line height in pixels. |
| 141 int line_height_; |
| 142 |
| 125 // The default style to use for any part of the text that isn't within | 143 // The default style to use for any part of the text that isn't within |
| 126 // a range in |style_ranges_|. | 144 // a range in |style_ranges_|. |
| 127 RangeStyleInfo default_style_info_; | 145 RangeStyleInfo default_style_info_; |
| 128 | 146 |
| 129 // The listener that will be informed of link clicks. | 147 // The listener that will be informed of link clicks. |
| 130 StyledLabelListener* listener_; | 148 StyledLabelListener* listener_; |
| 131 | 149 |
| 132 // The ranges that should be linkified, sorted by start position. | 150 // The ranges that should be linkified, sorted by start position. |
| 133 StyleRanges style_ranges_; | 151 StyleRanges style_ranges_; |
| 134 | 152 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 147 // Controls whether the text is automatically re-colored to be readable on the | 165 // Controls whether the text is automatically re-colored to be readable on the |
| 148 // background. | 166 // background. |
| 149 bool auto_color_readability_enabled_; | 167 bool auto_color_readability_enabled_; |
| 150 | 168 |
| 151 DISALLOW_COPY_AND_ASSIGN(StyledLabel); | 169 DISALLOW_COPY_AND_ASSIGN(StyledLabel); |
| 152 }; | 170 }; |
| 153 | 171 |
| 154 } // namespace views | 172 } // namespace views |
| 155 | 173 |
| 156 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ | 174 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
| OLD | NEW |