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/button/text_button.h" | 5 #include "views/controls/button/text_button.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "grit/app_resources.h" | 11 #include "grit/app_resources.h" |
12 #include "ui/base/animation/throb_animation.h" | 12 #include "ui/base/animation/throb_animation.h" |
13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
14 #include "ui/gfx/canvas_skia.h" | 14 #include "ui/gfx/canvas_skia.h" |
15 #include "views/controls/button/button.h" | 15 #include "views/controls/button/button.h" |
16 #include "views/events/event.h" | 16 #include "views/events/event.h" |
17 #include "views/widget/widget.h" | 17 #include "views/widget/widget.h" |
18 | 18 |
19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 20 #include "ui/gfx/native_theme_win.h" |
20 #include "ui/gfx/platform_font_win.h" | 21 #include "ui/gfx/platform_font_win.h" |
21 #endif | 22 #endif |
22 | 23 |
23 namespace views { | 24 namespace views { |
24 | 25 |
25 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
26 // The min size in DLUs comes from | 27 // The min size in DLUs comes from |
27 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/c
h14e.asp | 28 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/c
h14e.asp |
28 static const int kMinWidthDLUs = 50; | 29 static const int kMinWidthDLUs = 50; |
29 static const int kMinHeightDLUs = 14; | 30 static const int kMinHeightDLUs = 14; |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 return gfx::NativeTheme::kHovered; | 601 return gfx::NativeTheme::kHovered; |
601 case BS_PUSHED: | 602 case BS_PUSHED: |
602 return gfx::NativeTheme::kPressed; | 603 return gfx::NativeTheme::kPressed; |
603 default: | 604 default: |
604 NOTREACHED() << "Unknown state: " << state(); | 605 NOTREACHED() << "Unknown state: " << state(); |
605 return gfx::NativeTheme::kNormal; | 606 return gfx::NativeTheme::kNormal; |
606 } | 607 } |
607 } | 608 } |
608 | 609 |
609 const ui::Animation* TextButtonBase::GetThemeAnimation() const { | 610 const ui::Animation* TextButtonBase::GetThemeAnimation() const { |
| 611 #if defined(OS_WIN) |
| 612 return gfx::NativeThemeWin::instance()->IsThemingActive() |
| 613 ? hover_animation_.get() : NULL; |
| 614 #else |
610 return hover_animation_.get(); | 615 return hover_animation_.get(); |
| 616 #endif |
611 } | 617 } |
612 | 618 |
613 gfx::NativeTheme::State TextButtonBase::GetBackgroundThemeState( | 619 gfx::NativeTheme::State TextButtonBase::GetBackgroundThemeState( |
614 gfx::NativeTheme::ExtraParams* params) const { | 620 gfx::NativeTheme::ExtraParams* params) const { |
615 GetExtraParams(params); | 621 GetExtraParams(params); |
616 return gfx::NativeTheme::kNormal; | 622 return gfx::NativeTheme::kNormal; |
617 } | 623 } |
618 | 624 |
619 gfx::NativeTheme::State TextButtonBase::GetForegroundThemeState( | 625 gfx::NativeTheme::State TextButtonBase::GetForegroundThemeState( |
620 gfx::NativeTheme::ExtraParams* params) const { | 626 gfx::NativeTheme::ExtraParams* params) const { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 725 |
720 std::string TextButton::GetClassName() const { | 726 std::string TextButton::GetClassName() const { |
721 return kViewClassName; | 727 return kViewClassName; |
722 } | 728 } |
723 | 729 |
724 gfx::NativeTheme::Part TextButton::GetThemePart() const { | 730 gfx::NativeTheme::Part TextButton::GetThemePart() const { |
725 return gfx::NativeTheme::kPushButton; | 731 return gfx::NativeTheme::kPushButton; |
726 } | 732 } |
727 | 733 |
728 void TextButton::GetExtraParams(gfx::NativeTheme::ExtraParams* params) const { | 734 void TextButton::GetExtraParams(gfx::NativeTheme::ExtraParams* params) const { |
729 params->button.checked = false; | 735 TextButtonBase::GetExtraParams(params); |
730 params->button.indeterminate = false; | |
731 params->button.is_default = is_default_; | 736 params->button.is_default = is_default_; |
732 params->button.has_border = false; | |
733 params->button.classic_state = 0; | |
734 params->button.background_color = kEnabledColor; | |
735 } | 737 } |
736 | 738 |
737 gfx::Rect TextButton::GetTextBounds() const { | 739 gfx::Rect TextButton::GetTextBounds() const { |
738 int extra_width = 0; | 740 int extra_width = 0; |
739 | 741 |
740 const SkBitmap& icon = GetImageToPaint(); | 742 const SkBitmap& icon = GetImageToPaint(); |
741 if (icon.width() > 0) | 743 if (icon.width() > 0) |
742 extra_width = icon.width() + (text_.empty() ? 0 : icon_text_spacing_); | 744 extra_width = icon.width() + (text_.empty() ? 0 : icon_text_spacing_); |
743 | 745 |
744 gfx::Rect bounds(GetContentBounds(extra_width)); | 746 gfx::Rect bounds(GetContentBounds(extra_width)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 | 792 |
791 gfx::Size NativeTextButton::GetMinimumSize() { | 793 gfx::Size NativeTextButton::GetMinimumSize() { |
792 return GetPreferredSize(); | 794 return GetPreferredSize(); |
793 } | 795 } |
794 | 796 |
795 std::string NativeTextButton::GetClassName() const { | 797 std::string NativeTextButton::GetClassName() const { |
796 return kViewClassName; | 798 return kViewClassName; |
797 } | 799 } |
798 | 800 |
799 } // namespace views | 801 } // namespace views |
OLD | NEW |