OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <cmath> | 7 #include <cmath> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 int Label::GetBaseline() { | 179 int Label::GetBaseline() { |
180 return GetInsets().top() + font_.GetBaseline(); | 180 return GetInsets().top() + font_.GetBaseline(); |
181 } | 181 } |
182 | 182 |
183 gfx::Size Label::GetPreferredSize() { | 183 gfx::Size Label::GetPreferredSize() { |
184 // Return a size of (0, 0) if the label is not visible and if the | 184 // Return a size of (0, 0) if the label is not visible and if the |
185 // collapse_when_hidden_ flag is set. | 185 // collapse_when_hidden_ flag is set. |
186 // TODO(munjal): This logic probably belongs to the View class. But for now, | 186 // TODO(munjal): This logic probably belongs to the View class. But for now, |
187 // put it here since putting it in View class means all inheriting classes | 187 // put it here since putting it in View class means all inheriting classes |
188 // need ot respect the collapse_when_hidden_ flag. | 188 // need ot respect the collapse_when_hidden_ flag. |
189 if (!IsVisible() && collapse_when_hidden_) | 189 if (!visible() && collapse_when_hidden_) |
190 return gfx::Size(); | 190 return gfx::Size(); |
191 | 191 |
192 gfx::Size prefsize(GetTextSize()); | 192 gfx::Size prefsize(GetTextSize()); |
193 gfx::Insets insets = GetInsets(); | 193 gfx::Insets insets = GetInsets(); |
194 prefsize.Enlarge(insets.width(), insets.height()); | 194 prefsize.Enlarge(insets.width(), insets.height()); |
195 return prefsize; | 195 return prefsize; |
196 } | 196 } |
197 | 197 |
198 int Label::GetHeightForWidth(int w) { | 198 int Label::GetHeightForWidth(int w) { |
199 if (!is_multi_line_) | 199 if (!is_multi_line_) |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 font_, GetAvailableRect().width(), true)); | 454 font_, GetAvailableRect().width(), true)); |
455 } else { | 455 } else { |
456 *paint_text = UTF16ToWideHack(text_); | 456 *paint_text = UTF16ToWideHack(text_); |
457 } | 457 } |
458 | 458 |
459 *text_bounds = GetTextBounds(); | 459 *text_bounds = GetTextBounds(); |
460 *flags = ComputeMultiLineFlags(); | 460 *flags = ComputeMultiLineFlags(); |
461 } | 461 } |
462 | 462 |
463 } // namespace views | 463 } // namespace views |
OLD | NEW |