| 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 12 matching lines...) Expand all Loading... |
| 23 class NativeWindow; | 23 class NativeWindow; |
| 24 class NonClientFrameView; | 24 class NonClientFrameView; |
| 25 class Widget; | 25 class Widget; |
| 26 class WindowDelegate; | 26 class WindowDelegate; |
| 27 | 27 |
| 28 //////////////////////////////////////////////////////////////////////////////// | 28 //////////////////////////////////////////////////////////////////////////////// |
| 29 // Window class | 29 // Window class |
| 30 // | 30 // |
| 31 // Encapsulates window-like behavior. See WindowDelegate. | 31 // Encapsulates window-like behavior. See WindowDelegate. |
| 32 // | 32 // |
| 33 // TODO(beng): Subclass Widget as part of V2. |
| 34 // |
| 35 // TODO(beng): Note that this class being non-abstract means that we have a |
| 36 // violation of Google style in that we are using multiple |
| 37 // inheritance. The intention is to split this into a separate |
| 38 // object associated with but not equal to a NativeWidget |
| 39 // implementation. Multiple inheritance is required for this |
| 40 // transitional step. |
| 41 // |
| 33 class Window : public Widget, | 42 class Window : public Widget, |
| 34 public internal::NativeWindowDelegate { | 43 public internal::NativeWindowDelegate { |
| 35 public: | 44 public: |
| 36 struct InitParams { | 45 struct InitParams { |
| 37 // |window_delegate| cannot be NULL. | 46 // |window_delegate| cannot be NULL. |
| 38 explicit InitParams(WindowDelegate* window_delegate); | 47 explicit InitParams(WindowDelegate* window_delegate); |
| 39 | 48 |
| 40 WindowDelegate* window_delegate; | 49 WindowDelegate* window_delegate; |
| 41 gfx::NativeWindow parent_window; | 50 gfx::NativeWindow parent_window; |
| 42 NativeWindow* native_window; | 51 NativeWindow* native_window; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 87 |
| 79 // Retrieves the restored bounds for the window. | 88 // Retrieves the restored bounds for the window. |
| 80 gfx::Rect GetNormalBounds() const; | 89 gfx::Rect GetNormalBounds() const; |
| 81 | 90 |
| 82 // Sets the Window's bounds. The window is inserted after |other_window| in | 91 // Sets the Window's bounds. The window is inserted after |other_window| in |
| 83 // the window Z-order. If this window is not yet visible, other_window's | 92 // the window Z-order. If this window is not yet visible, other_window's |
| 84 // monitor is used as the constraining rectangle, rather than this window's | 93 // monitor is used as the constraining rectangle, rather than this window's |
| 85 // monitor. | 94 // monitor. |
| 86 void SetWindowBounds(const gfx::Rect& bounds, gfx::NativeWindow other_window); | 95 void SetWindowBounds(const gfx::Rect& bounds, gfx::NativeWindow other_window); |
| 87 | 96 |
| 97 // Makes the window visible. |
| 98 void Show(); |
| 99 |
| 88 // Like Show(), but does not activate the window. | 100 // Like Show(), but does not activate the window. |
| 89 void ShowInactive(); | 101 void ShowInactive(); |
| 90 | 102 |
| 103 // Hides the window. This does not delete the window, it just hides it. This |
| 104 // always hides the window, it is separate from the stack maintained by |
| 105 // Push/PopForceHidden. |
| 106 virtual void HideWindow(); |
| 107 |
| 91 // Prevents the window from being rendered as deactivated the next time it is. | 108 // Prevents the window from being rendered as deactivated the next time it is. |
| 92 // This state is reset automatically as soon as the window becomes activated | 109 // This state is reset automatically as soon as the window becomes activated |
| 93 // again. There is no ability to control the state through this API as this | 110 // again. There is no ability to control the state through this API as this |
| 94 // leads to sync problems. | 111 // leads to sync problems. |
| 95 void DisableInactiveRendering(); | 112 void DisableInactiveRendering(); |
| 96 | 113 |
| 114 // Activates the window, assuming it already exists and is visible. |
| 115 void Activate(); |
| 116 |
| 117 // Deactivates the window, making the next window in the Z order the active |
| 118 // window. |
| 119 void Deactivate(); |
| 120 |
| 121 // Closes the window, ultimately destroying it. The window hides immediately, |
| 122 // and is destroyed after a return to the message loop. Close() can be called |
| 123 // multiple times. |
| 124 virtual void Close() OVERRIDE; |
| 125 |
| 126 // Maximizes/minimizes/restores the window. |
| 127 void Maximize(); |
| 128 void Minimize(); |
| 129 void Restore(); |
| 130 |
| 131 // Whether or not the window is currently active. |
| 132 bool IsActive() const; |
| 133 |
| 134 // Whether or not the window is currently visible. |
| 135 bool IsVisible() const; |
| 136 |
| 137 // Whether or not the window is maximized or minimized. |
| 138 virtual bool IsMaximized() const; |
| 139 bool IsMinimized() const; |
| 140 |
| 97 // Accessors for fullscreen state. | 141 // Accessors for fullscreen state. |
| 98 void SetFullscreen(bool fullscreen); | 142 void SetFullscreen(bool fullscreen); |
| 99 bool IsFullscreen() const; | 143 bool IsFullscreen() const; |
| 100 | 144 |
| 101 // Sets whether or not the window should show its frame as a "transient drag | 145 // Sets whether or not the window should show its frame as a "transient drag |
| 102 // frame" - slightly transparent and without the standard window controls. | 146 // frame" - slightly transparent and without the standard window controls. |
| 103 void SetUseDragFrame(bool use_drag_frame); | 147 void SetUseDragFrame(bool use_drag_frame); |
| 104 | 148 |
| 105 // Toggles the enable state for the Close button (and the Close menu item in | 149 // Toggles the enable state for the Close button (and the Close menu item in |
| 106 // the system menu). | 150 // the system menu). |
| 107 void EnableClose(bool enable); | 151 void EnableClose(bool enable); |
| 108 | 152 |
| 109 // Tell the window to update its title from the delegate. | 153 // Tell the window to update its title from the delegate. |
| 110 void UpdateWindowTitle(); | 154 void UpdateWindowTitle(); |
| 111 | 155 |
| 112 // Tell the window to update its icon from the delegate. | 156 // Tell the window to update its icon from the delegate. |
| 113 void UpdateWindowIcon(); | 157 void UpdateWindowIcon(); |
| 114 | 158 |
| 159 // Sets whether or not the window is always-on-top. |
| 160 void SetIsAlwaysOnTop(bool always_on_top); |
| 161 |
| 115 // Creates an appropriate NonClientFrameView for this window. | 162 // Creates an appropriate NonClientFrameView for this window. |
| 116 virtual NonClientFrameView* CreateFrameViewForWindow(); | 163 virtual NonClientFrameView* CreateFrameViewForWindow(); |
| 117 | 164 |
| 118 // Updates the frame after an event caused it to be changed. | 165 // Updates the frame after an event caused it to be changed. |
| 119 virtual void UpdateFrameAfterFrameChange(); | 166 virtual void UpdateFrameAfterFrameChange(); |
| 120 | 167 |
| 168 // Retrieves the Window's native window handle. |
| 169 gfx::NativeWindow GetNativeWindow() const; |
| 170 |
| 121 void set_frame_type(FrameType frame_type) { frame_type_ = frame_type; } | 171 void set_frame_type(FrameType frame_type) { frame_type_ = frame_type; } |
| 122 FrameType frame_type() const { return frame_type_; } | 172 FrameType frame_type() const { return frame_type_; } |
| 123 | 173 |
| 124 // Whether we should be using a native frame. | 174 // Whether we should be using a native frame. |
| 125 bool ShouldUseNativeFrame() const; | 175 bool ShouldUseNativeFrame() const; |
| 126 | 176 |
| 127 // Forces the frame into the alternate frame type (custom or native) depending | 177 // Forces the frame into the alternate frame type (custom or native) depending |
| 128 // on its current state. | 178 // on its current state. |
| 129 void DebugToggleFrameType(); | 179 void DebugToggleFrameType(); |
| 130 | 180 |
| 131 // Tell the window that something caused the frame type to change. | 181 // Tell the window that something caused the frame type to change. |
| 132 void FrameTypeChanged(); | 182 void FrameTypeChanged(); |
| 133 | 183 |
| 134 // Overridden from Widget: | |
| 135 virtual void Show() OVERRIDE; | |
| 136 virtual void Close() OVERRIDE; | |
| 137 | |
| 138 WindowDelegate* window_delegate() { | 184 WindowDelegate* window_delegate() { |
| 139 return const_cast<WindowDelegate*>( | 185 return const_cast<WindowDelegate*>( |
| 140 const_cast<const Window*>(this)->window_delegate()); | 186 const_cast<const Window*>(this)->window_delegate()); |
| 141 } | 187 } |
| 142 const WindowDelegate* window_delegate() const { | 188 const WindowDelegate* window_delegate() const { |
| 143 return window_delegate_; | 189 return window_delegate_; |
| 144 } | 190 } |
| 145 | 191 |
| 146 NonClientView* non_client_view() { | 192 NonClientView* non_client_view() { |
| 147 return const_cast<NonClientView*>( | 193 return const_cast<NonClientView*>( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // The current frame type in use by this window. Defaults to | 263 // The current frame type in use by this window. Defaults to |
| 218 // FRAME_TYPE_DEFAULT. | 264 // FRAME_TYPE_DEFAULT. |
| 219 FrameType frame_type_; | 265 FrameType frame_type_; |
| 220 | 266 |
| 221 DISALLOW_COPY_AND_ASSIGN(Window); | 267 DISALLOW_COPY_AND_ASSIGN(Window); |
| 222 }; | 268 }; |
| 223 | 269 |
| 224 } // namespace views | 270 } // namespace views |
| 225 | 271 |
| 226 #endif // #ifndef VIEWS_WINDOW_WINDOW_H_ | 272 #endif // #ifndef VIEWS_WINDOW_WINDOW_H_ |
| OLD | NEW |