| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // implementation should be used. | 282 // implementation should be used. |
| 283 if (!View::HitTestRect(gfx::Rect(point, gfx::Size(1, 1)))) | 283 if (!View::HitTestRect(gfx::Rect(point, gfx::Size(1, 1)))) |
| 284 return NULL; | 284 return NULL; |
| 285 | 285 |
| 286 if (tooltip_text_.empty() && !ShouldShowDefaultTooltip()) | 286 if (tooltip_text_.empty() && !ShouldShowDefaultTooltip()) |
| 287 return NULL; | 287 return NULL; |
| 288 | 288 |
| 289 return this; | 289 return this; |
| 290 } | 290 } |
| 291 | 291 |
| 292 bool Label::HitTestRect(const gfx::Rect& rect) const { | |
| 293 return false; | |
| 294 } | |
| 295 | |
| 296 bool Label::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const { | 292 bool Label::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const { |
| 297 DCHECK(tooltip); | 293 DCHECK(tooltip); |
| 298 | 294 |
| 299 // If a tooltip has been explicitly set, use it. | 295 // If a tooltip has been explicitly set, use it. |
| 300 if (!tooltip_text_.empty()) { | 296 if (!tooltip_text_.empty()) { |
| 301 tooltip->assign(tooltip_text_); | 297 tooltip->assign(tooltip_text_); |
| 302 return true; | 298 return true; |
| 303 } | 299 } |
| 304 | 300 |
| 305 // Show the full text if the text does not fit. | 301 // Show the full text if the text does not fit. |
| 306 if (ShouldShowDefaultTooltip()) { | 302 if (ShouldShowDefaultTooltip()) { |
| 307 *tooltip = layout_text(); | 303 *tooltip = layout_text(); |
| 308 return true; | 304 return true; |
| 309 } | 305 } |
| 310 | 306 |
| 311 return false; | 307 return false; |
| 312 } | 308 } |
| 313 | 309 |
| 310 bool Label::CanAcceptEvent(const ui::Event& event) { |
| 311 return false; |
| 312 } |
| 313 |
| 314 void Label::GetAccessibleState(ui::AXViewState* state) { | 314 void Label::GetAccessibleState(ui::AXViewState* state) { |
| 315 state->role = ui::AX_ROLE_STATIC_TEXT; | 315 state->role = ui::AX_ROLE_STATIC_TEXT; |
| 316 state->AddStateFlag(ui::AX_STATE_READ_ONLY); | 316 state->AddStateFlag(ui::AX_STATE_READ_ONLY); |
| 317 state->name = layout_text(); | 317 state->name = layout_text(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void Label::PaintText(gfx::Canvas* canvas, | 320 void Label::PaintText(gfx::Canvas* canvas, |
| 321 const base::string16& text, | 321 const base::string16& text, |
| 322 const gfx::Rect& text_bounds, | 322 const gfx::Rect& text_bounds, |
| 323 int flags) { | 323 int flags) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 cached_heights_[i] = gfx::Size(); | 557 cached_heights_[i] = gfx::Size(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 bool Label::ShouldShowDefaultTooltip() const { | 560 bool Label::ShouldShowDefaultTooltip() const { |
| 561 return !is_multi_line_ && !is_obscured_ && | 561 return !is_multi_line_ && !is_obscured_ && |
| 562 gfx::GetStringWidth(layout_text(), font_list_) > | 562 gfx::GetStringWidth(layout_text(), font_list_) > |
| 563 GetAvailableRect().width(); | 563 GetAvailableRect().width(); |
| 564 } | 564 } |
| 565 | 565 |
| 566 } // namespace views | 566 } // namespace views |
| OLD | NEW |