| OLD | NEW |
| 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 "views/controls/menu/menu_win.h" | 5 #include "views/controls/menu/menu_win.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
| 11 #include "app/win/window_impl.h" | 11 #include "app/win/window_impl.h" |
| 12 #include "base/keyboard_codes.h" | 12 #include "base/keyboard_codes.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/stl_util-inl.h" | 14 #include "base/stl_util-inl.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "gfx/canvas.h" | 16 #include "gfx/canvas_skia.h" |
| 17 #include "gfx/font.h" | 17 #include "gfx/font.h" |
| 18 #include "gfx/rect.h" | 18 #include "gfx/rect.h" |
| 19 #include "views/accelerator.h" | 19 #include "views/accelerator.h" |
| 20 | 20 |
| 21 namespace views { | 21 namespace views { |
| 22 | 22 |
| 23 // The width of an icon, including the pixels between the icon and | 23 // The width of an icon, including the pixels between the icon and |
| 24 // the item label. | 24 // the item label. |
| 25 static const int kIconWidth = 23; | 25 static const int kIconWidth = 23; |
| 26 // Margins between the top of the item and the label. | 26 // Margins between the top of the item and the label. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 static_cast<int>(label.size()), &rect, format | DT_LEFT, NULL); | 177 static_cast<int>(label.size()), &rect, format | DT_LEFT, NULL); |
| 178 if (!accel.empty()) | 178 if (!accel.empty()) |
| 179 DrawTextEx(hDC, const_cast<wchar_t*>(accel.data()), | 179 DrawTextEx(hDC, const_cast<wchar_t*>(accel.data()), |
| 180 static_cast<int>(accel.size()), &rect, | 180 static_cast<int>(accel.size()), &rect, |
| 181 format | DT_RIGHT, NULL); | 181 format | DT_RIGHT, NULL); |
| 182 SelectObject(hDC, old_font); | 182 SelectObject(hDC, old_font); |
| 183 | 183 |
| 184 // Draw the icon after the label, otherwise it would be covered | 184 // Draw the icon after the label, otherwise it would be covered |
| 185 // by the label. | 185 // by the label. |
| 186 if (data->icon.width() != 0 && data->icon.height() != 0) { | 186 if (data->icon.width() != 0 && data->icon.height() != 0) { |
| 187 gfx::Canvas canvas(data->icon.width(), data->icon.height(), false); | 187 gfx::CanvasSkia canvas(data->icon.width(), data->icon.height(), false); |
| 188 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); | 188 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); |
| 189 canvas.DrawBitmapInt(data->icon, 0, 0); | 189 canvas.DrawBitmapInt(data->icon, 0, 0); |
| 190 canvas.getTopPlatformDevice().drawToHDC(hDC, lpdis->rcItem.left + | 190 canvas.getTopPlatformDevice().drawToHDC(hDC, lpdis->rcItem.left + |
| 191 kItemLeftMargin, lpdis->rcItem.top + (lpdis->rcItem.bottom - | 191 kItemLeftMargin, lpdis->rcItem.top + (lpdis->rcItem.bottom - |
| 192 lpdis->rcItem.top - data->icon.height()) / 2, NULL); | 192 lpdis->rcItem.top - data->icon.height()) / 2, NULL); |
| 193 } | 193 } |
| 194 | 194 |
| 195 } else { | 195 } else { |
| 196 // Draw the separator | 196 // Draw the separator |
| 197 lpdis->rcItem.top += (lpdis->rcItem.bottom - lpdis->rcItem.top) / 3; | 197 lpdis->rcItem.top += (lpdis->rcItem.bottom - lpdis->rcItem.top) / 3; |
| (...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 |