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/autocomplete/autocomplete_popup_view_win.h" | 5 #include "chrome/browser/autocomplete/autocomplete_popup_view_win.h" |
6 | 6 |
7 // TODO(deanm): Clean up these includes, not going to fight it now. | 7 // TODO(deanm): Clean up these includes, not going to fight it now. |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlapp.h> | 9 #include <atlapp.h> |
10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 | 81 |
82 int AutocompletePopupViewWin::MirroringContext::GetLeft(int x1, int x2) const { | 82 int AutocompletePopupViewWin::MirroringContext::GetLeft(int x1, int x2) const { |
83 return enabled_ ? | 83 return enabled_ ? |
84 (center_x_ + (center_x_ - std::max(x1, x2))) : std::min(x1, x2); | 84 (center_x_ + (center_x_ - std::max(x1, x2))) : std::min(x1, x2); |
85 } | 85 } |
86 | 86 |
87 const wchar_t AutocompletePopupViewWin::DrawLineInfo::ellipsis_str[] = | 87 const wchar_t AutocompletePopupViewWin::DrawLineInfo::ellipsis_str[] = |
88 L"\x2026"; | 88 L"\x2026"; |
89 | 89 |
90 AutocompletePopupViewWin::DrawLineInfo::DrawLineInfo(const ChromeFont& font) { | 90 AutocompletePopupViewWin::DrawLineInfo::DrawLineInfo(const gfx::Font& font) { |
91 // Create regular and bold fonts. | 91 // Create regular and bold fonts. |
92 regular_font = font.DeriveFont(-1); | 92 regular_font = font.DeriveFont(-1); |
93 bold_font = regular_font.DeriveFont(0, ChromeFont::BOLD); | 93 bold_font = regular_font.DeriveFont(0, gfx::Font::BOLD); |
94 | 94 |
95 // The total padding added to each line (bottom padding is what is | 95 // The total padding added to each line (bottom padding is what is |
96 // left over after DrawEntry() specifies its top offset). | 96 // left over after DrawEntry() specifies its top offset). |
97 static const int kTotalLinePadding = 5; | 97 static const int kTotalLinePadding = 5; |
98 font_height = std::max(regular_font.height(), bold_font.height()); | 98 font_height = std::max(regular_font.height(), bold_font.height()); |
99 line_height = font_height + kTotalLinePadding; | 99 line_height = font_height + kTotalLinePadding; |
100 ave_char_width = regular_font.GetExpectedTextWidth(1); | 100 ave_char_width = regular_font.GetExpectedTextWidth(1); |
101 ellipsis_width = std::max(regular_font.GetStringWidth(ellipsis_str), | 101 ellipsis_width = std::max(regular_font.GetStringWidth(ellipsis_str), |
102 bold_font.GetStringWidth(ellipsis_str)); | 102 bold_font.GetStringWidth(ellipsis_str)); |
103 | 103 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return RGB( | 179 return RGB( |
180 ((GetRValue(foreground) * alpha) + | 180 ((GetRValue(foreground) * alpha) + |
181 (GetRValue(background) * (0xff - alpha))) / 0xff, | 181 (GetRValue(background) * (0xff - alpha))) / 0xff, |
182 ((GetGValue(foreground) * alpha) + | 182 ((GetGValue(foreground) * alpha) + |
183 (GetGValue(background) * (0xff - alpha))) / 0xff, | 183 (GetGValue(background) * (0xff - alpha))) / 0xff, |
184 ((GetBValue(foreground) * alpha) + | 184 ((GetBValue(foreground) * alpha) + |
185 (GetBValue(background) * (0xff - alpha))) / 0xff); | 185 (GetBValue(background) * (0xff - alpha))) / 0xff); |
186 } | 186 } |
187 | 187 |
188 AutocompletePopupViewWin::AutocompletePopupViewWin( | 188 AutocompletePopupViewWin::AutocompletePopupViewWin( |
189 const ChromeFont& font, | 189 const gfx::Font& font, |
190 AutocompleteEditViewWin* edit_view, | 190 AutocompleteEditViewWin* edit_view, |
191 AutocompleteEditModel* edit_model, | 191 AutocompleteEditModel* edit_model, |
192 Profile* profile) | 192 Profile* profile) |
193 : model_(new AutocompletePopupModel(this, edit_model, profile)), | 193 : model_(new AutocompletePopupModel(this, edit_model, profile)), |
194 edit_view_(edit_view), | 194 edit_view_(edit_view), |
195 line_info_(font), | 195 line_info_(font), |
196 mirroring_context_(new MirroringContext()), | 196 mirroring_context_(new MirroringContext()), |
197 star_(ResourceBundle::GetSharedInstance().GetBitmapNamed( | 197 star_(ResourceBundle::GetSharedInstance().GetBitmapNamed( |
198 IDR_CONTENT_STAR_ON)) { | 198 IDR_CONTENT_STAR_ON)) { |
199 } | 199 } |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 ChromeCanvas canvas(star_->width(), star_->height(), false); | 673 ChromeCanvas canvas(star_->width(), star_->height(), false); |
674 // Make the background completely transparent. | 674 // Make the background completely transparent. |
675 canvas.drawColor(SK_ColorBLACK, SkPorterDuff::kClear_Mode); | 675 canvas.drawColor(SK_ColorBLACK, SkPorterDuff::kClear_Mode); |
676 canvas.DrawBitmapInt(*star_, 0, 0); | 676 canvas.DrawBitmapInt(*star_, 0, 0); |
677 canvas.getTopPlatformDevice().drawToHDC( | 677 canvas.getTopPlatformDevice().drawToHDC( |
678 dc, mirroring_context_->GetLeft(x, x + star_->width()), y, NULL); | 678 dc, mirroring_context_->GetLeft(x, x + star_->width()), y, NULL); |
679 } | 679 } |
680 | 680 |
681 // static | 681 // static |
682 AutocompletePopupView* AutocompletePopupView::CreatePopupView( | 682 AutocompletePopupView* AutocompletePopupView::CreatePopupView( |
683 const ChromeFont& font, | 683 const gfx::Font& font, |
684 AutocompleteEditViewWin* edit_view, | 684 AutocompleteEditViewWin* edit_view, |
685 AutocompleteEditModel* edit_model, | 685 AutocompleteEditModel* edit_model, |
686 Profile* profile, | 686 Profile* profile, |
687 AutocompletePopupPositioner* popup_positioner) { | 687 AutocompletePopupPositioner* popup_positioner) { |
688 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableOmnibox2)) { | 688 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableOmnibox2)) { |
689 return new AutocompletePopupContentsView(font, edit_view, edit_model, | 689 return new AutocompletePopupContentsView(font, edit_view, edit_model, |
690 profile, popup_positioner); | 690 profile, popup_positioner); |
691 } | 691 } |
692 return new AutocompletePopupViewWin(font, edit_view, edit_model, profile); | 692 return new AutocompletePopupViewWin(font, edit_view, edit_model, profile); |
693 } | 693 } |
OLD | NEW |