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

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

Issue 27286: All views::Window objects must have a NonClientView, regardless of whether or... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
« no previous file with comments | « chrome/views/non_client_view.cc ('k') | chrome/views/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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 CHROME_VIEWS_WINDOW_H__ 5 #ifndef CHROME_VIEWS_WINDOW_H__
6 #define CHROME_VIEWS_WINDOW_H__ 6 #define CHROME_VIEWS_WINDOW_H__
7 7
8 #include "chrome/common/notification_registrar.h" 8 #include "chrome/common/notification_registrar.h"
9 #include "chrome/views/client_view.h"
10 #include "chrome/views/non_client_view.h"
9 #include "chrome/views/widget_win.h" 11 #include "chrome/views/widget_win.h"
10 12
11 namespace gfx { 13 namespace gfx {
12 class Point; 14 class Point;
13 class Size; 15 class Size;
14 }; 16 };
15 17
16 namespace views { 18 namespace views {
17 19
18 class ClientView;
19 class Client; 20 class Client;
20 class NonClientView; 21 class NonClientView;
21 class WindowDelegate; 22 class WindowDelegate;
22 23
23 /////////////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////////////
24 // 25 //
25 // Window 26 // Window
26 // 27 //
27 // A Window is a WidgetWIn that has a caption and a border. The frame is 28 // A Window is a WidgetWIn that has a caption and a border. The frame is
28 // rendered by the operating system. 29 // rendered by the operating system.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 85
85 // Prevents the window from being rendered as deactivated when |disable| is 86 // Prevents the window from being rendered as deactivated when |disable| is
86 // true, until called with |disable| false. Used when a sub-window is to be 87 // true, until called with |disable| false. Used when a sub-window is to be
87 // shown that shouldn't visually de-activate the window. 88 // shown that shouldn't visually de-activate the window.
88 // Subclasses can override this to perform additional actions when this value 89 // Subclasses can override this to perform additional actions when this value
89 // changes. 90 // changes.
90 virtual void DisableInactiveRendering(bool disable); 91 virtual void DisableInactiveRendering(bool disable);
91 92
92 WindowDelegate* window_delegate() const { return window_delegate_; } 93 WindowDelegate* window_delegate() const { return window_delegate_; }
93 94
94 // Returns the ClientView object used by this Window.
95 ClientView* client_view() const { return client_view_; }
96
97 void set_focus_on_creation(bool focus_on_creation) { 95 void set_focus_on_creation(bool focus_on_creation) {
98 focus_on_creation_ = focus_on_creation; 96 focus_on_creation_ = focus_on_creation;
99 } 97 }
100 98
101 // Tell the window to update its title from the delegate. 99 // Tell the window to update its title from the delegate.
102 virtual void UpdateWindowTitle(); 100 virtual void UpdateWindowTitle();
103 101
104 // Tell the window to update its icon from the delegate. 102 // Tell the window to update its icon from the delegate.
105 virtual void UpdateWindowIcon(); 103 virtual void UpdateWindowIcon();
106 104
107 // Executes the specified SC_command. 105 // Executes the specified SC_command.
108 void ExecuteSystemMenuCommand(int command); 106 void ExecuteSystemMenuCommand(int command);
109 107
110 // The parent of this window. 108 // The parent of this window.
111 HWND owning_window() const { return owning_hwnd_; } 109 HWND owning_window() const { return owning_hwnd_; }
112 110
111 // Shortcut to access the ClientView associated with this window.
112 ClientView* client_view() const { return non_client_view_->client_view(); }
113
113 // Returns the preferred size of the contents view of this window based on 114 // Returns the preferred size of the contents view of this window based on
114 // its localized size data. The width in cols is held in a localized string 115 // its localized size data. The width in cols is held in a localized string
115 // resource identified by |col_resource_id|, the height in the same fashion. 116 // resource identified by |col_resource_id|, the height in the same fashion.
116 // TODO(beng): This should eventually live somewhere else, probably closer to 117 // TODO(beng): This should eventually live somewhere else, probably closer to
117 // ClientView. 118 // ClientView.
118 static int GetLocalizedContentsWidth(int col_resource_id); 119 static int GetLocalizedContentsWidth(int col_resource_id);
119 static int GetLocalizedContentsHeight(int row_resource_id); 120 static int GetLocalizedContentsHeight(int row_resource_id);
120 static gfx::Size GetLocalizedContentsSize(int col_resource_id, 121 static gfx::Size GetLocalizedContentsSize(int col_resource_id,
121 int row_resource_id); 122 int row_resource_id);
122 123
123 // NotificationObserver overrides: 124 // NotificationObserver overrides:
124 virtual void Observe(NotificationType type, 125 virtual void Observe(NotificationType type,
125 const NotificationSource& source, 126 const NotificationSource& source,
126 const NotificationDetails& details); 127 const NotificationDetails& details);
127 128
128 protected: 129 protected:
129 // Constructs the Window. |window_delegate| cannot be NULL. 130 // Constructs the Window. |window_delegate| cannot be NULL.
130 explicit Window(WindowDelegate* window_delegate); 131 explicit Window(WindowDelegate* window_delegate);
131 132
132 // Create the Window. 133 // Create the Window.
133 // If parent is NULL, this Window is top level on the desktop. 134 // If parent is NULL, this Window is top level on the desktop.
134 // If |bounds| is empty, the view is queried for its preferred size and 135 // If |bounds| is empty, the view is queried for its preferred size and
135 // centered on screen. 136 // centered on screen.
136 virtual void Init(HWND parent, const gfx::Rect& bounds); 137 virtual void Init(HWND parent, const gfx::Rect& bounds);
137 138
138 // Sets the specified view as the ClientView of this Window. The ClientView
139 // is responsible for laying out the Window's contents view, as well as
140 // performing basic hit-testing, and perhaps other responsibilities depending
141 // on the implementation. The Window's view hierarchy takes ownership of the
142 // ClientView unless the ClientView specifies otherwise. This must be called
143 // only once, and after the native window has been created.
144 // This is called by Init. |client_view| cannot be NULL.
145 virtual void SetClientView(ClientView* client_view);
146
147 // Sizes the window to the default size specified by its ClientView. 139 // Sizes the window to the default size specified by its ClientView.
148 virtual void SizeWindowToDefault(); 140 virtual void SizeWindowToDefault();
149 141
150 // Returns true if the Window is considered to be an "app window" - i.e. any 142 // Returns true if the Window is considered to be an "app window" - i.e. any
151 // window which when it is the last of its type closed causes the application 143 // window which when it is the last of its type closed causes the application
152 // to exit. 144 // to exit.
153 virtual bool IsAppWindow() const { return false; } 145 virtual bool IsAppWindow() const { return false; }
154 146
155 void set_client_view(ClientView* client_view) { client_view_ = client_view; }
156
157 // Shows the system menu at the specified screen point. 147 // Shows the system menu at the specified screen point.
158 void RunSystemMenu(const gfx::Point& point); 148 void RunSystemMenu(const gfx::Point& point);
159 149
160 // Overridden from WidgetWin: 150 // Overridden from WidgetWin:
161 virtual void OnActivate(UINT action, BOOL minimized, HWND window); 151 virtual void OnActivate(UINT action, BOOL minimized, HWND window);
162 virtual LRESULT OnAppCommand(HWND window, short app_command, WORD device, 152 virtual LRESULT OnAppCommand(HWND window, short app_command, WORD device,
163 int keystate); 153 int keystate);
164 virtual void OnCommand(UINT notification_code, int command_id, HWND window); 154 virtual void OnCommand(UINT notification_code, int command_id, HWND window);
165 virtual void OnDestroy(); 155 virtual void OnDestroy();
166 virtual LRESULT OnNCActivate(BOOL active); 156 virtual LRESULT OnNCActivate(BOOL active);
167 virtual LRESULT OnNCHitTest(const CPoint& point); 157 virtual LRESULT OnNCHitTest(const CPoint& point);
168 virtual void OnNCLButtonDown(UINT ht_component, const CPoint& point); 158 virtual void OnNCLButtonDown(UINT ht_component, const CPoint& point);
169 virtual void OnNCRButtonDown(UINT ht_component, const CPoint& point); 159 virtual void OnNCRButtonDown(UINT ht_component, const CPoint& point);
170 virtual LRESULT OnSetCursor(HWND window, UINT hittest_code, UINT message); 160 virtual LRESULT OnSetCursor(HWND window, UINT hittest_code, UINT message);
171 virtual void OnSize(UINT size_param, const CSize& new_size); 161 virtual void OnSize(UINT size_param, const CSize& new_size);
172 virtual void OnSysCommand(UINT notification_code, CPoint click); 162 virtual void OnSysCommand(UINT notification_code, CPoint click);
173 163
174 // The View that provides the non-client area of the window (title bar, 164 // The View that provides the non-client area of the window (title bar,
175 // window controls, sizing borders etc). To use an implementation other than 165 // window controls, sizing borders etc). To use an implementation other than
176 // the default, this class must be subclassed and this value set to the 166 // the default, this class must be subclassed and this value set to the
177 // desired implementation before calling |Init|. 167 // desired implementation before calling |Init|.
178 NonClientView* non_client_view_; 168 NonClientView* non_client_view_;
179 169
180 // Accessor for disable_inactive_rendering_. 170 // Accessor for disable_inactive_rendering_.
181 bool disable_inactive_rendering() const { 171 bool disable_inactive_rendering() const {
182 return disable_inactive_rendering_; 172 return disable_inactive_rendering_;
183 } 173 }
184 174
185 private: 175 private:
176 // Sets the specified view as the ClientView of this Window. The ClientView
177 // is responsible for laying out the Window's contents view, as well as
178 // performing basic hit-testing, and perhaps other responsibilities depending
179 // on the implementation. The Window's view hierarchy takes ownership of the
180 // ClientView unless the ClientView specifies otherwise. This must be called
181 // only once, and after the native window has been created.
182 // This is called by Init. |client_view| cannot be NULL.
183 void SetClientView(ClientView* client_view);
184
186 // Set the window as modal (by disabling all the other windows). 185 // Set the window as modal (by disabling all the other windows).
187 void BecomeModal(); 186 void BecomeModal();
188 187
189 // Sets-up the focus manager with the view that should have focus when the 188 // Sets-up the focus manager with the view that should have focus when the
190 // window is shown the first time. If NULL is returned, the focus goes to the 189 // window is shown the first time. If NULL is returned, the focus goes to the
191 // button if there is one, otherwise the to the Cancel button. 190 // button if there is one, otherwise the to the Cancel button.
192 void SetInitialFocus(); 191 void SetInitialFocus();
193 192
194 // Place and size the window when it is created. |create_bounds| are the 193 // Place and size the window when it is created. |create_bounds| are the
195 // bounds used when the window was created. 194 // bounds used when the window was created.
(...skipping 16 matching lines...) Expand all
212 DWORD CalculateWindowStyle(); 211 DWORD CalculateWindowStyle();
213 DWORD CalculateWindowExStyle(); 212 DWORD CalculateWindowExStyle();
214 213
215 // Asks the delegate if any to save the window's location and size. 214 // Asks the delegate if any to save the window's location and size.
216 void SaveWindowPosition(); 215 void SaveWindowPosition();
217 216
218 // Static resource initialization. 217 // Static resource initialization.
219 static void InitClass(); 218 static void InitClass();
220 static HCURSOR nwse_cursor_; 219 static HCURSOR nwse_cursor_;
221 220
222 // A ClientView object or subclass, responsible for sizing the contents view
223 // of the window, hit testing and perhaps other tasks depending on the
224 // implementation.
225 ClientView* client_view_;
226
227 // Our window delegate (see Init method for documentation). 221 // Our window delegate (see Init method for documentation).
228 WindowDelegate* window_delegate_; 222 WindowDelegate* window_delegate_;
229 223
230 // Whether we should SetFocus() on a newly created window after 224 // Whether we should SetFocus() on a newly created window after
231 // Init(). Defaults to true. 225 // Init(). Defaults to true.
232 bool focus_on_creation_; 226 bool focus_on_creation_;
233 227
234 // We need to save the parent window that spawned us, since GetParent() 228 // We need to save the parent window that spawned us, since GetParent()
235 // returns NULL for dialogs. 229 // returns NULL for dialogs.
236 HWND owning_hwnd_; 230 HWND owning_hwnd_;
(...skipping 29 matching lines...) Expand all
266 260
267 // Hold onto notifications. 261 // Hold onto notifications.
268 NotificationRegistrar notification_registrar_; 262 NotificationRegistrar notification_registrar_;
269 263
270 DISALLOW_COPY_AND_ASSIGN(Window); 264 DISALLOW_COPY_AND_ASSIGN(Window);
271 }; 265 };
272 266
273 } // namespace views 267 } // namespace views
274 268
275 #endif // CHROME_VIEWS_WINDOW_H__ 269 #endif // CHROME_VIEWS_WINDOW_H__
OLDNEW
« no previous file with comments | « chrome/views/non_client_view.cc ('k') | chrome/views/window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698