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 "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "ui/gfx/render_text.h" | 11 #include "ui/gfx/render_text.h" |
12 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 | 15 |
16 // A view subclass that can display a string. | 16 // A view subclass that can display a string. |
17 class VIEWS_EXPORT Label : public View { | 17 class VIEWS_EXPORT Label : public View { |
18 public: | 18 public: |
19 // Internal class name. | 19 // Internal class name. |
20 static const char kViewClassName[]; | 20 static const char kViewClassName[]; |
21 | 21 |
22 // The padding for the focus border when rendering focused text. | |
23 static const int kFocusBorderPadding; | |
24 | |
25 Label(); | 22 Label(); |
26 explicit Label(const base::string16& text); | 23 explicit Label(const base::string16& text); |
27 Label(const base::string16& text, const gfx::FontList& font_list); | 24 Label(const base::string16& text, const gfx::FontList& font_list); |
28 ~Label() override; | 25 ~Label() override; |
29 | 26 |
30 // Gets or sets the fonts used by this label. | 27 // Gets or sets the fonts used by this label. |
31 const gfx::FontList& font_list() const { return render_text_->font_list(); } | 28 const gfx::FontList& font_list() const { return render_text_->font_list(); } |
32 | 29 |
33 virtual void SetFontList(const gfx::FontList& font_list); | 30 virtual void SetFontList(const gfx::FontList& font_list); |
34 | 31 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // wrapped). If 0, no maximum width is enforced. | 111 // wrapped). If 0, no maximum width is enforced. |
115 void SizeToFit(int max_width); | 112 void SizeToFit(int max_width); |
116 | 113 |
117 // Sets whether the preferred size is empty when the label is not visible. | 114 // Sets whether the preferred size is empty when the label is not visible. |
118 void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; } | 115 void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; } |
119 | 116 |
120 // Get the text as displayed to the user, respecting the obscured flag. | 117 // Get the text as displayed to the user, respecting the obscured flag. |
121 base::string16 GetDisplayTextForTesting(); | 118 base::string16 GetDisplayTextForTesting(); |
122 | 119 |
123 // View: | 120 // View: |
124 gfx::Insets GetInsets() const override; | |
125 int GetBaseline() const override; | 121 int GetBaseline() const override; |
126 gfx::Size GetPreferredSize() const override; | 122 gfx::Size GetPreferredSize() const override; |
127 gfx::Size GetMinimumSize() const override; | 123 gfx::Size GetMinimumSize() const override; |
128 int GetHeightForWidth(int w) const override; | 124 int GetHeightForWidth(int w) const override; |
129 void Layout() override; | 125 void Layout() override; |
130 const char* GetClassName() const override; | 126 const char* GetClassName() const override; |
131 View* GetTooltipHandlerForPoint(const gfx::Point& point) override; | 127 View* GetTooltipHandlerForPoint(const gfx::Point& point) override; |
132 bool CanProcessEventsWithinSubtree() const override; | 128 bool CanProcessEventsWithinSubtree() const override; |
133 void GetAccessibleState(ui::AXViewState* state) override; | 129 void GetAccessibleState(ui::AXViewState* state) override; |
134 bool GetTooltipText(const gfx::Point& p, | 130 bool GetTooltipText(const gfx::Point& p, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // TODO(ckocagil): Remove is_first_paint_text_ before crbug.com/441028 is | 211 // TODO(ckocagil): Remove is_first_paint_text_ before crbug.com/441028 is |
216 // closed. | 212 // closed. |
217 bool is_first_paint_text_; | 213 bool is_first_paint_text_; |
218 | 214 |
219 DISALLOW_COPY_AND_ASSIGN(Label); | 215 DISALLOW_COPY_AND_ASSIGN(Label); |
220 }; | 216 }; |
221 | 217 |
222 } // namespace views | 218 } // namespace views |
223 | 219 |
224 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 220 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
OLD | NEW |