Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: chrome/browser/views/options/fonts_page_view.cc

Issue 3083022: Rework gfx::Font by moving platform-specific code into inner classes.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 font_name_ = font_name; 84 font_name_ = font_name;
85 font_size_ = font_size; 85 font_size_ = font_size;
86 std::wstring displayed_text = font_name_; 86 std::wstring displayed_text = font_name_;
87 87
88 // Append the font type and size. 88 // Append the font type and size.
89 displayed_text += L", "; 89 displayed_text += L", ";
90 displayed_text += UTF8ToWide(::StringPrintf("%d", font_size_)); 90 displayed_text += UTF8ToWide(::StringPrintf("%d", font_size_));
91 HDC hdc = GetDC(NULL); 91 HDC hdc = GetDC(NULL);
92 int font_size_point = MulDiv(font_size, 72, GetDeviceCaps(hdc, LOGPIXELSY)); 92 int font_size_point = MulDiv(font_size, 72, GetDeviceCaps(hdc, LOGPIXELSY));
93 gfx::Font font = gfx::Font::CreateFont(font_name, font_size_point); 93 gfx::Font font = gfx::Font(font_name, font_size_point);
94 font_text_label_->SetFont(font); 94 font_text_label_->SetFont(font);
95 font_text_label_->SetText(displayed_text); 95 font_text_label_->SetText(displayed_text);
96 } 96 }
97 97
98 void FontDisplayView::Paint(gfx::Canvas* canvas) { 98 void FontDisplayView::Paint(gfx::Canvas* canvas) {
99 HDC dc = canvas->BeginPlatformPaint(); 99 HDC dc = canvas->BeginPlatformPaint();
100 RECT rect = { 0, 0, width(), height() }; 100 RECT rect = { 0, 0, width(), height() };
101 gfx::NativeTheme::instance()->PaintTextField( 101 gfx::NativeTheme::instance()->PaintTextField(
102 dc, EP_BACKGROUND, EBS_NORMAL, 0, &rect, ::GetSysColor(COLOR_3DFACE), 102 dc, EP_BACKGROUND, EBS_NORMAL, 0, &rect, ::GetSysColor(COLOR_3DFACE),
103 true, true); 103 true, true);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (combo_box == default_encoding_combobox_) { 199 if (combo_box == default_encoding_combobox_) {
200 if (prev_index != new_index) { // Default-Encoding has been changed. 200 if (prev_index != new_index) { // Default-Encoding has been changed.
201 encoding_dropdown_clicked_ = true; 201 encoding_dropdown_clicked_ = true;
202 default_encoding_selected_ = default_encoding_combobox_model_-> 202 default_encoding_selected_ = default_encoding_combobox_model_->
203 GetEncodingCharsetByIndex(new_index); 203 GetEncodingCharsetByIndex(new_index);
204 default_encoding_changed_ = true; 204 default_encoding_changed_ = true;
205 } 205 }
206 } 206 }
207 } 207 }
208 208
209 void FontsPageView::FontSelected(const gfx::Font& const_font, void* params) { 209 void FontsPageView::FontSelected(const gfx::Font& font, void* params) {
210 gfx::Font font(const_font); 210 if (font.GetFontName().empty())
211 if (gfx::Font(font).FontName().empty())
212 return; 211 return;
213 int font_size = gfx::Font(font).FontSize(); 212 int font_size = font.GetFontSize();
214 // Currently we do not have separate font sizes for Serif and Sans Serif. 213 // Currently we do not have separate font sizes for Serif and Sans Serif.
215 // Therefore, when Serif font size is changed, Sans-Serif font size changes, 214 // Therefore, when Serif font size is changed, Sans-Serif font size changes,
216 // and vice versa. 215 // and vice versa.
217 if (font_type_being_changed_ == SERIF) { 216 if (font_type_being_changed_ == SERIF) {
218 sans_serif_font_size_pixel_ = serif_font_size_pixel_ = font_size; 217 sans_serif_font_size_pixel_ = serif_font_size_pixel_ = font_size;
219 serif_font_display_view_->SetFontType( 218 serif_font_display_view_->SetFontType(
220 font.FontName(), 219 font.GetFontName(),
221 serif_font_size_pixel_); 220 serif_font_size_pixel_);
222 sans_serif_font_display_view_->SetFontType( 221 sans_serif_font_display_view_->SetFontType(
223 sans_serif_font_display_view_->font_name(), 222 sans_serif_font_display_view_->font_name(),
224 sans_serif_font_size_pixel_); 223 sans_serif_font_size_pixel_);
225 } else if (font_type_being_changed_ == SANS_SERIF) { 224 } else if (font_type_being_changed_ == SANS_SERIF) {
226 sans_serif_font_size_pixel_ = serif_font_size_pixel_ = font_size; 225 sans_serif_font_size_pixel_ = serif_font_size_pixel_ = font_size;
227 sans_serif_font_display_view_->SetFontType( 226 sans_serif_font_display_view_->SetFontType(
228 font.FontName(), 227 font.GetFontName(),
229 sans_serif_font_size_pixel_); 228 sans_serif_font_size_pixel_);
230 serif_font_display_view_->SetFontType( 229 serif_font_display_view_->SetFontType(
231 serif_font_display_view_->font_name(), 230 serif_font_display_view_->font_name(),
232 sans_serif_font_size_pixel_); 231 sans_serif_font_size_pixel_);
233 } else if (font_type_being_changed_ == FIXED_WIDTH) { 232 } else if (font_type_being_changed_ == FIXED_WIDTH) {
234 fixed_width_font_size_pixel_ = font_size; 233 fixed_width_font_size_pixel_ = font_size;
235 fixed_width_font_display_view_->SetFontType(font.FontName(), font_size); 234 fixed_width_font_display_view_->SetFontType(font.GetFontName(), font_size);
236 } 235 }
237 font_changed_ = true; 236 font_changed_ = true;
238 } 237 }
239 238
240 void FontsPageView::SaveChanges() { 239 void FontsPageView::SaveChanges() {
241 // Set Fonts. 240 // Set Fonts.
242 if (font_changed_) { 241 if (font_changed_) {
243 serif_name_.SetValue(WideToUTF8(serif_font_display_view_->font_name())); 242 serif_name_.SetValue(WideToUTF8(serif_font_display_view_->font_name()));
244 serif_size_.SetValue(serif_font_size_pixel_); 243 serif_size_.SetValue(serif_font_size_pixel_);
245 sans_serif_name_.SetValue( 244 sans_serif_name_.SetValue(
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); 426 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
428 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 427 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
429 GridLayout::USE_PREF, 0, 0); 428 GridLayout::USE_PREF, 0, 0);
430 429
431 // Add Encoding Combobox. 430 // Add Encoding Combobox.
432 layout->StartRow(0, double_column_view_set_id); 431 layout->StartRow(0, double_column_view_set_id);
433 layout->AddView(default_encoding_combobox_label_); 432 layout->AddView(default_encoding_combobox_label_);
434 layout->AddView(default_encoding_combobox_, 1, 1, GridLayout::FILL, 433 layout->AddView(default_encoding_combobox_, 1, 1, GridLayout::FILL,
435 GridLayout::CENTER); 434 GridLayout::CENTER);
436 } 435 }
OLDNEW
« no previous file with comments | « chrome/browser/views/options/content_exceptions_table_view.cc ('k') | chrome/browser/views/options/languages_page_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698