Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: views/window/window.h

Issue 7015051: Re-land: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/window/native_window_delegate.h ('k') | views/window/window.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 // 32 //
33 // TODO(beng): Subclass Widget as part of V2. 33 // TODO(beng): Subclass Widget as part of V2.
34 // 34 //
35 // TODO(beng): Note that this class being non-abstract means that we have a 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 36 // violation of Google style in that we are using multiple
37 // inheritance. The intention is to split this into a separate 37 // inheritance. The intention is to split this into a separate
38 // object associated with but not equal to a NativeWidget 38 // object associated with but not equal to a NativeWidget
39 // implementation. Multiple inheritance is required for this 39 // implementation. Multiple inheritance is required for this
40 // transitional step. 40 // transitional step.
41 // 41 //
42 class Window : public internal::NativeWindowDelegate { 42 class Window : public Widget,
43 public internal::NativeWindowDelegate {
43 public: 44 public:
44 struct InitParams { 45 struct InitParams {
45 // |window_delegate| cannot be NULL. 46 // |window_delegate| cannot be NULL.
46 explicit InitParams(WindowDelegate* window_delegate); 47 explicit InitParams(WindowDelegate* window_delegate);
47 48
48 WindowDelegate* window_delegate; 49 WindowDelegate* window_delegate;
49 gfx::NativeWindow parent_window; 50 gfx::NativeWindow parent_window;
50 NativeWindow* native_window; 51 NativeWindow* native_window;
51 Widget::InitParams widget_init_params; 52 Widget::InitParams widget_init_params;
52 }; 53 };
(...skipping 11 matching lines...) Expand all
64 // Returns the preferred size of the contents view of this window based on 65 // Returns the preferred size of the contents view of this window based on
65 // its localized size data. The width in cols is held in a localized string 66 // its localized size data. The width in cols is held in a localized string
66 // resource identified by |col_resource_id|, the height in the same fashion. 67 // resource identified by |col_resource_id|, the height in the same fashion.
67 // TODO(beng): This should eventually live somewhere else, probably closer to 68 // TODO(beng): This should eventually live somewhere else, probably closer to
68 // ClientView. 69 // ClientView.
69 static int GetLocalizedContentsWidth(int col_resource_id); 70 static int GetLocalizedContentsWidth(int col_resource_id);
70 static int GetLocalizedContentsHeight(int row_resource_id); 71 static int GetLocalizedContentsHeight(int row_resource_id);
71 static gfx::Size GetLocalizedContentsSize(int col_resource_id, 72 static gfx::Size GetLocalizedContentsSize(int col_resource_id,
72 int row_resource_id); 73 int row_resource_id);
73 74
74 // Closes all windows that aren't identified as "app windows" via
75 // IsAppWindow. Called during application shutdown when the last "app window"
76 // is closed.
77 static void CloseAllSecondaryWindows();
78
79 // Used by |CloseAllSecondaryWindows|. If |widget|'s window is a secondary
80 // window, the window is closed. If |widget| has no window, it is closed.
81 // Does nothing if |widget| is null.
82 static void CloseSecondaryWidget(Widget* widget);
83
84 // Initializes the window. Must be called before any post-configuration 75 // Initializes the window. Must be called before any post-configuration
85 // operations are performed. 76 // operations are performed.
86 void InitWindow(const InitParams& params); 77 void InitWindow(const InitParams& params);
87 78
88 // Retrieves the window's bounds, including its frame. 79 // Retrieves the window's bounds, including its frame.
89 gfx::Rect GetBounds() const; 80 gfx::Rect GetBounds() const;
90 81
91 // Retrieves the restored bounds for the window. 82 // Retrieves the restored bounds for the window.
92 gfx::Rect GetNormalBounds() const; 83 gfx::Rect GetNormalBounds() const;
93 84
(...skipping 23 matching lines...) Expand all
117 // Activates the window, assuming it already exists and is visible. 108 // Activates the window, assuming it already exists and is visible.
118 void Activate(); 109 void Activate();
119 110
120 // Deactivates the window, making the next window in the Z order the active 111 // Deactivates the window, making the next window in the Z order the active
121 // window. 112 // window.
122 void Deactivate(); 113 void Deactivate();
123 114
124 // Closes the window, ultimately destroying it. The window hides immediately, 115 // Closes the window, ultimately destroying it. The window hides immediately,
125 // and is destroyed after a return to the message loop. Close() can be called 116 // and is destroyed after a return to the message loop. Close() can be called
126 // multiple times. 117 // multiple times.
127 void CloseWindow(); 118 virtual void Close() OVERRIDE;
128 119
129 // Maximizes/minimizes/restores the window. 120 // Maximizes/minimizes/restores the window.
130 void Maximize(); 121 void Maximize();
131 void Minimize(); 122 void Minimize();
132 void Restore(); 123 void Restore();
133 124
134 // Whether or not the window is currently active. 125 // Whether or not the window is currently active.
135 bool IsActive() const; 126 bool IsActive() const;
136 127
137 // Whether or not the window is currently visible. 128 // Whether or not the window is currently visible.
138 bool IsVisible() const; 129 bool IsVisible() const;
139 130
140 // Whether or not the window is maximized or minimized. 131 // Whether or not the window is maximized or minimized.
141 bool IsMaximized() const; 132 virtual bool IsMaximized() const;
142 bool IsMinimized() const; 133 bool IsMinimized() const;
143 134
144 // Accessors for fullscreen state. 135 // Accessors for fullscreen state.
145 void SetFullscreen(bool fullscreen); 136 void SetFullscreen(bool fullscreen);
146 bool IsFullscreen() const; 137 bool IsFullscreen() const;
147 138
148 // Sets whether or not the window should show its frame as a "transient drag 139 // Sets whether or not the window should show its frame as a "transient drag
149 // frame" - slightly transparent and without the standard window controls. 140 // frame" - slightly transparent and without the standard window controls.
150 void SetUseDragFrame(bool use_drag_frame); 141 void SetUseDragFrame(bool use_drag_frame);
151 142
152 // Returns true if the Window is considered to be an "app window" - i.e.
153 // any window which when it is the last of its type closed causes the
154 // application to exit.
155 virtual bool IsAppWindow() const;
156
157 // Toggles the enable state for the Close button (and the Close menu item in 143 // Toggles the enable state for the Close button (and the Close menu item in
158 // the system menu). 144 // the system menu).
159 void EnableClose(bool enable); 145 void EnableClose(bool enable);
160 146
161 // Tell the window to update its title from the delegate. 147 // Tell the window to update its title from the delegate.
162 void UpdateWindowTitle(); 148 void UpdateWindowTitle();
163 149
164 // Tell the window to update its icon from the delegate. 150 // Tell the window to update its icon from the delegate.
165 void UpdateWindowIcon(); 151 void UpdateWindowIcon();
166 152
167 // Sets whether or not the window is always-on-top. 153 // Sets whether or not the window is always-on-top.
168 void SetIsAlwaysOnTop(bool always_on_top); 154 void SetIsAlwaysOnTop(bool always_on_top);
169 155
170 // Creates an appropriate NonClientFrameView for this window. 156 // Creates an appropriate NonClientFrameView for this window.
171 virtual NonClientFrameView* CreateFrameViewForWindow(); 157 virtual NonClientFrameView* CreateFrameViewForWindow();
172 158
173 // Updates the frame after an event caused it to be changed. 159 // Updates the frame after an event caused it to be changed.
174 virtual void UpdateFrameAfterFrameChange(); 160 virtual void UpdateFrameAfterFrameChange();
175 161
176 // Retrieves the Window's native window handle. 162 // Retrieves the Window's native window handle.
177 gfx::NativeWindow GetNativeWindow() const; 163 gfx::NativeWindow GetNativeWindow() const;
178 164
179 // Whether we should be using a native frame. 165 // Whether we should be using a native frame.
180 bool ShouldUseNativeFrame() const; 166 bool ShouldUseNativeFrame() const;
181 167
182 // Tell the window that something caused the frame type to change. 168 // Tell the window that something caused the frame type to change.
183 void FrameTypeChanged(); 169 void FrameTypeChanged();
184 170
185 // TODO(beng): remove once Window subclasses Widget.
186 Widget* AsWidget();
187 const Widget* AsWidget() const;
188
189 WindowDelegate* window_delegate() { 171 WindowDelegate* window_delegate() {
190 return const_cast<WindowDelegate*>( 172 return const_cast<WindowDelegate*>(
191 const_cast<const Window*>(this)->window_delegate()); 173 const_cast<const Window*>(this)->window_delegate());
192 } 174 }
193 const WindowDelegate* window_delegate() const { 175 const WindowDelegate* window_delegate() const {
194 return window_delegate_; 176 return window_delegate_;
195 } 177 }
196 178
197 NonClientView* non_client_view() { 179 NonClientView* non_client_view() {
198 return const_cast<NonClientView*>( 180 return const_cast<NonClientView*>(
199 const_cast<const Window*>(this)->non_client_view()); 181 const_cast<const Window*>(this)->non_client_view());
200 } 182 }
201 const NonClientView* non_client_view() const { 183 const NonClientView* non_client_view() const {
202 return non_client_view_; 184 return non_client_view_;
203 } 185 }
204 186
205 ClientView* client_view() { 187 ClientView* client_view() {
206 return const_cast<ClientView*>( 188 return const_cast<ClientView*>(
207 const_cast<const Window*>(this)->client_view()); 189 const_cast<const Window*>(this)->client_view());
208 } 190 }
209 const ClientView* client_view() const { 191 const ClientView* client_view() const {
210 return non_client_view()->client_view(); 192 return non_client_view()->client_view();
211 } 193 }
212 194
213 NativeWindow* native_window() { return native_window_; } 195 NativeWindow* native_window() { return native_window_; }
214 196
215 protected: 197 protected:
216 // TODO(beng): Temporarily provided as a way to associate the subclass'
217 // implementation of NativeWidget with this.
218 void SetNativeWindow(NativeWindow* native_window);
219
220 // Overridden from NativeWindowDelegate: 198 // Overridden from NativeWindowDelegate:
221 virtual bool CanActivate() const OVERRIDE; 199 virtual bool CanActivate() const OVERRIDE;
222 virtual bool IsInactiveRenderingDisabled() const OVERRIDE; 200 virtual bool IsInactiveRenderingDisabled() const OVERRIDE;
223 virtual void EnableInactiveRendering() OVERRIDE; 201 virtual void EnableInactiveRendering() OVERRIDE;
224 virtual bool IsModal() const OVERRIDE; 202 virtual bool IsModal() const OVERRIDE;
225 virtual bool IsDialogBox() const OVERRIDE; 203 virtual bool IsDialogBox() const OVERRIDE;
226 virtual bool IsUsingNativeFrame() const OVERRIDE; 204 virtual bool IsUsingNativeFrame() const OVERRIDE;
227 virtual gfx::Size GetMinimumSize() const OVERRIDE; 205 virtual gfx::Size GetMinimumSize() const OVERRIDE;
228 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; 206 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
229 virtual bool ExecuteCommand(int command_id) OVERRIDE; 207 virtual bool ExecuteCommand(int command_id) OVERRIDE;
230 virtual void OnNativeWindowCreated(const gfx::Rect& bounds) OVERRIDE; 208 virtual void OnNativeWindowCreated(const gfx::Rect& bounds) OVERRIDE;
231 virtual void OnNativeWindowActivationChanged(bool active) OVERRIDE; 209 virtual void OnNativeWindowActivationChanged(bool active) OVERRIDE;
232 virtual void OnNativeWindowBeginUserBoundsChange() OVERRIDE; 210 virtual void OnNativeWindowBeginUserBoundsChange() OVERRIDE;
233 virtual void OnNativeWindowEndUserBoundsChange() OVERRIDE; 211 virtual void OnNativeWindowEndUserBoundsChange() OVERRIDE;
234 virtual void OnNativeWindowDestroying() OVERRIDE; 212 virtual void OnNativeWindowDestroying() OVERRIDE;
235 virtual void OnNativeWindowDestroyed() OVERRIDE; 213 virtual void OnNativeWindowDestroyed() OVERRIDE;
236 virtual void OnNativeWindowBoundsChanged() OVERRIDE; 214 virtual void OnNativeWindowBoundsChanged() OVERRIDE;
215 virtual Window* AsWindow() OVERRIDE;
216 virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE;
237 217
238 private: 218 private:
239 // Sizes and positions the window just after it is created. 219 // Sizes and positions the window just after it is created.
240 void SetInitialBounds(const gfx::Rect& bounds); 220 void SetInitialBounds(const gfx::Rect& bounds);
241 221
242 // Persists the window's restored position and maximized state using the 222 // Persists the window's restored position and maximized state using the
243 // window delegate. 223 // window delegate.
244 void SaveWindowPosition(); 224 void SaveWindowPosition();
245 225
246 NativeWindow* native_window_; 226 NativeWindow* native_window_;
(...skipping 20 matching lines...) Expand all
267 247
268 // Set to true if the window is in the process of closing . 248 // Set to true if the window is in the process of closing .
269 bool window_closed_; 249 bool window_closed_;
270 250
271 DISALLOW_COPY_AND_ASSIGN(Window); 251 DISALLOW_COPY_AND_ASSIGN(Window);
272 }; 252 };
273 253
274 } // namespace views 254 } // namespace views
275 255
276 #endif // #ifndef VIEWS_WINDOW_WINDOW_H_ 256 #endif // #ifndef VIEWS_WINDOW_WINDOW_H_
OLDNEW
« no previous file with comments | « views/window/native_window_delegate.h ('k') | views/window/window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698