1d2f2560dc24f8bd5785891b259151fadec51955
[platform/framework/web/crosswalk.git] / src / ui / aura / window_tree_host_win.h
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
3 // found in the LICENSE file.
4
5 #ifndef UI_AURA_WINDOW_TREE_HOST_WIN_H_
6 #define UI_AURA_WINDOW_TREE_HOST_WIN_H_
7
8 #include "base/compiler_specific.h"
9 #include "ui/aura/aura_export.h"
10 #include "ui/aura/window_tree_host.h"
11 #include "ui/events/event_source.h"
12 #include "ui/gfx/win/window_impl.h"
13
14 namespace aura {
15
16 class WindowTreeHostWin : public WindowTreeHost,
17                           public ui::EventSource,
18                           public gfx::WindowImpl {
19  public:
20   WindowTreeHostWin(const gfx::Rect& bounds);
21   virtual ~WindowTreeHostWin();
22   // WindowTreeHost:
23   virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
24   virtual void Show() OVERRIDE;
25   virtual void Hide() OVERRIDE;
26   virtual void ToggleFullScreen() OVERRIDE;
27   virtual gfx::Rect GetBounds() const OVERRIDE;
28   virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
29   virtual gfx::Insets GetInsets() const OVERRIDE;
30   virtual void SetInsets(const gfx::Insets& insets) OVERRIDE;
31   virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
32   virtual void SetCapture() OVERRIDE;
33   virtual void ReleaseCapture() OVERRIDE;
34   virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
35   virtual bool ConfineCursorToRootWindow() OVERRIDE;
36   virtual void UnConfineCursor() OVERRIDE;
37   virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
38   virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE;
39   virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE;
40   virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
41   virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
42
43   // ui::EventSource:
44   virtual ui::EventProcessor* GetEventProcessor() OVERRIDE;
45
46  private:
47   CR_BEGIN_MSG_MAP_EX(WindowTreeHostWin)
48     // Range handlers must go first!
49     CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
50     CR_MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE,
51                                 WM_NCXBUTTONDBLCLK,
52                                 OnMouseRange)
53
54     // Mouse capture events.
55     CR_MESSAGE_HANDLER_EX(WM_CAPTURECHANGED, OnCaptureChanged)
56
57     // Key events.
58     CR_MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent)
59     CR_MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent)
60     CR_MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent)
61     CR_MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent)
62     CR_MESSAGE_HANDLER_EX(WM_CHAR, OnKeyEvent)
63     CR_MESSAGE_HANDLER_EX(WM_SYSCHAR, OnKeyEvent)
64     CR_MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent)
65     CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate)
66
67     CR_MSG_WM_CLOSE(OnClose)
68     CR_MSG_WM_MOVE(OnMove)
69     CR_MSG_WM_PAINT(OnPaint)
70     CR_MSG_WM_SIZE(OnSize)
71   CR_END_MSG_MAP()
72
73   void OnClose();
74   LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param);
75   LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param);
76   LRESULT OnCaptureChanged(UINT message, WPARAM w_param, LPARAM l_param);
77   LRESULT OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param);
78   void OnMove(const gfx::Point& point);
79   void OnPaint(HDC dc);
80   void OnSize(UINT param, const gfx::Size& size);
81
82   bool fullscreen_;
83   bool has_capture_;
84   RECT saved_window_rect_;
85   DWORD saved_window_style_;
86   DWORD saved_window_ex_style_;
87
88   DISALLOW_COPY_AND_ASSIGN(WindowTreeHostWin);
89 };
90
91 namespace test {
92
93 // Set true to let WindowTreeHostWin use a popup window
94 // with no frame/title so that the window size and test's
95 // expectations matches.
96 AURA_EXPORT void SetUsePopupAsRootWindowForTest(bool use);
97
98 }  // namespace
99
100 }  // namespace aura
101
102 #endif  // UI_AURA_WINDOW_TREE_HOST_WIN_H_