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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 // Manually render a checkbox. | 275 // Manually render a checkbox. |
276 ui::NativeThemeWin* native_theme = ui::NativeThemeWin::instance(); | 276 ui::NativeThemeWin* native_theme = ui::NativeThemeWin::instance(); |
277 const MenuConfig& config = MenuConfig::instance(native_theme); | 277 const MenuConfig& config = MenuConfig::instance(native_theme); |
278 NativeTheme::State state; | 278 NativeTheme::State state; |
279 if (draw_item_struct->itemState & ODS_DISABLED) { | 279 if (draw_item_struct->itemState & ODS_DISABLED) { |
280 state = NativeTheme::kDisabled; | 280 state = NativeTheme::kDisabled; |
281 } else { | 281 } else { |
282 state = draw_item_struct->itemState & ODS_SELECTED ? | 282 state = draw_item_struct->itemState & ODS_SELECTED ? |
283 NativeTheme::kHovered : NativeTheme::kNormal; | 283 NativeTheme::kHovered : NativeTheme::kNormal; |
284 } | 284 } |
285 int height = | |
286 draw_item_struct->rcItem.bottom - draw_item_struct->rcItem.top; | |
287 int icon_y = kItemTopMargin + | |
288 (height - kItemTopMargin - kItemBottomMargin - | |
289 config.check_height) / 2; | |
Peter Kasting
2014/11/18 00:41:03
The DrawToNativeContext() call below does some cal
| |
290 gfx::Canvas canvas(gfx::Size(config.check_width, config.check_height), | 285 gfx::Canvas canvas(gfx::Size(config.check_width, config.check_height), |
291 1.0f, | 286 1.0f, |
292 false); | 287 false); |
293 NativeTheme::ExtraParams extra; | 288 NativeTheme::ExtraParams extra; |
294 extra.menu_check.is_radio = false; | 289 extra.menu_check.is_radio = false; |
295 gfx::Rect bounds(0, 0, config.check_width, config.check_height); | 290 gfx::Rect bounds(0, 0, config.check_width, config.check_height); |
296 | 291 |
297 // Draw the background and the check. | 292 // Draw the background and the check. |
298 native_theme->Paint( | 293 native_theme->Paint( |
299 canvas.sk_canvas(), NativeTheme::kMenuCheckBackground, | 294 canvas.sk_canvas(), NativeTheme::kMenuCheckBackground, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 open_native_menu_win_ = this; | 424 open_native_menu_win_ = this; |
430 HHOOK hhook = SetWindowsHookEx(WH_MSGFILTER, MenuMessageHook, | 425 HHOOK hhook = SetWindowsHookEx(WH_MSGFILTER, MenuMessageHook, |
431 GetModuleHandle(NULL), ::GetCurrentThreadId()); | 426 GetModuleHandle(NULL), ::GetCurrentThreadId()); |
432 | 427 |
433 // Mark that any registered listeners have not been called for this particular | 428 // Mark that any registered listeners have not been called for this particular |
434 // opening of the menu. | 429 // opening of the menu. |
435 listeners_called_ = false; | 430 listeners_called_ = false; |
436 | 431 |
437 // Command dispatch is done through WM_MENUCOMMAND, handled by the host | 432 // Command dispatch is done through WM_MENUCOMMAND, handled by the host |
438 // window. | 433 // window. |
439 HWND hwnd = host_window_->hwnd(); | |
440 menu_to_select_ = NULL; | 434 menu_to_select_ = NULL; |
441 position_to_select_ = -1; | 435 position_to_select_ = -1; |
442 menu_to_select_factory_.InvalidateWeakPtrs(); | 436 menu_to_select_factory_.InvalidateWeakPtrs(); |
443 bool destroyed = false; | 437 bool destroyed = false; |
444 destroyed_flag_ = &destroyed; | 438 destroyed_flag_ = &destroyed; |
445 model_->MenuWillShow(); | 439 model_->MenuWillShow(); |
446 TrackPopupMenu(menu_, flags, point.x(), point.y(), 0, host_window_->hwnd(), | 440 TrackPopupMenu(menu_, flags, point.x(), point.y(), 0, host_window_->hwnd(), |
447 NULL); | 441 NULL); |
448 UnhookWindowsHookEx(hhook); | 442 UnhookWindowsHookEx(hhook); |
449 open_native_menu_win_ = NULL; | 443 open_native_menu_win_ = NULL; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 | 751 |
758 //////////////////////////////////////////////////////////////////////////////// | 752 //////////////////////////////////////////////////////////////////////////////// |
759 // MenuWrapper, public: | 753 // MenuWrapper, public: |
760 | 754 |
761 // static | 755 // static |
762 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { | 756 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { |
763 return new NativeMenuWin(model, NULL); | 757 return new NativeMenuWin(model, NULL); |
764 } | 758 } |
765 | 759 |
766 } // namespace views | 760 } // namespace views |
OLD | NEW |