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 #include "ui/views/controls/label.h" | 5 #include "ui/views/controls/label.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <vector> | 10 #include <vector> |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 223 } |
224 | 224 |
225 std::string Label::GetClassName() const { | 225 std::string Label::GetClassName() const { |
226 return kViewClassName; | 226 return kViewClassName; |
227 } | 227 } |
228 | 228 |
229 bool Label::HitTestRect(const gfx::Rect& rect) const { | 229 bool Label::HitTestRect(const gfx::Rect& rect) const { |
230 return false; | 230 return false; |
231 } | 231 } |
232 | 232 |
233 void Label::OnMouseMoved(const MouseEvent& event) { | 233 void Label::OnMouseMoved(const ui::MouseEvent& event) { |
234 UpdateContainsMouse(event); | 234 UpdateContainsMouse(event); |
235 } | 235 } |
236 | 236 |
237 void Label::OnMouseEntered(const MouseEvent& event) { | 237 void Label::OnMouseEntered(const ui::MouseEvent& event) { |
238 UpdateContainsMouse(event); | 238 UpdateContainsMouse(event); |
239 } | 239 } |
240 | 240 |
241 void Label::OnMouseExited(const MouseEvent& event) { | 241 void Label::OnMouseExited(const ui::MouseEvent& event) { |
242 SetContainsMouse(false); | 242 SetContainsMouse(false); |
243 } | 243 } |
244 | 244 |
245 bool Label::GetTooltipText(const gfx::Point& p, string16* tooltip) const { | 245 bool Label::GetTooltipText(const gfx::Point& p, string16* tooltip) const { |
246 DCHECK(tooltip); | 246 DCHECK(tooltip); |
247 | 247 |
248 // If a tooltip has been explicitly set, use it. | 248 // If a tooltip has been explicitly set, use it. |
249 if (!tooltip_text_.empty()) { | 249 if (!tooltip_text_.empty()) { |
250 tooltip->assign(tooltip_text_); | 250 tooltip->assign(tooltip_text_); |
251 return true; | 251 return true; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 actual_enabled_color_ = auto_color_readability_ ? | 377 actual_enabled_color_ = auto_color_readability_ ? |
378 color_utils::GetReadableColor(requested_enabled_color_, | 378 color_utils::GetReadableColor(requested_enabled_color_, |
379 background_color_) : | 379 background_color_) : |
380 requested_enabled_color_; | 380 requested_enabled_color_; |
381 actual_disabled_color_ = auto_color_readability_ ? | 381 actual_disabled_color_ = auto_color_readability_ ? |
382 color_utils::GetReadableColor(requested_disabled_color_, | 382 color_utils::GetReadableColor(requested_disabled_color_, |
383 background_color_) : | 383 background_color_) : |
384 requested_disabled_color_; | 384 requested_disabled_color_; |
385 } | 385 } |
386 | 386 |
387 void Label::UpdateContainsMouse(const MouseEvent& event) { | 387 void Label::UpdateContainsMouse(const ui::MouseEvent& event) { |
388 SetContainsMouse(GetTextBounds().Contains(event.x(), event.y())); | 388 SetContainsMouse(GetTextBounds().Contains(event.x(), event.y())); |
389 } | 389 } |
390 | 390 |
391 void Label::SetContainsMouse(bool contains_mouse) { | 391 void Label::SetContainsMouse(bool contains_mouse) { |
392 if (contains_mouse_ == contains_mouse) | 392 if (contains_mouse_ == contains_mouse) |
393 return; | 393 return; |
394 contains_mouse_ = contains_mouse; | 394 contains_mouse_ = contains_mouse; |
395 if (GetMouseOverBackground()) | 395 if (GetMouseOverBackground()) |
396 SchedulePaint(); | 396 SchedulePaint(); |
397 } | 397 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 ui::ELIDE_AT_END); | 493 ui::ELIDE_AT_END); |
494 } else { | 494 } else { |
495 *paint_text = text_; | 495 *paint_text = text_; |
496 } | 496 } |
497 | 497 |
498 *text_bounds = GetTextBounds(); | 498 *text_bounds = GetTextBounds(); |
499 *flags = ComputeDrawStringFlags(); | 499 *flags = ComputeDrawStringFlags(); |
500 } | 500 } |
501 | 501 |
502 } // namespace views | 502 } // namespace views |
OLD | NEW |