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 #include "views/widget/native_widget_aura.h" | 5 #include "views/widget/native_widget_aura.h" |
6 | 6 |
| 7 #include "aura/window.h" |
| 8 #include "ui/gfx/canvas.h" |
| 9 #include "ui/gfx/compositor/layer.h" |
| 10 #include "views/widget/native_widget_delegate.h" |
| 11 |
7 namespace views { | 12 namespace views { |
8 | 13 |
9 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
10 // NativeWidgetAura, public: | 15 // NativeWidgetAura, public: |
11 | 16 |
12 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) { | 17 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) |
| 18 : delegate_(delegate), |
| 19 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))) { |
| 20 window_->set_id(1200); |
13 } | 21 } |
14 | 22 |
15 NativeWidgetAura::~NativeWidgetAura() { | 23 NativeWidgetAura::~NativeWidgetAura() { |
16 } | 24 } |
17 | 25 |
18 //////////////////////////////////////////////////////////////////////////////// | 26 //////////////////////////////////////////////////////////////////////////////// |
19 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: | 27 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: |
20 | 28 |
21 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { | 29 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| 30 window_->Init(); |
| 31 window_->SetBounds(params.bounds, 0); |
| 32 window_->SetParent(params.parent); |
| 33 // TODO(beng): do this some other way. |
| 34 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); |
| 35 window_->SetVisibility(aura::Window::VISIBILITY_SHOWN); |
22 } | 36 } |
23 | 37 |
24 NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() { | 38 NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() { |
| 39 NOTIMPLEMENTED(); |
25 return NULL; | 40 return NULL; |
26 } | 41 } |
27 | 42 |
28 void NativeWidgetAura::UpdateFrameAfterFrameChange() { | 43 void NativeWidgetAura::UpdateFrameAfterFrameChange() { |
| 44 NOTIMPLEMENTED(); |
29 } | 45 } |
30 | 46 |
31 bool NativeWidgetAura::ShouldUseNativeFrame() const { | 47 bool NativeWidgetAura::ShouldUseNativeFrame() const { |
| 48 NOTIMPLEMENTED(); |
32 return false; | 49 return false; |
33 } | 50 } |
34 | 51 |
35 void NativeWidgetAura::FrameTypeChanged() { | 52 void NativeWidgetAura::FrameTypeChanged() { |
| 53 NOTIMPLEMENTED(); |
36 } | 54 } |
37 | 55 |
38 Widget* NativeWidgetAura::GetWidget() { | 56 Widget* NativeWidgetAura::GetWidget() { |
39 return NULL; | 57 return delegate_->AsWidget(); |
40 } | 58 } |
41 | 59 |
42 const Widget* NativeWidgetAura::GetWidget() const { | 60 const Widget* NativeWidgetAura::GetWidget() const { |
43 return NULL; | 61 return delegate_->AsWidget(); |
44 } | 62 } |
45 | 63 |
46 gfx::NativeView NativeWidgetAura::GetNativeView() const { | 64 gfx::NativeView NativeWidgetAura::GetNativeView() const { |
47 return NULL; | 65 return window_; |
48 } | 66 } |
49 | 67 |
50 gfx::NativeWindow NativeWidgetAura::GetNativeWindow() const { | 68 gfx::NativeWindow NativeWidgetAura::GetNativeWindow() const { |
51 return NULL; | 69 return window_; |
52 } | 70 } |
53 | 71 |
54 Widget* NativeWidgetAura::GetTopLevelWidget() { | 72 Widget* NativeWidgetAura::GetTopLevelWidget() { |
55 NativeWidgetPrivate* native_widget = GetTopLevelNativeWidget(GetNativeView()); | 73 NativeWidgetPrivate* native_widget = GetTopLevelNativeWidget(GetNativeView()); |
56 return native_widget ? native_widget->GetWidget() : NULL; | 74 return native_widget ? native_widget->GetWidget() : NULL; |
57 } | 75 } |
58 | 76 |
59 const ui::Compositor* NativeWidgetAura::GetCompositor() const { | 77 const ui::Compositor* NativeWidgetAura::GetCompositor() const { |
60 return NULL; | 78 return window_->layer()->compositor(); |
61 } | 79 } |
62 | 80 |
63 ui::Compositor* NativeWidgetAura::GetCompositor() { | 81 ui::Compositor* NativeWidgetAura::GetCompositor() { |
64 return NULL; | 82 return window_->layer()->compositor(); |
65 } | 83 } |
66 | 84 |
67 void NativeWidgetAura::MarkLayerDirty() { | 85 void NativeWidgetAura::MarkLayerDirty() { |
| 86 NOTIMPLEMENTED(); |
68 } | 87 } |
69 | 88 |
70 void NativeWidgetAura::CalculateOffsetToAncestorWithLayer(gfx::Point* offset, | 89 void NativeWidgetAura::CalculateOffsetToAncestorWithLayer(gfx::Point* offset, |
71 View** ancestor) { | 90 View** ancestor) { |
| 91 NOTIMPLEMENTED(); |
72 } | 92 } |
73 | 93 |
74 void NativeWidgetAura::ViewRemoved(View* view) { | 94 void NativeWidgetAura::ViewRemoved(View* view) { |
| 95 NOTIMPLEMENTED(); |
75 } | 96 } |
76 | 97 |
77 void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) { | 98 void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) { |
| 99 NOTIMPLEMENTED(); |
78 } | 100 } |
79 | 101 |
80 void* NativeWidgetAura::GetNativeWindowProperty(const char* name) const { | 102 void* NativeWidgetAura::GetNativeWindowProperty(const char* name) const { |
| 103 NOTIMPLEMENTED(); |
81 return NULL; | 104 return NULL; |
82 } | 105 } |
83 | 106 |
84 TooltipManager* NativeWidgetAura::GetTooltipManager() const { | 107 TooltipManager* NativeWidgetAura::GetTooltipManager() const { |
| 108 NOTIMPLEMENTED(); |
85 return NULL; | 109 return NULL; |
86 } | 110 } |
87 | 111 |
88 bool NativeWidgetAura::IsScreenReaderActive() const { | 112 bool NativeWidgetAura::IsScreenReaderActive() const { |
| 113 NOTIMPLEMENTED(); |
89 return false; | 114 return false; |
90 } | 115 } |
91 | 116 |
92 void NativeWidgetAura::SendNativeAccessibilityEvent( | 117 void NativeWidgetAura::SendNativeAccessibilityEvent( |
93 View* view, | 118 View* view, |
94 ui::AccessibilityTypes::Event event_type) { | 119 ui::AccessibilityTypes::Event event_type) { |
| 120 NOTIMPLEMENTED(); |
95 } | 121 } |
96 | 122 |
97 void NativeWidgetAura::SetMouseCapture() { | 123 void NativeWidgetAura::SetMouseCapture() { |
| 124 NOTIMPLEMENTED(); |
98 } | 125 } |
99 | 126 |
100 void NativeWidgetAura::ReleaseMouseCapture() { | 127 void NativeWidgetAura::ReleaseMouseCapture() { |
| 128 NOTIMPLEMENTED(); |
101 } | 129 } |
102 | 130 |
103 bool NativeWidgetAura::HasMouseCapture() const { | 131 bool NativeWidgetAura::HasMouseCapture() const { |
| 132 NOTIMPLEMENTED(); |
104 return false; | 133 return false; |
105 } | 134 } |
106 | 135 |
107 InputMethod* NativeWidgetAura::CreateInputMethod() { | 136 InputMethod* NativeWidgetAura::CreateInputMethod() { |
| 137 NOTIMPLEMENTED(); |
108 return NULL; | 138 return NULL; |
109 } | 139 } |
110 | 140 |
111 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 141 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| 142 NOTIMPLEMENTED(); |
112 } | 143 } |
113 | 144 |
114 void NativeWidgetAura::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, | 145 void NativeWidgetAura::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, |
115 bool* maximized) const { | 146 bool* maximized) const { |
| 147 NOTIMPLEMENTED(); |
116 } | 148 } |
117 | 149 |
118 void NativeWidgetAura::SetWindowTitle(const std::wstring& title) { | 150 void NativeWidgetAura::SetWindowTitle(const std::wstring& title) { |
| 151 NOTIMPLEMENTED(); |
119 } | 152 } |
120 | 153 |
121 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon, | 154 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon, |
122 const SkBitmap& app_icon) { | 155 const SkBitmap& app_icon) { |
| 156 NOTIMPLEMENTED(); |
123 } | 157 } |
124 | 158 |
125 void NativeWidgetAura::SetAccessibleName(const std::wstring& name) { | 159 void NativeWidgetAura::SetAccessibleName(const std::wstring& name) { |
| 160 NOTIMPLEMENTED(); |
126 } | 161 } |
127 | 162 |
128 void NativeWidgetAura::SetAccessibleRole(ui::AccessibilityTypes::Role role) { | 163 void NativeWidgetAura::SetAccessibleRole(ui::AccessibilityTypes::Role role) { |
| 164 NOTIMPLEMENTED(); |
129 } | 165 } |
130 | 166 |
131 void NativeWidgetAura::SetAccessibleState(ui::AccessibilityTypes::State state) { | 167 void NativeWidgetAura::SetAccessibleState(ui::AccessibilityTypes::State state) { |
| 168 NOTIMPLEMENTED(); |
132 } | 169 } |
133 | 170 |
134 void NativeWidgetAura::BecomeModal() { | 171 void NativeWidgetAura::BecomeModal() { |
| 172 NOTIMPLEMENTED(); |
135 } | 173 } |
136 | 174 |
137 gfx::Rect NativeWidgetAura::GetWindowScreenBounds() const { | 175 gfx::Rect NativeWidgetAura::GetWindowScreenBounds() const { |
138 return gfx::Rect(); | 176 // TODO(beng): ensure screen bounds |
| 177 return window_->bounds(); |
139 } | 178 } |
140 | 179 |
141 gfx::Rect NativeWidgetAura::GetClientAreaScreenBounds() const { | 180 gfx::Rect NativeWidgetAura::GetClientAreaScreenBounds() const { |
142 return gfx::Rect(); | 181 // TODO(beng): |
| 182 return window_->bounds(); |
143 } | 183 } |
144 | 184 |
145 gfx::Rect NativeWidgetAura::GetRestoredBounds() const { | 185 gfx::Rect NativeWidgetAura::GetRestoredBounds() const { |
146 return gfx::Rect(); | 186 // TODO(beng): |
| 187 return window_->bounds(); |
147 } | 188 } |
148 | 189 |
149 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { | 190 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { |
| 191 window_->SetBounds(bounds, 0); |
150 } | 192 } |
151 | 193 |
152 void NativeWidgetAura::SetSize(const gfx::Size& size) { | 194 void NativeWidgetAura::SetSize(const gfx::Size& size) { |
| 195 window_->SetBounds(gfx::Rect(window_->bounds().origin(), size), 0); |
153 } | 196 } |
154 | 197 |
155 void NativeWidgetAura::SetBoundsConstrained(const gfx::Rect& bounds, | 198 void NativeWidgetAura::SetBoundsConstrained(const gfx::Rect& bounds, |
156 Widget* other_widget) { | 199 Widget* other_widget) { |
| 200 NOTIMPLEMENTED(); |
157 } | 201 } |
158 | 202 |
159 void NativeWidgetAura::MoveAbove(gfx::NativeView native_view) { | 203 void NativeWidgetAura::MoveAbove(gfx::NativeView native_view) { |
| 204 NOTIMPLEMENTED(); |
160 } | 205 } |
161 | 206 |
162 void NativeWidgetAura::MoveToTop() { | 207 void NativeWidgetAura::MoveToTop() { |
163 NOTIMPLEMENTED(); | 208 NOTIMPLEMENTED(); |
164 } | 209 } |
165 | 210 |
166 void NativeWidgetAura::SetShape(gfx::NativeRegion region) { | 211 void NativeWidgetAura::SetShape(gfx::NativeRegion region) { |
| 212 NOTIMPLEMENTED(); |
167 } | 213 } |
168 | 214 |
169 void NativeWidgetAura::Close() { | 215 void NativeWidgetAura::Close() { |
| 216 NOTIMPLEMENTED(); |
170 } | 217 } |
171 | 218 |
172 void NativeWidgetAura::CloseNow() { | 219 void NativeWidgetAura::CloseNow() { |
| 220 NOTIMPLEMENTED(); |
173 } | 221 } |
174 | 222 |
175 void NativeWidgetAura::EnableClose(bool enable) { | 223 void NativeWidgetAura::EnableClose(bool enable) { |
| 224 NOTIMPLEMENTED(); |
176 } | 225 } |
177 | 226 |
178 void NativeWidgetAura::Show() { | 227 void NativeWidgetAura::Show() { |
| 228 window_->SetVisibility(aura::Window::VISIBILITY_SHOWN); |
179 } | 229 } |
180 | 230 |
181 void NativeWidgetAura::Hide() { | 231 void NativeWidgetAura::Hide() { |
| 232 window_->SetVisibility(aura::Window::VISIBILITY_HIDDEN); |
182 } | 233 } |
183 | 234 |
184 void NativeWidgetAura::ShowMaximizedWithBounds( | 235 void NativeWidgetAura::ShowMaximizedWithBounds( |
185 const gfx::Rect& restored_bounds) { | 236 const gfx::Rect& restored_bounds) { |
| 237 NOTIMPLEMENTED(); |
186 } | 238 } |
187 | 239 |
188 void NativeWidgetAura::ShowWithState(ShowState state) { | 240 void NativeWidgetAura::ShowWithState(ShowState state) { |
| 241 NOTIMPLEMENTED(); |
189 } | 242 } |
190 | 243 |
191 bool NativeWidgetAura::IsVisible() const { | 244 bool NativeWidgetAura::IsVisible() const { |
192 return false; | 245 return window_->visibility() != aura::Window::VISIBILITY_HIDDEN; |
193 } | 246 } |
194 | 247 |
195 void NativeWidgetAura::Activate() { | 248 void NativeWidgetAura::Activate() { |
| 249 NOTIMPLEMENTED(); |
196 } | 250 } |
197 | 251 |
198 void NativeWidgetAura::Deactivate() { | 252 void NativeWidgetAura::Deactivate() { |
| 253 NOTIMPLEMENTED(); |
199 } | 254 } |
200 | 255 |
201 bool NativeWidgetAura::IsActive() const { | 256 bool NativeWidgetAura::IsActive() const { |
| 257 NOTIMPLEMENTED(); |
202 return false; | 258 return false; |
203 } | 259 } |
204 | 260 |
205 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { | 261 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { |
| 262 NOTIMPLEMENTED(); |
206 } | 263 } |
207 | 264 |
208 void NativeWidgetAura::Maximize() { | 265 void NativeWidgetAura::Maximize() { |
| 266 NOTIMPLEMENTED(); |
209 } | 267 } |
210 | 268 |
211 void NativeWidgetAura::Minimize() { | 269 void NativeWidgetAura::Minimize() { |
| 270 NOTIMPLEMENTED(); |
212 } | 271 } |
213 | 272 |
214 bool NativeWidgetAura::IsMaximized() const { | 273 bool NativeWidgetAura::IsMaximized() const { |
| 274 NOTIMPLEMENTED(); |
215 return false; | 275 return false; |
216 } | 276 } |
217 | 277 |
218 bool NativeWidgetAura::IsMinimized() const { | 278 bool NativeWidgetAura::IsMinimized() const { |
| 279 NOTIMPLEMENTED(); |
219 return false; | 280 return false; |
220 } | 281 } |
221 | 282 |
222 void NativeWidgetAura::Restore() { | 283 void NativeWidgetAura::Restore() { |
| 284 NOTIMPLEMENTED(); |
223 } | 285 } |
224 | 286 |
225 void NativeWidgetAura::SetFullscreen(bool fullscreen) { | 287 void NativeWidgetAura::SetFullscreen(bool fullscreen) { |
| 288 NOTIMPLEMENTED(); |
226 } | 289 } |
227 | 290 |
228 bool NativeWidgetAura::IsFullscreen() const { | 291 bool NativeWidgetAura::IsFullscreen() const { |
| 292 NOTIMPLEMENTED(); |
229 return false; | 293 return false; |
230 } | 294 } |
231 | 295 |
232 void NativeWidgetAura::SetOpacity(unsigned char opacity) { | 296 void NativeWidgetAura::SetOpacity(unsigned char opacity) { |
| 297 NOTIMPLEMENTED(); |
233 } | 298 } |
234 | 299 |
235 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { | 300 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { |
| 301 NOTIMPLEMENTED(); |
236 } | 302 } |
237 | 303 |
238 bool NativeWidgetAura::IsAccessibleWidget() const { | 304 bool NativeWidgetAura::IsAccessibleWidget() const { |
| 305 NOTIMPLEMENTED(); |
239 return false; | 306 return false; |
240 } | 307 } |
241 | 308 |
242 void NativeWidgetAura::RunShellDrag(View* view, | 309 void NativeWidgetAura::RunShellDrag(View* view, |
243 const ui::OSExchangeData& data, | 310 const ui::OSExchangeData& data, |
244 int operation) { | 311 int operation) { |
| 312 NOTIMPLEMENTED(); |
245 } | 313 } |
246 | 314 |
247 void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { | 315 void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { |
| 316 NOTIMPLEMENTED(); |
248 } | 317 } |
249 | 318 |
250 void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { | 319 void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { |
| 320 NOTIMPLEMENTED(); |
251 } | 321 } |
252 | 322 |
253 void NativeWidgetAura::ClearNativeFocus() { | 323 void NativeWidgetAura::ClearNativeFocus() { |
| 324 NOTIMPLEMENTED(); |
254 } | 325 } |
255 | 326 |
256 void NativeWidgetAura::FocusNativeView(gfx::NativeView native_view) { | 327 void NativeWidgetAura::FocusNativeView(gfx::NativeView native_view) { |
| 328 NOTIMPLEMENTED(); |
257 } | 329 } |
258 | 330 |
259 bool NativeWidgetAura::ConvertPointFromAncestor(const Widget* ancestor, | 331 bool NativeWidgetAura::ConvertPointFromAncestor(const Widget* ancestor, |
260 gfx::Point* point) const { | 332 gfx::Point* point) const { |
261 NOTREACHED(); | 333 NOTIMPLEMENTED(); |
262 return false; | 334 return false; |
263 } | 335 } |
264 | 336 |
265 void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) { | 337 void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) { |
266 } | 338 NOTIMPLEMENTED(); |
267 | 339 } |
| 340 |
| 341 //////////////////////////////////////////////////////////////////////////////// |
| 342 // NativeWidgetAura, aura::WindowDelegate implementation: |
| 343 |
| 344 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { |
| 345 delegate_->OnNativeWidgetPaint(canvas); |
| 346 } |
| 347 |
| 348 //////////////////////////////////////////////////////////////////////////////// |
| 349 // Widget, public: |
| 350 |
| 351 // static |
| 352 void Widget::NotifyLocaleChanged() { |
| 353 NOTIMPLEMENTED(); |
| 354 } |
| 355 |
| 356 // static |
| 357 void Widget::CloseAllSecondaryWidgets() { |
| 358 NOTIMPLEMENTED(); |
| 359 } |
| 360 |
| 361 bool Widget::ConvertRect(const Widget* source, |
| 362 const Widget* target, |
| 363 gfx::Rect* rect) { |
| 364 return false; |
| 365 } |
| 366 |
| 367 |
| 368 |
| 369 namespace internal { |
| 370 |
| 371 //////////////////////////////////////////////////////////////////////////////// |
| 372 // internal::NativeWidgetPrivate, public: |
| 373 |
| 374 // static |
| 375 NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( |
| 376 internal::NativeWidgetDelegate* delegate) { |
| 377 return new NativeWidgetAura(delegate); |
| 378 } |
| 379 |
| 380 // static |
| 381 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( |
| 382 gfx::NativeView native_view) { |
| 383 NOTIMPLEMENTED(); |
| 384 return NULL; |
| 385 } |
| 386 |
| 387 // static |
| 388 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow( |
| 389 gfx::NativeWindow native_window) { |
| 390 NOTIMPLEMENTED(); |
| 391 return NULL; |
| 392 } |
| 393 |
| 394 // static |
| 395 NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget( |
| 396 gfx::NativeView native_view) { |
| 397 NOTIMPLEMENTED(); |
| 398 return NULL; |
| 399 } |
| 400 |
| 401 // static |
| 402 void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view, |
| 403 Widget::Widgets* children) { |
| 404 NOTIMPLEMENTED(); |
| 405 } |
| 406 |
| 407 // static |
| 408 void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, |
| 409 gfx::NativeView new_parent) { |
| 410 NOTIMPLEMENTED(); |
| 411 } |
| 412 |
| 413 // static |
| 414 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 415 NOTIMPLEMENTED(); |
| 416 return false; |
| 417 } |
| 418 |
| 419 } // namespace internal |
268 } // namespace views | 420 } // namespace views |
OLD | NEW |