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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 if (ShouldShowDefaultTooltip()) { | 284 if (ShouldShowDefaultTooltip()) { |
285 *tooltip = text_; | 285 *tooltip = text_; |
286 return true; | 286 return true; |
287 } | 287 } |
288 | 288 |
289 return false; | 289 return false; |
290 } | 290 } |
291 | 291 |
292 void Label::GetAccessibleState(ui::AXViewState* state) { | 292 void Label::GetAccessibleState(ui::AXViewState* state) { |
293 state->role = ui::AX_ROLE_STATIC_TEXT; | 293 state->role = ui::AX_ROLE_STATIC_TEXT; |
294 state->state = ui::AX_STATE_READ_ONLY; | 294 state->AddStateFlag(ui::AX_STATE_READ_ONLY); |
295 state->name = text_; | 295 state->name = text_; |
296 } | 296 } |
297 | 297 |
298 void Label::PaintText(gfx::Canvas* canvas, | 298 void Label::PaintText(gfx::Canvas* canvas, |
299 const base::string16& text, | 299 const base::string16& text, |
300 const gfx::Rect& text_bounds, | 300 const gfx::Rect& text_bounds, |
301 int flags) { | 301 int flags) { |
302 gfx::ShadowValues shadows; | 302 gfx::ShadowValues shadows; |
303 if (has_shadow_) | 303 if (has_shadow_) |
304 shadows.push_back(gfx::ShadowValue(shadow_offset_, 0, | 304 shadows.push_back(gfx::ShadowValue(shadow_offset_, 0, |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 for (int i = 0; i < kCachedSizeLimit; ++i) | 525 for (int i = 0; i < kCachedSizeLimit; ++i) |
526 cached_heights_[i] = gfx::Size(); | 526 cached_heights_[i] = gfx::Size(); |
527 } | 527 } |
528 | 528 |
529 bool Label::ShouldShowDefaultTooltip() const { | 529 bool Label::ShouldShowDefaultTooltip() const { |
530 return !is_multi_line_ && | 530 return !is_multi_line_ && |
531 gfx::GetStringWidth(text_, font_list_) > GetAvailableRect().width(); | 531 gfx::GetStringWidth(text_, font_list_) > GetAvailableRect().width(); |
532 } | 532 } |
533 | 533 |
534 } // namespace views | 534 } // namespace views |
OLD | NEW |