Home | History | Annotate | Download | only in aura
      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 AURA_EXPORT WindowTreeHostWin : public WindowTreeHost,
     17                                       public ui::EventSource,
     18                                       public gfx::WindowImpl {
     19  public:
     20   explicit WindowTreeHostWin(const gfx::Rect& bounds);
     21   virtual ~WindowTreeHostWin();
     22   // WindowTreeHost:
     23   virtual ui::EventSource* GetEventSource() OVERRIDE;
     24   virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
     25   virtual void Show() OVERRIDE;
     26   virtual void Hide() OVERRIDE;
     27   virtual gfx::Rect GetBounds() const OVERRIDE;
     28   virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
     29   virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
     30   virtual void SetCapture() OVERRIDE;
     31   virtual void ReleaseCapture() OVERRIDE;
     32   virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
     33   virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE;
     34   virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE;
     35   virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
     36   virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
     37 
     38   // ui::EventSource:
     39   virtual ui::EventProcessor* GetEventProcessor() OVERRIDE;
     40 
     41  private:
     42   CR_BEGIN_MSG_MAP_EX(WindowTreeHostWin)
     43     // Range handlers must go first!
     44     CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
     45     CR_MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE,
     46                                 WM_NCXBUTTONDBLCLK,
     47                                 OnMouseRange)
     48 
     49     // Mouse capture events.
     50     CR_MESSAGE_HANDLER_EX(WM_CAPTURECHANGED, OnCaptureChanged)
     51 
     52     // Key events.
     53     CR_MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent)
     54     CR_MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent)
     55     CR_MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent)
     56     CR_MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent)
     57     CR_MESSAGE_HANDLER_EX(WM_CHAR, OnKeyEvent)
     58     CR_MESSAGE_HANDLER_EX(WM_SYSCHAR, OnKeyEvent)
     59     CR_MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent)
     60     CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate)
     61 
     62     CR_MSG_WM_CLOSE(OnClose)
     63     CR_MSG_WM_MOVE(OnMove)
     64     CR_MSG_WM_PAINT(OnPaint)
     65     CR_MSG_WM_SIZE(OnSize)
     66   CR_END_MSG_MAP()
     67 
     68   void OnClose();
     69   LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param);
     70   LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param);
     71   LRESULT OnCaptureChanged(UINT message, WPARAM w_param, LPARAM l_param);
     72   LRESULT OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param);
     73   void OnMove(const gfx::Point& point);
     74   void OnPaint(HDC dc);
     75   void OnSize(UINT param, const gfx::Size& size);
     76 
     77   bool has_capture_;
     78 
     79   DISALLOW_COPY_AND_ASSIGN(WindowTreeHostWin);
     80 };
     81 
     82 namespace test {
     83 
     84 // Set true to let WindowTreeHostWin use a popup window
     85 // with no frame/title so that the window size and test's
     86 // expectations matches.
     87 AURA_EXPORT void SetUsePopupAsRootWindowForTest(bool use);
     88 
     89 }  // namespace
     90 
     91 }  // namespace aura
     92 
     93 #endif  // UI_AURA_WINDOW_TREE_HOST_WIN_H_
     94