| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "third_party/skia/include/core/SkColor.h" |
| 13 #include "ui/base/range/range.h" | 14 #include "ui/base/range/range.h" |
| 14 #include "ui/gfx/size.h" | 15 #include "ui/gfx/size.h" |
| 15 #include "ui/views/controls/link_listener.h" | 16 #include "ui/views/controls/link_listener.h" |
| 16 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 17 | 18 |
| 18 namespace views { | 19 namespace views { |
| 19 | 20 |
| 20 class Link; | 21 class Link; |
| 21 class StyledLabelListener; | 22 class StyledLabelListener; |
| 22 | 23 |
| 23 // A class which can apply mixed styles to a block of text. Currently, text is | 24 // A class which can apply mixed styles to a block of text. Currently, text is |
| 24 // always multiline. Trailing whitespace in the styled label text is not | 25 // always multiline. Trailing whitespace in the styled label text is not |
| 25 // supported and will be trimmed on StyledLabel construction. Leading | 26 // supported and will be trimmed on StyledLabel construction. Leading |
| 26 // whitespace is respected, provided not only whitespace fits in the first line. | 27 // whitespace is respected, provided not only whitespace fits in the first line. |
| 27 // In this case, leading whitespace is ignored. | 28 // In this case, leading whitespace is ignored. |
| 28 class VIEWS_EXPORT StyledLabel : public View, public LinkListener { | 29 class VIEWS_EXPORT StyledLabel : public View, public LinkListener { |
| 29 public: | 30 public: |
| 30 // Parameters that define label style for a styled label's text range. | 31 // Parameters that define label style for a styled label's text range. |
| 31 struct VIEWS_EXPORT RangeStyleInfo { | 32 struct VIEWS_EXPORT RangeStyleInfo { |
| 32 RangeStyleInfo(); | 33 RangeStyleInfo(); |
| 33 ~RangeStyleInfo(); | 34 ~RangeStyleInfo(); |
| 34 | 35 |
| 35 // Creates a range style info with default values for link. | 36 // Creates a range style info with default values for link. |
| 36 static RangeStyleInfo CreateForLink(); | 37 static RangeStyleInfo CreateForLink(); |
| 37 | 38 |
| 38 // 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 |
| 39 // values defined in gfx::Font::FontStyle (BOLD, ITALIC, UNDERLINE). | 40 // values defined in gfx::Font::FontStyle (BOLD, ITALIC, UNDERLINE). |
| 40 int font_style; | 41 int font_style; |
| 41 | 42 |
| 43 // The text color for the range. |
| 44 SkColor color; |
| 45 |
| 42 // Tooltip for the range. | 46 // Tooltip for the range. |
| 43 string16 tooltip; | 47 string16 tooltip; |
| 44 | 48 |
| 45 // 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. |
| 46 bool disable_line_wrapping; | 50 bool disable_line_wrapping; |
| 47 | 51 |
| 48 // If set, the range will be created as a link. | 52 // If set, the range will be created as a link. |
| 49 bool is_link; | 53 bool is_link; |
| 50 }; | 54 }; |
| 51 | 55 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // This variable saves the result of the last GetHeightForWidth call in order | 109 // This variable saves the result of the last GetHeightForWidth call in order |
| 106 // to avoid repeated calculation. | 110 // to avoid repeated calculation. |
| 107 gfx::Size calculated_size_; | 111 gfx::Size calculated_size_; |
| 108 | 112 |
| 109 DISALLOW_COPY_AND_ASSIGN(StyledLabel); | 113 DISALLOW_COPY_AND_ASSIGN(StyledLabel); |
| 110 }; | 114 }; |
| 111 | 115 |
| 112 } // namespace views | 116 } // namespace views |
| 113 | 117 |
| 114 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ | 118 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
| OLD | NEW |