Chromium Code Reviews| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 HWND hwnd() const { return hwnd_; } | 89 HWND hwnd() const { return hwnd_; } |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 static const wchar_t* kWindowClassName; | 92 static const wchar_t* kWindowClassName; |
| 93 | 93 |
| 94 void RegisterClass() { | 94 void RegisterClass() { |
| 95 static bool registered = false; | 95 static bool registered = false; |
| 96 if (registered) | 96 if (registered) |
| 97 return; | 97 return; |
| 98 | 98 |
| 99 WNDCLASSEX wcex = {0}; | 99 WNDCLASSEX window_class; |
| 100 wcex.cbSize = sizeof(WNDCLASSEX); | 100 base::win::InitializeWindowClass( |
| 101 wcex.style = CS_DBLCLKS; | 101 kWindowClassName, |
| 102 wcex.lpfnWndProc = base::win::WrappedWindowProc<&MenuHostWindowProc>; | 102 &base::win::WrappedWindowProc<MenuHostWindowProc>, |
| 103 wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1); | 103 CS_DBLCLKS, |
| 104 wcex.lpszClassName = kWindowClassName; | 104 0, |
| 105 ATOM clazz = RegisterClassEx(&wcex); | 105 0, |
| 106 NULL, | |
| 107 reinterpret_cast<HBRUSH>(COLOR_WINDOW+1), | |
| 108 NULL, | |
| 109 NULL, | |
| 110 NULL, | |
| 111 &window_class); | |
| 112 ATOM clazz = RegisterClassEx(&window_class); | |
| 106 DCHECK(clazz); | 113 DCHECK(clazz); |
|
sky
2012/05/09 04:09:25
Make this a CHECK, otherwise we're going to fail.
alexeypa (please no reviews)
2012/05/09 16:56:52
Done.
| |
| 107 registered = true; | 114 registered = true; |
| 108 } | 115 } |
| 109 | 116 |
| 110 // Converts the WPARAM value passed to WM_MENUSELECT into an index | 117 // Converts the WPARAM value passed to WM_MENUSELECT into an index |
| 111 // corresponding to the menu item that was selected. | 118 // corresponding to the menu item that was selected. |
| 112 int GetMenuItemIndexFromWPARAM(HMENU menu, WPARAM w_param) const { | 119 int GetMenuItemIndexFromWPARAM(HMENU menu, WPARAM w_param) const { |
| 113 int count = GetMenuItemCount(menu); | 120 int count = GetMenuItemCount(menu); |
| 114 // For normal command menu items, Windows passes a command id as the LOWORD | 121 // For normal command menu items, Windows passes a command id as the LOWORD |
| 115 // of WPARAM for WM_MENUSELECT. We need to walk forward through the menu | 122 // of WPARAM for WM_MENUSELECT. We need to walk forward through the menu |
| 116 // items to find an item with a matching ID. Ugh! | 123 // items to find an item with a matching ID. Ugh! |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 | 748 |
| 742 //////////////////////////////////////////////////////////////////////////////// | 749 //////////////////////////////////////////////////////////////////////////////// |
| 743 // MenuWrapper, public: | 750 // MenuWrapper, public: |
| 744 | 751 |
| 745 // static | 752 // static |
| 746 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { | 753 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { |
| 747 return new NativeMenuWin(model, NULL); | 754 return new NativeMenuWin(model, NULL); |
| 748 } | 755 } |
| 749 | 756 |
| 750 } // namespace views | 757 } // namespace views |
| OLD | NEW |