OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_CONTROLS_LABEL_H_ | 5 #ifndef VIEWS_CONTROLS_LABEL_H_ |
6 #define VIEWS_CONTROLS_LABEL_H_ | 6 #define VIEWS_CONTROLS_LABEL_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "gfx/font.h" | 9 #include "gfx/font.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 }; | 43 }; |
44 | 44 |
45 // The view class name. | 45 // The view class name. |
46 static const char kViewClassName[]; | 46 static const char kViewClassName[]; |
47 | 47 |
48 Label(); | 48 Label(); |
49 explicit Label(const std::wstring& text); | 49 explicit Label(const std::wstring& text); |
50 Label(const std::wstring& text, const gfx::Font& font); | 50 Label(const std::wstring& text, const gfx::Font& font); |
51 virtual ~Label(); | 51 virtual ~Label(); |
52 | 52 |
53 // Overridden to compute the size required to display this label | 53 // Overridden to compute the size required to display this label. |
54 virtual gfx::Size GetPreferredSize(); | 54 virtual gfx::Size GetPreferredSize(); |
55 | 55 |
56 // Overriden to return the baseline of the label. | 56 // Overriden to return the baseline of the label. |
57 virtual int GetBaseline(); | 57 virtual int GetBaseline(); |
58 | 58 |
59 // Return the height necessary to display this label with the provided width. | 59 // Return the height necessary to display this label with the provided width. |
60 // This method is used to layout multi-line labels. It is equivalent to | 60 // This method is used to layout multi-line labels. It is equivalent to |
61 // GetPreferredSize().height() if the receiver is not multi-line | 61 // GetPreferredSize().height() if the receiver is not multi-line. |
62 virtual int GetHeightForWidth(int w); | 62 virtual int GetHeightForWidth(int w); |
63 | 63 |
64 // Overriden to dirty our text bounds if we're multi-line. | 64 // Overriden to dirty our text bounds if we're multi-line. |
65 virtual void DidChangeBounds(const gfx::Rect& previous, | 65 virtual void DidChangeBounds(const gfx::Rect& previous, |
66 const gfx::Rect& current); | 66 const gfx::Rect& current); |
67 | 67 |
68 // Returns views/Label. | 68 // Returns views/Label. |
69 virtual std::string GetClassName() const { return kViewClassName; } | 69 virtual std::string GetClassName() const { return kViewClassName; } |
70 | 70 |
71 // Overridden to paint | 71 // Overridden to paint |
72 virtual void Paint(gfx::Canvas* canvas); | 72 virtual void Paint(gfx::Canvas* canvas); |
73 | 73 |
74 // If the mouse is over the label, and a mouse over background has been | 74 // If the mouse is over the label, and a mouse over background has been |
75 // specified, its used. Otherwise super's implementation is invoked | 75 // specified, its used. Otherwise super's implementation is invoked. |
76 virtual void PaintBackground(gfx::Canvas* canvas); | 76 virtual void PaintBackground(gfx::Canvas* canvas); |
77 | 77 |
78 // Set the font. | 78 // Set the font. |
79 void SetFont(const gfx::Font& font); | 79 void SetFont(const gfx::Font& font); |
80 | 80 |
81 // Set the label text. | 81 // Set the label text. |
82 void SetText(const std::wstring& text); | 82 void SetText(const std::wstring& text); |
83 | 83 |
84 // Return the font used by this label. | 84 // Return the font used by this label. |
85 gfx::Font font() const { return font_; } | 85 gfx::Font font() const { return font_; } |
86 | 86 |
87 // Return the label text. | 87 // Return the label text. |
88 const std::wstring GetText() const; | 88 const std::wstring GetText() const; |
89 | 89 |
90 // Set URL Value - text_ is set to spec(). | 90 // Set URL Value - text_ is set to spec(). |
91 void SetURL(const GURL& url); | 91 void SetURL(const GURL& url); |
92 | 92 |
93 // Return the label URL. | 93 // Return the label URL. |
94 const GURL GetURL() const; | 94 const GURL GetURL() const; |
95 | 95 |
96 // Set the color | 96 // Set the color |
97 virtual void SetColor(const SkColor& color) { color_ = color; } | 97 virtual void SetColor(const SkColor& color) { color_ = color; } |
98 | 98 |
99 // Return a reference to the currently used color | 99 // Return a reference to the currently used color. |
100 virtual SkColor GetColor() const { return color_; } | 100 virtual SkColor GetColor() const { return color_; } |
101 | 101 |
102 // Set horizontal alignment. If the locale is RTL, and the RTL alignment | 102 // Set horizontal alignment. If the locale is RTL, and the RTL alignment |
103 // setting is set as USE_UI_ALIGNMENT, the alignment is flipped around. | 103 // setting is set as USE_UI_ALIGNMENT, the alignment is flipped around. |
104 // | 104 // |
105 // Caveat: for labels originating from a web page, the RTL alignment mode | 105 // Caveat: for labels originating from a web page, the RTL alignment mode |
106 // should be reset to AUTO_DETECT_ALIGNMENT before the horizontal alignment | 106 // should be reset to AUTO_DETECT_ALIGNMENT before the horizontal alignment |
107 // is set. Otherwise, the label's alignment specified as a parameter will be | 107 // is set. Otherwise, the label's alignment specified as a parameter will be |
108 // flipped in RTL locales. Please see the comments in SetRTLAlignmentMode for | 108 // flipped in RTL locales. Please see the comments in SetRTLAlignmentMode for |
109 // more information. | 109 // more information. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // allows this view to reserve space for a focus border that it otherwise | 258 // allows this view to reserve space for a focus border that it otherwise |
259 // might not have because it is not itself focusable. | 259 // might not have because it is not itself focusable. |
260 bool has_focus_border_; | 260 bool has_focus_border_; |
261 | 261 |
262 DISALLOW_COPY_AND_ASSIGN(Label); | 262 DISALLOW_COPY_AND_ASSIGN(Label); |
263 }; | 263 }; |
264 | 264 |
265 } // namespace views | 265 } // namespace views |
266 | 266 |
267 #endif // VIEWS_CONTROLS_LABEL_H_ | 267 #endif // VIEWS_CONTROLS_LABEL_H_ |
OLD | NEW |