Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/omnibox/omnibox_view_win.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <locale> | 8 #include <locale> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 44 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 45 #include "ui/base/dragdrop/drag_drop_types.h" | 45 #include "ui/base/dragdrop/drag_drop_types.h" |
| 46 #include "ui/base/dragdrop/drag_source.h" | 46 #include "ui/base/dragdrop/drag_source.h" |
| 47 #include "ui/base/dragdrop/drop_target.h" | 47 #include "ui/base/dragdrop/drop_target.h" |
| 48 #include "ui/base/dragdrop/os_exchange_data.h" | 48 #include "ui/base/dragdrop/os_exchange_data.h" |
| 49 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 49 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
| 50 #include "ui/base/events.h" | 50 #include "ui/base/events.h" |
| 51 #include "ui/base/keycodes/keyboard_codes.h" | 51 #include "ui/base/keycodes/keyboard_codes.h" |
| 52 #include "ui/base/l10n/l10n_util.h" | 52 #include "ui/base/l10n/l10n_util.h" |
| 53 #include "ui/base/l10n/l10n_util_win.h" | 53 #include "ui/base/l10n/l10n_util_win.h" |
| 54 #include "ui/base/scale.h" | |
| 54 #include "ui/base/win/mouse_wheel_util.h" | 55 #include "ui/base/win/mouse_wheel_util.h" |
| 55 #include "ui/gfx/canvas.h" | 56 #include "ui/gfx/canvas.h" |
| 56 #include "ui/views/button_drag_utils.h" | 57 #include "ui/views/button_drag_utils.h" |
| 57 #include "ui/views/controls/menu/menu_2.h" | 58 #include "ui/views/controls/menu/menu_2.h" |
| 58 #include "ui/views/controls/textfield/native_textfield_win.h" | 59 #include "ui/views/controls/textfield/native_textfield_win.h" |
| 59 #include "ui/views/widget/widget.h" | 60 #include "ui/views/widget/widget.h" |
| 60 | 61 |
| 61 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. | 62 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. |
| 62 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. | 63 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. |
| 63 | 64 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 GetTextMetrics(hdc, &tm); | 498 GetTextMetrics(hdc, &tm); |
| 498 const float kXHeightRatio = 0.7f; // The ratio of a font's x-height to its | 499 const float kXHeightRatio = 0.7f; // The ratio of a font's x-height to its |
| 499 // cap height. Sadly, Windows doesn't | 500 // cap height. Sadly, Windows doesn't |
| 500 // provide a true value for a font's | 501 // provide a true value for a font's |
| 501 // x-height in its text metrics, so we | 502 // x-height in its text metrics, so we |
| 502 // approximate. | 503 // approximate. |
| 503 font_x_height_ = static_cast<int>((static_cast<float>(font_.GetBaseline() - | 504 font_x_height_ = static_cast<int>((static_cast<float>(font_.GetBaseline() - |
| 504 tm.tmInternalLeading) * kXHeightRatio) + 0.5); | 505 tm.tmInternalLeading) * kXHeightRatio) + 0.5); |
| 505 // The distance from the top of the field to the desired baseline of the | 506 // The distance from the top of the field to the desired baseline of the |
| 506 // rendered text. | 507 // rendered text. |
| 507 const int kTextBaseline = popup_window_mode_ ? 15 : 18; | 508 int text_baseline = popup_window_mode_ ? 15 : 18; |
| 508 font_y_adjustment_ = kTextBaseline - font_.GetBaseline(); | 509 switch (ui::GetDisplayScale()) { |
| 510 case ui::SCALE_METRO_100: | |
| 511 case ui::SCALE_METRO_140: | |
| 512 case ui::SCALE_METRO_180: | |
| 513 // TODO(joi): Metro scales other than 100% will probably need a | |
| 514 // different value. | |
| 515 text_baseline = 21; | |
|
Peter Kasting
2012/04/19 17:39:55
If I understand correctly, this is because in metr
| |
| 516 break; | |
| 517 default: | |
| 518 // Leave the default as calculated above. | |
| 519 break; | |
| 520 } | |
| 521 font_y_adjustment_ = text_baseline - font_.GetBaseline(); | |
| 509 | 522 |
| 510 // Get the number of twips per pixel, which we need below to offset our text | 523 // Get the number of twips per pixel, which we need below to offset our text |
| 511 // by the desired number of pixels. | 524 // by the desired number of pixels. |
| 512 const long kTwipsPerPixel = kTwipsPerInch / GetDeviceCaps(hdc, LOGPIXELSY); | 525 const long kTwipsPerPixel = kTwipsPerInch / GetDeviceCaps(hdc, LOGPIXELSY); |
| 513 // It's unsafe to delete a DC with a non-stock object selected, so restore the | 526 // It's unsafe to delete a DC with a non-stock object selected, so restore the |
| 514 // original font. | 527 // original font. |
| 515 SelectObject(hdc, old_font); | 528 SelectObject(hdc, old_font); |
| 516 ::ReleaseDC(NULL, hdc); | 529 ::ReleaseDC(NULL, hdc); |
| 517 | 530 |
| 518 // Set the default character style -- adjust to our desired baseline. | 531 // Set the default character style -- adjust to our desired baseline. |
| (...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2713 bool popup_window_mode, | 2726 bool popup_window_mode, |
| 2714 LocationBarView* location_bar) { | 2727 LocationBarView* location_bar) { |
| 2715 return new OmniboxViewWin(controller, | 2728 return new OmniboxViewWin(controller, |
| 2716 toolbar_model, | 2729 toolbar_model, |
| 2717 location_bar, | 2730 location_bar, |
| 2718 command_updater, | 2731 command_updater, |
| 2719 popup_window_mode, | 2732 popup_window_mode, |
| 2720 location_bar); | 2733 location_bar); |
| 2721 } | 2734 } |
| 2722 #endif | 2735 #endif |
| OLD | NEW |