| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_WINDOW_NATIVE_WINDOW_WIN_H_ | 5 #ifndef VIEWS_WINDOW_NATIVE_WINDOW_WIN_H_ |
| 6 #define VIEWS_WINDOW_NATIVE_WINDOW_WIN_H_ | 6 #define VIEWS_WINDOW_NATIVE_WINDOW_WIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "views/widget/native_widget_win.h" | 9 #include "views/widget/native_widget_win.h" |
| 10 #include "views/window/native_window.h" | 10 #include "views/window/native_window.h" |
| 11 #include "views/window/window.h" | |
| 12 | |
| 13 namespace gfx { | |
| 14 class Font; | |
| 15 class Point; | |
| 16 class Size; | |
| 17 }; | |
| 18 | 11 |
| 19 namespace views { | 12 namespace views { |
| 20 namespace internal { | 13 namespace internal { |
| 21 class NativeWindowDelegate; | 14 class NativeWindowDelegate; |
| 22 | 15 |
| 23 // This is exposed only for testing | 16 // This is exposed only for testing |
| 24 // Adjusts the value of |child_rect| if necessary to ensure that it is | 17 // Adjusts the value of |child_rect| if necessary to ensure that it is |
| 25 // completely visible within |parent_rect|. | 18 // completely visible within |parent_rect|. |
| 26 void EnsureRectIsVisibleInRect(const gfx::Rect& parent_rect, | 19 void EnsureRectIsVisibleInRect(const gfx::Rect& parent_rect, |
| 27 gfx::Rect* child_rect, | 20 gfx::Rect* child_rect, |
| 28 int padding); | 21 int padding); |
| 29 | 22 |
| 30 } // namespace internal | 23 } // namespace internal |
| 31 | 24 |
| 32 class Client; | |
| 33 class WindowDelegate; | |
| 34 | |
| 35 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 36 // | 26 // |
| 37 // NativeWindowWin | 27 // NativeWindowWin |
| 38 // | 28 // |
| 39 // A NativeWindowWin is a NativeWidgetWin that encapsulates a window with a | 29 // A NativeWindowWin is a NativeWidgetWin that encapsulates a window with a |
| 40 // frame. The frame may or may not be rendered by the operating system. The | 30 // frame. The frame may or may not be rendered by the operating system. The |
| 41 // window may or may not be top level. | 31 // window may or may not be top level. |
| 42 // | 32 // |
| 43 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
| 44 class NativeWindowWin : public NativeWidgetWin, | 34 class NativeWindowWin : public NativeWidgetWin, |
| 45 public NativeWindow { | 35 public NativeWindow { |
| 46 public: | 36 public: |
| 47 explicit NativeWindowWin(internal::NativeWindowDelegate* delegate); | 37 explicit NativeWindowWin(internal::NativeWindowDelegate* delegate); |
| 48 virtual ~NativeWindowWin(); | 38 virtual ~NativeWindowWin(); |
| 49 | 39 |
| 50 // Returns the system set window title font. | |
| 51 static gfx::Font GetWindowTitleFont(); | |
| 52 | |
| 53 // Overridden from NativeWindow: | 40 // Overridden from NativeWindow: |
| 54 virtual Window* GetWindow() OVERRIDE; | 41 virtual Window* GetWindow() OVERRIDE; |
| 55 virtual const Window* GetWindow() const OVERRIDE; | 42 virtual const Window* GetWindow() const OVERRIDE; |
| 56 | 43 |
| 57 protected: | 44 protected: |
| 58 friend Window; | 45 friend Window; |
| 59 | 46 |
| 60 // Overridden from NativeWidgetWin: | |
| 61 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; | |
| 62 virtual void OnDestroy() OVERRIDE; | |
| 63 virtual LRESULT OnMouseRange(UINT message, | |
| 64 WPARAM w_param, | |
| 65 LPARAM l_param) OVERRIDE; | |
| 66 LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param); // Don't override. | |
| 67 virtual void OnNCPaint(HRGN rgn) OVERRIDE; | |
| 68 virtual void OnWindowPosChanging(WINDOWPOS* window_pos) OVERRIDE; | |
| 69 | |
| 70 // Overridden from NativeWindow: | 47 // Overridden from NativeWindow: |
| 71 virtual NativeWidget* AsNativeWidget() OVERRIDE; | 48 virtual NativeWidget* AsNativeWidget() OVERRIDE; |
| 72 virtual const NativeWidget* AsNativeWidget() const OVERRIDE; | 49 virtual const NativeWidget* AsNativeWidget() const OVERRIDE; |
| 73 virtual void BecomeModal() OVERRIDE; | |
| 74 | 50 |
| 75 private: | 51 private: |
| 76 // If necessary, enables all ancestors. | |
| 77 void RestoreEnabledIfNecessary(); | |
| 78 | |
| 79 // Calculate the appropriate window styles for this window. | |
| 80 DWORD CalculateWindowStyle(); | |
| 81 DWORD CalculateWindowExStyle(); | |
| 82 | |
| 83 // Stops ignoring SetWindowPos() requests (see below). | |
| 84 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; } | |
| 85 | |
| 86 // Update accessibility information via our WindowDelegate. | |
| 87 void UpdateAccessibleName(std::wstring& accessible_name); | |
| 88 void UpdateAccessibleRole(); | |
| 89 void UpdateAccessibleState(); | |
| 90 | |
| 91 // A delegate implementation that handles events received here. | 52 // A delegate implementation that handles events received here. |
| 92 internal::NativeWindowDelegate* delegate_; | 53 internal::NativeWindowDelegate* delegate_; |
| 93 | 54 |
| 94 // Whether all ancestors have been enabled. This is only used if is_modal_ is | |
| 95 // true. | |
| 96 bool restored_enabled_; | |
| 97 | |
| 98 // When true, this flag makes us discard incoming SetWindowPos() requests that | |
| 99 // only change our position/size. (We still allow changes to Z-order, | |
| 100 // activation, etc.) | |
| 101 bool ignore_window_pos_changes_; | |
| 102 | |
| 103 // The following factory is used to ignore SetWindowPos() calls for short time | |
| 104 // periods. | |
| 105 ScopedRunnableMethodFactory<NativeWindowWin> ignore_pos_changes_factory_; | |
| 106 | |
| 107 // Set to true when the user presses the right mouse button on the caption | |
| 108 // area. We need this so we can correctly show the context menu on mouse-up. | |
| 109 bool is_right_mouse_pressed_on_caption_; | |
| 110 | |
| 111 // The last-seen monitor containing us, and its rect and work area. These are | |
| 112 // used to catch updates to the rect and work area and react accordingly. | |
| 113 HMONITOR last_monitor_; | |
| 114 gfx::Rect last_monitor_rect_, last_work_area_; | |
| 115 | |
| 116 DISALLOW_COPY_AND_ASSIGN(NativeWindowWin); | 55 DISALLOW_COPY_AND_ASSIGN(NativeWindowWin); |
| 117 }; | 56 }; |
| 118 | 57 |
| 119 } // namespace views | 58 } // namespace views |
| 120 | 59 |
| 121 #endif // VIEWS_WINDOW_NATIVE_WINDOW_WIN_H_ | 60 #endif // VIEWS_WINDOW_NATIVE_WINDOW_WIN_H_ |
| OLD | NEW |