OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/sad_tab_view.h" | 5 #include "chrome/browser/views/sad_tab_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
10 #include "gfx/canvas.h" | 10 #include "gfx/canvas.h" |
| 11 #include "gfx/canvas_skia.h" |
11 #include "gfx/size.h" | 12 #include "gfx/size.h" |
12 #include "gfx/skia_util.h" | 13 #include "gfx/skia_util.h" |
13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
14 #include "grit/locale_settings.h" | 15 #include "grit/locale_settings.h" |
15 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
16 #include "third_party/skia/include/effects/SkGradientShader.h" | 17 #include "third_party/skia/include/effects/SkGradientShader.h" |
17 | 18 |
18 static const int kSadTabOffset = -64; | 19 static const int kSadTabOffset = -64; |
19 static const int kIconTitleSpacing = 20; | 20 static const int kIconTitleSpacing = 20; |
20 static const int kTitleMessageSpacing = 15; | 21 static const int kTitleMessageSpacing = 15; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 int icon_height = sad_tab_bitmap_->height(); | 83 int icon_height = sad_tab_bitmap_->height(); |
83 int icon_x = (width() - icon_width) / 2; | 84 int icon_x = (width() - icon_width) / 2; |
84 int icon_y = ((height() - icon_height) / 2) + kSadTabOffset; | 85 int icon_y = ((height() - icon_height) / 2) + kSadTabOffset; |
85 icon_bounds_.SetRect(icon_x, icon_y, icon_width, icon_height); | 86 icon_bounds_.SetRect(icon_x, icon_y, icon_width, icon_height); |
86 | 87 |
87 int title_x = (width() - title_width_) / 2; | 88 int title_x = (width() - title_width_) / 2; |
88 int title_y = icon_bounds_.bottom() + kIconTitleSpacing; | 89 int title_y = icon_bounds_.bottom() + kIconTitleSpacing; |
89 int title_height = title_font_->height(); | 90 int title_height = title_font_->height(); |
90 title_bounds_.SetRect(title_x, title_y, title_width_, title_height); | 91 title_bounds_.SetRect(title_x, title_y, title_width_, title_height); |
91 | 92 |
92 gfx::Canvas cc(0, 0, true); | 93 gfx::CanvasSkia cc(0, 0, true); |
93 int message_width = static_cast<int>(width() * kMessageSize); | 94 int message_width = static_cast<int>(width() * kMessageSize); |
94 int message_height = 0; | 95 int message_height = 0; |
95 cc.SizeStringInt(message_, *message_font_, &message_width, &message_height, | 96 cc.SizeStringInt(message_, *message_font_, &message_width, &message_height, |
96 gfx::Canvas::MULTI_LINE); | 97 gfx::Canvas::MULTI_LINE); |
97 int message_x = (width() - message_width) / 2; | 98 int message_x = (width() - message_width) / 2; |
98 int message_y = title_bounds_.bottom() + kTitleMessageSpacing; | 99 int message_y = title_bounds_.bottom() + kTitleMessageSpacing; |
99 message_bounds_.SetRect(message_x, message_y, message_width, message_height); | 100 message_bounds_.SetRect(message_x, message_y, message_width, message_height); |
100 | 101 |
101 if (learn_more_link_ != NULL) { | 102 if (learn_more_link_ != NULL) { |
102 gfx::Size sz = learn_more_link_->GetPreferredSize(); | 103 gfx::Size sz = learn_more_link_->GetPreferredSize(); |
(...skipping 23 matching lines...) Expand all Loading... |
126 rb.GetFont(ResourceBundle::BaseFont).DeriveFont(1)); | 127 rb.GetFont(ResourceBundle::BaseFont).DeriveFont(1)); |
127 sad_tab_bitmap_ = rb.GetBitmapNamed(IDR_SAD_TAB); | 128 sad_tab_bitmap_ = rb.GetBitmapNamed(IDR_SAD_TAB); |
128 | 129 |
129 title_ = l10n_util::GetString(IDS_SAD_TAB_TITLE); | 130 title_ = l10n_util::GetString(IDS_SAD_TAB_TITLE); |
130 title_width_ = title_font_->GetStringWidth(title_); | 131 title_width_ = title_font_->GetStringWidth(title_); |
131 message_ = l10n_util::GetString(IDS_SAD_TAB_MESSAGE); | 132 message_ = l10n_util::GetString(IDS_SAD_TAB_MESSAGE); |
132 | 133 |
133 initialized = true; | 134 initialized = true; |
134 } | 135 } |
135 } | 136 } |
OLD | NEW |