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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // |max_width| is the maximum width that will be used (longer lines will be | 165 // |max_width| is the maximum width that will be used (longer lines will be |
166 // wrapped). If 0, no maximum width is enforced. | 166 // wrapped). If 0, no maximum width is enforced. |
167 void SizeToFit(int max_width); | 167 void SizeToFit(int max_width); |
168 | 168 |
169 // Gets/sets the flag to determine whether the label should be collapsed when | 169 // Gets/sets the flag to determine whether the label should be collapsed when |
170 // it's hidden (not visible). If this flag is true, the label will return a | 170 // it's hidden (not visible). If this flag is true, the label will return a |
171 // preferred size of (0, 0) when it's not visible. | 171 // preferred size of (0, 0) when it's not visible. |
172 void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; } | 172 void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; } |
173 bool collapse_when_hidden() const { return collapse_when_hidden_; } | 173 bool collapse_when_hidden() const { return collapse_when_hidden_; } |
174 | 174 |
175 // Overridden from View: | 175 // View: |
176 virtual gfx::Insets GetInsets() const OVERRIDE; | 176 virtual gfx::Insets GetInsets() const OVERRIDE; |
177 virtual int GetBaseline() const OVERRIDE; | 177 virtual int GetBaseline() const OVERRIDE; |
178 // Overridden to compute the size required to display this label. | 178 // Overridden to compute the size required to display this label. |
179 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 179 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
180 // Returns the width of an ellipsis if the label is non-empty, or 0 otherwise. | 180 // Returns the width of an ellipsis if the label is non-empty, or 0 otherwise. |
181 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 181 virtual gfx::Size GetMinimumSize() const OVERRIDE; |
182 // Returns the height necessary to display this label with the provided width. | 182 // Returns the height necessary to display this label with the provided width. |
183 // This method is used to layout multi-line labels. It is equivalent to | 183 // This method is used to layout multi-line labels. It is equivalent to |
184 // GetPreferredSize().height() if the receiver is not multi-line. | 184 // GetPreferredSize().height() if the receiver is not multi-line. |
185 virtual int GetHeightForWidth(int w) const OVERRIDE; | 185 virtual int GetHeightForWidth(int w) const OVERRIDE; |
186 virtual const char* GetClassName() const OVERRIDE; | 186 virtual const char* GetClassName() const OVERRIDE; |
187 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) OVERRIDE; | 187 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) OVERRIDE; |
188 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; | 188 virtual bool CanProcessEventsWithinSubtree() const OVERRIDE; |
189 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 189 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
190 // Gets the tooltip text for labels that are wider than their bounds, except | 190 // Gets the tooltip text for labels that are wider than their bounds, except |
191 // when the label is multiline, in which case it just returns false (no | 191 // when the label is multiline, in which case it just returns false (no |
192 // tooltip). If a custom tooltip has been specified with SetTooltipText() | 192 // tooltip). If a custom tooltip has been specified with SetTooltipText() |
193 // it is returned instead. | 193 // it is returned instead. |
194 virtual bool GetTooltipText(const gfx::Point& p, | 194 virtual bool GetTooltipText(const gfx::Point& p, |
195 base::string16* tooltip) const OVERRIDE; | 195 base::string16* tooltip) const OVERRIDE; |
196 | 196 |
197 protected: | 197 protected: |
198 // Called by Paint to paint the text. Override this to change how | 198 // Called by Paint to paint the text. Override this to change how |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // The cached heights to avoid recalculation in GetHeightForWidth(). | 299 // The cached heights to avoid recalculation in GetHeightForWidth(). |
300 mutable std::vector<gfx::Size> cached_heights_; | 300 mutable std::vector<gfx::Size> cached_heights_; |
301 mutable int cached_heights_cursor_; | 301 mutable int cached_heights_cursor_; |
302 | 302 |
303 DISALLOW_COPY_AND_ASSIGN(Label); | 303 DISALLOW_COPY_AND_ASSIGN(Label); |
304 }; | 304 }; |
305 | 305 |
306 } // namespace views | 306 } // namespace views |
307 | 307 |
308 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 308 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
OLD | NEW |