Chromium Code Reviews| Index: ui/views/controls/styled_label.h |
| diff --git a/ui/views/controls/styled_label.h b/ui/views/controls/styled_label.h |
| index 3b683d2e4903e992c1ac7be3438df91db6924d37..86ed024465da4883d673cac26e28a6a4da32ee19 100644 |
| --- a/ui/views/controls/styled_label.h |
| +++ b/ui/views/controls/styled_label.h |
| @@ -25,12 +25,26 @@ class StyledLabelListener; |
| // of text. |
| class VIEWS_EXPORT StyledLabel : public View, public LinkListener { |
| public: |
| + // Parameters that define label style for a styled label's text range. |
| + struct RangeStyleInfo { |
| + RangeStyleInfo(); |
| + ~RangeStyleInfo(); |
| + |
| + int font_style; |
|
Evan Stade
2013/03/25 22:30:11
docs for these members (esp. the first one)
tbarzic
2013/03/26 21:32:33
Done.
|
| + string16 tooltip; |
| + bool disable_line_wrapping; |
| + bool linkify; |
| + }; |
| + |
| StyledLabel(const string16& text, StyledLabelListener* listener); |
| virtual ~StyledLabel(); |
| // Marks the given range within |text_| as a link. |
| void AddLink(const ui::Range& range); |
| + // Marks the given range within |text_| with style defined by |style_info|. |
| + void AddStyleRange(const ui::Range& range, const RangeStyleInfo& style_info); |
| + |
| // View implementation: |
| virtual gfx::Insets GetInsets() const OVERRIDE; |
| virtual int GetHeightForWidth(int w) OVERRIDE; |
| @@ -40,13 +54,18 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener { |
| virtual void LinkClicked(Link* source, int event_flags) OVERRIDE; |
| private: |
| - struct LinkRange { |
| - explicit LinkRange(const ui::Range& range) : range(range) {} |
| - ~LinkRange() {} |
| + struct StyleRange { |
| + StyleRange(const ui::Range& range, |
| + const RangeStyleInfo& style_info) |
|
Evan Stade
2013/03/25 22:30:11
nit: indent
tbarzic
2013/03/26 21:32:33
Done.
|
| + : range(range), |
| + style_info(style_info) { |
| + } |
| + ~StyleRange() {} |
| - bool operator<(const LinkRange& other) const; |
| + bool operator<(const StyleRange& other) const; |
| ui::Range range; |
| + RangeStyleInfo style_info; |
| }; |
| // Calculates how to layout child views, creates them and sets their size |
| @@ -62,10 +81,10 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener { |
| StyledLabelListener* listener_; |
| // The ranges that should be linkified, sorted by start position. |
| - std::priority_queue<LinkRange> link_ranges_; |
| + std::priority_queue<StyleRange> style_ranges_; |
| - // A mapping from Link* control to the range it corresponds to in |text_|. |
| - std::map<Link*, ui::Range> link_targets_; |
| + // A mapping from a link control to the range it corresponds to in |text_|. |
|
Evan Stade
2013/03/25 22:30:11
nit: a link?
tbarzic
2013/03/26 21:32:33
Done.
|
| + std::map<View*, ui::Range> link_targets_; |
| // This variable saves the result of the last GetHeightForWidth call in order |
| // to avoid repeated calculation. |