| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 5 #ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ |
| 6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ |
| 7 | 7 |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlapp.h> | 9 #include <atlapp.h> |
| 10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
| 11 #include <atlmisc.h> | 11 #include <atlmisc.h> |
| 12 | 12 |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/message_loop.h" | |
| 22 #include "base/win/scoped_comptr.h" | 21 #include "base/win/scoped_comptr.h" |
| 23 #include "base/win/win_util.h" | 22 #include "base/win/win_util.h" |
| 24 #include "ui/base/win/window_impl.h" | 23 #include "ui/base/win/window_impl.h" |
| 25 #include "ui/views/focus/focus_manager.h" | 24 #include "ui/views/focus/focus_manager.h" |
| 26 #include "ui/views/layout/layout_manager.h" | 25 #include "ui/views/layout/layout_manager.h" |
| 27 #include "ui/views/widget/native_widget_private.h" | 26 #include "ui/views/widget/native_widget_private.h" |
| 28 #include "ui/views/win/hwnd_message_handler_delegate.h" | 27 #include "ui/views/win/hwnd_message_handler_delegate.h" |
| 29 | 28 |
| 30 namespace ui { | 29 namespace ui { |
| 31 class Compositor; | 30 class Compositor; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // contained within an HWND, e.g. a control, a window, etc. Specializations | 63 // contained within an HWND, e.g. a control, a window, etc. Specializations |
| 65 // suitable for specific tasks, e.g. top level window, are derived from this. | 64 // suitable for specific tasks, e.g. top level window, are derived from this. |
| 66 // | 65 // |
| 67 // This Widget contains a RootView which owns the hierarchy of views within it. | 66 // This Widget contains a RootView which owns the hierarchy of views within it. |
| 68 // As long as views are part of this tree, they will be deleted automatically | 67 // As long as views are part of this tree, they will be deleted automatically |
| 69 // when the RootView is destroyed. If you remove a view from the tree, you are | 68 // when the RootView is destroyed. If you remove a view from the tree, you are |
| 70 // then responsible for cleaning up after it. | 69 // then responsible for cleaning up after it. |
| 71 // | 70 // |
| 72 /////////////////////////////////////////////////////////////////////////////// | 71 /////////////////////////////////////////////////////////////////////////////// |
| 73 class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, | 72 class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, |
| 74 public MessageLoopForUI::Observer, | |
| 75 public internal::NativeWidgetPrivate, | 73 public internal::NativeWidgetPrivate, |
| 76 public HWNDMessageHandlerDelegate { | 74 public HWNDMessageHandlerDelegate { |
| 77 public: | 75 public: |
| 78 explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate); | 76 explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate); |
| 79 virtual ~NativeWidgetWin(); | 77 virtual ~NativeWidgetWin(); |
| 80 | 78 |
| 81 // Returns the system set window title font. | 79 // Returns the system set window title font. |
| 82 static gfx::Font GetWindowTitleFont(); | 80 static gfx::Font GetWindowTitleFont(); |
| 83 | 81 |
| 84 // Show the window with the specified show command. | 82 // Show the window with the specified show command. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 102 | 100 |
| 103 // Places the window in a pseudo-fullscreen mode where it looks and acts as | 101 // Places the window in a pseudo-fullscreen mode where it looks and acts as |
| 104 // like a fullscreen window except that it remains within the boundaries | 102 // like a fullscreen window except that it remains within the boundaries |
| 105 // of the metro snap divider. | 103 // of the metro snap divider. |
| 106 void SetMetroSnapFullscreen(bool metro_snap); | 104 void SetMetroSnapFullscreen(bool metro_snap); |
| 107 | 105 |
| 108 bool IsInMetroSnapMode() const; | 106 bool IsInMetroSnapMode() const; |
| 109 | 107 |
| 110 void SetCanUpdateLayeredWindow(bool can_update); | 108 void SetCanUpdateLayeredWindow(bool can_update); |
| 111 | 109 |
| 112 BOOL IsWindow() const { | |
| 113 return ::IsWindow(GetNativeView()); | |
| 114 } | |
| 115 | |
| 116 BOOL ShowWindow(int command) { | |
| 117 DCHECK(::IsWindow(GetNativeView())); | |
| 118 return ::ShowWindow(GetNativeView(), command); | |
| 119 } | |
| 120 | |
| 121 HWND GetParent() const { | |
| 122 return ::GetParent(GetNativeView()); | |
| 123 } | |
| 124 | |
| 125 LONG GetWindowLong(int index) { | |
| 126 DCHECK(::IsWindow(GetNativeView())); | |
| 127 return ::GetWindowLong(GetNativeView(), index); | |
| 128 } | |
| 129 | |
| 130 BOOL GetWindowRect(RECT* rect) const { | |
| 131 return ::GetWindowRect(GetNativeView(), rect); | |
| 132 } | |
| 133 | |
| 134 LONG SetWindowLong(int index, LONG new_long) { | |
| 135 DCHECK(::IsWindow(GetNativeView())); | |
| 136 return ::SetWindowLong(GetNativeView(), index, new_long); | |
| 137 } | |
| 138 | |
| 139 BOOL SetWindowPos(HWND hwnd_after, int x, int y, int cx, int cy, UINT flags) { | |
| 140 DCHECK(::IsWindow(GetNativeView())); | |
| 141 return ::SetWindowPos(GetNativeView(), hwnd_after, x, y, cx, cy, flags); | |
| 142 } | |
| 143 | |
| 144 BOOL IsZoomed() const { | |
| 145 DCHECK(::IsWindow(GetNativeView())); | |
| 146 return ::IsZoomed(GetNativeView()); | |
| 147 } | |
| 148 | |
| 149 BOOL MoveWindow(int x, int y, int width, int height) { | |
| 150 return MoveWindow(x, y, width, height, TRUE); | |
| 151 } | |
| 152 | |
| 153 BOOL MoveWindow(int x, int y, int width, int height, BOOL repaint) { | |
| 154 DCHECK(::IsWindow(GetNativeView())); | |
| 155 return ::MoveWindow(GetNativeView(), x, y, width, height, repaint); | |
| 156 } | |
| 157 | |
| 158 int SetWindowRgn(HRGN region, BOOL redraw) { | |
| 159 DCHECK(::IsWindow(GetNativeView())); | |
| 160 return ::SetWindowRgn(GetNativeView(), region, redraw); | |
| 161 } | |
| 162 | |
| 163 BOOL GetClientRect(RECT* rect) const { | |
| 164 DCHECK(::IsWindow(GetNativeView())); | |
| 165 return ::GetClientRect(GetNativeView(), rect); | |
| 166 } | |
| 167 | |
| 168 // Overridden from internal::NativeWidgetPrivate: | 110 // Overridden from internal::NativeWidgetPrivate: |
| 169 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; | 111 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; |
| 170 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | 112 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; |
| 171 virtual void UpdateFrameAfterFrameChange() OVERRIDE; | 113 virtual void UpdateFrameAfterFrameChange() OVERRIDE; |
| 172 virtual bool ShouldUseNativeFrame() const OVERRIDE; | 114 virtual bool ShouldUseNativeFrame() const OVERRIDE; |
| 173 virtual void FrameTypeChanged() OVERRIDE; | 115 virtual void FrameTypeChanged() OVERRIDE; |
| 174 virtual Widget* GetWidget() OVERRIDE; | 116 virtual Widget* GetWidget() OVERRIDE; |
| 175 virtual const Widget* GetWidget() const OVERRIDE; | 117 virtual const Widget* GetWidget() const OVERRIDE; |
| 176 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 118 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
| 177 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; | 119 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 virtual void ClearNativeFocus() OVERRIDE; | 188 virtual void ClearNativeFocus() OVERRIDE; |
| 247 virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; | 189 virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; |
| 248 virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; | 190 virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; |
| 249 virtual void SetInactiveRenderingDisabled(bool value) OVERRIDE; | 191 virtual void SetInactiveRenderingDisabled(bool value) OVERRIDE; |
| 250 virtual Widget::MoveLoopResult RunMoveLoop( | 192 virtual Widget::MoveLoopResult RunMoveLoop( |
| 251 const gfx::Point& drag_offset) OVERRIDE; | 193 const gfx::Point& drag_offset) OVERRIDE; |
| 252 virtual void EndMoveLoop() OVERRIDE; | 194 virtual void EndMoveLoop() OVERRIDE; |
| 253 virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; | 195 virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; |
| 254 | 196 |
| 255 protected: | 197 protected: |
| 256 // Overridden from MessageLoop::Observer: | |
| 257 virtual base::EventStatus WillProcessEvent( | |
| 258 const base::NativeEvent& event) OVERRIDE; | |
| 259 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; | |
| 260 | |
| 261 // Overridden from WindowImpl: | 198 // Overridden from WindowImpl: |
| 262 virtual HICON GetDefaultWindowIcon() const OVERRIDE; | 199 virtual HICON GetDefaultWindowIcon() const OVERRIDE; |
| 263 virtual LRESULT OnWndProc(UINT message, | 200 virtual LRESULT OnWndProc(UINT message, |
| 264 WPARAM w_param, | 201 WPARAM w_param, |
| 265 LPARAM l_param) OVERRIDE; | 202 LPARAM l_param) OVERRIDE; |
| 266 | 203 |
| 267 // Message Handlers ---------------------------------------------------------- | 204 // Message Handlers ---------------------------------------------------------- |
| 268 | 205 |
| 269 BEGIN_MSG_MAP_EX(NativeWidgetWin) | 206 BEGIN_MSG_MAP_EX(NativeWidgetWin) |
| 270 // Range handlers must go first! | 207 // Range handlers must go first! |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 374 |
| 438 // Overridden from HWNDMessageHandlerDelegate: | 375 // Overridden from HWNDMessageHandlerDelegate: |
| 439 virtual bool IsWidgetWindow() const OVERRIDE; | 376 virtual bool IsWidgetWindow() const OVERRIDE; |
| 440 virtual bool IsUsingCustomFrame() const OVERRIDE; | 377 virtual bool IsUsingCustomFrame() const OVERRIDE; |
| 441 virtual void SchedulePaint() OVERRIDE; | 378 virtual void SchedulePaint() OVERRIDE; |
| 442 virtual void EnableInactiveRendering() OVERRIDE; | 379 virtual void EnableInactiveRendering() OVERRIDE; |
| 443 virtual bool IsInactiveRenderingDisabled() OVERRIDE; | 380 virtual bool IsInactiveRenderingDisabled() OVERRIDE; |
| 444 virtual bool CanResize() const OVERRIDE; | 381 virtual bool CanResize() const OVERRIDE; |
| 445 virtual bool CanMaximize() const OVERRIDE; | 382 virtual bool CanMaximize() const OVERRIDE; |
| 446 virtual bool CanActivate() const OVERRIDE; | 383 virtual bool CanActivate() const OVERRIDE; |
| 384 virtual bool WidgetSizeIsClientSize() const OVERRIDE; |
| 447 virtual bool CanSaveFocus() const OVERRIDE; | 385 virtual bool CanSaveFocus() const OVERRIDE; |
| 448 virtual void SaveFocusOnDeactivate() OVERRIDE; | 386 virtual void SaveFocusOnDeactivate() OVERRIDE; |
| 449 virtual void RestoreFocusOnActivate() OVERRIDE; | 387 virtual void RestoreFocusOnActivate() OVERRIDE; |
| 450 virtual void RestoreFocusOnEnable() OVERRIDE; | 388 virtual void RestoreFocusOnEnable() OVERRIDE; |
| 451 virtual bool IsModal() const OVERRIDE; | 389 virtual bool IsModal() const OVERRIDE; |
| 452 virtual int GetInitialShowState() const OVERRIDE; | 390 virtual int GetInitialShowState() const OVERRIDE; |
| 453 virtual bool WillProcessWorkAreaChange() const OVERRIDE; | 391 virtual bool WillProcessWorkAreaChange() const OVERRIDE; |
| 454 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; | 392 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; |
| 455 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* path) OVERRIDE; | 393 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* path) OVERRIDE; |
| 456 virtual bool GetClientAreaInsets(gfx::Insets* insets) const OVERRIDE; | 394 virtual bool GetClientAreaInsets(gfx::Insets* insets) const OVERRIDE; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 487 virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE; | 425 virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE; |
| 488 virtual bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) OVERRIDE; | 426 virtual bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) OVERRIDE; |
| 489 virtual void HandlePaint(gfx::Canvas* canvas) OVERRIDE; | 427 virtual void HandlePaint(gfx::Canvas* canvas) OVERRIDE; |
| 490 virtual void HandleScreenReaderDetected() OVERRIDE; | 428 virtual void HandleScreenReaderDetected() OVERRIDE; |
| 491 virtual bool HandleTooltipNotify(int w_param, | 429 virtual bool HandleTooltipNotify(int w_param, |
| 492 NMHDR* l_param, | 430 NMHDR* l_param, |
| 493 LRESULT* l_result) OVERRIDE; | 431 LRESULT* l_result) OVERRIDE; |
| 494 virtual void HandleTooltipMouseMove(UINT message, | 432 virtual void HandleTooltipMouseMove(UINT message, |
| 495 WPARAM w_param, | 433 WPARAM w_param, |
| 496 LPARAM l_param) OVERRIDE; | 434 LPARAM l_param) OVERRIDE; |
| 435 virtual bool PreHandleMSG(UINT message, |
| 436 WPARAM w_param, |
| 437 LPARAM l_param, |
| 438 LRESULT* result) OVERRIDE; |
| 439 virtual void PostHandleMSG(UINT message, |
| 440 WPARAM w_param, |
| 441 LPARAM l_param) OVERRIDE; |
| 497 virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE; | 442 virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE; |
| 498 | 443 |
| 499 private: | 444 private: |
| 500 typedef ScopedVector<ui::ViewProp> ViewProps; | 445 typedef ScopedVector<ui::ViewProp> ViewProps; |
| 501 | 446 |
| 502 // TODO(beng): This friendship can be removed once all methods relating to | 447 // TODO(beng): This friendship can be removed once all methods relating to |
| 503 // this object being a WindowImpl are moved to HWNDMessageHandler. | 448 // this object being a WindowImpl are moved to HWNDMessageHandler. |
| 504 friend HWNDMessageHandler; | 449 friend HWNDMessageHandler; |
| 505 | 450 |
| 506 void SetInitParams(const Widget::InitParams& params); | 451 void SetInitParams(const Widget::InitParams& params); |
| 507 | 452 |
| 508 // Determines whether the delegate expects the client size or the window size. | |
| 509 bool WidgetSizeIsClientSize() const; | |
| 510 | |
| 511 // A delegate implementation that handles events received here. | 453 // A delegate implementation that handles events received here. |
| 512 // See class documentation for Widget in widget.h for a note about ownership. | 454 // See class documentation for Widget in widget.h for a note about ownership. |
| 513 internal::NativeWidgetDelegate* delegate_; | 455 internal::NativeWidgetDelegate* delegate_; |
| 514 | 456 |
| 515 // See class documentation for Widget in widget.h for a note about ownership. | 457 // See class documentation for Widget in widget.h for a note about ownership. |
| 516 Widget::InitParams::Ownership ownership_; | 458 Widget::InitParams::Ownership ownership_; |
| 517 | 459 |
| 518 // Instance of accessibility information and handling for MSAA root | 460 // Instance of accessibility information and handling for MSAA root |
| 519 base::win::ScopedComPtr<IAccessible> accessibility_root_; | 461 base::win::ScopedComPtr<IAccessible> accessibility_root_; |
| 520 | 462 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 544 bool has_non_client_view_; | 486 bool has_non_client_view_; |
| 545 | 487 |
| 546 scoped_ptr<HWNDMessageHandler> message_handler_; | 488 scoped_ptr<HWNDMessageHandler> message_handler_; |
| 547 | 489 |
| 548 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); | 490 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); |
| 549 }; | 491 }; |
| 550 | 492 |
| 551 } // namespace views | 493 } // namespace views |
| 552 | 494 |
| 553 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 495 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ |
| OLD | NEW |