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 13 matching lines...) Expand all Loading... |
24 // always multiline, and the only style that may be applied is linkifying ranges | 24 // always multiline, and the only style that may be applied is linkifying ranges |
25 // of text. | 25 // of text. |
26 class VIEWS_EXPORT StyledLabel : public View, public LinkListener { | 26 class VIEWS_EXPORT StyledLabel : public View, public LinkListener { |
27 public: | 27 public: |
28 StyledLabel(const string16& text, StyledLabelListener* listener); | 28 StyledLabel(const string16& text, StyledLabelListener* listener); |
29 virtual ~StyledLabel(); | 29 virtual ~StyledLabel(); |
30 | 30 |
31 // Marks the given range within |text_| as a link. | 31 // Marks the given range within |text_| as a link. |
32 void AddLink(const ui::Range& range); | 32 void AddLink(const ui::Range& range); |
33 | 33 |
| 34 // Resizes the label to the given width and height big enough to display the |
| 35 // label text. |
| 36 void SizeToFit(int width); |
| 37 |
34 // View implementation: | 38 // View implementation: |
35 virtual gfx::Insets GetInsets() const OVERRIDE; | 39 virtual gfx::Insets GetInsets() const OVERRIDE; |
| 40 virtual gfx::Size GetPreferredSize() OVERRIDE; |
36 virtual int GetHeightForWidth(int w) OVERRIDE; | 41 virtual int GetHeightForWidth(int w) OVERRIDE; |
37 virtual void Layout() OVERRIDE; | 42 virtual void Layout() OVERRIDE; |
38 | 43 |
39 // LinkListener implementation: | 44 // LinkListener implementation: |
40 virtual void LinkClicked(Link* source, int event_flags) OVERRIDE; | 45 virtual void LinkClicked(Link* source, int event_flags) OVERRIDE; |
41 | 46 |
42 private: | 47 private: |
43 struct LinkRange { | 48 struct LinkRange { |
44 explicit LinkRange(const ui::Range& range) : range(range) {} | 49 explicit LinkRange(const ui::Range& range) : range(range) {} |
45 ~LinkRange() {} | 50 ~LinkRange() {} |
(...skipping 24 matching lines...) Expand all Loading... |
70 // This variable saves the result of the last GetHeightForWidth call in order | 75 // This variable saves the result of the last GetHeightForWidth call in order |
71 // to avoid repeated calculation. | 76 // to avoid repeated calculation. |
72 gfx::Size calculated_size_; | 77 gfx::Size calculated_size_; |
73 | 78 |
74 DISALLOW_COPY_AND_ASSIGN(StyledLabel); | 79 DISALLOW_COPY_AND_ASSIGN(StyledLabel); |
75 }; | 80 }; |
76 | 81 |
77 } // namespace views | 82 } // namespace views |
78 | 83 |
79 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ | 84 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
OLD | NEW |