| 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> |
| 11 | 11 |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "app/gfx/chrome_canvas.h" | 14 #include "app/gfx/canvas.h" |
| 15 #include "app/gfx/chrome_font.h" | 15 #include "app/gfx/font.h" |
| 16 #include "app/l10n_util.h" | 16 #include "app/l10n_util.h" |
| 17 #include "app/resource_bundle.h" | 17 #include "app/resource_bundle.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/gfx/native_theme.h" | 19 #include "base/gfx/native_theme.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/character_encoding.h" | 22 #include "chrome/browser/character_encoding.h" |
| 23 #include "chrome/browser/shell_dialogs.h" | 23 #include "chrome/browser/shell_dialogs.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/common/pref_service.h" | 25 #include "chrome/common/pref_service.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(gfx::Font 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(gfx::Canvas* 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: |
| 121 views::Label* font_text_label_; | 121 views::Label* font_text_label_; |
| 122 std::wstring font_name_; | 122 std::wstring font_name_; |
| 123 int font_size_; | 123 int font_size_; |
| 124 std::wstring font_text_label_string_; | 124 std::wstring font_text_label_string_; |
| 125 | 125 |
| 126 static const int kFontDisplayMaxWidthChars = 50; | 126 static const int kFontDisplayMaxWidthChars = 50; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 gfx::Font font = gfx::Font::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(gfx::Canvas* 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()); |
| (...skipping 320 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 |