| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // frame. The frame may or may not be rendered by the operating system. The | 40 // frame. The frame may or may not be rendered by the operating system. The |
| 41 // window may or may not be top level. | 41 // window may or may not be top level. |
| 42 // | 42 // |
| 43 //////////////////////////////////////////////////////////////////////////////// | 43 //////////////////////////////////////////////////////////////////////////////// |
| 44 class NativeWindowWin : public NativeWidgetWin, | 44 class NativeWindowWin : public NativeWidgetWin, |
| 45 public NativeWindow { | 45 public NativeWindow { |
| 46 public: | 46 public: |
| 47 explicit NativeWindowWin(internal::NativeWindowDelegate* delegate); | 47 explicit NativeWindowWin(internal::NativeWindowDelegate* delegate); |
| 48 virtual ~NativeWindowWin(); | 48 virtual ~NativeWindowWin(); |
| 49 | 49 |
| 50 // Show the window with the specified show command. | |
| 51 void Show(int show_state); | |
| 52 | |
| 53 // Returns the system set window title font. | 50 // Returns the system set window title font. |
| 54 static gfx::Font GetWindowTitleFont(); | 51 static gfx::Font GetWindowTitleFont(); |
| 55 | 52 |
| 56 // Overridden from NativeWindow: | 53 // Overridden from NativeWindow: |
| 57 virtual Window* GetWindow() OVERRIDE; | 54 virtual Window* GetWindow() OVERRIDE; |
| 58 virtual const Window* GetWindow() const OVERRIDE; | 55 virtual const Window* GetWindow() const OVERRIDE; |
| 59 | 56 |
| 60 protected: | 57 protected: |
| 61 friend Window; | 58 friend Window; |
| 62 | 59 |
| 63 // Returns the insets of the client area relative to the non-client area of | |
| 64 // the window. Override this function instead of OnNCCalcSize, which is | |
| 65 // crazily complicated. | |
| 66 virtual gfx::Insets GetClientAreaInsets() const; | |
| 67 | |
| 68 // Retrieve the show state of the window. This is one of the SW_SHOW* flags | |
| 69 // passed into Windows' ShowWindow method. For normal windows this defaults | |
| 70 // to SW_SHOWNORMAL, however windows (e.g. the main window) can override this | |
| 71 // method to provide different values (e.g. retrieve the user's specified | |
| 72 // show state from the shortcut starutp info). | |
| 73 virtual int GetShowState() const; | |
| 74 | |
| 75 // Overridden from NativeWidgetWin: | 60 // Overridden from NativeWidgetWin: |
| 76 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; | 61 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; |
| 77 virtual void OnActivateApp(BOOL active, DWORD thread_id) OVERRIDE; | |
| 78 virtual void OnDestroy() OVERRIDE; | 62 virtual void OnDestroy() OVERRIDE; |
| 79 virtual LRESULT OnDwmCompositionChanged(UINT msg, | |
| 80 WPARAM w_param, | |
| 81 LPARAM l_param) OVERRIDE; | |
| 82 virtual void OnEnterSizeMove() OVERRIDE; | |
| 83 virtual void OnExitSizeMove() OVERRIDE; | |
| 84 virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info) OVERRIDE; | |
| 85 virtual void OnInitMenu(HMENU menu) OVERRIDE; | |
| 86 virtual LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param) | |
| 87 OVERRIDE; | |
| 88 virtual LRESULT OnMouseRange(UINT message, | 63 virtual LRESULT OnMouseRange(UINT message, |
| 89 WPARAM w_param, | 64 WPARAM w_param, |
| 90 LPARAM l_param) OVERRIDE; | 65 LPARAM l_param) OVERRIDE; |
| 91 virtual LRESULT OnNCActivate(BOOL active) OVERRIDE; | |
| 92 LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param); // Don't override. | 66 LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param); // Don't override. |
| 93 virtual LRESULT OnNCHitTest(const CPoint& point) OVERRIDE; | |
| 94 virtual void OnNCPaint(HRGN rgn) OVERRIDE; | 67 virtual void OnNCPaint(HRGN rgn) OVERRIDE; |
| 95 virtual LRESULT OnNCUAHDrawCaption(UINT msg, | |
| 96 WPARAM w_param, | |
| 97 LPARAM l_param) OVERRIDE; | |
| 98 virtual LRESULT OnNCUAHDrawFrame(UINT msg, | |
| 99 WPARAM w_param, | |
| 100 LPARAM l_param) OVERRIDE; | |
| 101 virtual LRESULT OnSetCursor(UINT message, | |
| 102 WPARAM w_param, | |
| 103 LPARAM l_param) OVERRIDE; | |
| 104 virtual LRESULT OnSetIcon(UINT size_type, HICON new_icon) OVERRIDE; | |
| 105 virtual LRESULT OnSetText(const wchar_t* text) OVERRIDE; | |
| 106 virtual void OnSize(UINT size_param, const CSize& new_size) OVERRIDE; | |
| 107 virtual void OnSysCommand(UINT notification_code, CPoint click) OVERRIDE; | |
| 108 virtual void OnWindowPosChanging(WINDOWPOS* window_pos) OVERRIDE; | 68 virtual void OnWindowPosChanging(WINDOWPOS* window_pos) OVERRIDE; |
| 109 | 69 |
| 110 // Overridden from NativeWindow: | 70 // Overridden from NativeWindow: |
| 111 virtual NativeWidget* AsNativeWidget() OVERRIDE; | 71 virtual NativeWidget* AsNativeWidget() OVERRIDE; |
| 112 virtual const NativeWidget* AsNativeWidget() const OVERRIDE; | 72 virtual const NativeWidget* AsNativeWidget() const OVERRIDE; |
| 113 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | |
| 114 virtual void ShowNativeWindow(ShowState state) OVERRIDE; | |
| 115 virtual void BecomeModal() OVERRIDE; | 73 virtual void BecomeModal() OVERRIDE; |
| 116 virtual void EnableClose(bool enable) OVERRIDE; | |
| 117 | |
| 118 // Overridden from NativeWidgetWin: | |
| 119 virtual bool IsActive() const OVERRIDE; | |
| 120 | 74 |
| 121 private: | 75 private: |
| 122 // If necessary, enables all ancestors. | 76 // If necessary, enables all ancestors. |
| 123 void RestoreEnabledIfNecessary(); | 77 void RestoreEnabledIfNecessary(); |
| 124 | 78 |
| 125 // Calculate the appropriate window styles for this window. | 79 // Calculate the appropriate window styles for this window. |
| 126 DWORD CalculateWindowStyle(); | 80 DWORD CalculateWindowStyle(); |
| 127 DWORD CalculateWindowExStyle(); | 81 DWORD CalculateWindowExStyle(); |
| 128 | 82 |
| 129 // Lock or unlock the window from being able to redraw itself in response to | |
| 130 // updates to its invalid region. | |
| 131 class ScopedRedrawLock; | |
| 132 void LockUpdates(); | |
| 133 void UnlockUpdates(); | |
| 134 | |
| 135 // Stops ignoring SetWindowPos() requests (see below). | 83 // Stops ignoring SetWindowPos() requests (see below). |
| 136 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; } | 84 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; } |
| 137 | 85 |
| 138 // Update accessibility information via our WindowDelegate. | 86 // Update accessibility information via our WindowDelegate. |
| 139 void UpdateAccessibleName(std::wstring& accessible_name); | 87 void UpdateAccessibleName(std::wstring& accessible_name); |
| 140 void UpdateAccessibleRole(); | 88 void UpdateAccessibleRole(); |
| 141 void UpdateAccessibleState(); | 89 void UpdateAccessibleState(); |
| 142 | 90 |
| 143 // Calls the default WM_NCACTIVATE handler with the specified activation | |
| 144 // value, safely wrapping the call in a ScopedRedrawLock to prevent frame | |
| 145 // flicker. | |
| 146 LRESULT CallDefaultNCActivateHandler(BOOL active); | |
| 147 | |
| 148 // A delegate implementation that handles events received here. | 91 // A delegate implementation that handles events received here. |
| 149 internal::NativeWindowDelegate* delegate_; | 92 internal::NativeWindowDelegate* delegate_; |
| 150 | 93 |
| 151 // Whether all ancestors have been enabled. This is only used if is_modal_ is | 94 // Whether all ancestors have been enabled. This is only used if is_modal_ is |
| 152 // true. | 95 // true. |
| 153 bool restored_enabled_; | 96 bool restored_enabled_; |
| 154 | 97 |
| 155 // True if this window is the active top level window. | |
| 156 bool is_active_; | |
| 157 | |
| 158 // True if updates to this window are currently locked. | |
| 159 bool lock_updates_; | |
| 160 | |
| 161 // The window styles of the window before updates were locked. | |
| 162 DWORD saved_window_style_; | |
| 163 | |
| 164 // When true, this flag makes us discard incoming SetWindowPos() requests that | 98 // When true, this flag makes us discard incoming SetWindowPos() requests that |
| 165 // only change our position/size. (We still allow changes to Z-order, | 99 // only change our position/size. (We still allow changes to Z-order, |
| 166 // activation, etc.) | 100 // activation, etc.) |
| 167 bool ignore_window_pos_changes_; | 101 bool ignore_window_pos_changes_; |
| 168 | 102 |
| 169 // The following factory is used to ignore SetWindowPos() calls for short time | 103 // The following factory is used to ignore SetWindowPos() calls for short time |
| 170 // periods. | 104 // periods. |
| 171 ScopedRunnableMethodFactory<NativeWindowWin> ignore_pos_changes_factory_; | 105 ScopedRunnableMethodFactory<NativeWindowWin> ignore_pos_changes_factory_; |
| 172 | 106 |
| 173 // Set to true when the user presses the right mouse button on the caption | 107 // Set to true when the user presses the right mouse button on the caption |
| 174 // area. We need this so we can correctly show the context menu on mouse-up. | 108 // area. We need this so we can correctly show the context menu on mouse-up. |
| 175 bool is_right_mouse_pressed_on_caption_; | 109 bool is_right_mouse_pressed_on_caption_; |
| 176 | 110 |
| 177 // The last-seen monitor containing us, and its rect and work area. These are | 111 // The last-seen monitor containing us, and its rect and work area. These are |
| 178 // used to catch updates to the rect and work area and react accordingly. | 112 // used to catch updates to the rect and work area and react accordingly. |
| 179 HMONITOR last_monitor_; | 113 HMONITOR last_monitor_; |
| 180 gfx::Rect last_monitor_rect_, last_work_area_; | 114 gfx::Rect last_monitor_rect_, last_work_area_; |
| 181 | 115 |
| 182 DISALLOW_COPY_AND_ASSIGN(NativeWindowWin); | 116 DISALLOW_COPY_AND_ASSIGN(NativeWindowWin); |
| 183 }; | 117 }; |
| 184 | 118 |
| 185 } // namespace views | 119 } // namespace views |
| 186 | 120 |
| 187 #endif // VIEWS_WINDOW_NATIVE_WINDOW_WIN_H_ | 121 #endif // VIEWS_WINDOW_NATIVE_WINDOW_WIN_H_ |
| OLD | NEW |