- add sources.
[platform/framework/web/crosswalk.git] / src / ui / views / widget / child_window_message_processor.h
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_WIDGET_CHILD_WINDOW_MESSAGE_PROCESSOR_H_
6 #define UI_VIEWS_WIDGET_CHILD_WINDOW_MESSAGE_PROCESSOR_H_
7
8 #include <windows.h>
9
10 namespace ui {
11 class ViewProp;
12 }
13
14 namespace views {
15
16 // Windows sends a handful of messages to the parent window rather than the
17 // window itself. For example, selection changes of a rich edit (EN_SELCHANGE)
18 // are sent to the parent, not the window. Typically such message are best
19 // dealt with by the window rather than the parent. NativeWidgetWin allows for
20 // registering a ChildWindowMessageProcessor to handle such messages.
21 class ChildWindowMessageProcessor {
22  public:
23   // Registers |processor| for |hwnd|. The caller takes ownership of the
24   // returned object.
25   static ui::ViewProp* Register(HWND hwnd,
26                                  ChildWindowMessageProcessor* processor);
27
28   // Returns the ChildWindowMessageProcessor for |hwnd|, NULL if there isn't
29   // one.
30   static ChildWindowMessageProcessor* Get(HWND hwnd);
31
32   // Invoked for any messages that are sent to the parent and originated from
33   // the HWND this ChildWindowMessageProcessor was registered for. Returns true
34   // if the message was handled with a valid result in |result|. Returns false
35   // if the message was not handled.
36   virtual bool ProcessMessage(UINT message,
37                               WPARAM w_param,
38                               LPARAM l_param,
39                               LRESULT* result) = 0;
40
41  protected:
42   virtual ~ChildWindowMessageProcessor() {}
43 };
44
45 }  // namespace views
46
47 #endif  // UI_VIEWS_WIDGET_CHILD_WINDOW_MESSAGE_PROCESSOR_H_