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 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Overridden to compute the size required to display this label. | 180 // Overridden to compute the size required to display this label. |
181 virtual gfx::Size GetPreferredSize() OVERRIDE; | 181 virtual gfx::Size GetPreferredSize() 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) OVERRIDE; | 185 virtual int GetHeightForWidth(int w) OVERRIDE; |
186 virtual std::string GetClassName() const OVERRIDE; | 186 virtual std::string GetClassName() const OVERRIDE; |
187 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; | 187 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; |
188 // Mouse enter/exit are overridden to render mouse over background color. | 188 // Mouse enter/exit are overridden to render mouse over background color. |
189 // These invoke SetContainsMouse as necessary. | 189 // These invoke SetContainsMouse as necessary. |
190 virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; | 190 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; |
191 virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; | 191 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
192 virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; | 192 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
193 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 193 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
194 // Gets the tooltip text for labels that are wider than their bounds, except | 194 // Gets the tooltip text for labels that are wider than their bounds, except |
195 // when the label is multiline, in which case it just returns false (no | 195 // when the label is multiline, in which case it just returns false (no |
196 // tooltip). If a custom tooltip has been specified with SetTooltipText() | 196 // tooltip). If a custom tooltip has been specified with SetTooltipText() |
197 // it is returned instead. | 197 // it is returned instead. |
198 virtual bool GetTooltipText(const gfx::Point& p, | 198 virtual bool GetTooltipText(const gfx::Point& p, |
199 string16* tooltip) const OVERRIDE; | 199 string16* tooltip) const OVERRIDE; |
200 | 200 |
201 protected: | 201 protected: |
202 // Called by Paint to paint the text. Override this to change how | 202 // Called by Paint to paint the text. Override this to change how |
(...skipping 30 matching lines...) Expand all Loading... |
233 FRIEND_TEST_ALL_PREFIXES(LabelTest, DisableSubpixelRendering); | 233 FRIEND_TEST_ALL_PREFIXES(LabelTest, DisableSubpixelRendering); |
234 | 234 |
235 static gfx::Font GetDefaultFont(); | 235 static gfx::Font GetDefaultFont(); |
236 | 236 |
237 void Init(const string16& text, const gfx::Font& font); | 237 void Init(const string16& text, const gfx::Font& font); |
238 | 238 |
239 void RecalculateColors(); | 239 void RecalculateColors(); |
240 | 240 |
241 // If the mouse is over the text, SetContainsMouse(true) is invoked, otherwise | 241 // If the mouse is over the text, SetContainsMouse(true) is invoked, otherwise |
242 // SetContainsMouse(false) is invoked. | 242 // SetContainsMouse(false) is invoked. |
243 void UpdateContainsMouse(const MouseEvent& event); | 243 void UpdateContainsMouse(const ui::MouseEvent& event); |
244 | 244 |
245 // Updates whether the mouse is contained in the Label. If the new value | 245 // Updates whether the mouse is contained in the Label. If the new value |
246 // differs from the current value, and a mouse over background is specified, | 246 // differs from the current value, and a mouse over background is specified, |
247 // SchedulePaint is invoked. | 247 // SchedulePaint is invoked. |
248 void SetContainsMouse(bool contains_mouse); | 248 void SetContainsMouse(bool contains_mouse); |
249 | 249 |
250 // Returns where the text is drawn, in the receivers coordinate system. | 250 // Returns where the text is drawn, in the receivers coordinate system. |
251 gfx::Rect GetTextBounds() const; | 251 gfx::Rect GetTextBounds() const; |
252 | 252 |
253 int ComputeDrawStringFlags() const; | 253 int ComputeDrawStringFlags() const; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 // Should a shadow be drawn behind the text? | 302 // Should a shadow be drawn behind the text? |
303 bool has_shadow_; | 303 bool has_shadow_; |
304 | 304 |
305 | 305 |
306 DISALLOW_COPY_AND_ASSIGN(Label); | 306 DISALLOW_COPY_AND_ASSIGN(Label); |
307 }; | 307 }; |
308 | 308 |
309 } // namespace views | 309 } // namespace views |
310 | 310 |
311 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 311 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
OLD | NEW |