| 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/options/fonts_page_view.h" | 5 #include "chrome/browser/views/options/fonts_page_view.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <vsstyle.h> | 9 #include <vsstyle.h> |
| 10 #include <vssym32.h> | 10 #include <vssym32.h> |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 public: | 100 public: |
| 101 FontDisplayView(); | 101 FontDisplayView(); |
| 102 virtual ~FontDisplayView(); | 102 virtual ~FontDisplayView(); |
| 103 | 103 |
| 104 // This method takes in font size in pixel units, instead of the normal point | 104 // This method takes in font size in pixel units, instead of the normal point |
| 105 // unit because users expect the font size number to represent pixels and not | 105 // unit because users expect the font size number to represent pixels and not |
| 106 // points. | 106 // points. |
| 107 void SetFontType(const std::wstring& font_name, | 107 void SetFontType(const std::wstring& font_name, |
| 108 int font_size); | 108 int font_size); |
| 109 | 109 |
| 110 void SetFontType(ChromeFont font); | 110 void SetFontType(gfx::Font font); |
| 111 | 111 |
| 112 std::wstring font_name() { return font_name_; } | 112 std::wstring font_name() { return font_name_; } |
| 113 int font_size() { return font_size_; } | 113 int font_size() { return font_size_; } |
| 114 | 114 |
| 115 // views::View overrides: | 115 // views::View overrides: |
| 116 virtual void Paint(ChromeCanvas* canvas); | 116 virtual void Paint(ChromeCanvas* canvas); |
| 117 virtual void Layout(); | 117 virtual void Layout(); |
| 118 virtual gfx::Size GetPreferredSize(); | 118 virtual gfx::Size GetPreferredSize(); |
| 119 | 119 |
| 120 private: | 120 private: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 FontDisplayView::FontDisplayView() | 133 FontDisplayView::FontDisplayView() |
| 134 : font_text_label_(new views::Label) { | 134 : font_text_label_(new views::Label) { |
| 135 AddChildView(font_text_label_); | 135 AddChildView(font_text_label_); |
| 136 } | 136 } |
| 137 | 137 |
| 138 FontDisplayView::~FontDisplayView() { | 138 FontDisplayView::~FontDisplayView() { |
| 139 } | 139 } |
| 140 | 140 |
| 141 void FontDisplayView::SetFontType(ChromeFont font) { | 141 void FontDisplayView::SetFontType(gfx::Font font) { |
| 142 if (font.FontName().empty()) | 142 if (font.FontName().empty()) |
| 143 return; | 143 return; |
| 144 | 144 |
| 145 font_name_ = font.FontName(); | 145 font_name_ = font.FontName(); |
| 146 font_size_ = font.FontSize(); | 146 font_size_ = font.FontSize(); |
| 147 | 147 |
| 148 // Append the font type and size here. | 148 // Append the font type and size here. |
| 149 std::wstring displayed_text = font_name_; | 149 std::wstring displayed_text = font_name_; |
| 150 displayed_text += L", "; | 150 displayed_text += L", "; |
| 151 displayed_text += UTF8ToWide(StringPrintf("%d", font_size_)); | 151 displayed_text += UTF8ToWide(StringPrintf("%d", font_size_)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 163 | 163 |
| 164 font_name_ = font_name; | 164 font_name_ = font_name; |
| 165 font_size_ = font_size; | 165 font_size_ = font_size; |
| 166 std::wstring displayed_text = font_name_; | 166 std::wstring displayed_text = font_name_; |
| 167 | 167 |
| 168 // Append the font type and size. | 168 // Append the font type and size. |
| 169 displayed_text += L", "; | 169 displayed_text += L", "; |
| 170 displayed_text += UTF8ToWide(::StringPrintf("%d", font_size_)); | 170 displayed_text += UTF8ToWide(::StringPrintf("%d", font_size_)); |
| 171 HDC hdc = GetDC(NULL); | 171 HDC hdc = GetDC(NULL); |
| 172 int font_size_point = MulDiv(font_size, 72, GetDeviceCaps(hdc, LOGPIXELSY)); | 172 int font_size_point = MulDiv(font_size, 72, GetDeviceCaps(hdc, LOGPIXELSY)); |
| 173 ChromeFont font = ChromeFont::CreateFont(font_name, font_size_point); | 173 gfx::Font font = gfx::Font::CreateFont(font_name, font_size_point); |
| 174 font_text_label_->SetFont(font); | 174 font_text_label_->SetFont(font); |
| 175 font_text_label_->SetText(displayed_text); | 175 font_text_label_->SetText(displayed_text); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void FontDisplayView::Paint(ChromeCanvas* canvas) { | 178 void FontDisplayView::Paint(ChromeCanvas* canvas) { |
| 179 HDC dc = canvas->beginPlatformPaint(); | 179 HDC dc = canvas->beginPlatformPaint(); |
| 180 RECT rect = { 0, 0, width(), height() }; | 180 RECT rect = { 0, 0, width(), height() }; |
| 181 gfx::NativeTheme::instance()->PaintTextField( | 181 gfx::NativeTheme::instance()->PaintTextField( |
| 182 dc, EP_BACKGROUND, EBS_NORMAL, 0, &rect, ::GetSysColor(COLOR_3DFACE), | 182 dc, EP_BACKGROUND, EBS_NORMAL, 0, &rect, ::GetSysColor(COLOR_3DFACE), |
| 183 true, true); | 183 true, true); |
| 184 canvas->endPlatformPaint(); | 184 canvas->endPlatformPaint(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void FontDisplayView::Layout() { | 187 void FontDisplayView::Layout() { |
| 188 font_text_label_->SetBounds(0, 0, width(), height()); | 188 font_text_label_->SetBounds(0, 0, width(), height()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 gfx::Size FontDisplayView::GetPreferredSize() { | 191 gfx::Size FontDisplayView::GetPreferredSize() { |
| 192 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 192 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 193 ChromeFont font = rb.GetFont(ResourceBundle::BaseFont); | 193 gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); |
| 194 return gfx::Size(font.GetExpectedTextWidth(kFontDisplayMaxWidthChars), | 194 return gfx::Size(font.GetExpectedTextWidth(kFontDisplayMaxWidthChars), |
| 195 font.height() * kFontDisplayMaxHeightChars | 195 font.height() * kFontDisplayMaxHeightChars |
| 196 + 2 * kFontDisplayLabelPadding); | 196 + 2 * kFontDisplayLabelPadding); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void EmbellishTitle(views::Label* title_label) { | 199 void EmbellishTitle(views::Label* title_label) { |
| 200 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 200 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 201 ChromeFont title_font = | 201 gfx::Font title_font = |
| 202 rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, ChromeFont::BOLD); | 202 rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD); |
| 203 title_label->SetFont(title_font); | 203 title_label->SetFont(title_font); |
| 204 SkColor title_color = | 204 SkColor title_color = |
| 205 gfx::NativeTheme::instance()->GetThemeColorWithDefault( | 205 gfx::NativeTheme::instance()->GetThemeColorWithDefault( |
| 206 gfx::NativeTheme::BUTTON, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, | 206 gfx::NativeTheme::BUTTON, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, |
| 207 COLOR_WINDOWTEXT); | 207 COLOR_WINDOWTEXT); |
| 208 title_label->SetColor(title_color); | 208 title_label->SetColor(title_color); |
| 209 } | 209 } |
| 210 | 210 |
| 211 FontsPageView::FontsPageView(Profile* profile) | 211 FontsPageView::FontsPageView(Profile* profile) |
| 212 : ALLOW_THIS_IN_INITIALIZER_LIST( | 212 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (combo_box == default_encoding_combobox_) { | 279 if (combo_box == default_encoding_combobox_) { |
| 280 if (prev_index != new_index) { // Default-Encoding has been changed. | 280 if (prev_index != new_index) { // Default-Encoding has been changed. |
| 281 encoding_dropdown_clicked_ = true; | 281 encoding_dropdown_clicked_ = true; |
| 282 default_encoding_selected_ = default_encoding_combobox_model_-> | 282 default_encoding_selected_ = default_encoding_combobox_model_-> |
| 283 GetEncodingCharsetByIndex(new_index); | 283 GetEncodingCharsetByIndex(new_index); |
| 284 default_encoding_changed_ = true; | 284 default_encoding_changed_ = true; |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 void FontsPageView::FontSelected(const ChromeFont& const_font, void* params) { | 289 void FontsPageView::FontSelected(const gfx::Font& const_font, void* params) { |
| 290 ChromeFont font(const_font); | 290 gfx::Font font(const_font); |
| 291 if (ChromeFont(font).FontName().empty()) | 291 if (gfx::Font(font).FontName().empty()) |
| 292 return; | 292 return; |
| 293 int font_size = ChromeFont(font).FontSize(); | 293 int font_size = gfx::Font(font).FontSize(); |
| 294 // Currently we do not have separate font sizes for Serif and Sans Serif. | 294 // Currently we do not have separate font sizes for Serif and Sans Serif. |
| 295 // Therefore, when Serif font size is changed, Sans-Serif font size changes, | 295 // Therefore, when Serif font size is changed, Sans-Serif font size changes, |
| 296 // and vice versa. | 296 // and vice versa. |
| 297 if (font_type_being_changed_ == SERIF) { | 297 if (font_type_being_changed_ == SERIF) { |
| 298 sans_serif_font_size_pixel_ = serif_font_size_pixel_ = font_size; | 298 sans_serif_font_size_pixel_ = serif_font_size_pixel_ = font_size; |
| 299 serif_font_display_view_->SetFontType( | 299 serif_font_display_view_->SetFontType( |
| 300 font.FontName(), | 300 font.FontName(), |
| 301 serif_font_size_pixel_); | 301 serif_font_size_pixel_); |
| 302 sans_serif_font_display_view_->SetFontType( | 302 sans_serif_font_display_view_->SetFontType( |
| 303 sans_serif_font_display_view_->font_name(), | 303 sans_serif_font_display_view_->font_name(), |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 using views::GridLayout; | 436 using views::GridLayout; |
| 437 using views::ColumnSet; | 437 using views::ColumnSet; |
| 438 | 438 |
| 439 fonts_contents_ = new views::View; | 439 fonts_contents_ = new views::View; |
| 440 GridLayout* layout = new GridLayout(fonts_contents_); | 440 GridLayout* layout = new GridLayout(fonts_contents_); |
| 441 fonts_contents_->SetLayoutManager(layout); | 441 fonts_contents_->SetLayoutManager(layout); |
| 442 | 442 |
| 443 const int triple_column_view_set_id = 0; | 443 const int triple_column_view_set_id = 0; |
| 444 ColumnSet* column_set = layout->AddColumnSet(triple_column_view_set_id); | 444 ColumnSet* column_set = layout->AddColumnSet(triple_column_view_set_id); |
| 445 | 445 |
| 446 int label_width = ChromeFont().GetExpectedTextWidth( | 446 int label_width = gfx::Font().GetExpectedTextWidth( |
| 447 _wtoi(l10n_util::GetString(IDS_FONTSLANG_LABEL_WIDTH).c_str())); | 447 _wtoi(l10n_util::GetString(IDS_FONTSLANG_LABEL_WIDTH).c_str())); |
| 448 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, | 448 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, |
| 449 GridLayout::FIXED, label_width, 0); | 449 GridLayout::FIXED, label_width, 0); |
| 450 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 450 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |
| 451 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, | 451 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, |
| 452 GridLayout::USE_PREF, 0, 0); | 452 GridLayout::USE_PREF, 0, 0); |
| 453 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 453 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |
| 454 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, | 454 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, |
| 455 GridLayout::USE_PREF, 0, 0); | 455 GridLayout::USE_PREF, 0, 0); |
| 456 | 456 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 509 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |
| 510 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 510 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
| 511 GridLayout::USE_PREF, 0, 0); | 511 GridLayout::USE_PREF, 0, 0); |
| 512 | 512 |
| 513 // Add Encoding ComboBox. | 513 // Add Encoding ComboBox. |
| 514 layout->StartRow(0, double_column_view_set_id); | 514 layout->StartRow(0, double_column_view_set_id); |
| 515 layout->AddView(default_encoding_combobox_label_); | 515 layout->AddView(default_encoding_combobox_label_); |
| 516 layout->AddView(default_encoding_combobox_, 1, 1, GridLayout::FILL, | 516 layout->AddView(default_encoding_combobox_, 1, 1, GridLayout::FILL, |
| 517 GridLayout::CENTER); | 517 GridLayout::CENTER); |
| 518 } | 518 } |
| OLD | NEW |