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 #ifndef VIEWS_WIDGET_CHILD_WINDOW_MESSAGE_PROCESSOR_H_ | 5 #ifndef VIEWS_WIDGET_CHILD_WINDOW_MESSAGE_PROCESSOR_H_ |
6 #define VIEWS_WIDGET_CHILD_WINDOW_MESSAGE_PROCESSOR_H_ | 6 #define VIEWS_WIDGET_CHILD_WINDOW_MESSAGE_PROCESSOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
11 namespace app { | 11 namespace app { |
12 class ViewProp; | 12 namespace win { |
| 13 class ScopedProp; |
| 14 } |
13 } | 15 } |
14 | 16 |
15 namespace views { | 17 namespace views { |
16 | 18 |
17 // Windows sends a handful of messages to the parent window rather than the | 19 // Windows sends a handful of messages to the parent window rather than the |
18 // window itself. For example, selection changes of a rich edit (EN_SELCHANGE) | 20 // window itself. For example, selection changes of a rich edit (EN_SELCHANGE) |
19 // are sent to the parent, not the window. Typically such message are best | 21 // are sent to the parent, not the window. Typically such message are best |
20 // dealt with by the window rather than the parent. WidgetWin allows for | 22 // dealt with by the window rather than the parent. WidgetWin allows for |
21 // registering a ChildWindowMessageProcessor to handle such messages. | 23 // registering a ChildWindowMessageProcessor to handle such messages. |
22 class ChildWindowMessageProcessor { | 24 class ChildWindowMessageProcessor { |
23 public: | 25 public: |
24 // Registers |processor| for |hwnd|. The caller takes ownership of the | 26 // Registers |processor| for |hwnd|. The caller takes ownership of the |
25 // returned object. | 27 // returned object. |
26 static app::ViewProp* Register(HWND hwnd, | 28 static app::win::ScopedProp* Register(HWND hwnd, |
27 ChildWindowMessageProcessor* processor); | 29 ChildWindowMessageProcessor* processor); |
28 | 30 |
29 // Returns the ChildWindowMessageProcessor for |hwnd|, NULL if there isn't | 31 // Returns the ChildWindowMessageProcessor for |hwnd|, NULL if there isn't |
30 // one. | 32 // one. |
31 static ChildWindowMessageProcessor* Get(HWND hwnd); | 33 static ChildWindowMessageProcessor* Get(HWND hwnd); |
32 | 34 |
33 // Invoked for any messages that are sent to the parent and originated from | 35 // Invoked for any messages that are sent to the parent and originated from |
34 // the HWND this ChildWindowMessageProcessor was registered for. Returns true | 36 // the HWND this ChildWindowMessageProcessor was registered for. Returns true |
35 // if the message was handled with a valid result in |result|. Returns false | 37 // if the message was handled with a valid result in |result|. Returns false |
36 // if the message was not handled. | 38 // if the message was not handled. |
37 virtual bool ProcessMessage(UINT message, | 39 virtual bool ProcessMessage(UINT message, |
38 WPARAM w_param, | 40 WPARAM w_param, |
39 LPARAM l_param, | 41 LPARAM l_param, |
40 LRESULT* result) = 0; | 42 LRESULT* result) = 0; |
41 | 43 |
42 protected: | 44 protected: |
43 virtual ~ChildWindowMessageProcessor() {} | 45 virtual ~ChildWindowMessageProcessor() {} |
44 }; | 46 }; |
45 | 47 |
46 } // namespace views | 48 } // namespace views |
47 | 49 |
48 #endif // VIEWS_WIDGET_CHILD_WINDOW_MESSAGE_PROCESSOR_H_ | 50 #endif // VIEWS_WIDGET_CHILD_WINDOW_MESSAGE_PROCESSOR_H_ |
OLD | NEW |