OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_LABEL_H_ | 5 #ifndef UI_VIEWS_CONTROLS_LABEL_H_ |
6 #define UI_VIEWS_CONTROLS_LABEL_H_ | 6 #define UI_VIEWS_CONTROLS_LABEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // UI's directionality as the label's directionality. | 37 // UI's directionality as the label's directionality. |
38 // | 38 // |
39 // If the text originates from a web page, its directionality is determined | 39 // If the text originates from a web page, its directionality is determined |
40 // based on its first character with strong directionality, disregarding what | 40 // based on its first character with strong directionality, disregarding what |
41 // directionality the Chrome UI is. | 41 // directionality the Chrome UI is. |
42 enum DirectionalityMode { | 42 enum DirectionalityMode { |
43 USE_UI_DIRECTIONALITY = 0, | 43 USE_UI_DIRECTIONALITY = 0, |
44 AUTO_DETECT_DIRECTIONALITY | 44 AUTO_DETECT_DIRECTIONALITY |
45 }; | 45 }; |
46 | 46 |
| 47 enum ElideBehavior { |
| 48 NO_ELIDE, |
| 49 ELIDE_IN_MIDDLE, |
| 50 ELIDE_AT_END, |
| 51 }; |
| 52 |
47 // The view class name. | 53 // The view class name. |
48 static const char kViewClassName[]; | 54 static const char kViewClassName[]; |
49 | 55 |
50 // The padding for the focus border when rendering focused text. | 56 // The padding for the focus border when rendering focused text. |
51 static const int kFocusBorderPadding; | 57 static const int kFocusBorderPadding; |
52 | 58 |
53 Label(); | 59 Label(); |
54 explicit Label(const string16& text); | 60 explicit Label(const string16& text); |
55 Label(const string16& text, const gfx::Font& font); | 61 Label(const string16& text, const gfx::Font& font); |
56 virtual ~Label(); | 62 virtual ~Label(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // Default is false. | 129 // Default is false. |
124 void SetMultiLine(bool multi_line); | 130 void SetMultiLine(bool multi_line); |
125 | 131 |
126 // Returns whether the label text can wrap on multiple lines. | 132 // Returns whether the label text can wrap on multiple lines. |
127 bool is_multi_line() const { return is_multi_line_; } | 133 bool is_multi_line() const { return is_multi_line_; } |
128 | 134 |
129 // Sets whether the label text can be split on words. | 135 // Sets whether the label text can be split on words. |
130 // Default is false. This only works when is_multi_line is true. | 136 // Default is false. This only works when is_multi_line is true. |
131 void SetAllowCharacterBreak(bool allow_character_break); | 137 void SetAllowCharacterBreak(bool allow_character_break); |
132 | 138 |
133 // Sets whether the label text should be elided in the middle (if necessary). | 139 // Sets whether the label text should be elided in the middle or end (if |
134 // The default is to elide at the end. | 140 // necessary). The default is to not elide at all. |
135 // NOTE: This is not supported for multi-line strings. | 141 // NOTE: Eliding in the middle is not supported for multi-line strings. |
136 void SetElideInMiddle(bool elide_in_middle); | 142 void SetElideBehavior(ElideBehavior elide_behavior); |
137 | 143 |
138 // Sets the tooltip text. Default behavior for a label (single-line) is to | 144 // Sets the tooltip text. Default behavior for a label (single-line) is to |
139 // show the full text if it is wider than its bounds. Calling this overrides | 145 // show the full text if it is wider than its bounds. Calling this overrides |
140 // the default behavior and lets you set a custom tooltip. To revert to | 146 // the default behavior and lets you set a custom tooltip. To revert to |
141 // default behavior, call this with an empty string. | 147 // default behavior, call this with an empty string. |
142 void SetTooltipText(const string16& tooltip_text); | 148 void SetTooltipText(const string16& tooltip_text); |
143 | 149 |
144 // The background color to use when the mouse is over the label. Label | 150 // The background color to use when the mouse is over the label. Label |
145 // takes ownership of the Background. | 151 // takes ownership of the Background. |
146 void SetMouseOverBackground(Background* background); | 152 void SetMouseOverBackground(Background* background); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 SkColor requested_enabled_color_; | 264 SkColor requested_enabled_color_; |
259 SkColor actual_enabled_color_; | 265 SkColor actual_enabled_color_; |
260 SkColor requested_disabled_color_; | 266 SkColor requested_disabled_color_; |
261 SkColor actual_disabled_color_; | 267 SkColor actual_disabled_color_; |
262 SkColor background_color_; | 268 SkColor background_color_; |
263 bool auto_color_readability_; | 269 bool auto_color_readability_; |
264 mutable gfx::Size text_size_; | 270 mutable gfx::Size text_size_; |
265 mutable bool text_size_valid_; | 271 mutable bool text_size_valid_; |
266 bool is_multi_line_; | 272 bool is_multi_line_; |
267 bool allow_character_break_; | 273 bool allow_character_break_; |
268 bool elide_in_middle_; | 274 ElideBehavior elide_behavior_; |
269 bool is_email_; | 275 bool is_email_; |
270 Alignment horiz_alignment_; | 276 Alignment horiz_alignment_; |
271 string16 tooltip_text_; | 277 string16 tooltip_text_; |
272 // Whether the mouse is over this label. | 278 // Whether the mouse is over this label. |
273 bool contains_mouse_; | 279 bool contains_mouse_; |
274 scoped_ptr<Background> mouse_over_background_; | 280 scoped_ptr<Background> mouse_over_background_; |
275 // Whether to collapse the label when it's not visible. | 281 // Whether to collapse the label when it's not visible. |
276 bool collapse_when_hidden_; | 282 bool collapse_when_hidden_; |
277 // The following member variable is used to control whether the | 283 // The following member variable is used to control whether the |
278 // directionality is auto-detected based on first strong directionality | 284 // directionality is auto-detected based on first strong directionality |
(...skipping 17 matching lines...) Expand all Loading... |
296 // Should a shadow be drawn behind the text? | 302 // Should a shadow be drawn behind the text? |
297 bool has_shadow_; | 303 bool has_shadow_; |
298 | 304 |
299 | 305 |
300 DISALLOW_COPY_AND_ASSIGN(Label); | 306 DISALLOW_COPY_AND_ASSIGN(Label); |
301 }; | 307 }; |
302 | 308 |
303 } // namespace views | 309 } // namespace views |
304 | 310 |
305 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 311 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
OLD | NEW |