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/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void Layout() override; | 128 void Layout() override; |
129 const char* GetClassName() const override; | 129 const char* GetClassName() const override; |
130 View* GetTooltipHandlerForPoint(const gfx::Point& point) override; | 130 View* GetTooltipHandlerForPoint(const gfx::Point& point) override; |
131 bool CanProcessEventsWithinSubtree() const override; | 131 bool CanProcessEventsWithinSubtree() const override; |
132 void GetAccessibleState(ui::AXViewState* state) override; | 132 void GetAccessibleState(ui::AXViewState* state) override; |
133 bool GetTooltipText(const gfx::Point& p, | 133 bool GetTooltipText(const gfx::Point& p, |
134 base::string16* tooltip) const override; | 134 base::string16* tooltip) const override; |
135 void OnEnabledChanged() override; | 135 void OnEnabledChanged() override; |
136 | 136 |
137 protected: | 137 protected: |
| 138 // Create a single RenderText instance to actually be painted. |
| 139 virtual scoped_ptr<gfx::RenderText> CreateRenderText( |
| 140 const base::string16& text, |
| 141 gfx::HorizontalAlignment alignment, |
| 142 gfx::DirectionalityMode directionality, |
| 143 gfx::ElideBehavior elide_behavior); |
| 144 |
138 void PaintText(gfx::Canvas* canvas); | 145 void PaintText(gfx::Canvas* canvas); |
139 | 146 |
140 SkColor disabled_color() const { return actual_disabled_color_; } | 147 SkColor disabled_color() const { return actual_disabled_color_; } |
141 | 148 |
142 // View: | 149 // View: |
143 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 150 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
144 void VisibilityChanged(View* starting_from, bool is_visible) override; | 151 void VisibilityChanged(View* starting_from, bool is_visible) override; |
145 void OnPaint(gfx::Canvas* canvas) override; | 152 void OnPaint(gfx::Canvas* canvas) override; |
146 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 153 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
147 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 154 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
148 | 155 |
149 private: | 156 private: |
150 FRIEND_TEST_ALL_PREFIXES(LabelTest, ResetRenderTextData); | 157 FRIEND_TEST_ALL_PREFIXES(LabelTest, ResetRenderTextData); |
151 FRIEND_TEST_ALL_PREFIXES(LabelTest, MultilineSupportedRenderText); | 158 FRIEND_TEST_ALL_PREFIXES(LabelTest, MultilineSupportedRenderText); |
152 FRIEND_TEST_ALL_PREFIXES(LabelTest, TextChangeWithoutLayout); | 159 FRIEND_TEST_ALL_PREFIXES(LabelTest, TextChangeWithoutLayout); |
153 FRIEND_TEST_ALL_PREFIXES(LabelFocusTest, FocusBounds); | 160 FRIEND_TEST_ALL_PREFIXES(LabelFocusTest, FocusBounds); |
154 FRIEND_TEST_ALL_PREFIXES(LabelFocusTest, EmptyLabel); | 161 FRIEND_TEST_ALL_PREFIXES(LabelFocusTest, EmptyLabel); |
155 | 162 |
156 void Init(const base::string16& text, const gfx::FontList& font_list); | 163 void Init(const base::string16& text, const gfx::FontList& font_list); |
157 | 164 |
158 void ResetLayout(); | 165 void ResetLayout(); |
159 | 166 |
160 // Create a single RenderText instance to actually be painted. | |
161 scoped_ptr<gfx::RenderText> CreateRenderText( | |
162 const base::string16& text, | |
163 gfx::HorizontalAlignment alignment, | |
164 gfx::DirectionalityMode directionality, | |
165 gfx::ElideBehavior elide_behavior); | |
166 | |
167 // Set up |lines_| to actually be painted. | 167 // Set up |lines_| to actually be painted. |
168 void MaybeBuildRenderTextLines(); | 168 void MaybeBuildRenderTextLines(); |
169 | 169 |
170 gfx::Rect GetFocusBounds(); | 170 gfx::Rect GetFocusBounds(); |
171 | 171 |
172 // Get the text broken into lines as needed to fit the given |width|. | 172 // Get the text broken into lines as needed to fit the given |width|. |
173 std::vector<base::string16> GetLinesForWidth(int width) const; | 173 std::vector<base::string16> GetLinesForWidth(int width) const; |
174 | 174 |
175 // Get the text size for the current layout. | 175 // Get the text size for the current layout. |
176 gfx::Size GetTextSize() const; | 176 gfx::Size GetTextSize() const; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // TODO(vadimt): Remove is_first_paint_text_ before crbug.com/431326 is | 215 // TODO(vadimt): Remove is_first_paint_text_ before crbug.com/431326 is |
216 // closed. | 216 // closed. |
217 bool is_first_paint_text_; | 217 bool is_first_paint_text_; |
218 | 218 |
219 DISALLOW_COPY_AND_ASSIGN(Label); | 219 DISALLOW_COPY_AND_ASSIGN(Label); |
220 }; | 220 }; |
221 | 221 |
222 } // namespace views | 222 } // namespace views |
223 | 223 |
224 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 224 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
OLD | NEW |