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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // The padding for the focus border when rendering focused text. | 30 // The padding for the focus border when rendering focused text. |
31 const int kFocusBorderPadding = 1; | 31 const int kFocusBorderPadding = 1; |
32 const int kCachedSizeLimit = 10; | 32 const int kCachedSizeLimit = 10; |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 namespace views { | 36 namespace views { |
37 | 37 |
38 // static | 38 // static |
39 const char Label::kViewClassName[] = "views/Label"; | 39 const char Label::kViewClassName[] = "Label"; |
40 | 40 |
41 Label::Label() { | 41 Label::Label() { |
42 Init(string16(), GetDefaultFont()); | 42 Init(string16(), GetDefaultFont()); |
43 } | 43 } |
44 | 44 |
45 Label::Label(const string16& text) { | 45 Label::Label(const string16& text) { |
46 Init(text, GetDefaultFont()); | 46 Init(text, GetDefaultFont()); |
47 } | 47 } |
48 | 48 |
49 Label::Label(const string16& text, const gfx::Font& font) { | 49 Label::Label(const string16& text, const gfx::Font& font) { |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 for (int i = 0; i < kCachedSizeLimit; ++i) | 521 for (int i = 0; i < kCachedSizeLimit; ++i) |
522 cached_heights_[i] = gfx::Size(); | 522 cached_heights_[i] = gfx::Size(); |
523 } | 523 } |
524 | 524 |
525 bool Label::ShouldShowDefaultTooltip() const { | 525 bool Label::ShouldShowDefaultTooltip() const { |
526 return !is_multi_line_ && | 526 return !is_multi_line_ && |
527 font_.GetStringWidth(text_) > GetAvailableRect().width(); | 527 font_.GetStringWidth(text_) > GetAvailableRect().width(); |
528 } | 528 } |
529 | 529 |
530 } // namespace views | 530 } // namespace views |
OLD | NEW |