OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/native_menu_win.h" | 5 #include "views/controls/menu/native_menu_win.h" |
6 | 6 |
7 #include <Windowsx.h> | 7 #include <Windowsx.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 243 |
244 // Draw the icon after the label, otherwise it would be covered | 244 // Draw the icon after the label, otherwise it would be covered |
245 // by the label. | 245 // by the label. |
246 SkBitmap icon; | 246 SkBitmap icon; |
247 if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) { | 247 if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) { |
248 // We currently don't support items with both icons and checkboxes. | 248 // We currently don't support items with both icons and checkboxes. |
249 DCHECK(type != ui::MenuModel::TYPE_CHECK); | 249 DCHECK(type != ui::MenuModel::TYPE_CHECK); |
250 gfx::CanvasSkia canvas(icon.width(), icon.height(), false); | 250 gfx::CanvasSkia canvas(icon.width(), icon.height(), false); |
251 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); | 251 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); |
252 canvas.DrawBitmapInt(icon, 0, 0); | 252 canvas.DrawBitmapInt(icon, 0, 0); |
253 canvas.getTopPlatformDevice().drawToHDC(dc, | 253 skia::DrawToNativeContext( |
254 draw_item_struct->rcItem.left + kItemLeftMargin, | 254 &canvas, dc, draw_item_struct->rcItem.left + kItemLeftMargin, |
255 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - | 255 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - |
256 draw_item_struct->rcItem.top - icon.height()) / 2, NULL); | 256 draw_item_struct->rcItem.top - icon.height()) / 2, NULL); |
257 } else if (type == ui::MenuModel::TYPE_CHECK && | 257 } else if (type == ui::MenuModel::TYPE_CHECK && |
258 data->native_menu_win->model_->IsItemCheckedAt( | 258 data->native_menu_win->model_->IsItemCheckedAt( |
259 data->model_index)) { | 259 data->model_index)) { |
260 // Manually render a checkbox. | 260 // Manually render a checkbox. |
261 const MenuConfig& config = MenuConfig::instance(); | 261 const MenuConfig& config = MenuConfig::instance(); |
262 NativeTheme::State state; | 262 NativeTheme::State state; |
263 if (draw_item_struct->itemState & ODS_DISABLED) { | 263 if (draw_item_struct->itemState & ODS_DISABLED) { |
264 state = NativeTheme::kDisabled; | 264 state = NativeTheme::kDisabled; |
(...skipping 11 matching lines...) Expand all Loading... |
276 extra.menu_check.is_radio = false; | 276 extra.menu_check.is_radio = false; |
277 gfx::Rect bounds(0, 0, config.check_width, config.check_height); | 277 gfx::Rect bounds(0, 0, config.check_width, config.check_height); |
278 | 278 |
279 // Draw the background and the check. | 279 // Draw the background and the check. |
280 NativeTheme::instance()->Paint( | 280 NativeTheme::instance()->Paint( |
281 &canvas, NativeTheme::kMenuCheckBackground, state, bounds, extra); | 281 &canvas, NativeTheme::kMenuCheckBackground, state, bounds, extra); |
282 NativeTheme::instance()->Paint( | 282 NativeTheme::instance()->Paint( |
283 &canvas, NativeTheme::kMenuCheck, state, bounds, extra); | 283 &canvas, NativeTheme::kMenuCheck, state, bounds, extra); |
284 | 284 |
285 // Draw checkbox to menu. | 285 // Draw checkbox to menu. |
286 canvas.getTopPlatformDevice().drawToHDC(dc, | 286 skia::DrawToNativeContext(&canvas, dc, |
287 draw_item_struct->rcItem.left + kItemLeftMargin, | 287 draw_item_struct->rcItem.left + kItemLeftMargin, |
288 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - | 288 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - |
289 draw_item_struct->rcItem.top - config.check_height) / 2, NULL); | 289 draw_item_struct->rcItem.top - config.check_height) / 2, NULL); |
290 } | 290 } |
291 | 291 |
292 } else { | 292 } else { |
293 // Draw the separator | 293 // Draw the separator |
294 draw_item_struct->rcItem.top += | 294 draw_item_struct->rcItem.top += |
295 (draw_item_struct->rcItem.bottom - draw_item_struct->rcItem.top) / 3; | 295 (draw_item_struct->rcItem.bottom - draw_item_struct->rcItem.top) / 3; |
296 DrawEdge(dc, &draw_item_struct->rcItem, EDGE_ETCHED, BF_TOP); | 296 DrawEdge(dc, &draw_item_struct->rcItem, EDGE_ETCHED, BF_TOP); |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 763 |
764 //////////////////////////////////////////////////////////////////////////////// | 764 //////////////////////////////////////////////////////////////////////////////// |
765 // MenuWrapper, public: | 765 // MenuWrapper, public: |
766 | 766 |
767 // static | 767 // static |
768 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { | 768 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { |
769 return new NativeMenuWin(menu->model(), NULL); | 769 return new NativeMenuWin(menu->model(), NULL); |
770 } | 770 } |
771 | 771 |
772 } // namespace views | 772 } // namespace views |
OLD | NEW |