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 "chrome/browser/chromeos/drop_shadow_label.h" | 5 #include "chrome/browser/chromeos/drop_shadow_label.h" |
6 | 6 |
| 7 #include "base/utf_string_conversions.h" |
7 #include "gfx/canvas.h" | 8 #include "gfx/canvas.h" |
8 #include "gfx/color_utils.h" | 9 #include "gfx/color_utils.h" |
9 | 10 |
10 using views::Label; | 11 using views::Label; |
11 | 12 |
12 namespace chromeos { | 13 namespace chromeos { |
13 | 14 |
14 static const int kDefaultDropShadowSize = 2; | 15 static const int kDefaultDropShadowSize = 2; |
15 | 16 |
16 // Default color is black. | 17 // Default color is black. |
(...skipping 20 matching lines...) Expand all Loading... |
37 void DropShadowLabel::PaintText(gfx::Canvas* canvas, | 38 void DropShadowLabel::PaintText(gfx::Canvas* canvas, |
38 const std::wstring& text, | 39 const std::wstring& text, |
39 const gfx::Rect& text_bounds, | 40 const gfx::Rect& text_bounds, |
40 int flags) { | 41 int flags) { |
41 if (drop_shadow_size_ > 0) { | 42 if (drop_shadow_size_ > 0) { |
42 SkColor color = SkColorSetARGB(kShadowOpacity * SkColorGetA(GetColor()), | 43 SkColor color = SkColorSetARGB(kShadowOpacity * SkColorGetA(GetColor()), |
43 SkColorGetR(kDefaultColor), | 44 SkColorGetR(kDefaultColor), |
44 SkColorGetG(kDefaultColor), | 45 SkColorGetG(kDefaultColor), |
45 SkColorGetB(kDefaultColor)); | 46 SkColorGetB(kDefaultColor)); |
46 for (int i = 0; i < drop_shadow_size_; i++) { | 47 for (int i = 0; i < drop_shadow_size_; i++) { |
47 canvas->DrawStringInt(text, font(), color, | 48 canvas->DrawStringInt(WideToUTF16Hack(text), font(), color, |
48 text_bounds.x() + i, text_bounds.y(), | 49 text_bounds.x() + i, text_bounds.y(), |
49 text_bounds.width(), text_bounds.height(), flags); | 50 text_bounds.width(), text_bounds.height(), flags); |
50 canvas->DrawStringInt(text, font(), color, | 51 canvas->DrawStringInt(WideToUTF16Hack(text), font(), color, |
51 text_bounds.x() + i, text_bounds.y() + i, | 52 text_bounds.x() + i, text_bounds.y() + i, |
52 text_bounds.width(), text_bounds.height(), flags); | 53 text_bounds.width(), text_bounds.height(), flags); |
53 canvas->DrawStringInt(text, font(), color, | 54 canvas->DrawStringInt(WideToUTF16Hack(text), font(), color, |
54 text_bounds.x(), text_bounds.y() + i, | 55 text_bounds.x(), text_bounds.y() + i, |
55 text_bounds.width(), text_bounds.height(), flags); | 56 text_bounds.width(), text_bounds.height(), flags); |
56 } | 57 } |
57 } | 58 } |
58 | 59 |
59 canvas->DrawStringInt(text, font(), GetColor(), | 60 canvas->DrawStringInt(WideToUTF16Hack(text), font(), GetColor(), |
60 text_bounds.x(), text_bounds.y(), | 61 text_bounds.x(), text_bounds.y(), |
61 text_bounds.width(), text_bounds.height(), flags); | 62 text_bounds.width(), text_bounds.height(), flags); |
62 | 63 |
63 if (HasFocus() || paint_as_focused()) { | 64 if (HasFocus() || paint_as_focused()) { |
64 gfx::Rect focus_bounds = text_bounds; | 65 gfx::Rect focus_bounds = text_bounds; |
65 focus_bounds.Inset(-Label::kFocusBorderPadding, | 66 focus_bounds.Inset(-Label::kFocusBorderPadding, |
66 -Label::kFocusBorderPadding); | 67 -Label::kFocusBorderPadding); |
67 canvas->DrawFocusRect(focus_bounds.x(), focus_bounds.y(), | 68 canvas->DrawFocusRect(focus_bounds.x(), focus_bounds.y(), |
68 focus_bounds.width(), focus_bounds.height()); | 69 focus_bounds.width(), focus_bounds.height()); |
69 } | 70 } |
70 } | 71 } |
71 | 72 |
72 gfx::Size DropShadowLabel::GetTextSize() const { | 73 gfx::Size DropShadowLabel::GetTextSize() const { |
73 gfx::Size text_size = Label::GetTextSize(); | 74 gfx::Size text_size = Label::GetTextSize(); |
74 text_size.SetSize(text_size.width() + drop_shadow_size_, | 75 text_size.SetSize(text_size.width() + drop_shadow_size_, |
75 text_size.height() + drop_shadow_size_); | 76 text_size.height() + drop_shadow_size_); |
76 return text_size; | 77 return text_size; |
77 } | 78 } |
78 | 79 |
79 } // namespace chromeos | 80 } // namespace chromeos |
OLD | NEW |