OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/button/text_button.h" | 5 #include "views/controls/button/text_button.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/throb_animation.h" | 9 #include "app/throb_animation.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/utf_string_conversions.h" |
11 #include "gfx/canvas_skia.h" | 12 #include "gfx/canvas_skia.h" |
12 #include "views/controls/button/button.h" | 13 #include "views/controls/button/button.h" |
13 #include "views/event.h" | 14 #include "views/event.h" |
14 #include "grit/app_resources.h" | 15 #include "grit/app_resources.h" |
15 | 16 |
16 namespace views { | 17 namespace views { |
17 | 18 |
18 // Default space between the icon and text. | 19 // Default space between the icon and text. |
19 static const int kDefaultIconTextSpacing = 5; | 20 static const int kDefaultIconTextSpacing = 5; |
20 | 21 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 } | 395 } |
395 } | 396 } |
396 | 397 |
397 void TextButton::UpdateColor() { | 398 void TextButton::UpdateColor() { |
398 color_ = IsEnabled() ? color_enabled_ : color_disabled_; | 399 color_ = IsEnabled() ? color_enabled_ : color_disabled_; |
399 } | 400 } |
400 | 401 |
401 void TextButton::UpdateTextSize() { | 402 void TextButton::UpdateTextSize() { |
402 int width = 0, height = 0; | 403 int width = 0, height = 0; |
403 gfx::CanvasSkia::SizeStringInt( | 404 gfx::CanvasSkia::SizeStringInt( |
404 text_, font_, &width, &height, | 405 WideToUTF16Hack(text_), font_, &width, &height, |
405 gfx::Canvas::NO_ELLIPSIS | PrefixTypeToCanvasType(prefix_type_)); | 406 gfx::Canvas::NO_ELLIPSIS | PrefixTypeToCanvasType(prefix_type_)); |
406 | 407 |
407 // Add 2 extra pixels to width and height when text halo is used. | 408 // Add 2 extra pixels to width and height when text halo is used. |
408 if (has_text_halo_) { | 409 if (has_text_halo_) { |
409 width += 2; | 410 width += 2; |
410 height += 2; | 411 height += 2; |
411 } | 412 } |
412 | 413 |
413 text_size_.SetSize(width, font_.GetHeight()); | 414 text_size_.SetSize(width, font_.GetHeight()); |
414 max_text_size_.SetSize(std::max(max_text_size_.width(), text_size_.width()), | 415 max_text_size_.SetSize(std::max(max_text_size_.width(), text_size_.width()), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 454 |
454 std::string TextButton::GetClassName() const { | 455 std::string TextButton::GetClassName() const { |
455 return kViewClassName; | 456 return kViewClassName; |
456 } | 457 } |
457 | 458 |
458 void TextButton::Paint(gfx::Canvas* canvas) { | 459 void TextButton::Paint(gfx::Canvas* canvas) { |
459 Paint(canvas, false); | 460 Paint(canvas, false); |
460 } | 461 } |
461 | 462 |
462 } // namespace views | 463 } // namespace views |
OLD | NEW |