| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/keyboard_codes.h" | 7 #include "app/keyboard_codes.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/l10n_util_win.h" | 9 #include "app/l10n_util_win.h" |
| 10 #include "app/win/hwnd_util.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
| 12 #include "base/win_util.h" | |
| 13 #include "gfx/canvas_skia.h" | 13 #include "gfx/canvas_skia.h" |
| 14 #include "gfx/font.h" | 14 #include "gfx/font.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "views/accelerator.h" | 16 #include "views/accelerator.h" |
| 17 #include "views/controls/menu/menu_2.h" | 17 #include "views/controls/menu/menu_2.h" |
| 18 | 18 |
| 19 namespace views { | 19 namespace views { |
| 20 | 20 |
| 21 // The width of an icon, including the pixels between the icon and | 21 // The width of an icon, including the pixels between the icon and |
| 22 // the item label. | 22 // the item label. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // A window that receives messages from Windows relevant to the native menu | 51 // A window that receives messages from Windows relevant to the native menu |
| 52 // structure we have constructed in NativeMenuWin. | 52 // structure we have constructed in NativeMenuWin. |
| 53 class NativeMenuWin::MenuHostWindow { | 53 class NativeMenuWin::MenuHostWindow { |
| 54 public: | 54 public: |
| 55 MenuHostWindow() { | 55 MenuHostWindow() { |
| 56 RegisterClass(); | 56 RegisterClass(); |
| 57 hwnd_ = CreateWindowEx(l10n_util::GetExtendedStyles(), kWindowClassName, | 57 hwnd_ = CreateWindowEx(l10n_util::GetExtendedStyles(), kWindowClassName, |
| 58 L"", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); | 58 L"", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); |
| 59 win_util::SetWindowUserData(hwnd_, this); | 59 app::win::SetWindowUserData(hwnd_, this); |
| 60 } | 60 } |
| 61 | 61 |
| 62 ~MenuHostWindow() { | 62 ~MenuHostWindow() { |
| 63 DestroyWindow(hwnd_); | 63 DestroyWindow(hwnd_); |
| 64 } | 64 } |
| 65 | 65 |
| 66 HWND hwnd() const { return hwnd_; } | 66 HWND hwnd() const { return hwnd_; } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 static const wchar_t* kWindowClassName; | 69 static const wchar_t* kWindowClassName; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // TODO(beng): bring over owner draw from old menu system. | 268 // TODO(beng): bring over owner draw from old menu system. |
| 269 } | 269 } |
| 270 return false; | 270 return false; |
| 271 } | 271 } |
| 272 | 272 |
| 273 static LRESULT CALLBACK MenuHostWindowProc(HWND window, | 273 static LRESULT CALLBACK MenuHostWindowProc(HWND window, |
| 274 UINT message, | 274 UINT message, |
| 275 WPARAM w_param, | 275 WPARAM w_param, |
| 276 LPARAM l_param) { | 276 LPARAM l_param) { |
| 277 MenuHostWindow* host = | 277 MenuHostWindow* host = |
| 278 reinterpret_cast<MenuHostWindow*>(win_util::GetWindowUserData(window)); | 278 reinterpret_cast<MenuHostWindow*>(app::win::GetWindowUserData(window)); |
| 279 // host is null during initial construction. | 279 // host is null during initial construction. |
| 280 LRESULT l_result = 0; | 280 LRESULT l_result = 0; |
| 281 if (!host || !host->ProcessWindowMessage(window, message, w_param, l_param, | 281 if (!host || !host->ProcessWindowMessage(window, message, w_param, l_param, |
| 282 &l_result)) { | 282 &l_result)) { |
| 283 return DefWindowProc(window, message, w_param, l_param); | 283 return DefWindowProc(window, message, w_param, l_param); |
| 284 } | 284 } |
| 285 return l_result; | 285 return l_result; |
| 286 } | 286 } |
| 287 | 287 |
| 288 HWND hwnd_; | 288 HWND hwnd_; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 626 |
| 627 //////////////////////////////////////////////////////////////////////////////// | 627 //////////////////////////////////////////////////////////////////////////////// |
| 628 // MenuWrapper, public: | 628 // MenuWrapper, public: |
| 629 | 629 |
| 630 // static | 630 // static |
| 631 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { | 631 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { |
| 632 return new NativeMenuWin(menu->model(), NULL); | 632 return new NativeMenuWin(menu->model(), NULL); |
| 633 } | 633 } |
| 634 | 634 |
| 635 } // namespace views | 635 } // namespace views |
| OLD | NEW |