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 "ui/views/controls/menu/menu_win.h" | 5 #include "ui/views/controls/menu/menu_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "ui/base/accelerators/accelerator.h" | 12 #include "ui/base/accelerators/accelerator.h" |
13 #include "ui/base/keycodes/keyboard_codes.h" | 13 #include "ui/base/keycodes/keyboard_codes.h" |
14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
15 #include "ui/base/l10n/l10n_util_win.h" | 15 #include "ui/base/l10n/l10n_util_win.h" |
16 #include "ui/base/layout.h" | |
Ben Goodger (Google)
2013/09/16 23:10:31
etc
| |
16 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
17 #include "ui/gfx/font.h" | 18 #include "ui/gfx/font.h" |
18 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
19 #include "ui/gfx/win/window_impl.h" | 20 #include "ui/gfx/win/window_impl.h" |
20 | 21 |
21 namespace views { | 22 namespace views { |
22 | 23 |
23 // The width of an icon, including the pixels between the icon and | 24 // The width of an icon, including the pixels between the icon and |
24 // the item label. | 25 // the item label. |
25 const int kIconWidth = 23; | 26 const int kIconWidth = 23; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 DrawTextEx(hDC, const_cast<wchar_t*>(label.data()), | 177 DrawTextEx(hDC, const_cast<wchar_t*>(label.data()), |
177 static_cast<int>(label.size()), &rect, format | DT_LEFT, NULL); | 178 static_cast<int>(label.size()), &rect, format | DT_LEFT, NULL); |
178 if (!accel.empty()) | 179 if (!accel.empty()) |
179 DrawTextEx(hDC, const_cast<wchar_t*>(accel.data()), | 180 DrawTextEx(hDC, const_cast<wchar_t*>(accel.data()), |
180 static_cast<int>(accel.size()), &rect, | 181 static_cast<int>(accel.size()), &rect, |
181 format | DT_RIGHT, NULL); | 182 format | DT_RIGHT, NULL); |
182 SelectObject(hDC, old_font); | 183 SelectObject(hDC, old_font); |
183 | 184 |
184 // Draw the icon after the label, otherwise it would be covered | 185 // Draw the icon after the label, otherwise it would be covered |
185 // by the label. | 186 // by the label. |
186 gfx::ImageSkiaRep icon_image_rep = | 187 gfx::ImageSkiaRep icon_image_rep = data->icon.GetRepresentation(1.0f); |
187 data->icon.GetRepresentation(ui::SCALE_FACTOR_100P); | |
188 if (data->icon.width() != 0 && data->icon.height() != 0) { | 188 if (data->icon.width() != 0 && data->icon.height() != 0) { |
189 gfx::Canvas canvas(icon_image_rep, false); | 189 gfx::Canvas canvas(icon_image_rep, false); |
190 skia::DrawToNativeContext( | 190 skia::DrawToNativeContext( |
191 canvas.sk_canvas(), hDC, lpdis->rcItem.left + kItemLeftMargin, | 191 canvas.sk_canvas(), hDC, lpdis->rcItem.left + kItemLeftMargin, |
192 lpdis->rcItem.top + (lpdis->rcItem.bottom - lpdis->rcItem.top - | 192 lpdis->rcItem.top + (lpdis->rcItem.bottom - lpdis->rcItem.top - |
193 data->icon.height()) / 2, NULL); | 193 data->icon.height()) / 2, NULL); |
194 } | 194 } |
195 | 195 |
196 } else { | 196 } else { |
197 // Draw the separator | 197 // Draw the separator |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 break; | 565 break; |
566 | 566 |
567 default: | 567 default: |
568 NOTREACHED(); | 568 NOTREACHED(); |
569 return 0; | 569 return 0; |
570 } | 570 } |
571 return align_flags; | 571 return align_flags; |
572 } | 572 } |
573 | 573 |
574 } // namespace views | 574 } // namespace views |
OLD | NEW |