| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/controls/label.h" | 5 #include "views/controls/label.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "app/gfx/canvas.h" | 10 #include "app/gfx/canvas.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } | 411 } |
| 412 return insets; | 412 return insets; |
| 413 } | 413 } |
| 414 | 414 |
| 415 // static | 415 // static |
| 416 gfx::Font Label::GetDefaultFont() { | 416 gfx::Font Label::GetDefaultFont() { |
| 417 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); | 417 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); |
| 418 } | 418 } |
| 419 | 419 |
| 420 void Label::UpdateContainsMouse(const MouseEvent& event) { | 420 void Label::UpdateContainsMouse(const MouseEvent& event) { |
| 421 SetContainsMouse(GetTextBounds().Contains(event.x(), event.y())); | 421 if (is_multi_line_) { |
| 422 gfx::Rect rect(width(), GetHeightForWidth(width())); |
| 423 SetContainsMouse(rect.Contains(event.x(), event.y())); |
| 424 } else { |
| 425 SetContainsMouse(GetTextBounds().Contains(event.x(), event.y())); |
| 426 } |
| 422 } | 427 } |
| 423 | 428 |
| 424 void Label::SetContainsMouse(bool contains_mouse) { | 429 void Label::SetContainsMouse(bool contains_mouse) { |
| 425 if (contains_mouse_ == contains_mouse) | 430 if (contains_mouse_ == contains_mouse) |
| 426 return; | 431 return; |
| 427 contains_mouse_ = contains_mouse; | 432 contains_mouse_ = contains_mouse; |
| 428 if (GetMouseOverBackground()) | 433 if (GetMouseOverBackground()) |
| 429 SchedulePaint(); | 434 SchedulePaint(); |
| 430 } | 435 } |
| 431 | 436 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 } | 499 } |
| 495 | 500 |
| 496 bool Label::GetAccessibleState(AccessibilityTypes::State* state) { | 501 bool Label::GetAccessibleState(AccessibilityTypes::State* state) { |
| 497 DCHECK(state); | 502 DCHECK(state); |
| 498 | 503 |
| 499 *state = AccessibilityTypes::STATE_READONLY; | 504 *state = AccessibilityTypes::STATE_READONLY; |
| 500 return true; | 505 return true; |
| 501 } | 506 } |
| 502 | 507 |
| 503 } // namespace views | 508 } // namespace views |
| OLD | NEW |