| 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 11 matching lines...) Expand all Loading... |
| 22 class Link; | 22 class Link; |
| 23 class StyledLabelListener; | 23 class StyledLabelListener; |
| 24 | 24 |
| 25 // A class which can apply mixed styles to a block of text. Currently, text is | 25 // A class which can apply mixed styles to a block of text. Currently, text is |
| 26 // always multiline. Trailing whitespace in the styled label text is not | 26 // always multiline. Trailing whitespace in the styled label text is not |
| 27 // supported and will be trimmed on StyledLabel construction. Leading | 27 // supported and will be trimmed on StyledLabel construction. Leading |
| 28 // whitespace is respected, provided not only whitespace fits in the first line. | 28 // whitespace is respected, provided not only whitespace fits in the first line. |
| 29 // In this case, leading whitespace is ignored. | 29 // In this case, leading whitespace is ignored. |
| 30 class VIEWS_EXPORT StyledLabel : public View, public LinkListener { | 30 class VIEWS_EXPORT StyledLabel : public View, public LinkListener { |
| 31 public: | 31 public: |
| 32 // Internal class name. |
| 33 static const char kViewClassName[]; |
| 34 |
| 32 // Parameters that define label style for a styled label's text range. | 35 // Parameters that define label style for a styled label's text range. |
| 33 struct VIEWS_EXPORT RangeStyleInfo { | 36 struct VIEWS_EXPORT RangeStyleInfo { |
| 34 RangeStyleInfo(); | 37 RangeStyleInfo(); |
| 35 ~RangeStyleInfo(); | 38 ~RangeStyleInfo(); |
| 36 | 39 |
| 37 // Creates a range style info with default values for link. | 40 // Creates a range style info with default values for link. |
| 38 static RangeStyleInfo CreateForLink(); | 41 static RangeStyleInfo CreateForLink(); |
| 39 | 42 |
| 40 // The font style that will be applied to the range. Should be a bitmask of | 43 // The font style that will be applied to the range. Should be a bitmask of |
| 41 // values defined in gfx::Font::FontStyle (BOLD, ITALIC, UNDERLINE). | 44 // values defined in gfx::Font::FontStyle (BOLD, ITALIC, UNDERLINE). |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // readable over it. | 86 // readable over it. |
| 84 void SetDisplayedOnBackgroundColor(SkColor color); | 87 void SetDisplayedOnBackgroundColor(SkColor color); |
| 85 SkColor displayed_on_background_color() const { | 88 SkColor displayed_on_background_color() const { |
| 86 return displayed_on_background_color_; | 89 return displayed_on_background_color_; |
| 87 } | 90 } |
| 88 | 91 |
| 89 void set_auto_color_readability_enabled(bool auto_color_readability) { | 92 void set_auto_color_readability_enabled(bool auto_color_readability) { |
| 90 auto_color_readability_enabled_ = auto_color_readability; | 93 auto_color_readability_enabled_ = auto_color_readability; |
| 91 } | 94 } |
| 92 | 95 |
| 93 // View implementation: | 96 // views::View: |
| 97 const char* GetClassName() const override; |
| 94 gfx::Insets GetInsets() const override; | 98 gfx::Insets GetInsets() const override; |
| 95 int GetHeightForWidth(int w) const override; | 99 int GetHeightForWidth(int w) const override; |
| 96 void Layout() override; | 100 void Layout() override; |
| 97 void PreferredSizeChanged() override; | 101 void PreferredSizeChanged() override; |
| 98 | 102 |
| 99 // LinkListener implementation: | 103 // LinkListener implementation: |
| 100 void LinkClicked(Link* source, int event_flags) override; | 104 void LinkClicked(Link* source, int event_flags) override; |
| 101 | 105 |
| 102 private: | 106 private: |
| 103 struct StyleRange { | 107 struct StyleRange { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // Controls whether the text is automatically re-colored to be readable on the | 160 // Controls whether the text is automatically re-colored to be readable on the |
| 157 // background. | 161 // background. |
| 158 bool auto_color_readability_enabled_; | 162 bool auto_color_readability_enabled_; |
| 159 | 163 |
| 160 DISALLOW_COPY_AND_ASSIGN(StyledLabel); | 164 DISALLOW_COPY_AND_ASSIGN(StyledLabel); |
| 161 }; | 165 }; |
| 162 | 166 |
| 163 } // namespace views | 167 } // namespace views |
| 164 | 168 |
| 165 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ | 169 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
| OLD | NEW |