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" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 | 140 |
141 // Like SizeToFit, but uses a smaller width if possible. | 141 // Like SizeToFit, but uses a smaller width if possible. |
142 void SetMaximumWidth(int max_width); | 142 void SetMaximumWidth(int max_width); |
143 | 143 |
144 // Sets whether the preferred size is empty when the label is not visible. | 144 // Sets whether the preferred size is empty when the label is not visible. |
145 void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; } | 145 void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; } |
146 | 146 |
147 // Get the text as displayed to the user, respecting the obscured flag. | 147 // Get the text as displayed to the user, respecting the obscured flag. |
148 base::string16 GetDisplayTextForTesting(); | 148 base::string16 GetDisplayTextForTesting(); |
149 | 149 |
150 // Returns true if the label can be made selectable. For example, links do not | |
151 // support text selection. | |
152 // Subclasses should override this function in case they want to selectively | |
153 // support text selection. If a subclass stops supporting text selection, it | |
154 // should call SetSelectable(false). | |
155 virtual bool IsSelectionSupported() const; | |
msw
2016/12/13 03:04:56
nit: reorder function definition order to match th
karandeepb
2016/12/16 02:58:38
It is already matched, the order was probably inco
| |
156 | |
150 // Returns true if the label is selectable. Default is false. | 157 // Returns true if the label is selectable. Default is false. |
151 bool selectable() const { return !!selection_controller_; } | 158 bool selectable() const { return !!selection_controller_; } |
152 | 159 |
153 // Sets whether the label is selectable. False is returned if the call fails, | 160 // Sets whether the label is selectable. False is returned if the call fails, |
154 // i.e. when selection is not supported but |selectable| is true. For example, | 161 // i.e. when selection is not supported but |selectable| is true. For example, |
155 // obscured labels do not support text selection. | 162 // obscured labels do not support text selection. |
156 bool SetSelectable(bool selectable); | 163 bool SetSelectable(bool selectable); |
157 | 164 |
158 // Returns true if the label has a selection. | 165 // Returns true if the label has a selection. |
159 bool HasSelection() const; | 166 bool HasSelection() const; |
(...skipping 28 matching lines...) Expand all Loading... | |
188 virtual std::unique_ptr<gfx::RenderText> CreateRenderText( | 195 virtual std::unique_ptr<gfx::RenderText> CreateRenderText( |
189 const base::string16& text, | 196 const base::string16& text, |
190 gfx::HorizontalAlignment alignment, | 197 gfx::HorizontalAlignment alignment, |
191 gfx::DirectionalityMode directionality, | 198 gfx::DirectionalityMode directionality, |
192 gfx::ElideBehavior elide_behavior) const; | 199 gfx::ElideBehavior elide_behavior) const; |
193 | 200 |
194 void PaintText(gfx::Canvas* canvas); | 201 void PaintText(gfx::Canvas* canvas); |
195 | 202 |
196 SkColor disabled_color() const { return actual_disabled_color_; } | 203 SkColor disabled_color() const { return actual_disabled_color_; } |
197 | 204 |
198 // Returns true if the label can be made selectable. For example, links do not | |
199 // support text selection. | |
200 // Subclasses should override this function in case they want to selectively | |
201 // support text selection. If a subclass stops supporting text selection, it | |
202 // should call SetSelectable(false). | |
203 virtual bool IsSelectionSupported() const; | |
204 | |
205 // View: | 205 // View: |
206 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 206 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
207 void VisibilityChanged(View* starting_from, bool is_visible) override; | 207 void VisibilityChanged(View* starting_from, bool is_visible) override; |
208 void OnPaint(gfx::Canvas* canvas) override; | 208 void OnPaint(gfx::Canvas* canvas) override; |
209 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 209 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
210 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 210 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
211 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; | 211 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; |
212 void OnFocus() override; | 212 void OnFocus() override; |
213 void OnBlur() override; | 213 void OnBlur() override; |
214 bool OnMousePressed(const ui::MouseEvent& event) override; | 214 bool OnMousePressed(const ui::MouseEvent& event) override; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 // Context menu related members. | 343 // Context menu related members. |
344 ui::SimpleMenuModel context_menu_contents_; | 344 ui::SimpleMenuModel context_menu_contents_; |
345 std::unique_ptr<views::MenuRunner> context_menu_runner_; | 345 std::unique_ptr<views::MenuRunner> context_menu_runner_; |
346 | 346 |
347 DISALLOW_COPY_AND_ASSIGN(Label); | 347 DISALLOW_COPY_AND_ASSIGN(Label); |
348 }; | 348 }; |
349 | 349 |
350 } // namespace views | 350 } // namespace views |
351 | 351 |
352 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 352 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
OLD | NEW |