| 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_WINDOW_H_ | 5 #ifndef VIEWS_WINDOW_WINDOW_H_ |
| 6 #define VIEWS_WINDOW_WINDOW_H_ | 6 #define VIEWS_WINDOW_WINDOW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
| 10 #include "views/widget/widget.h" | 10 #include "views/widget/widget.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // ClientView. | 57 // ClientView. |
| 58 static int GetLocalizedContentsWidth(int col_resource_id); | 58 static int GetLocalizedContentsWidth(int col_resource_id); |
| 59 static int GetLocalizedContentsHeight(int row_resource_id); | 59 static int GetLocalizedContentsHeight(int row_resource_id); |
| 60 static gfx::Size GetLocalizedContentsSize(int col_resource_id, | 60 static gfx::Size GetLocalizedContentsSize(int col_resource_id, |
| 61 int row_resource_id); | 61 int row_resource_id); |
| 62 | 62 |
| 63 // Initializes the window. Must be called before any post-configuration | 63 // Initializes the window. Must be called before any post-configuration |
| 64 // operations are performed. | 64 // operations are performed. |
| 65 void InitWindow(const InitParams& params); | 65 void InitWindow(const InitParams& params); |
| 66 | 66 |
| 67 // Retrieves the window's bounds, including its frame. | |
| 68 gfx::Rect GetBounds() const; | |
| 69 | |
| 70 // Retrieves the restored bounds for the window. | |
| 71 gfx::Rect GetNormalBounds() const; | |
| 72 | |
| 73 // Like Show(), but does not activate the window. | |
| 74 void ShowInactive(); | |
| 75 | |
| 76 // Prevents the window from being rendered as deactivated the next time it is. | |
| 77 // This state is reset automatically as soon as the window becomes activated | |
| 78 // again. There is no ability to control the state through this API as this | |
| 79 // leads to sync problems. | |
| 80 void DisableInactiveRendering(); | |
| 81 | |
| 82 // Toggles the enable state for the Close button (and the Close menu item in | |
| 83 // the system menu). | |
| 84 void EnableClose(bool enable); | |
| 85 | |
| 86 // Tell the window to update its title from the delegate. | |
| 87 void UpdateWindowTitle(); | |
| 88 | |
| 89 // Tell the window to update its icon from the delegate. | |
| 90 void UpdateWindowIcon(); | |
| 91 | |
| 92 // Overridden from Widget: | 67 // Overridden from Widget: |
| 93 virtual void Show() OVERRIDE; | 68 virtual void Show() OVERRIDE; |
| 94 virtual void Close() OVERRIDE; | 69 virtual Window* AsWindow() OVERRIDE; |
| 70 virtual const Window* AsWindow() const OVERRIDE; |
| 95 | 71 |
| 96 WindowDelegate* window_delegate() { | 72 WindowDelegate* window_delegate() { |
| 97 return const_cast<WindowDelegate*>( | 73 return const_cast<WindowDelegate*>( |
| 98 const_cast<const Window*>(this)->window_delegate()); | 74 const_cast<const Window*>(this)->window_delegate()); |
| 99 } | 75 } |
| 100 const WindowDelegate* window_delegate() const { | 76 const WindowDelegate* window_delegate() const { |
| 101 return reinterpret_cast<WindowDelegate*>(widget_delegate()); | 77 return reinterpret_cast<WindowDelegate*>(widget_delegate()); |
| 102 } | 78 } |
| 103 | 79 |
| 104 NativeWindow* native_window() { return native_window_; } | 80 NativeWindow* native_window() { return native_window_; } |
| 105 | 81 |
| 106 protected: | 82 protected: |
| 107 // Overridden from NativeWindowDelegate: | 83 // Overridden from NativeWindowDelegate: |
| 108 virtual bool CanActivate() const OVERRIDE; | |
| 109 virtual bool IsInactiveRenderingDisabled() const OVERRIDE; | |
| 110 virtual void EnableInactiveRendering() OVERRIDE; | |
| 111 virtual bool IsModal() const OVERRIDE; | 84 virtual bool IsModal() const OVERRIDE; |
| 112 virtual bool IsDialogBox() const OVERRIDE; | 85 virtual bool IsDialogBox() const OVERRIDE; |
| 113 virtual gfx::Size GetMinimumSize() OVERRIDE; | |
| 114 virtual int GetNonClientComponent(const gfx::Point& point) OVERRIDE; | |
| 115 virtual bool ExecuteCommand(int command_id) OVERRIDE; | |
| 116 virtual void OnNativeWindowCreated(const gfx::Rect& bounds) OVERRIDE; | 86 virtual void OnNativeWindowCreated(const gfx::Rect& bounds) OVERRIDE; |
| 117 virtual void OnNativeWindowActivationChanged(bool active) OVERRIDE; | |
| 118 virtual void OnNativeWindowBeginUserBoundsChange() OVERRIDE; | |
| 119 virtual void OnNativeWindowEndUserBoundsChange() OVERRIDE; | |
| 120 virtual void OnNativeWindowDestroying() OVERRIDE; | |
| 121 virtual void OnNativeWindowBoundsChanged() OVERRIDE; | |
| 122 virtual Window* AsWindow() OVERRIDE; | |
| 123 virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE; | 87 virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE; |
| 124 | 88 |
| 125 private: | 89 private: |
| 126 // Sizes and positions the window just after it is created. | 90 // Sizes and positions the window just after it is created. |
| 127 void SetInitialBounds(const gfx::Rect& bounds); | 91 void SetInitialBounds(const gfx::Rect& bounds); |
| 128 | 92 |
| 129 // Persists the window's restored position and maximized state using the | |
| 130 // window delegate. | |
| 131 void SaveWindowPosition(); | |
| 132 | |
| 133 NativeWindow* native_window_; | 93 NativeWindow* native_window_; |
| 134 | 94 |
| 135 // The saved maximized state for this window. See note in SetInitialBounds | 95 // The saved maximized state for this window. See note in SetInitialBounds |
| 136 // that explains why we save this. | 96 // that explains why we save this. |
| 137 bool saved_maximized_state_; | 97 bool saved_maximized_state_; |
| 138 | 98 |
| 139 // The smallest size the window can be. | 99 // The smallest size the window can be. |
| 140 gfx::Size minimum_size_; | 100 gfx::Size minimum_size_; |
| 141 | 101 |
| 142 // True when the window should be rendered as active, regardless of whether | |
| 143 // or not it actually is. | |
| 144 bool disable_inactive_rendering_; | |
| 145 | |
| 146 // Set to true if the window is in the process of closing . | |
| 147 bool window_closed_; | |
| 148 | |
| 149 DISALLOW_COPY_AND_ASSIGN(Window); | 102 DISALLOW_COPY_AND_ASSIGN(Window); |
| 150 }; | 103 }; |
| 151 | 104 |
| 152 } // namespace views | 105 } // namespace views |
| 153 | 106 |
| 154 #endif // #ifndef VIEWS_WINDOW_WINDOW_H_ | 107 #endif // #ifndef VIEWS_WINDOW_WINDOW_H_ |
| OLD | NEW |