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

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

Issue 6623025: Make more methods on Widget non-virtual and move to NativeWidget... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « views/widget/native_widget.h ('k') | views/widget/widget.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_WIDGET_WIDGET_H_ 5 #ifndef VIEWS_WIDGET_WIDGET_H_
6 #define VIEWS_WIDGET_WIDGET_H_ 6 #define VIEWS_WIDGET_WIDGET_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 EventsParam accept_events, 87 EventsParam accept_events,
88 DeleteParam delete_on_destroy, 88 DeleteParam delete_on_destroy,
89 MirroringParam mirror_in_rtl); 89 MirroringParam mirror_in_rtl);
90 90
91 // Enumerates all windows pertaining to us and notifies their 91 // Enumerates all windows pertaining to us and notifies their
92 // view hierarchies that the locale has changed. 92 // view hierarchies that the locale has changed.
93 static void NotifyLocaleChanged(); 93 static void NotifyLocaleChanged();
94 94
95 Widget(); 95 Widget();
96 96
97 // Unconverted methods -------------------------------------------------------
98
99 // TODO(beng):
100 // Widget subclasses are still implementing these methods by overriding from
101 // here rather than by implementing NativeWidget.
102
97 // Initialize the Widget with a parent and an initial desired size. 103 // Initialize the Widget with a parent and an initial desired size.
98 // |contents_view| is the view that will be the single child of RootView 104 // |contents_view| is the view that will be the single child of RootView
99 // within this Widget. As contents_view is inserted into RootView's tree, 105 // within this Widget. As contents_view is inserted into RootView's tree,
100 // RootView assumes ownership of this view and cleaning it up. If you remove 106 // RootView assumes ownership of this view and cleaning it up. If you remove
101 // this view, you are responsible for its destruction. If this value is NULL, 107 // this view, you are responsible for its destruction. If this value is NULL,
102 // the caller is responsible for populating the RootView, and sizing its 108 // the caller is responsible for populating the RootView, and sizing its
103 // contents as the window is sized. 109 // contents as the window is sized.
104 virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds); 110 virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds);
105 virtual void InitWithWidget(Widget* parent, const gfx::Rect& bounds); 111 virtual void InitWithWidget(Widget* parent, const gfx::Rect& bounds);
106 112
113 // Returns the gfx::NativeView associated with this Widget.
114 virtual gfx::NativeView GetNativeView() const;
115
116 // Starts a drag operation for the specified view. |point| is a position in
117 // |view| coordinates that the drag was initiated from.
118 virtual void GenerateMousePressedForView(View* view,
119 const gfx::Point& point);
120
121 // Returns the accelerator given a command id. Returns false if there is
122 // no accelerator associated with a given id, which is a common condition.
123 virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
124
125 // Returns the Window containing this Widget, or NULL if not contained in a
126 // window.
127 virtual Window* GetWindow();
128 virtual const Window* GetWindow() const;
129
130 // Forwarded from the RootView so that the widget can do any cleanup.
131 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
132
133 // Converted methods ---------------------------------------------------------
134
135 // TODO(beng):
136 // Widget subclasses are implementing these methods by implementing
137 // NativeWidget. Remove this comment once complete.
138
107 // Returns the topmost Widget in a hierarchy. Will return NULL if called 139 // Returns the topmost Widget in a hierarchy. Will return NULL if called
108 // before the underlying Native Widget has been initialized. 140 // before the underlying Native Widget has been initialized.
109 Widget* GetTopLevelWidget(); 141 Widget* GetTopLevelWidget();
110 const Widget* GetTopLevelWidget() const; 142 const Widget* GetTopLevelWidget() const;
111 143
112 // Gets/Sets the WidgetDelegate. 144 // Gets/Sets the WidgetDelegate.
113 WidgetDelegate* widget_delegate() const { return widget_delegate_; } 145 WidgetDelegate* widget_delegate() const { return widget_delegate_; }
114 void set_widget_delegate(WidgetDelegate* widget_delegate) { 146 void set_widget_delegate(WidgetDelegate* widget_delegate) {
115 widget_delegate_ = widget_delegate; 147 widget_delegate_ = widget_delegate;
116 } 148 }
117 149
118 // Sets the specified view as the contents of this Widget. There can only 150 // Sets the specified view as the contents of this Widget. There can only
119 // be one contents view child of this Widget's RootView. This view is sized to 151 // be one contents view child of this Widget's RootView. This view is sized to
120 // fit the entire size of the RootView. The RootView takes ownership of this 152 // fit the entire size of the RootView. The RootView takes ownership of this
121 // View, unless it is set as not being parent-owned. 153 // View, unless it is set as not being parent-owned.
122 void SetContentsView(View* view); 154 void SetContentsView(View* view);
123 155
124 // Returns the bounds of the Widget in screen coordinates. 156 // Returns the bounds of the Widget in screen coordinates.
125 gfx::Rect GetWindowScreenBounds() const; 157 gfx::Rect GetWindowScreenBounds() const;
126 158
127 // Returns the bounds of the Widget's client area in screen coordinates. 159 // Returns the bounds of the Widget's client area in screen coordinates.
128 gfx::Rect GetClientAreaScreenBounds() const; 160 gfx::Rect GetClientAreaScreenBounds() const;
129 161
130 // Sizes and/or places the widget to the specified bounds, size or position. 162 // Sizes and/or places the widget to the specified bounds, size or position.
131 virtual void SetBounds(const gfx::Rect& bounds); 163 void SetBounds(const gfx::Rect& bounds);
132 164
133 // Places the widget in front of the specified widget in z-order. 165 // Places the widget in front of the specified widget in z-order.
134 virtual void MoveAbove(Widget* widget); 166 void MoveAbove(Widget* widget);
135 167
136 // Sets a shape on the widget. This takes ownership of shape. 168 // Sets a shape on the widget. This takes ownership of shape.
137 virtual void SetShape(gfx::NativeRegion shape); 169 void SetShape(gfx::NativeRegion shape);
138 170
139 // Hides the widget then closes it after a return to the message loop. 171 // Hides the widget then closes it after a return to the message loop.
140 virtual void Close(); 172 void Close();
141 173
174 // TODO(beng): Move off public API.
142 // Closes the widget immediately. Compare to |Close|. This will destroy the 175 // Closes the widget immediately. Compare to |Close|. This will destroy the
143 // window handle associated with this Widget, so should not be called from 176 // window handle associated with this Widget, so should not be called from
144 // any code that expects it to be valid beyond this call. 177 // any code that expects it to be valid beyond this call.
145 virtual void CloseNow(); 178 void CloseNow();
146 179
147 // Shows or hides the widget, without changing activation state. 180 // Shows or hides the widget, without changing activation state.
148 virtual void Show(); 181 void Show();
149 virtual void Hide(); 182 void Hide();
150
151 // Returns the gfx::NativeView associated with this Widget.
152 virtual gfx::NativeView GetNativeView() const;
153 183
154 // Sets the opacity of the widget. This may allow widgets behind the widget 184 // Sets the opacity of the widget. This may allow widgets behind the widget
155 // in the Z-order to become visible, depending on the capabilities of the 185 // in the Z-order to become visible, depending on the capabilities of the
156 // underlying windowing system. Note that the caller must then schedule a 186 // underlying windowing system. Note that the caller must then schedule a
157 // repaint to allow this change to take effect. 187 // repaint to allow this change to take effect.
158 virtual void SetOpacity(unsigned char opacity); 188 void SetOpacity(unsigned char opacity);
159 189
160 // Sets the widget to be on top of all other widgets in the windowing system. 190 // Sets the widget to be on top of all other widgets in the windowing system.
161 virtual void SetAlwaysOnTop(bool on_top); 191 void SetAlwaysOnTop(bool on_top);
162 192
163 // Returns the RootView contained by this Widget. 193 // Returns the RootView contained by this Widget.
164 virtual RootView* GetRootView(); 194 RootView* GetRootView();
165 195
166 // Returns whether the Widget is visible to the user. 196 // Returns whether the Widget is visible to the user.
167 virtual bool IsVisible() const; 197 bool IsVisible() const;
168 198
169 // Returns whether the Widget is the currently active window. 199 // Returns whether the Widget is the currently active window.
170 virtual bool IsActive() const; 200 bool IsActive() const;
171 201
172 // Returns whether the Widget is customized for accessibility. 202 // Returns whether the Widget is customized for accessibility.
173 virtual bool IsAccessibleWidget() const; 203 bool IsAccessibleWidget() const;
174
175 // Starts a drag operation for the specified view. |point| is a position in
176 // |view| coordinates that the drag was initiated from.
177 virtual void GenerateMousePressedForView(View* view,
178 const gfx::Point& point);
179
180 // Returns the accelerator given a command id. Returns false if there is
181 // no accelerator associated with a given id, which is a common condition.
182 virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
183
184 // Returns the Window containing this Widget, or NULL if not contained in a
185 // window.
186 virtual Window* GetWindow();
187 virtual const Window* GetWindow() const;
188 204
189 // Returns the ThemeProvider that provides theme resources for this Widget. 205 // Returns the ThemeProvider that provides theme resources for this Widget.
190 virtual ThemeProvider* GetThemeProvider() const; 206 virtual ThemeProvider* GetThemeProvider() const;
191 207
192 // Returns the FocusManager for this widget. 208 // Returns the FocusManager for this widget.
193 // Note that all widgets in a widget hierarchy share the same focus manager. 209 // Note that all widgets in a widget hierarchy share the same focus manager.
210 // TODO(beng): remove virtual.
194 virtual FocusManager* GetFocusManager(); 211 virtual FocusManager* GetFocusManager();
195 212
196 // Forwarded from the RootView so that the widget can do any cleanup.
197 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
198
199 // Returns true if the native view |native_view| is contained in the 213 // Returns true if the native view |native_view| is contained in the
200 // views::View hierarchy rooted at this widget. 214 // views::View hierarchy rooted at this widget.
201 // TODO(beng): const. 215 // TODO(beng): const.
202 bool ContainsNativeView(gfx::NativeView native_view); 216 bool ContainsNativeView(gfx::NativeView native_view);
203 217
204 // Starts a drag operation for the specified view. This blocks until the drag 218 // Starts a drag operation for the specified view. This blocks until the drag
205 // operation completes. |view| can be NULL. 219 // operation completes. |view| can be NULL.
206 // If the view is non-NULL it can be accessed during the drag by calling 220 // If the view is non-NULL it can be accessed during the drag by calling
207 // dragged_view(). If the view has not been deleted during the drag, 221 // dragged_view(). If the view has not been deleted during the drag,
208 // OnDragDone() is called on it. 222 // OnDragDone() is called on it.
209 void RunShellDrag(View* view, const ui::OSExchangeData& data, int operation); 223 void RunShellDrag(View* view, const ui::OSExchangeData& data, int operation);
210 224
211 // Returns the view that requested the current drag operation via 225 // Returns the view that requested the current drag operation via
212 // RunShellDrag(), or NULL if there is no such view or drag operation. 226 // RunShellDrag(), or NULL if there is no such view or drag operation.
213 View* dragged_view() { return dragged_view_; } 227 View* dragged_view() { return dragged_view_; }
214 228
215 // Adds the specified |rect| in client area coordinates to the rectangle to be 229 // Adds the specified |rect| in client area coordinates to the rectangle to be
216 // redrawn. 230 // redrawn.
217 void SchedulePaintInRect(const gfx::Rect& rect); 231 void SchedulePaintInRect(const gfx::Rect& rect);
218 232
219 // Sets the currently visible cursor. If |cursor| is NULL, the cursor used 233 // Sets the currently visible cursor. If |cursor| is NULL, the cursor used
220 // before the current is restored. 234 // before the current is restored.
221 void SetCursor(gfx::NativeCursor cursor); 235 void SetCursor(gfx::NativeCursor cursor);
222 236
223 // Retrieves the focus traversable for this widget. 237 // Retrieves the focus traversable for this widget.
224 virtual FocusTraversable* GetFocusTraversable(); 238 FocusTraversable* GetFocusTraversable();
225 239
226 // Notifies the view hierarchy contained in this widget that theme resources 240 // Notifies the view hierarchy contained in this widget that theme resources
227 // changed. 241 // changed.
228 void ThemeChanged(); 242 void ThemeChanged();
229 243
230 // Notifies the view hierarchy contained in this widget that locale resources 244 // Notifies the view hierarchy contained in this widget that locale resources
231 // changed. 245 // changed.
232 void LocaleChanged(); 246 void LocaleChanged();
233 247
234 void SetFocusTraversableParent(FocusTraversable* parent); 248 void SetFocusTraversableParent(FocusTraversable* parent);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Valid for the lifetime of RunShellDrag(), indicates the view the drag 306 // Valid for the lifetime of RunShellDrag(), indicates the view the drag
293 // started from. 307 // started from.
294 View* dragged_view_; 308 View* dragged_view_;
295 309
296 DISALLOW_COPY_AND_ASSIGN(Widget); 310 DISALLOW_COPY_AND_ASSIGN(Widget);
297 }; 311 };
298 312
299 } // namespace views 313 } // namespace views
300 314
301 #endif // VIEWS_WIDGET_WIDGET_H_ 315 #endif // VIEWS_WIDGET_WIDGET_H_
OLDNEW
« no previous file with comments | « views/widget/native_widget.h ('k') | views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698