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/native_menu_win.h" | 5 #include "ui/views/controls/menu/native_menu_win.h" |
6 | 6 |
7 #include <Windowsx.h> | 7 #include <Windowsx.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 249 |
250 ui::MenuModel::ItemType type = | 250 ui::MenuModel::ItemType type = |
251 data->native_menu_win->model_->GetTypeAt(data->model_index); | 251 data->native_menu_win->model_->GetTypeAt(data->model_index); |
252 | 252 |
253 // Draw the icon after the label, otherwise it would be covered | 253 // Draw the icon after the label, otherwise it would be covered |
254 // by the label. | 254 // by the label. |
255 gfx::ImageSkia icon; | 255 gfx::ImageSkia icon; |
256 if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) { | 256 if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) { |
257 // We currently don't support items with both icons and checkboxes. | 257 // We currently don't support items with both icons and checkboxes. |
258 DCHECK(type != ui::MenuModel::TYPE_CHECK); | 258 DCHECK(type != ui::MenuModel::TYPE_CHECK); |
259 gfx::Canvas canvas(icon, false); | 259 gfx::Canvas canvas(icon.GetRepresentation(ui::SCALE_FACTOR_100P), |
| 260 false); |
260 skia::DrawToNativeContext( | 261 skia::DrawToNativeContext( |
261 canvas.sk_canvas(), dc, | 262 canvas.sk_canvas(), dc, |
262 draw_item_struct->rcItem.left + kItemLeftMargin, | 263 draw_item_struct->rcItem.left + kItemLeftMargin, |
263 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - | 264 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - |
264 draw_item_struct->rcItem.top - icon.height()) / 2, NULL); | 265 draw_item_struct->rcItem.top - icon.height()) / 2, NULL); |
265 } else if (type == ui::MenuModel::TYPE_CHECK && | 266 } else if (type == ui::MenuModel::TYPE_CHECK && |
266 data->native_menu_win->model_->IsItemCheckedAt( | 267 data->native_menu_win->model_->IsItemCheckedAt( |
267 data->model_index)) { | 268 data->model_index)) { |
268 // Manually render a checkbox. | 269 // Manually render a checkbox. |
269 const MenuConfig& config = MenuConfig::instance(); | 270 const MenuConfig& config = MenuConfig::instance(); |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 | 749 |
749 //////////////////////////////////////////////////////////////////////////////// | 750 //////////////////////////////////////////////////////////////////////////////// |
750 // MenuWrapper, public: | 751 // MenuWrapper, public: |
751 | 752 |
752 // static | 753 // static |
753 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { | 754 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { |
754 return new NativeMenuWin(model, NULL); | 755 return new NativeMenuWin(model, NULL); |
755 } | 756 } |
756 | 757 |
757 } // namespace views | 758 } // namespace views |
OLD | NEW |