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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 false); | 264 false); |
265 skia::DrawToNativeContext( | 265 skia::DrawToNativeContext( |
266 canvas.sk_canvas(), dc, | 266 canvas.sk_canvas(), dc, |
267 draw_item_struct->rcItem.left + kItemLeftMargin, | 267 draw_item_struct->rcItem.left + kItemLeftMargin, |
268 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - | 268 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - |
269 draw_item_struct->rcItem.top - skia_icon->height()) / 2, NULL); | 269 draw_item_struct->rcItem.top - skia_icon->height()) / 2, NULL); |
270 } else if (type == ui::MenuModel::TYPE_CHECK && | 270 } else if (type == ui::MenuModel::TYPE_CHECK && |
271 data->native_menu_win->model_->IsItemCheckedAt( | 271 data->native_menu_win->model_->IsItemCheckedAt( |
272 data->model_index)) { | 272 data->model_index)) { |
273 // Manually render a checkbox. | 273 // Manually render a checkbox. |
274 ui::NativeThemeWin* native_theme = ui::NativeThemeWin::instance(); | 274 const MenuConfig& config = MenuConfig::instance(); |
275 const MenuConfig& config = MenuConfig::instance(native_theme); | |
276 NativeTheme::State state; | 275 NativeTheme::State state; |
277 if (draw_item_struct->itemState & ODS_DISABLED) { | 276 if (draw_item_struct->itemState & ODS_DISABLED) { |
278 state = NativeTheme::kDisabled; | 277 state = NativeTheme::kDisabled; |
279 } else { | 278 } else { |
280 state = draw_item_struct->itemState & ODS_SELECTED ? | 279 state = draw_item_struct->itemState & ODS_SELECTED ? |
281 NativeTheme::kHovered : NativeTheme::kNormal; | 280 NativeTheme::kHovered : NativeTheme::kNormal; |
282 } | 281 } |
283 gfx::Canvas canvas(gfx::Size(config.check_width, config.check_height), | 282 gfx::Canvas canvas(gfx::Size(config.check_width, config.check_height), |
284 1.0f, | 283 1.0f, |
285 false); | 284 false); |
286 NativeTheme::ExtraParams extra; | 285 NativeTheme::ExtraParams extra; |
287 extra.menu_check.is_radio = false; | 286 extra.menu_check.is_radio = false; |
288 gfx::Rect bounds(0, 0, config.check_width, config.check_height); | 287 gfx::Rect bounds(0, 0, config.check_width, config.check_height); |
289 | 288 |
290 // Draw the background and the check. | 289 // Draw the background and the check. |
| 290 ui::NativeThemeWin* native_theme = ui::NativeThemeWin::instance(); |
291 native_theme->Paint( | 291 native_theme->Paint( |
292 canvas.sk_canvas(), NativeTheme::kMenuCheckBackground, | 292 canvas.sk_canvas(), NativeTheme::kMenuCheckBackground, |
293 state, bounds, extra); | 293 state, bounds, extra); |
294 native_theme->Paint( | 294 native_theme->Paint( |
295 canvas.sk_canvas(), NativeTheme::kMenuCheck, state, bounds, extra); | 295 canvas.sk_canvas(), NativeTheme::kMenuCheck, state, bounds, extra); |
296 | 296 |
297 // Draw checkbox to menu. | 297 // Draw checkbox to menu. |
298 skia::DrawToNativeContext(canvas.sk_canvas(), dc, | 298 skia::DrawToNativeContext(canvas.sk_canvas(), dc, |
299 draw_item_struct->rcItem.left + kItemLeftMargin, | 299 draw_item_struct->rcItem.left + kItemLeftMargin, |
300 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - | 300 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 | 749 |
750 //////////////////////////////////////////////////////////////////////////////// | 750 //////////////////////////////////////////////////////////////////////////////// |
751 // MenuWrapper, public: | 751 // MenuWrapper, public: |
752 | 752 |
753 // static | 753 // static |
754 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { | 754 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { |
755 return new NativeMenuWin(model, NULL); | 755 return new NativeMenuWin(model, NULL); |
756 } | 756 } |
757 | 757 |
758 } // namespace views | 758 } // namespace views |
OLD | NEW |